UNPKG

3.1 kBMarkdownView Raw
1# block-opening-brace-space-before
2
3Require a single space or disallow whitespace before the opening brace of blocks.
4
5<!-- prettier-ignore -->
6```css
7 a { color: pink; }
8/** ↑
9 * The space before this brace */
10```
11
12The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
13
14## Options
15
16`string`: `"always"|"never"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
17
18### `"always"`
19
20There _must always_ be a single space before the opening brace.
21
22The following patterns are considered violations:
23
24<!-- prettier-ignore -->
25```css
26a{ color: pink; }
27```
28
29<!-- prettier-ignore -->
30```css
31a
32{ color: pink; }
33```
34
35The following patterns are _not_ considered violations:
36
37<!-- prettier-ignore -->
38```css
39a { color: pink; }
40```
41
42<!-- prettier-ignore -->
43```css
44a {
45color: pink; }
46```
47
48### `"never"`
49
50There _must never_ be whitespace before the opening brace.
51
52The following patterns are considered violations:
53
54<!-- prettier-ignore -->
55```css
56a { color: pink; }
57```
58
59<!-- prettier-ignore -->
60```css
61a
62{ color: pink; }
63```
64
65The following patterns are _not_ considered violations:
66
67<!-- prettier-ignore -->
68```css
69a{ color: pink; }
70```
71
72<!-- prettier-ignore -->
73```css
74a{
75color: pink; }
76```
77
78### `"always-single-line"`
79
80There _must always_ be a single space before the opening brace in single-line blocks.
81
82The following patterns are considered violations:
83
84<!-- prettier-ignore -->
85```css
86a{ color: pink; }
87```
88
89The following patterns are _not_ considered violations:
90
91<!-- prettier-ignore -->
92```css
93a { color: pink; }
94```
95
96<!-- prettier-ignore -->
97```css
98a{
99color: pink; }
100```
101
102### `"never-single-line"`
103
104There _must never_ be whitespace before the opening brace in single-line blocks.
105
106The following patterns are considered violations:
107
108<!-- prettier-ignore -->
109```css
110a { color: pink; }
111```
112
113The following patterns are _not_ considered violations:
114
115<!-- prettier-ignore -->
116```css
117a{ color: pink; }
118```
119
120<!-- prettier-ignore -->
121```css
122a {
123color: pink; }
124```
125
126### `"always-multi-line"`
127
128There _must always_ be a single space before the opening brace in multi-line blocks.
129
130The following patterns are considered violations:
131
132<!-- prettier-ignore -->
133```css
134a{
135color: pink; }
136```
137
138The following patterns are _not_ considered violations:
139
140<!-- prettier-ignore -->
141```css
142a{ color: pink; }
143```
144
145<!-- prettier-ignore -->
146```css
147a {
148color: pink; }
149```
150
151### `"never-multi-line"`
152
153There _must never_ be whitespace before the opening brace in multi-line blocks.
154
155The following patterns are considered violations:
156
157<!-- prettier-ignore -->
158```css
159a {
160color: pink; }
161```
162
163The following patterns are _not_ considered violations:
164
165<!-- prettier-ignore -->
166```css
167a { color: pink; }
168```
169
170<!-- prettier-ignore -->
171```css
172a{
173color: pink;}
174```
175
176## Optional secondary options
177
178### `ignoreAtRules: ["/regex/", /regex/, "non-regex"]`
179
180Given:
181
182```
183["/fo/"]
184```
185
186The following patterns are _not_ considered violations:
187
188<!-- prettier-ignore -->
189```css
190@for ...
191{}
192```
193
194<!-- prettier-ignore -->
195```css
196@for ...{}
197```