@@ -65,14 +65,8 @@ Examples of **incorrect** code for this rule with the `"always"` option:
65
65
``` js
66
66
/* eslint lines-around-directive: ["error", "always"] */
67
67
68
- /* Top of file */
69
- " use strict" ;
70
- var foo;
71
-
72
- /* Top of file */
73
68
// comment
74
69
" use strict" ;
75
- " use asm" ;
76
70
var foo;
77
71
78
72
function foo () {
@@ -90,23 +84,29 @@ function foo() {
90
84
91
85
:::
92
86
93
- Examples of ** correct** code for this rule with the ` "always" ` option:
94
-
95
- ::: correct { "sourceType": "script" }
87
+ ::: incorrect { "sourceType": "script" }
96
88
97
89
``` js
98
90
/* eslint lines-around-directive: ["error", "always"] */
99
91
100
- /* Top of file */
92
+ // comment
101
93
" use strict" ;
102
-
94
+ " use asm " ;
103
95
var foo;
96
+ ```
97
+
98
+ :::
99
+
100
+ Examples of ** correct** code for this rule with the ` "always" ` option:
101
+
102
+ ::: correct { "sourceType": "script" }
103
+
104
+ ``` js
105
+ /* eslint lines-around-directive: ["error", "always"] */
104
106
105
- /* Top of file */
106
107
// comment
107
108
108
109
" use strict" ;
109
- " use asm" ;
110
110
111
111
var foo;
112
112
@@ -128,6 +128,21 @@ function foo() {
128
128
129
129
:::
130
130
131
+ ::: correct { "sourceType": "script" }
132
+
133
+ ``` js
134
+ /* eslint lines-around-directive: ["error", "always"] */
135
+
136
+ // comment
137
+
138
+ " use strict" ;
139
+ " use asm" ;
140
+
141
+ var foo;
142
+ ```
143
+
144
+ :::
145
+
131
146
### never
132
147
133
148
Examples of ** incorrect** code for this rule with the ` "never" ` option:
@@ -137,17 +152,9 @@ Examples of **incorrect** code for this rule with the `"never"` option:
137
152
``` js
138
153
/* eslint lines-around-directive: ["error", "never"] */
139
154
140
- /* Top of file */
141
-
142
- " use strict" ;
143
-
144
- var foo;
145
-
146
- /* Top of file */
147
155
// comment
148
156
149
157
" use strict" ;
150
- " use asm" ;
151
158
152
159
var foo;
153
160
@@ -169,21 +176,30 @@ function foo() {
169
176
170
177
:::
171
178
172
- Examples of ** correct** code for this rule with the ` "never" ` option:
173
-
174
- ::: correct { "sourceType": "script" }
179
+ ::: incorrect { "sourceType": "script" }
175
180
176
181
``` js
177
182
/* eslint lines-around-directive: ["error", "never"] */
178
183
179
- /* Top of file */
184
+ // comment
185
+
180
186
" use strict" ;
187
+ " use asm" ;
188
+
181
189
var foo;
190
+ ```
191
+
192
+ :::
193
+
194
+ Examples of ** correct** code for this rule with the ` "never" ` option:
195
+
196
+ ::: correct { "sourceType": "script" }
197
+
198
+ ``` js
199
+ /* eslint lines-around-directive: ["error", "never"] */
182
200
183
- /* Top of file */
184
201
// comment
185
202
" use strict" ;
186
- " use asm" ;
187
203
var foo;
188
204
189
205
function foo () {
@@ -201,6 +217,19 @@ function foo() {
201
217
202
218
:::
203
219
220
+ ::: correct { "sourceType": "script" }
221
+
222
+ ``` js
223
+ /* eslint lines-around-directive: ["error", "never"] */
224
+
225
+ // comment
226
+ " use strict" ;
227
+ " use asm" ;
228
+ var foo;
229
+ ```
230
+
231
+ :::
232
+
204
233
### before & after
205
234
206
235
Examples of ** incorrect** code for this rule with the ` { "before": "never", "after": "always" } ` option:
@@ -210,16 +239,9 @@ Examples of **incorrect** code for this rule with the `{ "before": "never", "aft
210
239
``` js
211
240
/* eslint lines-around-directive: ["error", { "before": "never", "after": "always" }] */
212
241
213
- /* Top of file */
214
-
215
- " use strict" ;
216
- var foo;
217
-
218
- /* Top of file */
219
242
// comment
220
243
221
244
" use strict" ;
222
- " use asm" ;
223
245
var foo;
224
246
225
247
function foo () {
@@ -238,22 +260,29 @@ function foo() {
238
260
239
261
:::
240
262
241
- Examples of ** correct** code for this rule with the ` { "before": "never", "after": "always" } ` option:
242
-
243
- ::: correct { "sourceType": "script" }
263
+ ::: incorrect { "sourceType": "script" }
244
264
245
265
``` js
246
266
/* eslint lines-around-directive: ["error", { "before": "never", "after": "always" }] */
247
267
248
- /* Top of file */
249
- " use strict" ;
268
+ // comment
250
269
270
+ " use strict" ;
271
+ " use asm" ;
251
272
var foo;
273
+ ```
274
+
275
+ :::
276
+
277
+ Examples of ** correct** code for this rule with the ` { "before": "never", "after": "always" } ` option:
278
+
279
+ ::: correct { "sourceType": "script" }
280
+
281
+ ``` js
282
+ /* eslint lines-around-directive: ["error", { "before": "never", "after": "always" }] */
252
283
253
- /* Top of file */
254
284
// comment
255
285
" use strict" ;
256
- " use asm" ;
257
286
258
287
var foo;
259
288
@@ -274,22 +303,29 @@ function foo() {
274
303
275
304
:::
276
305
277
- Examples of ** incorrect** code for this rule with the ` { "before": "always", "after": "never" } ` option:
278
-
279
- ::: incorrect { "sourceType": "script" }
306
+ ::: correct { "sourceType": "script" }
280
307
281
308
``` js
282
- /* eslint lines-around-directive: ["error", { "before": "always ", "after": "never " }] */
309
+ /* eslint lines-around-directive: ["error", { "before": "never ", "after": "always " }] */
283
310
284
- /* Top of file */
311
+ // comment
285
312
" use strict" ;
313
+ " use asm" ;
286
314
287
315
var foo;
316
+ ```
317
+
318
+ :::
319
+
320
+ Examples of ** incorrect** code for this rule with the ` { "before": "always", "after": "never" } ` option:
321
+
322
+ ::: incorrect { "sourceType": "script" }
323
+
324
+ ``` js
325
+ /* eslint lines-around-directive: ["error", { "before": "always", "after": "never" }] */
288
326
289
- /* Top of file */
290
327
// comment
291
328
" use strict" ;
292
- " use asm" ;
293
329
294
330
var foo;
295
331
@@ -310,22 +346,30 @@ function foo() {
310
346
311
347
:::
312
348
313
- Examples of ** correct** code for this rule with the ` { "before": "always", "after": "never" } ` option:
314
-
315
- ::: correct { "sourceType": "script" }
349
+ ::: incorrect { "sourceType": "script" }
316
350
317
351
``` js
318
352
/* eslint lines-around-directive: ["error", { "before": "always", "after": "never" }] */
319
353
320
- /* Top of file */
354
+ // comment
321
355
" use strict" ;
356
+ " use asm" ;
357
+
322
358
var foo;
359
+ ```
360
+
361
+ :::
362
+
363
+ Examples of ** correct** code for this rule with the ` { "before": "always", "after": "never" } ` option:
364
+
365
+ ::: correct { "sourceType": "script" }
366
+
367
+ ``` js
368
+ /* eslint lines-around-directive: ["error", { "before": "always", "after": "never" }] */
323
369
324
- /* Top of file */
325
370
// comment
326
371
327
372
" use strict" ;
328
- " use asm" ;
329
373
var foo;
330
374
331
375
function foo () {
@@ -344,6 +388,20 @@ function foo() {
344
388
345
389
:::
346
390
391
+ ::: correct { "sourceType": "script" }
392
+
393
+ ``` js
394
+ /* eslint lines-around-directive: ["error", { "before": "always", "after": "never" }] */
395
+
396
+ // comment
397
+
398
+ " use strict" ;
399
+ " use asm" ;
400
+ var foo;
401
+ ```
402
+
403
+ :::
404
+
347
405
## When Not To Use It
348
406
349
407
You can safely disable this rule if you do not have any strict conventions about whether or not directive prologues should have blank newlines before or after them.
0 commit comments