Skip to content

noUnmatchableAnbSelector (CSS)

Language CSS
biome.json
{
"linter": {
"rules": {
"correctness": {
"noUnmatchableAnbSelector": "error"
}
}
}
}

Disallow An+B formulas that cannot select an element.

Pseudo-classes such as :nth-child() use an An+B formula to describe element positions: A controls the interval and B is the starting offset. Element positions begin at 1, so a formula that produces only 0 can never match.

See the CSS syntax specification for the complete formula syntax.

a:nth-child(0) {}
code-block.css:1:13 lint/correctness/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This selector will never match any elements.

> 1 │ a:nth-child(0) {}
│ ^
2 │

ℹ Avoid using An+B selectors that always evaluate to 0.

ℹ For more details, see the official spec for An+B selectors.

a:nth-last-child(0n) {}
code-block.css:1:18 lint/correctness/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This selector will never match any elements.

> 1 │ a:nth-last-child(0n) {}
│ ^^
2 │

ℹ Avoid using An+B selectors that always evaluate to 0.

ℹ For more details, see the official spec for An+B selectors.

a:nth-of-type(0n+0) {}
code-block.css:1:15 lint/correctness/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This selector will never match any elements.

> 1 │ a:nth-of-type(0n+0) {}
│ ^^^^
2 │

ℹ Avoid using An+B selectors that always evaluate to 0.

ℹ For more details, see the official spec for An+B selectors.

a:nth-last-of-type(0 of a) {}
code-block.css:1:20 lint/correctness/noUnmatchableAnbSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This selector will never match any elements.

> 1 │ a:nth-last-of-type(0 of a) {}
│ ^^^^^^
2 │

ℹ Avoid using An+B selectors that always evaluate to 0.

ℹ For more details, see the official spec for An+B selectors.

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