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/extensions.md
+27-3
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,33 @@ In order to provide a consistent use of file extensions across your code base, t
8
8
9
9
This rule either takes one string option, one object option, or a string and an object option. If it is the string `"never"` (the default value), then the rule forbids the use for any extension. If it is the string `"always"`, then the rule enforces the use of extensions for all import statements. If it is the string `"ignorePackages"`, then the rule enforces the use of extensions for all import statements except package imports.
10
10
11
-
By providing an object you can configure each extension separately, so for example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension.
For example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension.
24
+
25
+
By providing both a string and an object, the string will set the default setting for all extensions, and the object can be used to set granular overrides for specific extensions.
By providing both a string and an object, the string will set the default setting for all extensions, and the object can be used to set granular overrides for specific extensions. For example, `[<enabled>, "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg".
37
+
For example, `["error", "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg".
14
38
15
39
### Exception
16
40
@@ -110,7 +134,7 @@ import express from 'express';
110
134
111
135
```
112
136
113
-
The following patterns are not considered problems when configuration set to `[ 'always', {ignorePackages: true} ]`:
137
+
The following patterns are not considered problems when configuration set to `['error', 'always', {ignorePackages: true} ]`:
Ensures that there is no resolvable path back to this module via its dependencies.
4
+
5
+
This includes cycles of depth 1 (imported module imports me) to `Infinity`, if the
6
+
[`maxDepth`](#maxdepth) option is not set.
7
+
8
+
```js
9
+
// dep-b.js
10
+
import'./dep-a.js'
11
+
12
+
exportfunctionb() { /* ... */ }
13
+
14
+
// dep-a.js
15
+
import { b } from'./dep-b.js'// reported: Dependency cycle detected.
16
+
```
17
+
18
+
This rule does _not_ detect imports that resolve directly to the linted module;
19
+
for that, see [`no-self-import`].
20
+
21
+
22
+
## Rule Details
23
+
24
+
### Options
25
+
26
+
By default, this rule only detects cycles for ES6 imports, but see the [`no-unresolved` options](./no-unresolved.md#options) as this rule also supports the same `commonjs` and `amd` flags. However, these flags only impact which import types are _linted_; the
27
+
import/export infrastructure only registers `import` statements in dependencies, so
28
+
cycles created by `require` within imported modules may not be detected.
29
+
30
+
#### `maxDepth`
31
+
32
+
There is a `maxDepth` option available to prevent full expansion of very deep dependency trees:
0 commit comments