id-pattern
What it does
Section titled “What it does”Reports an id that does not match the option pattern, a regex that by default means kebab-case: lowercase letters and digits in words joined by -, beginning with a letter.
Why it matters
Section titled “Why it matters”An id is a name that scripts, links and styles refer to; a single style makes it predictable. An id in capitals or with _ is often written one way and referred to another.
To fix, rename the id and everything that refers to it, or change the pattern.
Example
Section titled “Example”<!DOCTYPE html><title>x</title><p id="fooBar" class="ok fooBar x_y"></p><p id="foo-bar"></p><p id="1a"></p><input name="fooBar">...<input name="foo[]">...Configuration
Section titled “Configuration”angular: lint: rules: id-pattern: level: warn # off (default), warn, error options: pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"html: lint: rules: id-pattern: level: warn # off (default), warn, error options: pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"svelte: lint: rules: id-pattern: level: warn # off (default), warn, error options: pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"vue: lint: rules: id-pattern: level: warn # off (default), warn, error options: pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"| Option | Type | Default | Description |
|---|---|---|---|
pattern |
string | "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" |
The regex the value must match. |
Suppress one line with sudsy-disable-next-line id-pattern in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| html-eslint | id-naming-convention |
partial | the convention is the pattern option (a regex), not named styles |
| html-validate | id-pattern |
full |