no-unknown-property
Configuration
rslint.config.ts
Disallow usage of unknown DOM property.
Rule Details
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 use
hyphens and lowercase letters in JSX.
The rule flags four classes of issue on lowercase HTML/DOM tags:
unknownProp— an attribute that does not match any known React DOM property / aria / data-* attribute.unknownPropWithStandardName— an attribute whose lowercased form matches a standard React property name, but whose casing differs (for exampleclass→className,onmousedown→onMouseDown). Automatically fixable.invalidPropOnTag— an attribute that is recognized, but only valid on a specific set of tags (for examplecrossOriginonscript/imgbut notdiv).dataLowercaseRequired— adata-*attribute that contains uppercase characters, reported only when therequireDataLowercaseoption is set.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Rule Options
ignore: optional array of property and attribute names to skip during validation.requireDataLowercase: optional boolean (defaultfalse). Whentrue, anydata-*attribute that contains uppercase characters is reported. React itself warns about such attributes at runtime; enabling this option catches them statically.
Examples of correct code with { "ignore": ["css"] }:
Examples of incorrect code with { "requireDataLowercase": true }:
React version detection
Some recognized attributes depend on the configured React version
(settings.react.version):
- React
< 16.1still acceptsallowTransparency. - React
>= 16.4adds the pointer-event handlers (onPointerDown,onPointerUp, …). - React
>= 19addsprecedencefor stylesheet support.
When the version is not set, the rule assumes the latest React.