no-redundant-for
What it does
Section titled “What it does”Reports a <label> whose for names a control that is inside the label.
Why it matters
Section titled “Why it matters”The label already names the control it holds, so the for and the id it needs say the same thing twice, and they can drift apart when one is renamed.
To fix, remove the for (and the id if nothing else uses it).
Example
Section titled “Example”...<p id="a-b_c"></p>...<label for="x"><input type="text" id="x"></label><label for="y">y</label><input type="text" id="y">...Configuration
Section titled “Configuration”angular: lint: rules: no-redundant-for: warn # off (default), warn, errorhtml: lint: rules: no-redundant-for: warn # off (default), warn, errorsvelte: lint: rules: no-redundant-for: warn # off (default), warn, errorvue: lint: rules: no-redundant-for: warn # off (default), warn, errorEnabled by the presets: html/html-validate-recommended.
Suppress one line with sudsy-disable-next-line no-redundant-for 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 | no-redundant-for |
full |