UNPKG

1.16 kBMarkdownView Raw
1# selector-max-pseudo-class
2
3Limit the number of pseudo-classes in a selector.
4
5<!-- prettier-ignore -->
6```css
7.foo .bar:first-child:hover {}
8/* ↑ ↑
9 ↑ ↑
10 1 2 -- this selector contains two pseudo-classes */
11```
12
13This rule resolves nested selectors before counting the number of pseudo-classes in a selector. Each selector in a [selector list](https://www.w3.org/TR/selectors4/#selector-list) is evaluated separately.
14
15The content of the `:not()` pseudo-class is also evaluated separately. The rule processes the argument as if it were an independent selector, and the result does not count toward the total for the entire selector.
16
17## Options
18
19`int`: Maximum pseudo-classes allowed.
20
21For example, with `1`:
22
23The following patterns are considered violations:
24
25<!-- prettier-ignore -->
26```css
27a:first-child:focus {}
28```
29
30<!-- prettier-ignore -->
31```css
32.foo .bar:first-child:hover {}
33```
34
35The following patterns are _not_ considered violations:
36
37<!-- prettier-ignore -->
38```css
39a {}
40```
41
42<!-- prettier-ignore -->
43```css
44a:first-child {}
45```
46
47<!-- prettier-ignore -->
48```css
49.foo .bar:first-child {}
50```