Skip to content

selector-anb-no-unmatchable

Reports an :nth-child() and the like whose An+B can never match (0, 0n, -n, -2n-1).

The selector matches no element, so the rule does nothing. It is a miscalculated formula, or a leftover of a larger one.

To fix, correct the formula; -n+3 matches the first three.

Reported
...
a:nth-child(0), a:nth-child(2n+1), a:nth-last-child(-n) {}
...
@keyframes k { from { top: 0 } to { top: 1px } }
...
After the fix
...
a:nth-child(0), a:nth-child(2n+1), a:nth-last-child(-n) {}
...
@keyframes k { from { top: 0 } to { top: 1px } }
...
css:
lint:
rules:
selector-anb-no-unmatchable: warn # off, warn (default), error
less:
lint:
rules:
selector-anb-no-unmatchable: warn # off, warn (default), error
scss:
lint:
rules:
selector-anb-no-unmatchable: warn # off, warn (default), error

Enabled by the presets: css/stylelint-recommended.

Suppress one line with sudsy-disable-next-line selector-anb-no-unmatchable 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 selector-anb-no-unmatchable full