.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / selector-max-type / README.md
1 # selector-max-type
2
3 Limit the number of type selectors in a selector.
4
5 ```css
6     a {}
7 /** ↑
8  * This type of selector */
9 ```
10
11 This rule resolves nested selectors before counting the number of type selectors. Each selector in a [selector list](https://www.w3.org/TR/selectors4/#selector-list) is evaluated separately.
12
13 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.
14
15 ## Options
16
17 `int`: Maximum type selectors allowed.
18
19 For example, with `2`:
20
21 The following patterns are considered violations:
22
23 ```css
24 div a span {}
25 ```
26
27 ```css
28 div a {
29   & span {}
30 }
31 ```
32
33 ```css
34 div a {
35   & > a {}
36 }
37 ```
38
39 The following patterns are *not* considered violations:
40
41 ```css
42 div {}
43 ```
44
45 ```css
46 div a {}
47 ```
48
49 ```css
50 .foo div a {}
51 ```
52
53 ```css
54 div.foo a {}
55 ```
56
57 ```css
58 /* each selector in a selector list is evaluated separately */
59 div,
60 a span {}
61 ```
62
63 ```css
64 /* `span` is inside `:not()`, so it is evaluated separately */
65 div a .foo:not(span) {}
66 ```
67
68 The following patterns are *not* considered violations:
69
70 ## Optional secondary options
71
72 ### `ignore: ["child", "compounded", "descendant"]`
73
74 #### `"child"`
75
76 Discount child type selectors.
77
78 For example, with `2`:
79
80 The following patterns are *not* considered violations:
81
82 ```css
83 div span > a {}
84 ```
85
86 ```css
87 #bar div span > a {}
88 ```
89
90 #### `"compounded"`
91
92 Discount compounded type selectors -- i.e. type selectors chained with other selectors.
93
94 For example, with `2`:
95
96 The following patterns are *not* considered violations:
97
98 ```css
99 div span a.foo {}
100 ```
101
102 ```css
103 div span a#bar {}
104 ```
105
106 #### `"descendant"`
107
108 Discount descendant type selectors.
109
110 For example, with `2`:
111
112 The following patterns are *not* considered violations:
113
114 ```css
115 .foo div span a {}
116 ```
117
118 ```css
119 #bar div span a {}
120 ```
121
122 ### `ignoreTypes: ["/regex/", "string"]`
123
124 Given:
125
126 ```js
127 ["/^my-/", "custom"]
128 ```
129
130 For example, with `2`.
131
132 The following patterns are *not* considered violations:
133
134 ```css
135 div a custom {}
136 ```
137
138 ```css
139 div a my-type {}
140 ```
141
142 ```css
143 div a my-other-type {}
144 ```