no-duplicate-id
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/html-validate-standardhtml/htmlhinthtml/html-eslint-recommended
What it does
Section titled “What it does”Reports an id that an earlier element of the document already has.
Why it matters
Section titled “Why it matters”Ids must be unique. Scripts, links, labels and styles find the first element only, so the second one is silently unreachable.
To fix, give the element another id.
Example
Section titled “Example”...<main hidden></main>...<p id="a"></p><p id="a"></p>...<p id=""></p><ul><li>a</li></ul>...Configuration
Section titled “Configuration”angular: lint: rules: no-duplicate-id: warn # off, warn (default), errorhtml: lint: rules: no-duplicate-id: warn # off, warn (default), errorsvelte: lint: rules: no-duplicate-id: warn # off, warn (default), errorvue: lint: rules: no-duplicate-id: warn # off, warn (default), errorEnabled by the presets: html/html-validate-standard, html/htmlhint, html/html-eslint-recommended.
Suppress one line with sudsy-disable-next-line no-duplicate-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-eslint | no-duplicate-id |
full | |
| html-validate | no-dup-id |
partial | ids are not scoped per <template>; no include and exclude options |
| htmlhint | id-unique |
full |