no-duplicate-selectors
CSS / SCSS / LessCSS / SCSS / LessCSS / SCSS / Lesssuspiciousno fixdefault: offcss/stylelint-recommended
What it does
Section titled “What it does”Reports a selector list that is already used by an earlier rule in the same block or file; the order of the selectors in the list does not matter (b, a repeats a, b).
Why it matters
Section titled “Why it matters”Rules with the same selector are one rule written twice. The declarations end up apart, so a later change to one of them is easy to make in the wrong place, and the cascade between the two is hard to follow.
To fix, merge the declarations into the first rule.
Example
Section titled “Example”a { color: red }b, a { color: red }a, b { color: red }a { color: blue }@media print { a { color: red } }...Configuration
Section titled “Configuration”css: lint: rules: no-duplicate-selectors: warn # off (default), warn, errorless: lint: rules: no-duplicate-selectors: warn # off (default), warn, errorscss: lint: rules: no-duplicate-selectors: warn # off (default), warn, errorEnabled by the presets: css/stylelint-recommended.
Suppress one line with sudsy-disable-next-line no-duplicate-selectors 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 |
|---|---|---|
| stylelint | no-duplicate-selectors |
full |