attr-pattern
What it does
Section titled “What it does”Reports an attribute name that does not match the option pattern, a regex that by default allows letters, digits, - and : in either case. An underscore, for example, is reported (data_x).
Why it matters
Section titled “Why it matters”A naming rule for attributes keeps custom data attributes and framework attributes uniform. A name outside the usual character set is most often a typing error that the browser silently accepts as a new attribute.
To fix, rename the attribute, or change the pattern.
Example
Section titled “Example”...<input name="fooBar">...<input name="foo[]"><p fooBar="x" data-X="y" a_b="c"></p>Configuration
Section titled “Configuration”angular: lint: rules: attr-pattern: level: warn # off (default), warn, error options: pattern: "(?i)^[a-z0-9:-]+$"html: lint: rules: attr-pattern: level: warn # off (default), warn, error options: pattern: "(?i)^[a-z0-9:-]+$"svelte: lint: rules: attr-pattern: level: warn # off (default), warn, error options: pattern: "(?i)^[a-z0-9:-]+$"vue: lint: rules: attr-pattern: level: warn # off (default), warn, error options: pattern: "(?i)^[a-z0-9:-]+$"| Option | Type | Default | Description |
|---|---|---|---|
pattern |
string | "(?i)^[a-z0-9:-]+$" |
The regex the value must match. |
Suppress one line with sudsy-disable-next-line attr-pattern in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| html-validate | attr-pattern |
full |