valid-id
Angular templatesHTMLVue / SvelteVue / Sveltesuspiciousno fixdefault: offhtml/html-validate-recommended
What it does
Section titled “What it does”Reports an id that is empty, has white space, begins with a digit or has characters other than letters, digits, - and _.
Why it matters
Section titled “Why it matters”Such an id is valid HTML5, but it must be escaped in CSS selectors (#1a does not select it) and some scripts and older tools fail on it.
To fix, rename the id.
Example
Section titled “Example”<!DOCTYPE html><title>x</title><p id="1a"></p><p id="a b"></p><p id="a-b_c"></p><p id=""></p>...<label for="y">y</label><input type="text" id="y">...Configuration
Section titled “Configuration”angular: lint: rules: valid-id: warn # off (default), warn, errorhtml: lint: rules: valid-id: warn # off (default), warn, errorsvelte: lint: rules: valid-id: warn # off (default), warn, errorvue: lint: rules: valid-id: warn # off (default), warn, errorEnabled by the presets: html/html-validate-recommended.
Suppress one line with sudsy-disable-next-line valid-id 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-validate | valid-id |
partial | the strict form only, without the relaxed option |