1 | # selector-combinator-space-after
|
2 |
|
3 | Require a single space or disallow whitespace after the combinators of selectors.
|
4 |
|
5 |
|
6 | ```css
|
7 | a > b + c ~ d e >>> f { color: pink; }
|
8 | /** ↑ ↑ ↑ ↑ ↑
|
9 | * These are combinators */
|
10 | ```
|
11 |
|
12 | Combinators are used to combine several different selectors into new and more specific ones. There are several types of combinators, including: child (`>`), adjacent sibling (`+`), general sibling (`~`), and descendant (which is represented by a blank space between two selectors).
|
13 |
|
14 | The descendant combinator is _not_ checked by this rule.
|
15 |
|
16 | Also, `+` and `-` signs within `:nth-*()` arguments are not checked (e.g. `a:nth-child(2n+1)`).
|
17 |
|
18 | The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
|
19 |
|
20 | ## Options
|
21 |
|
22 | `string`: `"always"|"never"`
|
23 |
|
24 | ### `"always"`
|
25 |
|
26 | There _must always_ be a single space after the combinators.
|
27 |
|
28 | The following patterns are considered problems:
|
29 |
|
30 |
|
31 | ```css
|
32 | a +b { color: pink; }
|
33 | ```
|
34 |
|
35 |
|
36 | ```css
|
37 | a>b { color: pink; }
|
38 | ```
|
39 |
|
40 | The following patterns are _not_ considered problems:
|
41 |
|
42 |
|
43 | ```css
|
44 | a + b { color: pink; }
|
45 | ```
|
46 |
|
47 |
|
48 | ```css
|
49 | a> b { color: pink; }
|
50 | ```
|
51 |
|
52 | ### `"never"`
|
53 |
|
54 | There _must never_ be whitespace after the combinators.
|
55 |
|
56 | The following patterns are considered problems:
|
57 |
|
58 |
|
59 | ```css
|
60 | a + b { color: pink; }
|
61 | ```
|
62 |
|
63 |
|
64 | ```css
|
65 | a> b { color: pink; }
|
66 | ```
|
67 |
|
68 | The following patterns are _not_ considered problems:
|
69 |
|
70 |
|
71 | ```css
|
72 | a +b { color: pink; }
|
73 | ```
|
74 |
|
75 |
|
76 | ```css
|
77 | a>b { color: pink; }
|
78 | ```
|