Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.15 KB

no-unknown-at-rules.md

File metadata and controls

51 lines (34 loc) · 1.15 KB

no-unknown-at-rules

Disallow unknown at-rules.

Background

CSS contains a number of at-rules, each beginning with a @, that perform various operations. Some common at-rules include:

  • @import
  • @media
  • @font-face
  • @keyframes
  • @supports
  • @namespace
  • @page
  • @charset

It's important to use a known at-rule because unknown at-rules cause the browser to ignore the entire block, including any rules contained within. For example:

/* typo */
@charse "UTF-8";

Here, the @charset at-rule is incorrectly spelled as @charse, which means that it will be ignored.

Rule Details

This rule warns when it finds a CSS at-rule that isn't part of the CSS specification. The at-rule data is provided via the CSSTree project.

Examples of incorrect code:

@charse "UTF-8";

@importx url(foo.css);

@foobar {
	.my-style {
		color: red;
	}
}

When Not to Use It

If you are purposely using at-rules that aren't part of the CSS specification, then you can safely disable this rule.

Prior Art