Back to Biomejs

noUnknownAtRules

src/content/docs/linter/rules/no-unknown-at-rules.mdx

latest6.1 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="CSS" icon="seti:css"> ## Summary - Rule available since: `v2.0.0` - Diagnostic Category: [`lint/suspicious/noUnknownAtRules`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`at-rule-no-unknown`](https://github.com/stylelint/stylelint/blob/main/lib/rules/at-rule-no-unknown/README.md)

How to configure

json
{
	"linter": {
		"rules": {
			"suspicious": {
				"noUnknownAtRules": "error"
			}
		}
	}
}

Description

Disallow unknown at-rules.

For details on known at-rules, see the MDN web docs.

Examples

Invalid

css
@uNkNoWn {}
<pre class="language-text"><code class="language-text">code-block.css:1:2 <a href="https://biomejs.dev/linter/rules/no-unknown-at-rules">lint/suspicious/noUnknownAtRules</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unexpected unknown at-rule: </span><span style="color: Tomato;"><strong>uNkNoWn</strong></span><span style="color: Tomato;"> </span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>@uNkNoWn &#123;&#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>uNkNoWn</strong></span><span style="color: lightgreen;"> is not a standard CSS at-rule, which may lead to unexpected styling results or failure to interpret the styles as intended.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">See </span><span style="color: lightgreen;"><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule">MDN web docs</a></span><span style="color: lightgreen;"> for a known list of at-rules.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">To fix this issue, consider removing the unknown at-rule.</span> </code></pre>
css
@unknown-at-rule {
  font-size: 14px;
}
<pre class="language-text"><code class="language-text">code-block.css:1:2 <a href="https://biomejs.dev/linter/rules/no-unknown-at-rules">lint/suspicious/noUnknownAtRules</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unexpected unknown at-rule: </span><span style="color: Tomato;"><strong>unknown-at-rule</strong></span><span style="color: Tomato;"> </span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>@unknown-at-rule &#123; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> font-size: 14px; <strong>3 │ </strong>&#125; <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>unknown-at-rule</strong></span><span style="color: lightgreen;"> is not a standard CSS at-rule, which may lead to unexpected styling results or failure to interpret the styles as intended.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">See </span><span style="color: lightgreen;"><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule">MDN web docs</a></span><span style="color: lightgreen;"> for a known list of at-rules.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">To fix this issue, consider removing the unknown at-rule.</span> </code></pre>

Valid

css
@charset 'UTF-8';
css
@media (max-width: 960px) {
  body {
    font-size: 13px;
  }
}

Options

ignore

A list of unknown at-rule names to ignore (case-insensitive).

json
{
	"linter": {
		"rules": {
			"suspicious": {
				"noUnknownAtRules": {
					"options": {
						"ignore": [
							"custom-at-rule",
							"my-custom-rule"
						]
					}
				}
			}
		}
	}
}

Valid

css
@custom-at-rule {}
@my-custom-rule {
  color: red;
}
</TabItem> </Tabs>