Disallow usage of unknown attributes

Rule ID:
no-unknown-attributes
Category:
-
Standards:
-

Experimental: This rule is still in an early stage. If you encounter false positives or missing attributes, please file a bug report.

This rule requires all attributes used on an element to be valid for that element. Global HTML attributes (e.g. id, class, style, hidden) are included automatically.

Elements without metadata (e.g. custom elements) are ignored.

Rule details

Examples of incorrect code for this rule:

<div unknown="value"></div>
error: Attribute "unknown" is not allowed on <div> element (no-unknown-attributes)
> 1 | <div unknown="value"></div>
    |      ^^^^^^^


1 error found.

Examples of correct code for this rule:

<div id="foo" class="bar" hidden></div>
<input type="text" name="username" />
error: Attribute "name" is not allowed on <input> element (no-unknown-attributes)
  1 | <div id="foo" class="bar" hidden></div>
> 2 | <input type="text" name="username" />
    |                    ^^^^


1 error found.

Exceptions

Currently this rule ignores:

Version history