UNPKG

1.71 kBMarkdownView Raw
1# selector-combinator-space-before
2
3Require a single space or disallow whitespace before the combinators of selectors.
4
5<!-- prettier-ignore -->
6```css
7 a > b + c ~ d e >>> f { color: pink; }
8/** ↑ ↑ ↑ ↑ ↑
9 * These are combinators */
10```
11
12Combinators 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
14The descendant combinator is _not_ checked by this rule.
15
16Also, `+` and `-` signs within `:nth-*()` arguments are not checked (e.g. `a:nth-child(2n+1)`).
17
18The [`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
26There _must always_ be a single space before the combinators.
27
28The following patterns are considered violations:
29
30<!-- prettier-ignore -->
31```css
32a+ b { color: pink; }
33```
34
35<!-- prettier-ignore -->
36```css
37a>b { color: pink; }
38```
39
40The following patterns are _not_ considered violations:
41
42<!-- prettier-ignore -->
43```css
44a + b { color: pink; }
45```
46
47<!-- prettier-ignore -->
48```css
49a >b { color: pink; }
50```
51
52### `"never"`
53
54There _must never_ be whitespace before the combinators.
55
56The following patterns are considered violations:
57
58<!-- prettier-ignore -->
59```css
60a + b { color: pink; }
61```
62
63<!-- prettier-ignore -->
64```css
65a >b { color: pink; }
66```
67
68The following patterns are _not_ considered violations:
69
70<!-- prettier-ignore -->
71```css
72a+ b { color: pink; }
73```
74
75<!-- prettier-ignore -->
76```css
77a>b { color: pink; }
78```