.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / selector-max-class / README.md
1 # selector-max-class
2
3 Limit the number of classes in a selector.
4
5 ```css
6 div .foo.bar[data-val] > a.baz {}
7 /*  ↑   ↑                 ↑
8     |   |                 |
9     1   2                 3  -- this selector contains three classes */
10 ```
11
12 This rule resolves nested selectors before counting the number of classes in a selector. Each selector in a [selector list](https://www.w3.org/TR/selectors4/#selector-list) is evaluated separately.
13
14 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.
15
16 ## Options
17
18 `int`: Maximum classes allowed.
19
20 For example, with `2`:
21
22 The following patterns are considered violations:
23
24 ```css
25 .foo.bar.baz {}
26 ```
27
28 ```css
29 .foo .bar {
30   & > .baz {}
31 }
32 ```
33
34 The following patterns are *not* considered violations:
35
36 ```css
37 div {}
38 ```
39
40 ```css
41 .foo .bar {}
42 ```
43
44 ```css
45 .foo.bar,
46 .lorem.ipsum {} /* each selector in a selector list is evaluated separately */
47 ```
48
49 ```css
50 .foo .bar :not(.lorem.ipsum) {} /* `.lorem.ipsum` is inside `:not()`, so it is evaluated separately */
51 ```