noUnmatchableAnbSelector (since v1.8.0)
Diagnostic Category: lint/nursery/noUnmatchableAnbSelector
Sources:
Disallow unmatchable An+B selectors.
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
Section titled ExamplesInvalid
Section titled Invalida:nth-child(0) {}code-block.css:1:13 lint/nursery/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/nursery/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/nursery/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/nursery/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
Section titled Valida:nth-child(1) {}a:nth-last-child(1n) {}a:nth-of-type(1n+0) {}a:nth-last-of-type(1 of a) {}