跳转到内容

noUnknownAttribute

此内容尚不支持你的语言。

biome.json
{
"linter": {
"rules": {
"nursery": {
"noUnknownAttribute": "error"
}
}
}
}

Disallow unknown DOM properties.

In JSX, most DOM properties and attributes should be camelCased to be consistent with standard JavaScript style. This can be a possible source of error if you are used to writing plain HTML. Only data-* and aria-* attributes are allowed to use hyphens and lowercase letters in JSX.

<div allowTransparency="true" />
code-block.jsx:1:6 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The property ‘allowTransparency’ is not a valid DOM attribute.

> 1 │ <div allowTransparency=“true” />
^^^^^^^^^^^^^^^^^^^^^^^^
2 │

This property is not recognized as a valid HTML/DOM attribute or React prop.

Check the spelling or consider using a valid data-* attribute for custom properties.

<div onclick={() => {}} />
code-block.jsx:1:6 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Property ‘onclick’ is not a valid React prop name.

> 1 │ <div onclick={() => {}} />
^^^^^^^^^^^^^^^^^^
2 │

React uses camelCased props, while HTML uses kebab-cased attributes.

Use ‘onClick’ instead of ‘onclick’ for React components.

<div for="bar" />
code-block.jsx:1:6 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Property ‘for’ is not a valid React prop name.

> 1 │ <div for=“bar” />
^^^^^^^^^
2 │

React uses camelCased props, while HTML uses kebab-cased attributes.

Use ‘htmlFor’ instead of ‘for’ for React components.

<div className="foo" />
<div onClick={() => {}} />
<div htmlFor="bar" />
<div data-foo="bar" />
<div aria-label="Close" />

An array of property and attribute names to ignore during validation.

{
"noUnknownAttribute": {
"options": {
"ignore": ["custom-attribute", "non-standard-prop"]
}
}
}