.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / no-duplicate-selectors / README.md
1 # no-duplicate-selectors
2
3 Disallow duplicate selectors within a stylesheet.
4
5 ```css
6     .foo {} .bar {} .foo {}
7 /** ↑              ↑
8  * These duplicates */
9 ```
10
11 This rule checks for two types of duplication:
12
13 -   Duplication of a single selector with a rule's selector list, e.g. `a, b, a {}`.
14 -   Duplication of a selector list within a stylesheet, e.g. `a, b {} a, b {}`. Duplicates are found even if the selectors come in different orders or have different spacing, e.g. `a d, b > c {} b>c, a   d {}`.
15
16 The same selector *is* allowed to repeat in the following circumstances:
17
18 -   It is used in different selector lists, e.g. `a {} a, b {}`.
19 -   The duplicates are determined to originate in different stylesheets, e.g. you have concatenated or compiled files in a way that produces sourcemaps for PostCSS to read, e.g. postcss-import).
20 -   The duplicates are in rules with different parent nodes, e.g. inside and outside of a media query.
21
22 This rule resolves nested selectors. So `a b {} a { & b {} }` counts as a violation, because the resolved selectors end up with a duplicate.
23
24 ## Options
25
26 ### `true`
27
28 The following patterns are considered violations:
29
30 ```css
31 .foo,
32 .bar,
33 .foo {}
34 ```
35
36 ```css
37 .foo {}
38 .bar {}
39 .foo {}
40 ```
41
42 ```css
43 .foo .bar {}
44 .bar {}
45 .foo .bar {}
46 ```
47
48 ```css
49 @media (min-width: 10px) {
50   .foo {}
51   .foo {}
52 }
53 ```
54
55 ```css
56 .foo, .bar {}
57 .bar, .foo {}
58 ```
59
60 ```css
61 a .foo, b + .bar {}
62 b+.bar,
63 a
64   .foo {}
65 ```
66
67 ```css
68 a b {}
69 a {
70   & b {}
71 }
72 ```
73
74 The following patterns are *not* considered violations:
75
76 ```css
77 .foo {}
78 @media (min-width: 10px) {
79   .foo {}
80 }
81 ```
82
83 ```css
84 .foo {
85   .foo {}
86 }
87 ```
88
89 ```css
90 .foo {}
91 .bar {}
92 .foo .bar {}
93 .bar .foo {}
94 ```
95
96 ```css
97 a b {}
98 a {
99   & b,
100   & c {}
101 }
102 ```