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
* Ensure all imports appear before other statements ([`imports-first`])
36
+
* Report repeated import of the same module in multiple places ([`no-duplicates`])
37
+
38
+
[`no-require`]: ./docs/rules/no-require.md
39
+
[`imports-first`]: ./docs/rules/imports-first.md
40
+
[`no-duplicates`]: ./docs/rules/no-duplicates.md
29
41
30
42
## Installation
31
43
@@ -63,199 +75,6 @@ rules:
63
75
# etc...
64
76
```
65
77
66
-
67
-
# Rule Details
68
-
69
-
### `no-unresolved`
70
-
71
-
Ensures an imported module can be resolved to a module on the local filesystem,
72
-
as defined by standard Node `require.resolve` behavior.
73
-
74
-
See [settings](#settings) for customization options for the resolution (i.e.
75
-
additional filetypes, `NODE_PATH`, etc.)
76
-
77
-
This rule can also optionally report on unresolved modules in CommonJS `require('./foo')` calls and AMD `require(['./foo'], function (foo){...})` and `define(['./foo'], function (foo){...})`.
78
-
79
-
To enable this, send `{ commonjs: true/false, amd: true/false }` as a rule option.
80
-
Both are disabled by default.
81
-
82
-
If you are using Webpack, see the section on [resolver plugins](#resolver-plugins).
83
-
84
-
### `named`
85
-
86
-
Verifies that all named imports are part of the set of named exports in the referenced module.
87
-
88
-
For `export`, verifies that all named exports exist in the referenced module.
89
-
90
-
### `default`
91
-
92
-
If a default import is requested, this rule will report if there is no default
93
-
export in the imported module.
94
-
95
-
For [ES7], reports if a default is named and exported but is not found in the
96
-
referenced module.
97
-
98
-
### `namespace`
99
-
100
-
Enforces names exist at the time they are dereferenced, when imported as a full namespace (i.e. `import * as foo from './foo'; foo.bar();` will report if `bar` is not exported by `./foo`.).
101
-
102
-
Will report at the import declaration if there are _no_ exported names found.
103
-
104
-
Also, will report for computed references (i.e. `foo["bar"]()`).
105
-
106
-
Reports on assignment to a member of an imported namespace.
107
-
108
-
**Implementation note**: currently, this rule does not check for possible
109
-
redefinition of the namespace in an intermediate scope. Adherence to the ESLint
110
-
`no-shadow` rule for namespaces will prevent this from being a problem.
111
-
112
-
For [ES7], reports if an exported namespace would be empty (no names exported from the referenced module.)
113
-
114
-
### `no-require`
115
-
116
-
Reports `require([string])` function calls. Will not report if >1 argument,
117
-
or single argument is not a literal string.
118
-
119
-
Intended for temporary use when migrating to pure ES6 modules.
120
-
121
-
Given:
122
-
```js
123
-
// ./mod.js
124
-
exportconstfoo='bar'
125
-
exportfunctionbar() { return foo }
126
-
127
-
// ./common.js
128
-
exports.something='whatever'
129
-
```
130
-
131
-
This would be reported:
132
-
133
-
```js
134
-
var mod =require('./mod')
135
-
, common =require('./common')
136
-
, fs =require('fs')
137
-
, whateverModule =require('./not-found')
138
-
```
139
-
140
-
### `no-named-as-default`
141
-
142
-
Reports use of an exported name as the locally imported name of a default export.
143
-
144
-
Given:
145
-
```js
146
-
// foo.js
147
-
exportdefault'foo';
148
-
exportconstbar='baz';
149
-
```
150
-
151
-
...this would be valid:
152
-
```js
153
-
importfoofrom'./foo.js';
154
-
```
155
-
156
-
...and this would be reported:
157
-
```js
158
-
// message: Using exported name 'bar' as identifier for default export.
159
-
importbarfrom'./foo.js';
160
-
```
161
-
162
-
Rationale: using an exported name as the name of the default export is likely...
163
-
164
-
-*misleading*: others familiar with `foo.js` probably expect the name to be `foo`
165
-
-*a mistake*: only needed to import `bar` and forgot the brackets (the case that is prompting this)
166
-
167
-
For [ES7], this also prevents exporting the default from a referenced module as a name within than module, for the same reasons:
168
-
169
-
```js
170
-
// valid:
171
-
exportfoofrom'./foo.js'
172
-
173
-
// message: Using exported name 'bar' as identifier for default export.
0 commit comments