hint
hint copied to clipboard
[Feature] Add hint to report when using `nth-child(0)` in CSS
🚀 Feature request
Description
The nth-child
and related psedo-selectors are 1-based. Passing 0
silently fails in browsers today, leading to confusion and wasting developer time (see https://twitter.com/dan_abramov/status/1492277543185096704). By warning when these selectors are passed 0
, webhint can help developers find and fix this issue faster.
Details
The set of 1-based selectors to look for:
-
nth-child
https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child -
nth-last-child
https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child -
nth-of-type
https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type -
nth-last-of-type
https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-of-type