Back to Biomejs

noUnknownProperty

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

latest5.3 KB
Original Source

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

<Tabs> <TabItem label="CSS" icon="seti:css"> ## Summary - Rule available since: `v1.8.0` - Diagnostic Category: [`lint/correctness/noUnknownProperty`](/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 [`property-no-unknown`](https://github.com/stylelint/stylelint/blob/main/lib/rules/property-no-unknown/README.md)

How to configure

json
{
	"linter": {
		"rules": {
			"correctness": {
				"noUnknownProperty": "error"
			}
		}
	}
}

Description

Disallow unknown properties.

This rule considers properties defined in the CSS Specifications and browser specific properties to be known. https://github.com/known-css/known-css-properties#source

This rule ignores:

  • custom variables e.g. --custom-property
  • vendor-prefixed properties (e.g., -moz-align-self, -webkit-align-self)

Examples

Invalid

css
a {
  colr: blue;
}
<pre class="language-text"><code class="language-text">code-block.css:2:3 <a href="https://biomejs.dev/linter/rules/no-unknown-property">lint/correctness/noUnknownProperty</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unknown property is not allowed.</span> <strong>1 │ </strong>a &#123; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> colr: blue; <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>3 │ </strong>&#125; <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">See </span><span style="color: lightgreen;"><a href="https://stylelint.io/user-guide/rules/property-no-unknown/">CSS Specifications and browser specific properties</a></span><span style="color: lightgreen;"> for more details.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">To resolve this issue, replace the unknown property with a valid CSS property.</span> </code></pre>
css
a {
  my-property: 1;
}
<pre class="language-text"><code class="language-text">code-block.css:2:3 <a href="https://biomejs.dev/linter/rules/no-unknown-property">lint/correctness/noUnknownProperty</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unknown property is not allowed.</span> <strong>1 │ </strong>a &#123; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> my-property: 1; <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>3 │ </strong>&#125; <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">See </span><span style="color: lightgreen;"><a href="https://stylelint.io/user-guide/rules/property-no-unknown/">CSS Specifications and browser specific properties</a></span><span style="color: lightgreen;"> for more details.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">To resolve this issue, replace the unknown property with a valid CSS property.</span> </code></pre>

Valid

css
a {
  color: green;
}
css
a {
  fill: black;
}
css
a {
  -moz-align-self: center;
}

Options

ignore

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

json
{
	"linter": {
		"rules": {
			"correctness": {
				"noUnknownProperty": {
					"options": {
						"ignore": [
							"custom-property"
						]
					}
				}
			}
		}
	}
}

Valid

css
a {
  custom-property: black;
}
</TabItem> </Tabs>