eslint-plugin-fast-import 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +30 -17
- package/dist/plugin.d.ts +6 -2
- package/dist/plugin.js +26 -4
- package/dist/plugin.js.map +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 1.7.1 (1/3/2026)
|
|
4
|
+
|
|
5
|
+
- Fixed bug where `requireFileExtensions` option was causing settings validation to fail
|
|
6
|
+
|
|
7
|
+
## 1.7.0 (1/2/2026)
|
|
8
|
+
|
|
9
|
+
- Added `requireFileExtensions` option to configuration helpers
|
|
10
|
+
|
|
3
11
|
## 1.6.0 (1/2/2026)
|
|
4
12
|
|
|
5
13
|
- Removed support for implicit workspace dependency resolution
|
package/README.md
CHANGED
|
@@ -35,8 +35,6 @@
|
|
|
35
35
|
- [Do you support user-supplied resolvers like eslint-plugin-import does?](#do-you-support-user-supplied-resolvers-like-eslint-plugin-import-does)
|
|
36
36
|
- [License](#license)
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
38
|
Fast Import implements a series of lint rules that validates imports and exports are used correctly. These rules specifically analyze who is importing what and looking for errors.
|
|
41
39
|
|
|
42
40
|
Fast Import uses a novel algorithm combined with the [OXC Rust based parser](https://www.npmjs.com/package/oxc-parser) that is significantly more performant than other import plugins. Fast Import also includes an editor mode that keeps its internal datastructures up to date with file system changes. This way you don't get stale errors in your editor when you change branches, unlike other plugins.
|
|
@@ -54,8 +52,8 @@ npm install --save-dev eslint-plugin-fast-import
|
|
|
54
52
|
☑️ Set in the recommended configuration.<br />
|
|
55
53
|
🧰 Set in the all configuration.
|
|
56
54
|
|
|
57
|
-
| Name | 💼
|
|
58
|
-
| --------------------------------------------------------------------------- |
|
|
55
|
+
| Name | 💼 | 🔧 |
|
|
56
|
+
| --------------------------------------------------------------------------- | ----- | --- |
|
|
59
57
|
| [no-cycle](src/rules/cycle/README.md) | 🧰 ☑️ | |
|
|
60
58
|
| [no-entry-point-imports](src/rules/entryPoint/README.md) | 🧰 ☑️ | |
|
|
61
59
|
| [no-external-barrel-reexports](src/rules/externalBarrelReexports/README.md) | 🧰 ☑️ | |
|
|
@@ -63,15 +61,14 @@ npm install --save-dev eslint-plugin-fast-import
|
|
|
63
61
|
| [no-test-imports-in-prod](src/rules/testInProd/README.md) | 🧰 ☑️ | |
|
|
64
62
|
| [no-unresolved-imports](src/rules/unresolved/README.md) | 🧰 ☑️ | |
|
|
65
63
|
| [no-unused-exports](src/rules/unused/README.md) | 🧰 ☑️ | |
|
|
66
|
-
| [consistent-file-extensions](src/rules/extension/README.md) | 🧰
|
|
67
|
-
| [require-node-prefix](src/rules/nodePrefix/README.md) | 🧰
|
|
68
|
-
| [no-restricted-imports](src/rules/restricted/README.md)
|
|
64
|
+
| [consistent-file-extensions](src/rules/extension/README.md) | 🧰 | 🔧 |
|
|
65
|
+
| [require-node-prefix](src/rules/nodePrefix/README.md) | 🧰 | 🔧 |
|
|
66
|
+
| [no-restricted-imports](src/rules/restricted/README.md) \* | | |
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
\* No restricted imports requires rule-specific options for use, and so is not enabled in any configuration.
|
|
71
69
|
|
|
72
70
|
There is also a configuration called "off" that disables all rules. This configuration is useful if you want to disable all rules for specific files after enabling rules for all other files.
|
|
73
71
|
|
|
74
|
-
|
|
75
72
|
## Configuration
|
|
76
73
|
|
|
77
74
|
Fast Import only supports ESLint 9+ and flat configs. For most simple TypeScript applications, you can add Fast Import with:
|
|
@@ -83,8 +80,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
83
80
|
|
|
84
81
|
export default [
|
|
85
82
|
recommended({
|
|
86
|
-
rootDir: dirname(fileURLToPath(import.meta.url))
|
|
87
|
-
})
|
|
83
|
+
rootDir: dirname(fileURLToPath(import.meta.url)),
|
|
84
|
+
}),
|
|
88
85
|
];
|
|
89
86
|
```
|
|
90
87
|
|
|
@@ -108,16 +105,16 @@ CommonJS Example:
|
|
|
108
105
|
|
|
109
106
|
```js
|
|
110
107
|
recommended({
|
|
111
|
-
rootDir: __dirname
|
|
112
|
-
})
|
|
108
|
+
rootDir: __dirname,
|
|
109
|
+
});
|
|
113
110
|
```
|
|
114
111
|
|
|
115
112
|
ESM Example using `dirname` from `node:path` and `fileURLToPath` from `node:url`:
|
|
116
113
|
|
|
117
114
|
```js
|
|
118
115
|
recommended({
|
|
119
|
-
rootDir: dirname(fileURLToPath(import.meta.url))
|
|
120
|
-
})
|
|
116
|
+
rootDir: dirname(fileURLToPath(import.meta.url)),
|
|
117
|
+
});
|
|
121
118
|
```
|
|
122
119
|
|
|
123
120
|
#### alias
|
|
@@ -127,6 +124,7 @@ Type: `Record<string, string>`
|
|
|
127
124
|
`alias` defines a set of module specifier aliases. For example, if you use Next.js with its default configuration, you're probably familiar with the alias it creates: `@/` points to `src/`, such that a file inside of `src` can import `src/components/foo/index.ts` with `@/components/foo`.
|
|
128
125
|
|
|
129
126
|
Fast Import defaults to the values inside of `tsconfig.json`, if present, with a few limitations:
|
|
127
|
+
|
|
130
128
|
- Aliases that point to files outside of `rootDir`, or point to files inside of `node_modules`, are ignored
|
|
131
129
|
- Aliases with more than one file, e.g. `"@/": ["a.ts", "b.ts"]`, are ignored
|
|
132
130
|
|
|
@@ -241,6 +239,21 @@ recommended({
|
|
|
241
239
|
})
|
|
242
240
|
```
|
|
243
241
|
|
|
242
|
+
#### requireFileExtensions
|
|
243
|
+
|
|
244
|
+
Type: boolean
|
|
245
|
+
|
|
246
|
+
A quick way to set the `mode` for `consistent-file-extensions`. See [consistent-file-extensions](src/rules/extension/README.md#options) for more details. `true` sets the mode to `always`, `false` sets the mode to `never`.
|
|
247
|
+
|
|
248
|
+
Example:
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
recommended({
|
|
252
|
+
rootDir: __dirname
|
|
253
|
+
requireFileExtensions: true
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
244
257
|
## Comparisons to import and import-x
|
|
245
258
|
|
|
246
259
|
Below are performance and accuracy comparisons to [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) and [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x)
|
|
@@ -439,8 +452,8 @@ As we read in the previous section, Fast Import provides AST ranges for reportin
|
|
|
439
452
|
```js
|
|
440
453
|
context.report({
|
|
441
454
|
messageId: 'someMessageId',
|
|
442
|
-
loc: getLocFromRange(context, someImportEntry.reportNodeRange)
|
|
443
|
-
})
|
|
455
|
+
loc: getLocFromRange(context, someImportEntry.reportNodeRange),
|
|
456
|
+
});
|
|
444
457
|
```
|
|
445
458
|
|
|
446
459
|
### registerUpdateListener(listener)
|
package/dist/plugin.d.ts
CHANGED
|
@@ -63,5 +63,9 @@ declare const plugin: {
|
|
|
63
63
|
processors: {};
|
|
64
64
|
};
|
|
65
65
|
export default plugin;
|
|
66
|
-
export declare function recommended(settings: UserSettings
|
|
67
|
-
|
|
66
|
+
export declare function recommended({ requireFileExtensions, ...settings }: UserSettings & {
|
|
67
|
+
requireFileExtensions?: boolean;
|
|
68
|
+
}): TSESLint.FlatConfig.Config;
|
|
69
|
+
export declare function all({ requireFileExtensions, ...settings }: UserSettings & {
|
|
70
|
+
requireFileExtensions?: boolean;
|
|
71
|
+
}): TSESLint.FlatConfig.Config;
|
package/dist/plugin.js
CHANGED
|
@@ -89,17 +89,39 @@ Object.assign(plugin.configs, {
|
|
|
89
89
|
off: offConfig,
|
|
90
90
|
});
|
|
91
91
|
export default plugin;
|
|
92
|
-
export function recommended(settings) {
|
|
92
|
+
export function recommended({ requireFileExtensions, ...settings }) {
|
|
93
93
|
return {
|
|
94
|
-
...
|
|
94
|
+
...{
|
|
95
|
+
...recommendedConfig,
|
|
96
|
+
rules: {
|
|
97
|
+
...recommendedConfig.rules,
|
|
98
|
+
'fast-import/consistent-file-extensions': [
|
|
99
|
+
'error',
|
|
100
|
+
{
|
|
101
|
+
mode: requireFileExtensions !== false ? 'always' : 'never',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
95
106
|
settings: {
|
|
96
107
|
'fast-import': settings,
|
|
97
108
|
},
|
|
98
109
|
};
|
|
99
110
|
}
|
|
100
|
-
export function all(settings) {
|
|
111
|
+
export function all({ requireFileExtensions, ...settings }) {
|
|
101
112
|
return {
|
|
102
|
-
...
|
|
113
|
+
...{
|
|
114
|
+
...allConfig,
|
|
115
|
+
rules: {
|
|
116
|
+
...allConfig.rules,
|
|
117
|
+
'fast-import/consistent-file-extensions': [
|
|
118
|
+
'error',
|
|
119
|
+
{
|
|
120
|
+
mode: requireFileExtensions !== false ? 'always' : 'never',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
103
125
|
settings: {
|
|
104
126
|
'fast-import': settings,
|
|
105
127
|
},
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4DAA4D,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;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