1 | # custom-property-empty-line-before
|
2 |
|
3 | Require or disallow an empty line before custom properties.
|
4 |
|
5 |
|
6 | ```css
|
7 | a {
|
8 | top: 10px;
|
9 | /* ← */
|
10 | --foo: pink; /* ↑ */
|
11 | } /* ↑ */
|
12 | /** ↑
|
13 | * This line */
|
14 | ```
|
15 |
|
16 | The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule. We recommend to enable [`indentation`](../indentation/README.md) rule for better autofixing results with this rule.
|
17 |
|
18 | ## Options
|
19 |
|
20 | `string`: `"always"|"never"`
|
21 |
|
22 | ### `"always"`
|
23 |
|
24 | The following patterns are considered violations:
|
25 |
|
26 |
|
27 | ```css
|
28 | a {
|
29 | top: 10px;
|
30 | --foo: pink;
|
31 | --bar: red;
|
32 | }
|
33 | ```
|
34 |
|
35 | The following patterns are _not_ considered violations:
|
36 |
|
37 |
|
38 | ```css
|
39 | a {
|
40 | top: 10px;
|
41 |
|
42 | --foo: pink;
|
43 |
|
44 | --bar: red;
|
45 | }
|
46 | ```
|
47 |
|
48 | ### `"never"`
|
49 |
|
50 | The following patterns are considered violations:
|
51 |
|
52 |
|
53 | ```css
|
54 | a {
|
55 | top: 10px;
|
56 |
|
57 | --foo: pink;
|
58 |
|
59 | --bar: red;
|
60 | }
|
61 | ```
|
62 |
|
63 |
|
64 | ```css
|
65 | a {
|
66 |
|
67 | --foo: pink;
|
68 | --bar: red;
|
69 | }
|
70 | ```
|
71 |
|
72 | The following patterns are _not_ considered violations:
|
73 |
|
74 |
|
75 | ```css
|
76 | a {
|
77 | top: 10px;
|
78 | --foo: pink;
|
79 | --bar: red;
|
80 | }
|
81 | ```
|
82 |
|
83 |
|
84 | ```css
|
85 | a {
|
86 | --foo: pink;
|
87 | --bar: red;
|
88 | }
|
89 | ```
|
90 |
|
91 | ## Optional secondary options
|
92 |
|
93 | ### `except: ["after-comment", "after-custom-property", "first-nested"]`
|
94 |
|
95 | #### `"after-comment"`
|
96 |
|
97 | Reverse the primary option for custom properties that follow a comment.
|
98 |
|
99 | Shared-line comments do not trigger this option.
|
100 |
|
101 | For example, with `"always"`:
|
102 |
|
103 | The following patterns are considered violations:
|
104 |
|
105 |
|
106 | ```css
|
107 | a {
|
108 |
|
109 | --foo: pink;
|
110 | /* comment */
|
111 |
|
112 | --bar: red;
|
113 | }
|
114 | ```
|
115 |
|
116 |
|
117 | ```css
|
118 | a {
|
119 |
|
120 | --foo: pink; /* comment */
|
121 | --bar: red;
|
122 | }
|
123 | ```
|
124 |
|
125 | The following patterns are _not_ considered violations:
|
126 |
|
127 |
|
128 | ```css
|
129 | a {
|
130 |
|
131 | --foo: pink;
|
132 | /* comment */
|
133 | --bar: red;
|
134 | }
|
135 | ```
|
136 |
|
137 |
|
138 | ```css
|
139 | a {
|
140 |
|
141 | --foo: pink; /* comment */
|
142 |
|
143 | --bar: red;
|
144 | }
|
145 | ```
|
146 |
|
147 | #### `"after-custom-property"`
|
148 |
|
149 | Reverse the primary option for custom properties that follow another custom property.
|
150 |
|
151 | Shared-line comments do not affect this option.
|
152 |
|
153 | For example, with `"always"`:
|
154 |
|
155 | The following patterns are considered violations:
|
156 |
|
157 |
|
158 | ```css
|
159 | a {
|
160 |
|
161 | --foo: pink;
|
162 |
|
163 | --bar: red;
|
164 | }
|
165 | ```
|
166 |
|
167 |
|
168 | ```css
|
169 | a {
|
170 |
|
171 | --foo: pink; /* comment */
|
172 |
|
173 | --bar: red;
|
174 | }
|
175 | ```
|
176 |
|
177 | The following patterns are _not_ considered violations:
|
178 |
|
179 |
|
180 | ```css
|
181 | a {
|
182 |
|
183 | --foo: pink;
|
184 | --bar: red;
|
185 | }
|
186 | ```
|
187 |
|
188 |
|
189 | ```css
|
190 | a {
|
191 |
|
192 | --foo: pink; /* comment */
|
193 | --bar: red;
|
194 | }
|
195 | ```
|
196 |
|
197 | #### `"first-nested"`
|
198 |
|
199 | Reverse the primary option for custom properties that are nested and the first child of their parent node.
|
200 |
|
201 | For example, with `"always"`:
|
202 |
|
203 | The following patterns are considered violations:
|
204 |
|
205 |
|
206 | ```css
|
207 | a {
|
208 |
|
209 | --foo: pink;
|
210 |
|
211 | --bar: red;
|
212 | }
|
213 | ```
|
214 |
|
215 | The following patterns are _not_ considered violations:
|
216 |
|
217 |
|
218 | ```css
|
219 | a {
|
220 | --foo: pink;
|
221 |
|
222 | --bar: red;
|
223 | }
|
224 | ```
|
225 |
|
226 | ### `ignore: ["after-comment", "first-nested", "inside-single-line-block"]`
|
227 |
|
228 | #### `"after-comment"`
|
229 |
|
230 | Ignore custom properties that follow a comment.
|
231 |
|
232 | For example, with `"always"`:
|
233 |
|
234 | The following patterns are _not_ considered violations:
|
235 |
|
236 |
|
237 | ```css
|
238 | a {
|
239 | /* comment */
|
240 | --foo: pink;
|
241 | }
|
242 | ```
|
243 |
|
244 | #### `"first-nested"`
|
245 |
|
246 | Ignore custom properties that are nested and the first child of their parent node.
|
247 |
|
248 | For example, with `"always"`:
|
249 |
|
250 | The following patterns are _not_ considered violations:
|
251 |
|
252 |
|
253 | ```css
|
254 | a {
|
255 | --foo: pink;
|
256 |
|
257 | --bar: red;
|
258 | }
|
259 | ```
|
260 |
|
261 | #### `"inside-single-line-block"`
|
262 |
|
263 | Ignore custom properties that are inside single-line blocks.
|
264 |
|
265 | For example, with `"always"`:
|
266 |
|
267 | The following patterns are _not_ considered violations:
|
268 |
|
269 |
|
270 | ```css
|
271 | a { --foo: pink; --bar: red; }
|
272 | ```
|