Skip to content

Commit efa1723

Browse files
author
Pete Gleeson
committed
adds more examples to the import/extensions rule docs
1 parent 158f4e8 commit efa1723

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

docs/rules/extensions.md

+27-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,33 @@ In order to provide a consistent use of file extensions across your code base, t
88

99
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.
1010

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.
11+
```json
12+
"import/extensions": [<severity>, "never" | "always" | "ignorePackages"]
13+
```
14+
15+
By providing an object you can configure each extension separately.
16+
17+
```json
18+
"import/extensions": [<severity>, {
19+
<extension>: "never" | "always" | "ignorePackages"
20+
}]
21+
```
22+
23+
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.
26+
27+
```json
28+
"import/extensions": [
29+
<severity>,
30+
"never" | "always" | "ignorePackages",
31+
{
32+
<extension>: "never" | "always" | "ignorePackages"
33+
}
34+
]
35+
```
1236

13-
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".
1438

1539
### Exception
1640

@@ -110,7 +134,7 @@ import express from 'express';
110134

111135
```
112136

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} ]`:
114138

115139
```js
116140
import Component from './Component.jsx';

0 commit comments

Comments
 (0)