.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / selector-max-attribute / README.md
1 # selector-max-attribute
2
3 Limit the number of attribute selectors in a selector.
4
5 ```css
6     [rel="external"] {}
7 /** ↑
8  * This type of selector */
9 ```
10
11 This rule resolves nested selectors before counting the number of attribute 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 attribute selectors allowed.
18
19 For example, with `2`:
20
21 The following patterns are considered violations:
22
23 ```css
24 [type="number"][name="quality"][data-attribute="value"] {}
25 ```
26
27 ```css
28 [type="number"][name="quality"][disabled] {}
29 ```
30
31 ```css
32 [type="number"][name="quality"] {
33   & [data-attribute="value"] {}
34 }
35 ```
36
37 ```css
38 [type="number"][name="quality"] {
39   & [disabled] {}
40 }
41 ```
42
43 ```css
44 [type="number"][name="quality"] {
45   & > [data-attribute="value"] {}
46 }
47 ```
48
49 ```css
50 /* `[type="text"][data-attribute="value"][disabled]` is inside `:not()`, so it is evaluated separately */
51 input:not([type="text"][data-attribute="value"][disabled]) {}
52 ```
53
54 The following patterns are *not* considered violations:
55
56 ```css
57 [type="text"] {}
58 ```
59
60 ```css
61 [type="text"][name="message"] {}
62 ```
63
64 ```css
65 [type="text"][disabled]
66 ```
67
68 ```css
69 /* each selector in a selector list is evaluated separately */
70 [type="text"][name="message"],
71 [type="number"][name="quality"] {}
72 ```
73
74 ```css
75 /* `[disabled]` is inside `:not()`, so it is evaluated separately */
76 [type="text"][name="message"]:not([disabled]) {}
77 ```
78
79 ## Optional secondary options
80
81 ### `ignoreAttributes: ["/regex/", "string"]`
82
83 Given:
84
85 ```js
86 ["/^my-/", "dir"]
87 ```
88
89 For example, with `0`.
90
91 The following patterns are *not* considered violations:
92
93 ```css
94 [dir] [my-attr] {}
95 ```
96
97 ```css
98 [dir] [my-other-attr] {}
99 ```