Skip to main content

selector-anb-no-unmatchable

Disallow unmatchable An+B selectors.

a:nth-child(0n+0) {}
/*↑ ↑
* This unmatchable An+B selector */

Use this rule to avoid selectors that never match. An An+B argument that always evaluates to 0, e.g. :nth-child(0n), matches nothing, as An+B is one-indexed.

This rule supports 1 message argument: the unmatchable selector.

Options​

true​

{
"selector-anb-no-unmatchable": true
}

The following patterns are considered problems:

a:nth-child(0) {}
a:nth-last-child(0n) {}
a:nth-of-type(0n+0) {}
a:nth-last-of-type(0 of a) {}

The following patterns are not considered problems:

a:nth-child(1) {}
a:nth-last-child(1n) {}
a:nth-of-type(1n+0) {}
a:nth-last-of-type(1 of a) {}