Skip to content

no-duplicate-selectors

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).

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.

Reported
a { color: red }
b, a { color: red }
a, b { color: red }
a { color: blue }
@media print { a { color: red } }
...
css:
lint:
rules:
no-duplicate-selectors: warn # off (default), warn, error
less:
lint:
rules:
no-duplicate-selectors: warn # off (default), warn, error
scss:
lint:
rules:
no-duplicate-selectors: warn # off (default), warn, error

Enabled 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.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint no-duplicate-selectors full