Skip to content

noUnmatchableAnbSelector

诊断类别:lint/correctness/noUnmatchableAnbSelector

¥Diagnostic Category: lint/correctness/noUnmatchableAnbSelector

自从:v1.8.0

¥Since: v1.8.0

来源:

¥Sources:

禁止不匹配的 An+B 选择器。

¥Disallow unmatchable An+B selectors.

始终求值为 0 的选择器将不匹配任何元素。有关 An+B 语法的更多详细信息,请参阅:https://www.w3.org/TR/css-syntax-3/#anb-microsyntax

¥Selectors that always evaluate to 0 will not match any elements. For more details about the An+B syntax, see: https://www.w3.org/TR/css-syntax-3/#anb-microsyntax

¥Examples

¥Invalid

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.

¥Valid

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

¥Related links