Back to Biomejs

noUnknownFunction

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

latest3.6 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/noUnknownFunction`](/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 [`function-no-unknown`](https://github.com/stylelint/stylelint/blob/main/lib/rules/function-no-unknown/README.md)

How to configure

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

Description

Disallow unknown CSS value functions.

This rule ignores double-dashed custom functions, e.g. --custom-function().

Data sources of known CSS value functions are:

Examples

Invalid

css
a { transform: unknown(1); }
<pre class="language-text"><code class="language-text">code-block.css:1:16 <a href="https://biomejs.dev/linter/rules/no-unknown-function">lint/correctness/noUnknownFunction</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Unexpected unknown function: </span><span style="color: Tomato;"><strong>unknown</strong></span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; transform: unknown(1); &#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;">Use a known function instead.</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/CSS_Functions">MDN web docs</a></span><span style="color: lightgreen;"> for more details.</span> </code></pre>

Valid

css
a { transform: scale(1); }

Options

ignore

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

json
{
	"linter": {
		"rules": {
			"correctness": {
				"noUnknownFunction": {
					"options": {
						"ignore": [
							"custom-function"
						]
					}
				}
			}
		}
	}
}

Valid

css
a { transform: custom-function(1); }
</TabItem> </Tabs>