@@ -65,14 +65,8 @@ Examples of **incorrect** code for this rule with the `"always"` option:
6565``` js
6666/* eslint lines-around-directive: ["error", "always"] */
6767
68- /* Top of file */
69- " use strict" ;
70- var foo;
71-
72- /* Top of file */
7368// comment
7469" use strict" ;
75- " use asm" ;
7670var foo;
7771
7872function foo () {
@@ -90,23 +84,29 @@ function foo() {
9084
9185:::
9286
93- Examples of ** correct** code for this rule with the ` "always" ` option:
94-
95- ::: correct { "sourceType": "script" }
87+ ::: incorrect { "sourceType": "script" }
9688
9789``` js
9890/* eslint lines-around-directive: ["error", "always"] */
9991
100- /* Top of file */
92+ // comment
10193" use strict" ;
102-
94+ " use asm " ;
10395var 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"] */
104106
105- /* Top of file */
106107// comment
107108
108109" use strict" ;
109- " use asm" ;
110110
111111var foo;
112112
@@ -128,6 +128,21 @@ function foo() {
128128
129129:::
130130
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+
131146### never
132147
133148Examples 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:
137152``` js
138153/* eslint lines-around-directive: ["error", "never"] */
139154
140- /* Top of file */
141-
142- " use strict" ;
143-
144- var foo;
145-
146- /* Top of file */
147155// comment
148156
149157" use strict" ;
150- " use asm" ;
151158
152159var foo;
153160
@@ -169,21 +176,30 @@ function foo() {
169176
170177:::
171178
172- Examples of ** correct** code for this rule with the ` "never" ` option:
173-
174- ::: correct { "sourceType": "script" }
179+ ::: incorrect { "sourceType": "script" }
175180
176181``` js
177182/* eslint lines-around-directive: ["error", "never"] */
178183
179- /* Top of file */
184+ // comment
185+
180186" use strict" ;
187+ " use asm" ;
188+
181189var 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"] */
182200
183- /* Top of file */
184201// comment
185202" use strict" ;
186- " use asm" ;
187203var foo;
188204
189205function foo () {
@@ -201,6 +217,19 @@ function foo() {
201217
202218:::
203219
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+
204233### before & after
205234
206235Examples 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
210239``` js
211240/* eslint lines-around-directive: ["error", { "before": "never", "after": "always" }] */
212241
213- /* Top of file */
214-
215- " use strict" ;
216- var foo;
217-
218- /* Top of file */
219242// comment
220243
221244" use strict" ;
222- " use asm" ;
223245var foo;
224246
225247function foo () {
@@ -238,22 +260,29 @@ function foo() {
238260
239261:::
240262
241- Examples of ** correct** code for this rule with the ` { "before": "never", "after": "always" } ` option:
242-
243- ::: correct { "sourceType": "script" }
263+ ::: incorrect { "sourceType": "script" }
244264
245265``` js
246266/* eslint lines-around-directive: ["error", { "before": "never", "after": "always" }] */
247267
248- /* Top of file */
249- " use strict" ;
268+ // comment
250269
270+ " use strict" ;
271+ " use asm" ;
251272var 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" }] */
252283
253- /* Top of file */
254284// comment
255285" use strict" ;
256- " use asm" ;
257286
258287var foo;
259288
@@ -274,22 +303,29 @@ function foo() {
274303
275304:::
276305
277- Examples of ** incorrect** code for this rule with the ` { "before": "always", "after": "never" } ` option:
278-
279- ::: incorrect { "sourceType": "script" }
306+ ::: correct { "sourceType": "script" }
280307
281308``` js
282- /* eslint lines-around-directive: ["error", { "before": "always ", "after": "never " }] */
309+ /* eslint lines-around-directive: ["error", { "before": "never ", "after": "always " }] */
283310
284- /* Top of file */
311+ // comment
285312" use strict" ;
313+ " use asm" ;
286314
287315var 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" }] */
288326
289- /* Top of file */
290327// comment
291328" use strict" ;
292- " use asm" ;
293329
294330var foo;
295331
@@ -310,22 +346,30 @@ function foo() {
310346
311347:::
312348
313- Examples of ** correct** code for this rule with the ` { "before": "always", "after": "never" } ` option:
314-
315- ::: correct { "sourceType": "script" }
349+ ::: incorrect { "sourceType": "script" }
316350
317351``` js
318352/* eslint lines-around-directive: ["error", { "before": "always", "after": "never" }] */
319353
320- /* Top of file */
354+ // comment
321355" use strict" ;
356+ " use asm" ;
357+
322358var 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" }] */
323369
324- /* Top of file */
325370// comment
326371
327372" use strict" ;
328- " use asm" ;
329373var foo;
330374
331375function foo () {
@@ -344,6 +388,20 @@ function foo() {
344388
345389:::
346390
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+
347405## When Not To Use It
348406
349407You 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