You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/newline-after-import.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
# newline-after-import
2
2
3
-
Enforces having an empty line after the last top-level import statement or require call.
3
+
Enforces having one or more empty line after the last top-level import statement or require call.
4
4
5
5
## Rule Details
6
6
7
+
This rule has one option, `newlines` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`.
8
+
7
9
Valid:
8
10
9
11
```js
@@ -26,7 +28,7 @@ const BAR = require('./bar')
26
28
constBAZ=1
27
29
```
28
30
29
-
...whereas here imports will be reported:
31
+
Invalid:
30
32
31
33
```js
32
34
import*asfoofrom'foo'
@@ -46,6 +48,40 @@ const BAZ = 1
46
48
constBAR=require('./bar')
47
49
```
48
50
51
+
With `newlines` set to `2` this will be considered valid:
52
+
53
+
```js
54
+
importdefaultExportfrom'./foo'
55
+
56
+
57
+
constFOO='BAR'
58
+
```
59
+
60
+
With `newlines` set to `2` these will be considered invalid:
0 commit comments