1 | # selector-max-combinators
|
2 |
|
3 | Limit the number of combinators in a selector.
|
4 |
|
5 |
|
6 | ```css
|
7 | a > b + c ~ d e { color: pink; }
|
8 | /** ↑ ↑ ↑ ↑
|
9 | * These are combinators */
|
10 | ```
|
11 |
|
12 | This rule resolves nested selectors before counting the number of combinators selectors. Each selector in a [selector list](https://www.w3.org/TR/selectors4/#selector-list) is evaluated separately.
|
13 |
|
14 | ## Options
|
15 |
|
16 | `int`: Maximum combinators selectors allowed.
|
17 |
|
18 | For example, with `2`:
|
19 |
|
20 | The following patterns are considered violations:
|
21 |
|
22 |
|
23 | ```css
|
24 | a b ~ c + d {}
|
25 | ```
|
26 |
|
27 |
|
28 | ```css
|
29 | a b ~ c {
|
30 | & > d {}
|
31 | }
|
32 | ```
|
33 |
|
34 |
|
35 | ```css
|
36 | a b {
|
37 | & ~ c {
|
38 | & + d {}
|
39 | }
|
40 | }
|
41 | ```
|
42 |
|
43 | The following patterns are _not_ considered violations:
|
44 |
|
45 |
|
46 | ```css
|
47 | a {}
|
48 | ```
|
49 |
|
50 |
|
51 | ```css
|
52 | a b {}
|
53 | ```
|
54 |
|
55 |
|
56 | ```css
|
57 | a b ~ c {}
|
58 | ```
|
59 |
|
60 |
|
61 | ```css
|
62 | a b {
|
63 | & ~ c {}
|
64 | }
|
65 | ```
|
66 |
|
67 |
|
68 | ```css
|
69 | /* each selector in a selector list is evaluated separately */
|
70 | a b,
|
71 | c > d {}
|
72 | ```
|