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/import-style.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
Sometimes a module contains unrelated functions, like `util`, thus it is a good practice to enforce destructuring or named imports here. Other times, in modules like `path`, it is good to use default import as they have similar functions, all likely to be utilized.
11
11
12
-
This rule only applies to modules listed in the `styles` option. Imports of unlisted modules are not affected.
12
+
This rule applies to modules listed in the `styles` option and the default styles below. Other imports are not affected.
13
13
14
14
This rule defines 4 import styles:
15
15
@@ -39,6 +39,14 @@ import * as util from 'node:util';
39
39
import {promisify} from'node:util';
40
40
```
41
41
42
+
```js
43
+
// ❌
44
+
import*aspathfrom'node:path';
45
+
46
+
// ✅
47
+
importpathfrom'node:path';
48
+
```
49
+
42
50
## Options
43
51
44
52
### styles
@@ -49,9 +57,11 @@ You can extend default import styles per module by passing the `styles` option.
49
57
50
58
Default options per module are:
51
59
52
-
-`util` - `named` only
53
-
-`path` - `default` only
54
60
-`chalk` - `default` only
61
+
-`path` - `default` only
62
+
-`util` - `named` only
63
+
64
+
Imports with the `node:` protocol are matched as if the protocol were omitted. For example, `node:util` uses the same style as `util`. Configure these modules by their bare name, like `util` or `path`.
0 commit comments