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-2
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 lines after the last top-level import statement or require call.
4
4
5
5
## Rule Details
6
6
7
+
This rule has one option, `count` 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 `count` set to `2` this will be considered valid:
52
+
53
+
```js
54
+
importdefaultExportfrom'./foo'
55
+
56
+
57
+
constFOO='BAR'
58
+
```
59
+
60
+
With `count` set to `2` these will be considered invalid:
61
+
62
+
```js
63
+
importdefaultExportfrom'./foo'
64
+
constFOO='BAR'
65
+
```
66
+
67
+
```js
68
+
importdefaultExportfrom'./foo'
69
+
70
+
constFOO='BAR'
71
+
```
72
+
73
+
74
+
## Example options usage
75
+
```
76
+
{
77
+
...
78
+
"rules": {
79
+
"import/newline-after-import": [{ "count": 2 }]
80
+
}
81
+
}
82
+
```
83
+
84
+
49
85
## When Not To Use It
50
86
51
87
If you like to visually group module imports with its usage, you don't want to use this rule.
Reports if a module's default export is unnamed. This includes several types of unnamed data types; literals, object expressions, arrays, anonymous functions, arrow functions, and anonymous class declarations.
4
+
5
+
Ensuring that default exports are named helps improve the grepability of the codebase by encouraging the re-use of the same identifier for the module's default export at its declaration site and at its import sites.
6
+
7
+
## Options
8
+
9
+
By default, all types of anonymous default exports are forbidden, but any types can be selectively allowed by toggling them on in the options.
10
+
11
+
The complete default configuration looks like this.
Copy file name to clipboardExpand all lines: docs/rules/no-extraneous-dependencies.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Forbid the use of extraneous packages
2
2
3
3
Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies` or `peerDependencies`.
4
-
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything.
4
+
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behaviour can be changed with the rule option `packageDir`.
5
5
6
6
### Options
7
7
@@ -25,7 +25,13 @@ You can also use an array of globs instead of literal booleans:
When using an array of globs, the setting will be activated if the name of the file being linted matches a single glob in the array.
28
+
When using an array of globs, the setting will be set to `true` (no errors reported) if the name of the file being linted matches a single glob in the array, and `false` otherwise.
29
+
30
+
Also there is one more option called `packageDir`, this option is to specify the path to the folder containing package.json and is relative to the current working directory.
Copy file name to clipboardExpand all lines: docs/rules/no-named-as-default.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ import foo from './foo.js';
27
27
importbarfrom'./foo.js';
28
28
```
29
29
30
-
For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within than module, for the same reasons:
30
+
For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within that module, for the same reasons:
Enforces or forbids new lines between import groups:
99
99
100
100
- If set to `ignore`, no errors related to new lines between import groups will be reported (default).
101
101
- If set to `always`, at least one new line between each group will be enforced, and new lines inside a group will be forbidden. To prevent multiple lines between imports, core `no-multiple-empty-lines` rule can be used.
102
+
- If set to `always-and-inside-groups`, it will act like `always` except newlines are allowed inside import groups.
102
103
- If set to `never`, no new lines are allowed in the entire import section.
103
104
104
105
With the default group setting, the following will be invalid:
0 commit comments