eslint-plugin-import-next 2.3.15 → 2.3.16
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/package.json +2 -2
- package/src/files/foo.js +1 -6
- package/src/files/no-default.js +1 -4
- package/src/index.js +1 -273
- package/src/oxlint.js +1 -3
- package/src/rules/consistent-type-specifier-style.js +1 -109
- package/src/rules/default.js +1 -56
- package/src/rules/dynamic-import-chunkname.js +1 -115
- package/src/rules/enforce-dependency-direction.js +1 -213
- package/src/rules/enforce-import-order.js +1 -299
- package/src/rules/enforce-team-boundaries.js +1 -191
- package/src/rules/export.js +1 -111
- package/src/rules/exports-last.js +1 -67
- package/src/rules/extensions.js +1 -107
- package/src/rules/first.js +1 -53
- package/src/rules/group-exports.js +1 -69
- package/src/rules/max-dependencies.js +1 -241
- package/src/rules/named.js +1 -67
- package/src/rules/namespace.js +1 -64
- package/src/rules/newline-after-import.js +1 -57
- package/src/rules/no-absolute-path.js +1 -139
- package/src/rules/no-amd.js +1 -108
- package/src/rules/no-anonymous-default-export.js +1 -135
- package/src/rules/no-barrel-file.js +1 -194
- package/src/rules/no-barrel-import.js +1 -135
- package/src/rules/no-commonjs.js +1 -312
- package/src/rules/no-cross-domain-imports.js +1 -233
- package/src/rules/no-cycle.js +2 -396
- package/src/rules/no-default-export.js +2 -213
- package/src/rules/no-deprecated.js +1 -316
- package/src/rules/no-duplicates.js +1 -81
- package/src/rules/no-dynamic-require.js +1 -78
- package/src/rules/no-empty-named-blocks.js +1 -103
- package/src/rules/no-extraneous-dependencies.js +7 -385
- package/src/rules/no-full-package-import.js +1 -134
- package/src/rules/no-import-module-exports.js +1 -76
- package/src/rules/no-internal-modules.js +1 -256
- package/src/rules/no-legacy-imports.js +1 -125
- package/src/rules/no-mutable-exports.js +1 -146
- package/src/rules/no-named-as-default-member.js +1 -73
- package/src/rules/no-named-as-default.js +1 -90
- package/src/rules/no-named-default.js +1 -48
- package/src/rules/no-named-export.js +1 -174
- package/src/rules/no-namespace.js +1 -71
- package/src/rules/no-nodejs-modules.js +1 -229
- package/src/rules/no-relative-packages.js +1 -161
- package/src/rules/no-relative-parent-imports.js +1 -118
- package/src/rules/no-restricted-paths.js +1 -89
- package/src/rules/no-self-import.js +1 -145
- package/src/rules/no-unassigned-import.js +1 -115
- package/src/rules/no-unresolved.js +1 -189
- package/src/rules/no-unused-modules.js +1 -82
- package/src/rules/no-useless-path-segments.js +1 -139
- package/src/rules/prefer-default-export.js +1 -188
- package/src/rules/prefer-direct-import.js +1 -170
- package/src/rules/prefer-modern-api.js +1 -212
- package/src/rules/prefer-node-protocol.js +1 -174
- package/src/rules/prefer-tree-shakeable-imports.js +1 -134
- package/src/rules/require-import-approval.js +1 -174
- package/src/rules/unambiguous.js +1 -70
- package/src/types/index.js +1 -2
- package/src/utils/typescript-peer.js +1 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-import-next",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.16",
|
|
4
4
|
"description": "ESLint plugin for imports and module boundaries — drop-in replacement for eslint-plugin-import, 3.1x faster end-to-end, zero-config migration.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"typescript": ">=4.8.4"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@interlace/eslint-devkit": "^1.
|
|
79
|
+
"@interlace/eslint-devkit": "^1.10.0",
|
|
80
80
|
"oxc-resolver": "^11.24.2"
|
|
81
81
|
},
|
|
82
82
|
"funding": {
|
package/src/files/foo.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bar = void 0;
|
|
4
|
-
exports.default = foo;
|
|
5
|
-
function foo() { return 'bar'; }
|
|
6
|
-
exports.bar = 'baz';
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.bar=void 0;exports.default=foo;function foo(){return"bar"}exports.bar="baz";
|
package/src/files/no-default.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,273 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearCircularDependencyCache = exports.configs = exports.plugin = exports.rules = void 0;
|
|
4
|
-
const no_cycle_1 = require("./rules/no-cycle");
|
|
5
|
-
Object.defineProperty(exports, "clearCircularDependencyCache", { enumerable: true, get: function () { return no_cycle_1.clearCircularDependencyCache; } });
|
|
6
|
-
exports.rules = {
|
|
7
|
-
get 'no-duplicates'() { return require("./rules/no-duplicates").noDuplicates; },
|
|
8
|
-
get named() { return require("./rules/named").named; },
|
|
9
|
-
get default() { return require("./rules/default").defaultRule; },
|
|
10
|
-
get namespace() { return require("./rules/namespace").namespace; },
|
|
11
|
-
get extensions() { return require("./rules/extensions").extensions; },
|
|
12
|
-
get 'no-self-import'() { return require("./rules/no-self-import").noSelfImport; },
|
|
13
|
-
get 'no-unresolved'() { return require("./rules/no-unresolved").noUnresolved; },
|
|
14
|
-
get 'no-absolute-path'() { return require("./rules/no-absolute-path").noAbsolutePath; },
|
|
15
|
-
get 'no-dynamic-require'() { return require("./rules/no-dynamic-require").noDynamicRequire; },
|
|
16
|
-
get 'no-relative-packages'() { return require("./rules/no-relative-packages").noRelativePackages; },
|
|
17
|
-
get 'no-useless-path-segments'() { return require("./rules/no-useless-path-segments").noUselessPathSegments; },
|
|
18
|
-
get 'no-amd'() { return require("./rules/no-amd").noAmd; },
|
|
19
|
-
get 'no-commonjs'() { return require("./rules/no-commonjs").noCommonjs; },
|
|
20
|
-
get 'no-nodejs-modules'() { return require("./rules/no-nodejs-modules").noNodejsModules; },
|
|
21
|
-
get 'no-import-module-exports'() { return require("./rules/no-import-module-exports").noImportModuleExports; },
|
|
22
|
-
get unambiguous() { return require("./rules/unambiguous").unambiguous; },
|
|
23
|
-
get 'no-cycle'() { return require("./rules/no-cycle").noCycle; },
|
|
24
|
-
get 'no-internal-modules'() { return require("./rules/no-internal-modules").noInternalModules; },
|
|
25
|
-
get 'no-cross-domain-imports'() { return require("./rules/no-cross-domain-imports").noCrossDomainImports; },
|
|
26
|
-
get 'enforce-dependency-direction'() { return require("./rules/enforce-dependency-direction").enforceDependencyDirection; },
|
|
27
|
-
get 'no-restricted-paths'() { return require("./rules/no-restricted-paths").noRestrictedPaths; },
|
|
28
|
-
get 'no-relative-parent-imports'() { return require("./rules/no-relative-parent-imports").noRelativeParentImports; },
|
|
29
|
-
get export() { return require("./rules/export").exportRule; },
|
|
30
|
-
get 'no-default-export'() { return require("./rules/no-default-export").noDefaultExport; },
|
|
31
|
-
get 'no-named-export'() { return require("./rules/no-named-export").noNamedExport; },
|
|
32
|
-
get 'prefer-default-export'() { return require("./rules/prefer-default-export").preferDefaultExport; },
|
|
33
|
-
get 'no-anonymous-default-export'() { return require("./rules/no-anonymous-default-export").noAnonymousDefaultExport; },
|
|
34
|
-
get 'no-mutable-exports'() { return require("./rules/no-mutable-exports").noMutableExports; },
|
|
35
|
-
get 'no-deprecated'() { return require("./rules/no-deprecated").noDeprecated; },
|
|
36
|
-
get 'exports-last'() { return require("./rules/exports-last").exportsLast; },
|
|
37
|
-
get 'group-exports'() { return require("./rules/group-exports").groupExports; },
|
|
38
|
-
get 'enforce-import-order'() { return require("./rules/enforce-import-order").enforceImportOrder; },
|
|
39
|
-
get order() { return require("./rules/enforce-import-order").enforceImportOrder; },
|
|
40
|
-
get 'no-unassigned-import'() { return require("./rules/no-unassigned-import").noUnassignedImport; },
|
|
41
|
-
get first() { return require("./rules/first").first; },
|
|
42
|
-
get 'newline-after-import'() { return require("./rules/newline-after-import").newlineAfterImport; },
|
|
43
|
-
get 'no-empty-named-blocks'() { return require("./rules/no-empty-named-blocks").noEmptyNamedBlocks; },
|
|
44
|
-
get 'no-named-as-default'() { return require("./rules/no-named-as-default").noNamedAsDefault; },
|
|
45
|
-
get 'no-named-as-default-member'() { return require("./rules/no-named-as-default-member").noNamedAsDefaultMember; },
|
|
46
|
-
get 'no-named-default'() { return require("./rules/no-named-default").noNamedDefault; },
|
|
47
|
-
get 'no-namespace'() { return require("./rules/no-namespace").noNamespace; },
|
|
48
|
-
get 'consistent-type-specifier-style'() { return require("./rules/consistent-type-specifier-style").consistentTypeSpecifierStyle; },
|
|
49
|
-
get 'dynamic-import-chunkname'() { return require("./rules/dynamic-import-chunkname").dynamicImportChunkname; },
|
|
50
|
-
get 'no-extraneous-dependencies'() { return require("./rules/no-extraneous-dependencies").noExtraneousDependencies; },
|
|
51
|
-
get 'no-unused-modules'() { return require("./rules/no-unused-modules").noUnusedModules; },
|
|
52
|
-
get 'max-dependencies'() { return require("./rules/max-dependencies").maxDependencies; },
|
|
53
|
-
get 'prefer-node-protocol'() { return require("./rules/prefer-node-protocol").preferNodeProtocol; },
|
|
54
|
-
get 'no-barrel-file'() { return require("./rules/no-barrel-file").noBarrelFile; },
|
|
55
|
-
get 'no-barrel-import'() { return require("./rules/no-barrel-import").noBarrelImport; },
|
|
56
|
-
get 'prefer-tree-shakeable-imports'() { return require("./rules/prefer-tree-shakeable-imports").preferTreeShakeableImports; },
|
|
57
|
-
get 'prefer-direct-import'() { return require("./rules/prefer-direct-import").preferDirectImport; },
|
|
58
|
-
get 'no-full-package-import'() { return require("./rules/no-full-package-import").noFullPackageImport; },
|
|
59
|
-
get 'enforce-team-boundaries'() { return require("./rules/enforce-team-boundaries").enforceTeamBoundaries; },
|
|
60
|
-
get 'no-legacy-imports'() { return require("./rules/no-legacy-imports").noLegacyImports; },
|
|
61
|
-
get 'require-import-approval'() { return require("./rules/require-import-approval").requireImportApproval; },
|
|
62
|
-
get 'prefer-modern-api'() { return require("./rules/prefer-modern-api").preferModernApi; },
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
exports.plugin = {
|
|
66
|
-
meta: {
|
|
67
|
-
name: 'eslint-plugin-import-next',
|
|
68
|
-
version: '2.3.15',
|
|
69
|
-
},
|
|
70
|
-
rules: exports.rules,
|
|
71
|
-
};
|
|
72
|
-
exports.configs = {
|
|
73
|
-
flagship: {
|
|
74
|
-
plugins: { 'import-next': exports.plugin },
|
|
75
|
-
rules: {
|
|
76
|
-
'import-next/no-cycle': 'error',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
recommended: {
|
|
80
|
-
plugins: {
|
|
81
|
-
'import-next': exports.plugin,
|
|
82
|
-
},
|
|
83
|
-
rules: {
|
|
84
|
-
'import-next/no-unresolved': 'error',
|
|
85
|
-
'import-next/named': 'error',
|
|
86
|
-
'import-next/default': 'error',
|
|
87
|
-
'import-next/namespace': 'warn',
|
|
88
|
-
'import-next/no-duplicates': 'error',
|
|
89
|
-
'import-next/export': 'error',
|
|
90
|
-
'import-next/no-cycle': 'error',
|
|
91
|
-
'import-next/no-self-import': 'error',
|
|
92
|
-
'import-next/no-named-as-default': 'warn',
|
|
93
|
-
'import-next/no-named-as-default-member': 'warn',
|
|
94
|
-
'import-next/no-amd': 'warn',
|
|
95
|
-
'import-next/order': 'warn',
|
|
96
|
-
'import-next/first': 'warn',
|
|
97
|
-
'import-next/newline-after-import': 'warn',
|
|
98
|
-
'import-next/no-empty-named-blocks': 'warn',
|
|
99
|
-
'import-next/no-extraneous-dependencies': 'warn',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
strict: {
|
|
103
|
-
plugins: {
|
|
104
|
-
'import-next': exports.plugin,
|
|
105
|
-
},
|
|
106
|
-
rules: {
|
|
107
|
-
'import-next/no-unresolved': 'error',
|
|
108
|
-
'import-next/named': 'error',
|
|
109
|
-
'import-next/default': 'error',
|
|
110
|
-
'import-next/namespace': 'error',
|
|
111
|
-
'import-next/extensions': 'error',
|
|
112
|
-
'import-next/no-self-import': 'error',
|
|
113
|
-
'import-next/no-duplicates': 'error',
|
|
114
|
-
'import-next/no-absolute-path': 'error',
|
|
115
|
-
'import-next/no-dynamic-require': 'error',
|
|
116
|
-
'import-next/no-useless-path-segments': 'error',
|
|
117
|
-
'import-next/export': 'error',
|
|
118
|
-
'import-next/no-amd': 'error',
|
|
119
|
-
'import-next/no-commonjs': 'error',
|
|
120
|
-
'import-next/no-nodejs-modules': 'error',
|
|
121
|
-
'import-next/no-import-module-exports': 'error',
|
|
122
|
-
'import-next/unambiguous': 'error',
|
|
123
|
-
'import-next/no-cycle': 'error',
|
|
124
|
-
'import-next/no-internal-modules': 'error',
|
|
125
|
-
'import-next/no-cross-domain-imports': 'error',
|
|
126
|
-
'import-next/enforce-dependency-direction': 'error',
|
|
127
|
-
'import-next/no-restricted-paths': 'error',
|
|
128
|
-
'import-next/no-relative-parent-imports': 'error',
|
|
129
|
-
'import-next/no-relative-packages': 'error',
|
|
130
|
-
'import-next/no-anonymous-default-export': 'error',
|
|
131
|
-
'import-next/no-mutable-exports': 'error',
|
|
132
|
-
'import-next/no-deprecated': 'error',
|
|
133
|
-
'import-next/exports-last': 'error',
|
|
134
|
-
'import-next/group-exports': 'error',
|
|
135
|
-
'import-next/order': 'error',
|
|
136
|
-
'import-next/no-unassigned-import': 'error',
|
|
137
|
-
'import-next/first': 'error',
|
|
138
|
-
'import-next/newline-after-import': 'error',
|
|
139
|
-
'import-next/no-empty-named-blocks': 'error',
|
|
140
|
-
'import-next/no-named-as-default': 'error',
|
|
141
|
-
'import-next/no-named-as-default-member': 'error',
|
|
142
|
-
'import-next/no-named-default': 'error',
|
|
143
|
-
'import-next/no-namespace': 'error',
|
|
144
|
-
'import-next/consistent-type-specifier-style': 'error',
|
|
145
|
-
'import-next/no-extraneous-dependencies': 'error',
|
|
146
|
-
'import-next/no-unused-modules': 'error',
|
|
147
|
-
'import-next/max-dependencies': 'error',
|
|
148
|
-
'import-next/prefer-node-protocol': 'error',
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
typescript: {
|
|
152
|
-
plugins: {
|
|
153
|
-
'import-next': exports.plugin,
|
|
154
|
-
},
|
|
155
|
-
rules: {
|
|
156
|
-
'import-next/no-unresolved': 'error',
|
|
157
|
-
'import-next/named': 'off',
|
|
158
|
-
'import-next/default': 'error',
|
|
159
|
-
'import-next/namespace': 'error',
|
|
160
|
-
'import-next/export': 'error',
|
|
161
|
-
'import-next/no-cycle': 'error',
|
|
162
|
-
'import-next/no-duplicates': 'error',
|
|
163
|
-
'import-next/order': 'warn',
|
|
164
|
-
'import-next/first': 'warn',
|
|
165
|
-
'import-next/newline-after-import': 'warn',
|
|
166
|
-
'import-next/consistent-type-specifier-style': ['warn', 'prefer-inline'],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
'module-resolution': {
|
|
170
|
-
plugins: {
|
|
171
|
-
'import-next': exports.plugin,
|
|
172
|
-
},
|
|
173
|
-
rules: {
|
|
174
|
-
'import-next/no-unresolved': 'error',
|
|
175
|
-
'import-next/named': 'error',
|
|
176
|
-
'import-next/default': 'error',
|
|
177
|
-
'import-next/namespace': 'error',
|
|
178
|
-
'import-next/extensions': 'warn',
|
|
179
|
-
'import-next/no-self-import': 'error',
|
|
180
|
-
'import-next/no-duplicates': 'error',
|
|
181
|
-
'import-next/no-absolute-path': 'error',
|
|
182
|
-
'import-next/no-useless-path-segments': 'warn',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
'import-style': {
|
|
186
|
-
plugins: {
|
|
187
|
-
'import-next': exports.plugin,
|
|
188
|
-
},
|
|
189
|
-
rules: {
|
|
190
|
-
'import-next/order': 'error',
|
|
191
|
-
'import-next/first': 'error',
|
|
192
|
-
'import-next/newline-after-import': 'error',
|
|
193
|
-
'import-next/no-duplicates': 'error',
|
|
194
|
-
'import-next/no-unassigned-import': 'warn',
|
|
195
|
-
'import-next/no-empty-named-blocks': 'error',
|
|
196
|
-
'import-next/no-namespace': 'warn',
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
esm: {
|
|
200
|
-
plugins: {
|
|
201
|
-
'import-next': exports.plugin,
|
|
202
|
-
},
|
|
203
|
-
rules: {
|
|
204
|
-
'import-next/no-amd': 'error',
|
|
205
|
-
'import-next/no-commonjs': 'error',
|
|
206
|
-
'import-next/no-import-module-exports': 'error',
|
|
207
|
-
'import-next/unambiguous': 'error',
|
|
208
|
-
'import-next/prefer-node-protocol': 'error',
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
architecture: {
|
|
212
|
-
plugins: {
|
|
213
|
-
'import-next': exports.plugin,
|
|
214
|
-
},
|
|
215
|
-
rules: {
|
|
216
|
-
'import-next/no-cycle': 'error',
|
|
217
|
-
'import-next/no-internal-modules': 'error',
|
|
218
|
-
'import-next/no-cross-domain-imports': 'error',
|
|
219
|
-
'import-next/enforce-dependency-direction': 'error',
|
|
220
|
-
'import-next/no-restricted-paths': 'error',
|
|
221
|
-
'import-next/no-relative-parent-imports': 'warn',
|
|
222
|
-
'import-next/no-relative-packages': 'error',
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
errors: {
|
|
226
|
-
plugins: {
|
|
227
|
-
'import-next': exports.plugin,
|
|
228
|
-
},
|
|
229
|
-
rules: {
|
|
230
|
-
'import-next/no-unresolved': 'error',
|
|
231
|
-
'import-next/named': 'error',
|
|
232
|
-
'import-next/default': 'error',
|
|
233
|
-
'import-next/namespace': 'error',
|
|
234
|
-
'import-next/export': 'error',
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
warnings: {
|
|
238
|
-
plugins: {
|
|
239
|
-
'import-next': exports.plugin,
|
|
240
|
-
},
|
|
241
|
-
rules: {
|
|
242
|
-
'import-next/no-named-as-default': 'warn',
|
|
243
|
-
'import-next/no-named-as-default-member': 'warn',
|
|
244
|
-
'import-next/no-duplicates': 'warn',
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
performance: {
|
|
248
|
-
plugins: {
|
|
249
|
-
'import-next': exports.plugin,
|
|
250
|
-
},
|
|
251
|
-
rules: {
|
|
252
|
-
'import-next/no-barrel-file': 'error',
|
|
253
|
-
'import-next/no-barrel-import': 'warn',
|
|
254
|
-
'import-next/prefer-tree-shakeable-imports': 'warn',
|
|
255
|
-
'import-next/prefer-direct-import': 'warn',
|
|
256
|
-
'import-next/no-full-package-import': 'warn',
|
|
257
|
-
'import-next/no-cycle': 'error',
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
enterprise: {
|
|
261
|
-
plugins: {
|
|
262
|
-
'import-next': exports.plugin,
|
|
263
|
-
},
|
|
264
|
-
rules: {
|
|
265
|
-
'import-next/enforce-team-boundaries': 'off',
|
|
266
|
-
'import-next/no-legacy-imports': 'off',
|
|
267
|
-
'import-next/no-cross-domain-imports': 'warn',
|
|
268
|
-
'import-next/enforce-dependency-direction': 'warn',
|
|
269
|
-
'import-next/no-internal-modules': 'warn',
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
};
|
|
273
|
-
exports.default = exports.plugin;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearCircularDependencyCache=exports.configs=exports.plugin=exports.rules=void 0;const no_cycle_1=require("./rules/no-cycle");Object.defineProperty(exports,"clearCircularDependencyCache",{enumerable:true,get:function(){return no_cycle_1.clearCircularDependencyCache}});exports.rules={get"no-duplicates"(){return require("./rules/no-duplicates").noDuplicates},get named(){return require("./rules/named").named},get default(){return require("./rules/default").defaultRule},get namespace(){return require("./rules/namespace").namespace},get extensions(){return require("./rules/extensions").extensions},get"no-self-import"(){return require("./rules/no-self-import").noSelfImport},get"no-unresolved"(){return require("./rules/no-unresolved").noUnresolved},get"no-absolute-path"(){return require("./rules/no-absolute-path").noAbsolutePath},get"no-dynamic-require"(){return require("./rules/no-dynamic-require").noDynamicRequire},get"no-relative-packages"(){return require("./rules/no-relative-packages").noRelativePackages},get"no-useless-path-segments"(){return require("./rules/no-useless-path-segments").noUselessPathSegments},get"no-amd"(){return require("./rules/no-amd").noAmd},get"no-commonjs"(){return require("./rules/no-commonjs").noCommonjs},get"no-nodejs-modules"(){return require("./rules/no-nodejs-modules").noNodejsModules},get"no-import-module-exports"(){return require("./rules/no-import-module-exports").noImportModuleExports},get unambiguous(){return require("./rules/unambiguous").unambiguous},get"no-cycle"(){return require("./rules/no-cycle").noCycle},get"no-internal-modules"(){return require("./rules/no-internal-modules").noInternalModules},get"no-cross-domain-imports"(){return require("./rules/no-cross-domain-imports").noCrossDomainImports},get"enforce-dependency-direction"(){return require("./rules/enforce-dependency-direction").enforceDependencyDirection},get"no-restricted-paths"(){return require("./rules/no-restricted-paths").noRestrictedPaths},get"no-relative-parent-imports"(){return require("./rules/no-relative-parent-imports").noRelativeParentImports},get export(){return require("./rules/export").exportRule},get"no-default-export"(){return require("./rules/no-default-export").noDefaultExport},get"no-named-export"(){return require("./rules/no-named-export").noNamedExport},get"prefer-default-export"(){return require("./rules/prefer-default-export").preferDefaultExport},get"no-anonymous-default-export"(){return require("./rules/no-anonymous-default-export").noAnonymousDefaultExport},get"no-mutable-exports"(){return require("./rules/no-mutable-exports").noMutableExports},get"no-deprecated"(){return require("./rules/no-deprecated").noDeprecated},get"exports-last"(){return require("./rules/exports-last").exportsLast},get"group-exports"(){return require("./rules/group-exports").groupExports},get"enforce-import-order"(){return require("./rules/enforce-import-order").enforceImportOrder},get order(){return require("./rules/enforce-import-order").enforceImportOrder},get"no-unassigned-import"(){return require("./rules/no-unassigned-import").noUnassignedImport},get first(){return require("./rules/first").first},get"newline-after-import"(){return require("./rules/newline-after-import").newlineAfterImport},get"no-empty-named-blocks"(){return require("./rules/no-empty-named-blocks").noEmptyNamedBlocks},get"no-named-as-default"(){return require("./rules/no-named-as-default").noNamedAsDefault},get"no-named-as-default-member"(){return require("./rules/no-named-as-default-member").noNamedAsDefaultMember},get"no-named-default"(){return require("./rules/no-named-default").noNamedDefault},get"no-namespace"(){return require("./rules/no-namespace").noNamespace},get"consistent-type-specifier-style"(){return require("./rules/consistent-type-specifier-style").consistentTypeSpecifierStyle},get"dynamic-import-chunkname"(){return require("./rules/dynamic-import-chunkname").dynamicImportChunkname},get"no-extraneous-dependencies"(){return require("./rules/no-extraneous-dependencies").noExtraneousDependencies},get"no-unused-modules"(){return require("./rules/no-unused-modules").noUnusedModules},get"max-dependencies"(){return require("./rules/max-dependencies").maxDependencies},get"prefer-node-protocol"(){return require("./rules/prefer-node-protocol").preferNodeProtocol},get"no-barrel-file"(){return require("./rules/no-barrel-file").noBarrelFile},get"no-barrel-import"(){return require("./rules/no-barrel-import").noBarrelImport},get"prefer-tree-shakeable-imports"(){return require("./rules/prefer-tree-shakeable-imports").preferTreeShakeableImports},get"prefer-direct-import"(){return require("./rules/prefer-direct-import").preferDirectImport},get"no-full-package-import"(){return require("./rules/no-full-package-import").noFullPackageImport},get"enforce-team-boundaries"(){return require("./rules/enforce-team-boundaries").enforceTeamBoundaries},get"no-legacy-imports"(){return require("./rules/no-legacy-imports").noLegacyImports},get"require-import-approval"(){return require("./rules/require-import-approval").requireImportApproval},get"prefer-modern-api"(){return require("./rules/prefer-modern-api").preferModernApi}};exports.plugin={meta:{name:"eslint-plugin-import-next",version:"2.3.16"},rules:exports.rules};exports.configs={flagship:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-cycle":"error"}},recommended:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-unresolved":"error","import-next/named":"error","import-next/default":"error","import-next/namespace":"warn","import-next/no-duplicates":"error","import-next/export":"error","import-next/no-cycle":"error","import-next/no-self-import":"error","import-next/no-named-as-default":"warn","import-next/no-named-as-default-member":"warn","import-next/no-amd":"warn","import-next/order":"warn","import-next/first":"warn","import-next/newline-after-import":"warn","import-next/no-empty-named-blocks":"warn","import-next/no-extraneous-dependencies":"warn"}},strict:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-unresolved":"error","import-next/named":"error","import-next/default":"error","import-next/namespace":"error","import-next/extensions":"error","import-next/no-self-import":"error","import-next/no-duplicates":"error","import-next/no-absolute-path":"error","import-next/no-dynamic-require":"error","import-next/no-useless-path-segments":"error","import-next/export":"error","import-next/no-amd":"error","import-next/no-commonjs":"error","import-next/no-nodejs-modules":"error","import-next/no-import-module-exports":"error","import-next/unambiguous":"error","import-next/no-cycle":"error","import-next/no-internal-modules":"error","import-next/no-cross-domain-imports":"error","import-next/enforce-dependency-direction":"error","import-next/no-restricted-paths":"error","import-next/no-relative-parent-imports":"error","import-next/no-relative-packages":"error","import-next/no-anonymous-default-export":"error","import-next/no-mutable-exports":"error","import-next/no-deprecated":"error","import-next/exports-last":"error","import-next/group-exports":"error","import-next/order":"error","import-next/no-unassigned-import":"error","import-next/first":"error","import-next/newline-after-import":"error","import-next/no-empty-named-blocks":"error","import-next/no-named-as-default":"error","import-next/no-named-as-default-member":"error","import-next/no-named-default":"error","import-next/no-namespace":"error","import-next/consistent-type-specifier-style":"error","import-next/no-extraneous-dependencies":"error","import-next/no-unused-modules":"error","import-next/max-dependencies":"error","import-next/prefer-node-protocol":"error"}},typescript:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-unresolved":"error","import-next/named":"off","import-next/default":"error","import-next/namespace":"error","import-next/export":"error","import-next/no-cycle":"error","import-next/no-duplicates":"error","import-next/order":"warn","import-next/first":"warn","import-next/newline-after-import":"warn","import-next/consistent-type-specifier-style":["warn","prefer-inline"]}},"module-resolution":{plugins:{"import-next":exports.plugin},rules:{"import-next/no-unresolved":"error","import-next/named":"error","import-next/default":"error","import-next/namespace":"error","import-next/extensions":"warn","import-next/no-self-import":"error","import-next/no-duplicates":"error","import-next/no-absolute-path":"error","import-next/no-useless-path-segments":"warn"}},"import-style":{plugins:{"import-next":exports.plugin},rules:{"import-next/order":"error","import-next/first":"error","import-next/newline-after-import":"error","import-next/no-duplicates":"error","import-next/no-unassigned-import":"warn","import-next/no-empty-named-blocks":"error","import-next/no-namespace":"warn"}},esm:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-amd":"error","import-next/no-commonjs":"error","import-next/no-import-module-exports":"error","import-next/unambiguous":"error","import-next/prefer-node-protocol":"error"}},architecture:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-cycle":"error","import-next/no-internal-modules":"error","import-next/no-cross-domain-imports":"error","import-next/enforce-dependency-direction":"error","import-next/no-restricted-paths":"error","import-next/no-relative-parent-imports":"warn","import-next/no-relative-packages":"error"}},errors:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-unresolved":"error","import-next/named":"error","import-next/default":"error","import-next/namespace":"error","import-next/export":"error"}},warnings:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-named-as-default":"warn","import-next/no-named-as-default-member":"warn","import-next/no-duplicates":"warn"}},performance:{plugins:{"import-next":exports.plugin},rules:{"import-next/no-barrel-file":"error","import-next/no-barrel-import":"warn","import-next/prefer-tree-shakeable-imports":"warn","import-next/prefer-direct-import":"warn","import-next/no-full-package-import":"warn","import-next/no-cycle":"error"}},enterprise:{plugins:{"import-next":exports.plugin},rules:{"import-next/enforce-team-boundaries":"off","import-next/no-legacy-imports":"off","import-next/no-cross-domain-imports":"warn","import-next/enforce-dependency-direction":"warn","import-next/no-internal-modules":"warn"}}};exports.default=exports.plugin;
|
package/src/oxlint.js
CHANGED
|
@@ -1,109 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.consistentTypeSpecifierStyle = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
exports.consistentTypeSpecifierStyle = (0, eslint_devkit_1.createRule)({
|
|
6
|
-
name: 'consistent-type-specifier-style',
|
|
7
|
-
meta: {
|
|
8
|
-
type: 'suggestion',
|
|
9
|
-
docs: {
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/consistent-type-specifier-style.md',
|
|
11
|
-
description: 'Enforce or ban the use of inline type-only markers for named imports',
|
|
12
|
-
cwe: 'CWE-1078',
|
|
13
|
-
cvss: 2.5,
|
|
14
|
-
},
|
|
15
|
-
fixable: 'code',
|
|
16
|
-
messages: {
|
|
17
|
-
preferInline: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
-
icon: eslint_devkit_1.MessageIcons.ARCHITECTURE,
|
|
19
|
-
issueName: 'Type Import Style',
|
|
20
|
-
cwe: 'CWE-1078',
|
|
21
|
-
description: 'Use inline type specifier: import { type Foo }',
|
|
22
|
-
severity: 'LOW',
|
|
23
|
-
fix: 'Convert to inline type: import { type {{name}} } from ...',
|
|
24
|
-
documentationLink: 'https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md',
|
|
25
|
-
}),
|
|
26
|
-
preferTopLevel: (0, eslint_devkit_1.formatLLMMessage)({
|
|
27
|
-
icon: eslint_devkit_1.MessageIcons.ARCHITECTURE,
|
|
28
|
-
issueName: 'Type Import Style',
|
|
29
|
-
cwe: 'CWE-1078',
|
|
30
|
-
description: 'Use top-level type import: import type { Foo }',
|
|
31
|
-
severity: 'LOW',
|
|
32
|
-
fix: 'Convert to top-level type: import type { {{name}} } from ...',
|
|
33
|
-
documentationLink: 'https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md',
|
|
34
|
-
}),
|
|
35
|
-
},
|
|
36
|
-
schema: [
|
|
37
|
-
{
|
|
38
|
-
type: 'string',
|
|
39
|
-
enum: ['prefer-inline', 'prefer-top-level'],
|
|
40
|
-
default: 'prefer-inline',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
defaultOptions: ['prefer-inline'],
|
|
45
|
-
create(context) {
|
|
46
|
-
const style = context.options[0] || 'prefer-inline';
|
|
47
|
-
const sourceCode = context.sourceCode;
|
|
48
|
-
function getSpecifierText(spec) {
|
|
49
|
-
const imported = spec.imported.type === 'Identifier'
|
|
50
|
-
? spec.imported.name
|
|
51
|
-
: spec.imported.value;
|
|
52
|
-
const local = spec.local.name;
|
|
53
|
-
if (imported === local) {
|
|
54
|
-
return imported;
|
|
55
|
-
}
|
|
56
|
-
return `${imported} as ${local}`;
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
ImportDeclaration(node) {
|
|
60
|
-
const isTypeImport = node.importKind === 'type';
|
|
61
|
-
if (style === 'prefer-inline') {
|
|
62
|
-
if (isTypeImport && node.specifiers.length > 0) {
|
|
63
|
-
const namedSpecifiers = node.specifiers.filter((s) => s.type === 'ImportSpecifier');
|
|
64
|
-
if (namedSpecifiers.length > 0) {
|
|
65
|
-
context.report({
|
|
66
|
-
node,
|
|
67
|
-
messageId: 'preferInline',
|
|
68
|
-
data: {
|
|
69
|
-
name: namedSpecifiers.map((s) => s.local.name).join(', '),
|
|
70
|
-
},
|
|
71
|
-
fix(fixer) {
|
|
72
|
-
const specifiersText = namedSpecifiers
|
|
73
|
-
.map((spec) => `type ${getSpecifierText(spec)}`)
|
|
74
|
-
.join(', ');
|
|
75
|
-
const sourceText = sourceCode.getText(node.source);
|
|
76
|
-
const newImport = `import { ${specifiersText} } from ${sourceText};`;
|
|
77
|
-
return fixer.replaceText(node, newImport);
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
const namedSpecifiers = node.specifiers.filter((s) => s.type === 'ImportSpecifier');
|
|
85
|
-
const inlineTypeSpecifiers = namedSpecifiers.filter((s) => s.importKind === 'type');
|
|
86
|
-
if (!isTypeImport &&
|
|
87
|
-
namedSpecifiers.length > 0 &&
|
|
88
|
-
inlineTypeSpecifiers.length === namedSpecifiers.length) {
|
|
89
|
-
context.report({
|
|
90
|
-
node,
|
|
91
|
-
messageId: 'preferTopLevel',
|
|
92
|
-
data: {
|
|
93
|
-
name: namedSpecifiers.map((s) => s.local.name).join(', '),
|
|
94
|
-
},
|
|
95
|
-
fix(fixer) {
|
|
96
|
-
const specifiersText = namedSpecifiers
|
|
97
|
-
.map((spec) => getSpecifierText(spec))
|
|
98
|
-
.join(', ');
|
|
99
|
-
const sourceText = sourceCode.getText(node.source);
|
|
100
|
-
const newImport = `import type { ${specifiersText} } from ${sourceText};`;
|
|
101
|
-
return fixer.replaceText(node, newImport);
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.consistentTypeSpecifierStyle=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.consistentTypeSpecifierStyle=(0,eslint_devkit_1.createRule)({name:"consistent-type-specifier-style",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/consistent-type-specifier-style.md",description:"Enforce or ban the use of inline type-only markers for named imports",cwe:"CWE-1078",cvss:2.5},fixable:"code",messages:{preferInline:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.ARCHITECTURE,issueName:"Type Import Style",cwe:"CWE-1078",description:"Use inline type specifier: import { type Foo }",severity:"LOW",fix:"Convert to inline type: import { type {{name}} } from ...",documentationLink:"https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md"}),preferTopLevel:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.ARCHITECTURE,issueName:"Type Import Style",cwe:"CWE-1078",description:"Use top-level type import: import type { Foo }",severity:"LOW",fix:"Convert to top-level type: import type { {{name}} } from ...",documentationLink:"https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md"})},schema:[{type:"string",enum:["prefer-inline","prefer-top-level"],default:"prefer-inline"}]},defaultOptions:["prefer-inline"],create(context){const style=context.options[0]||"prefer-inline";const sourceCode=context.sourceCode;function getSpecifierText(spec){const imported=spec.imported.type==="Identifier"?spec.imported.name:spec.imported.value;const local=spec.local.name;if(imported===local){return imported}return`${imported} as ${local}`}return{ImportDeclaration(node){const isTypeImport=node.importKind==="type";if(style==="prefer-inline"){if(isTypeImport&&node.specifiers.length>0){const namedSpecifiers=node.specifiers.filter(s=>s.type==="ImportSpecifier");if(namedSpecifiers.length>0){context.report({node,messageId:"preferInline",data:{name:namedSpecifiers.map(s=>s.local.name).join(", ")},fix(fixer){const specifiersText=namedSpecifiers.map(spec=>`type ${getSpecifierText(spec)}`).join(", ");const sourceText=sourceCode.getText(node.source);const newImport=`import { ${specifiersText} } from ${sourceText};`;return fixer.replaceText(node,newImport)}})}}}else{const namedSpecifiers=node.specifiers.filter(s=>s.type==="ImportSpecifier");const inlineTypeSpecifiers=namedSpecifiers.filter(s=>s.importKind==="type");if(!isTypeImport&&namedSpecifiers.length>0&&inlineTypeSpecifiers.length===namedSpecifiers.length){context.report({node,messageId:"preferTopLevel",data:{name:namedSpecifiers.map(s=>s.local.name).join(", ")},fix(fixer){const specifiersText=namedSpecifiers.map(spec=>getSpecifierText(spec)).join(", ");const sourceText=sourceCode.getText(node.source);const newImport=`import type { ${specifiersText} } from ${sourceText};`;return fixer.replaceText(node,newImport)}})}}}}}});
|
package/src/rules/default.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultRule = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
const eslint_devkit_2 = require("@interlace/eslint-devkit");
|
|
6
|
-
const typescript_peer_1 = require("../utils/typescript-peer");
|
|
7
|
-
exports.defaultRule = (0, eslint_devkit_1.createRule)({
|
|
8
|
-
name: 'default',
|
|
9
|
-
meta: {
|
|
10
|
-
type: 'problem',
|
|
11
|
-
docs: {
|
|
12
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/default.md',
|
|
13
|
-
description: 'Ensure a default export is present, given a default import',
|
|
14
|
-
},
|
|
15
|
-
messages: {
|
|
16
|
-
noDefaultExport: (0, eslint_devkit_2.formatLLMMessage)({
|
|
17
|
-
icon: eslint_devkit_2.MessageIcons.QUALITY,
|
|
18
|
-
issueName: 'Missing Default Export',
|
|
19
|
-
description: 'No default export found in imported module',
|
|
20
|
-
severity: 'HIGH',
|
|
21
|
-
fix: 'Use named imports or add a default export to the module',
|
|
22
|
-
documentationLink: 'https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/default.md',
|
|
23
|
-
}),
|
|
24
|
-
},
|
|
25
|
-
schema: [],
|
|
26
|
-
},
|
|
27
|
-
defaultOptions: [],
|
|
28
|
-
create(context) {
|
|
29
|
-
if (!(0, eslint_devkit_2.hasParserServices)(context))
|
|
30
|
-
return {};
|
|
31
|
-
const services = (0, eslint_devkit_2.getParserServices)(context);
|
|
32
|
-
const checker = services.program?.getTypeChecker?.();
|
|
33
|
-
return {
|
|
34
|
-
ImportDefaultSpecifier(node) {
|
|
35
|
-
if (node.parent.type === 'ImportDeclaration' &&
|
|
36
|
-
node.parent.importKind === 'type')
|
|
37
|
-
return;
|
|
38
|
-
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
39
|
-
const symbol = checker?.getSymbolAtLocation?.(tsNode);
|
|
40
|
-
const moduleNode = services.esTreeNodeToTSNodeMap.get(node.parent.source);
|
|
41
|
-
const moduleSymbol = checker?.getSymbolAtLocation?.(moduleNode);
|
|
42
|
-
if (moduleSymbol && !symbol) {
|
|
43
|
-
const tsModule = (0, typescript_peer_1.loadTypeScript)();
|
|
44
|
-
if (tsModule &&
|
|
45
|
-
moduleSymbol.exports &&
|
|
46
|
-
!moduleSymbol.exports.has(tsModule.InternalSymbolName.Default)) {
|
|
47
|
-
context.report({
|
|
48
|
-
node,
|
|
49
|
-
messageId: 'noDefaultExport',
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultRule=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const typescript_peer_1=require("../utils/typescript-peer");exports.defaultRule=(0,eslint_devkit_1.createRule)({name:"default",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/default.md",description:"Ensure a default export is present, given a default import"},messages:{noDefaultExport:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.QUALITY,issueName:"Missing Default Export",description:"No default export found in imported module",severity:"HIGH",fix:"Use named imports or add a default export to the module",documentationLink:"https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/default.md"})},schema:[]},defaultOptions:[],create(context){if(!(0,eslint_devkit_2.hasParserServices)(context))return{};const services=(0,eslint_devkit_2.getParserServices)(context);const checker=services.program?.getTypeChecker?.();return{ImportDefaultSpecifier(node){if(node.parent.type==="ImportDeclaration"&&node.parent.importKind==="type")return;const tsNode=services.esTreeNodeToTSNodeMap.get(node);const symbol=checker?.getSymbolAtLocation?.(tsNode);const moduleNode=services.esTreeNodeToTSNodeMap.get(node.parent.source);const moduleSymbol=checker?.getSymbolAtLocation?.(moduleNode);if(moduleSymbol&&!symbol){const tsModule=(0,typescript_peer_1.loadTypeScript)();if(tsModule&&moduleSymbol.exports&&!moduleSymbol.exports.has(tsModule.InternalSymbolName.Default)){context.report({node,messageId:"noDefaultExport"})}}}}}});
|
|
@@ -1,115 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dynamicImportChunkname = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
exports.dynamicImportChunkname = (0, eslint_devkit_1.createRule)({
|
|
6
|
-
name: 'dynamic-import-chunkname',
|
|
7
|
-
meta: {
|
|
8
|
-
type: 'suggestion',
|
|
9
|
-
docs: {
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/dynamic-import-chunkname.md',
|
|
11
|
-
description: 'Enforce a leading comment with the webpackChunkName for dynamic imports',
|
|
12
|
-
cwe: 'CWE-1078',
|
|
13
|
-
cvss: 2.5,
|
|
14
|
-
},
|
|
15
|
-
hasSuggestions: true,
|
|
16
|
-
messages: {
|
|
17
|
-
missingChunkName: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
-
icon: eslint_devkit_1.MessageIcons.ARCHITECTURE,
|
|
19
|
-
issueName: 'Missing Chunk Name',
|
|
20
|
-
cwe: 'CWE-1078',
|
|
21
|
-
description: 'Dynamic import is missing webpackChunkName comment',
|
|
22
|
-
severity: 'LOW',
|
|
23
|
-
fix: 'Add /* webpackChunkName: "chunk-name" */ before the import path',
|
|
24
|
-
documentationLink: 'https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/dynamic-import-chunkname.md',
|
|
25
|
-
}),
|
|
26
|
-
invalidChunkName: (0, eslint_devkit_1.formatLLMMessage)({
|
|
27
|
-
icon: eslint_devkit_1.MessageIcons.ARCHITECTURE,
|
|
28
|
-
issueName: 'Invalid Chunk Name',
|
|
29
|
-
cwe: 'CWE-1078',
|
|
30
|
-
description: 'webpackChunkName "{{chunkName}}" does not match pattern',
|
|
31
|
-
severity: 'LOW',
|
|
32
|
-
fix: 'Update chunk name to match the required pattern',
|
|
33
|
-
documentationLink: 'https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/dynamic-import-chunkname.md',
|
|
34
|
-
}),
|
|
35
|
-
suggestChunkName: 'Add webpackChunkName comment',
|
|
36
|
-
},
|
|
37
|
-
schema: [
|
|
38
|
-
{
|
|
39
|
-
type: 'object',
|
|
40
|
-
properties: {
|
|
41
|
-
importFunctions: {
|
|
42
|
-
type: 'array',
|
|
43
|
-
items: { type: 'string' },
|
|
44
|
-
},
|
|
45
|
-
allowEmpty: { type: 'boolean', default: false },
|
|
46
|
-
webpackChunknameFormat: { type: 'string' },
|
|
47
|
-
},
|
|
48
|
-
additionalProperties: false,
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
defaultOptions: [
|
|
53
|
-
{
|
|
54
|
-
importFunctions: [],
|
|
55
|
-
allowEmpty: false,
|
|
56
|
-
webpackChunknameFormat: '[a-zA-Z0-9-_/.]+',
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
create(context) {
|
|
60
|
-
const options = context.options[0] || {};
|
|
61
|
-
const { allowEmpty = false, webpackChunknameFormat = '[a-zA-Z0-9-_/.]+' } = options;
|
|
62
|
-
const chunkNamePattern = new RegExp(`^${webpackChunknameFormat}$`);
|
|
63
|
-
const sourceCode = context.sourceCode;
|
|
64
|
-
function checkChunkName(node) {
|
|
65
|
-
const comments = sourceCode.getCommentsBefore(node.source);
|
|
66
|
-
let foundChunkName = null;
|
|
67
|
-
let hasWebpackComment = false;
|
|
68
|
-
for (const comment of comments) {
|
|
69
|
-
const text = comment.value.trim();
|
|
70
|
-
const match = text.match(/webpackChunkName:\s*["']([^"']+)["']/);
|
|
71
|
-
if (match) {
|
|
72
|
-
hasWebpackComment = true;
|
|
73
|
-
foundChunkName = match[1];
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (!hasWebpackComment) {
|
|
78
|
-
if (!allowEmpty) {
|
|
79
|
-
context.report({
|
|
80
|
-
node,
|
|
81
|
-
messageId: 'missingChunkName',
|
|
82
|
-
suggest: [
|
|
83
|
-
{
|
|
84
|
-
messageId: 'suggestChunkName',
|
|
85
|
-
fix(fixer) {
|
|
86
|
-
const source = node.source;
|
|
87
|
-
if (source.type === 'Literal' && typeof source.value === 'string') {
|
|
88
|
-
const chunkName = source.value
|
|
89
|
-
.split('/')
|
|
90
|
-
.pop()
|
|
91
|
-
?.replace(/[^a-zA-Z0-9-_]/g, '-') || 'chunk';
|
|
92
|
-
return fixer.insertTextBefore(source, `/* webpackChunkName: "${chunkName}" */ `);
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else if (foundChunkName && !chunkNamePattern.test(foundChunkName)) {
|
|
102
|
-
context.report({
|
|
103
|
-
node,
|
|
104
|
-
messageId: 'invalidChunkName',
|
|
105
|
-
data: { chunkName: foundChunkName },
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
ImportExpression(node) {
|
|
111
|
-
checkChunkName(node);
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.dynamicImportChunkname=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.dynamicImportChunkname=(0,eslint_devkit_1.createRule)({name:"dynamic-import-chunkname",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-import-next/docs/rules/dynamic-import-chunkname.md",description:"Enforce a leading comment with the webpackChunkName for dynamic imports",cwe:"CWE-1078",cvss:2.5},hasSuggestions:true,messages:{missingChunkName:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.ARCHITECTURE,issueName:"Missing Chunk Name",cwe:"CWE-1078",description:"Dynamic import is missing webpackChunkName comment",severity:"LOW",fix:'Add /* webpackChunkName: "chunk-name" */ before the import path',documentationLink:"https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/dynamic-import-chunkname.md"}),invalidChunkName:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.ARCHITECTURE,issueName:"Invalid Chunk Name",cwe:"CWE-1078",description:'webpackChunkName "{{chunkName}}" does not match pattern',severity:"LOW",fix:"Update chunk name to match the required pattern",documentationLink:"https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/dynamic-import-chunkname.md"}),suggestChunkName:"Add webpackChunkName comment"},schema:[{type:"object",properties:{importFunctions:{type:"array",items:{type:"string"}},allowEmpty:{type:"boolean",default:false},webpackChunknameFormat:{type:"string"}},additionalProperties:false}]},defaultOptions:[{importFunctions:[],allowEmpty:false,webpackChunknameFormat:"[a-zA-Z0-9-_/.]+"}],create(context){const options=context.options[0]||{};const{allowEmpty=false,webpackChunknameFormat="[a-zA-Z0-9-_/.]+"}=options;const chunkNamePattern=new RegExp(`^${webpackChunknameFormat}$`);const sourceCode=context.sourceCode;function checkChunkName(node){const comments=sourceCode.getCommentsBefore(node.source);let foundChunkName=null;let hasWebpackComment=false;for(const comment of comments){const text=comment.value.trim();const match=text.match(/webpackChunkName:\s*["']([^"']+)["']/);if(match){hasWebpackComment=true;foundChunkName=match[1];break}}if(!hasWebpackComment){if(!allowEmpty){context.report({node,messageId:"missingChunkName",suggest:[{messageId:"suggestChunkName",fix(fixer){const source=node.source;if(source.type==="Literal"&&typeof source.value==="string"){const chunkName=source.value.split("/").pop()?.replace(/[^a-zA-Z0-9-_]/g,"-")||"chunk";return fixer.insertTextBefore(source,`/* webpackChunkName: "${chunkName}" */ `)}return null}}]})}}else if(foundChunkName&&!chunkNamePattern.test(foundChunkName)){context.report({node,messageId:"invalidChunkName",data:{chunkName:foundChunkName}})}}return{ImportExpression(node){checkChunkName(node)}}}});
|