eslint-plugin-import-next 2.1.0 → 2.2.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +142 -259
  3. package/package.json +1 -1
  4. package/src/files/foo.d.ts +5 -0
  5. package/src/files/foo.js +5 -0
  6. package/src/files/no-default.d.ts +5 -0
  7. package/src/files/no-default.js +5 -0
  8. package/src/index.d.ts +1093 -57
  9. package/src/index.js +97 -9
  10. package/src/rules/consistent-type-specifier-style.d.ts +11 -1
  11. package/src/rules/consistent-type-specifier-style.js +5 -0
  12. package/src/rules/default.d.ts +7 -1
  13. package/src/rules/default.js +5 -0
  14. package/src/rules/dynamic-import-chunkname.d.ts +16 -1
  15. package/src/rules/dynamic-import-chunkname.js +5 -0
  16. package/src/rules/enforce-dependency-direction.d.ts +17 -1
  17. package/src/rules/enforce-dependency-direction.js +5 -0
  18. package/src/rules/enforce-import-order.d.ts +14 -1
  19. package/src/rules/enforce-import-order.js +5 -0
  20. package/src/rules/enforce-team-boundaries.d.ts +45 -0
  21. package/src/rules/enforce-team-boundaries.js +230 -0
  22. package/src/rules/export.d.ts +15 -1
  23. package/src/rules/export.js +5 -0
  24. package/src/rules/exports-last.d.ts +13 -1
  25. package/src/rules/exports-last.js +5 -0
  26. package/src/rules/extensions.d.ts +15 -1
  27. package/src/rules/extensions.js +5 -0
  28. package/src/rules/first.d.ts +7 -1
  29. package/src/rules/first.js +5 -0
  30. package/src/rules/group-exports.d.ts +13 -1
  31. package/src/rules/group-exports.js +5 -0
  32. package/src/rules/max-dependencies.d.ts +14 -1
  33. package/src/rules/max-dependencies.js +5 -0
  34. package/src/rules/named.d.ts +7 -1
  35. package/src/rules/named.js +5 -0
  36. package/src/rules/namespace.d.ts +7 -1
  37. package/src/rules/namespace.js +5 -0
  38. package/src/rules/newline-after-import.d.ts +7 -1
  39. package/src/rules/newline-after-import.js +5 -0
  40. package/src/rules/no-absolute-path.d.ts +15 -1
  41. package/src/rules/no-absolute-path.js +5 -0
  42. package/src/rules/no-amd.d.ts +13 -1
  43. package/src/rules/no-amd.js +5 -0
  44. package/src/rules/no-anonymous-default-export.d.ts +14 -1
  45. package/src/rules/no-anonymous-default-export.js +5 -0
  46. package/src/rules/no-barrel-file.d.ts +53 -0
  47. package/src/rules/no-barrel-file.js +225 -0
  48. package/src/rules/no-barrel-import.d.ts +46 -0
  49. package/src/rules/no-barrel-import.js +160 -0
  50. package/src/rules/no-commonjs.d.ts +14 -1
  51. package/src/rules/no-commonjs.js +5 -0
  52. package/src/rules/no-cross-domain-imports.d.ts +17 -1
  53. package/src/rules/no-cross-domain-imports.js +5 -0
  54. package/src/rules/no-cycle.d.ts +8 -1
  55. package/src/rules/no-cycle.js +5 -0
  56. package/src/rules/no-default-export.d.ts +14 -1
  57. package/src/rules/no-default-export.js +5 -0
  58. package/src/rules/no-deprecated.d.ts +14 -1
  59. package/src/rules/no-deprecated.js +5 -0
  60. package/src/rules/no-duplicates.d.ts +7 -1
  61. package/src/rules/no-duplicates.js +5 -0
  62. package/src/rules/no-dynamic-require.d.ts +16 -1
  63. package/src/rules/no-dynamic-require.js +5 -0
  64. package/src/rules/no-empty-named-blocks.d.ts +15 -1
  65. package/src/rules/no-empty-named-blocks.js +5 -0
  66. package/src/rules/no-extraneous-dependencies.d.ts +13 -1
  67. package/src/rules/no-extraneous-dependencies.js +5 -0
  68. package/src/rules/no-full-package-import.d.ts +40 -0
  69. package/src/rules/no-full-package-import.js +152 -0
  70. package/src/rules/no-import-module-exports.d.ts +15 -1
  71. package/src/rules/no-import-module-exports.js +5 -0
  72. package/src/rules/no-internal-modules.d.ts +14 -1
  73. package/src/rules/no-internal-modules.js +5 -0
  74. package/src/rules/no-legacy-imports.d.ts +45 -0
  75. package/src/rules/no-legacy-imports.js +134 -0
  76. package/src/rules/no-mutable-exports.d.ts +14 -1
  77. package/src/rules/no-mutable-exports.js +5 -0
  78. package/src/rules/no-named-as-default-member.d.ts +13 -1
  79. package/src/rules/no-named-as-default-member.js +5 -0
  80. package/src/rules/no-named-as-default.d.ts +13 -1
  81. package/src/rules/no-named-as-default.js +5 -0
  82. package/src/rules/no-named-default.d.ts +13 -1
  83. package/src/rules/no-named-default.js +5 -0
  84. package/src/rules/no-named-export.d.ts +14 -1
  85. package/src/rules/no-named-export.js +5 -0
  86. package/src/rules/no-namespace.d.ts +15 -1
  87. package/src/rules/no-namespace.js +5 -0
  88. package/src/rules/no-nodejs-modules.d.ts +14 -1
  89. package/src/rules/no-nodejs-modules.js +5 -0
  90. package/src/rules/no-relative-packages.d.ts +15 -1
  91. package/src/rules/no-relative-packages.js +5 -0
  92. package/src/rules/no-relative-parent-imports.d.ts +14 -1
  93. package/src/rules/no-relative-parent-imports.js +5 -0
  94. package/src/rules/no-restricted-paths.d.ts +14 -1
  95. package/src/rules/no-restricted-paths.js +5 -0
  96. package/src/rules/no-self-import.d.ts +9 -1
  97. package/src/rules/no-self-import.js +5 -0
  98. package/src/rules/no-unassigned-import.d.ts +14 -1
  99. package/src/rules/no-unassigned-import.js +5 -0
  100. package/src/rules/no-unresolved.d.ts +10 -1
  101. package/src/rules/no-unresolved.js +5 -0
  102. package/src/rules/no-unused-modules.d.ts +13 -1
  103. package/src/rules/no-unused-modules.js +5 -0
  104. package/src/rules/no-useless-path-segments.d.ts +15 -1
  105. package/src/rules/no-useless-path-segments.js +5 -0
  106. package/src/rules/prefer-default-export.d.ts +14 -1
  107. package/src/rules/prefer-default-export.js +5 -0
  108. package/src/rules/prefer-direct-import.d.ts +49 -0
  109. package/src/rules/prefer-direct-import.js +189 -0
  110. package/src/rules/prefer-modern-api.d.ts +45 -0
  111. package/src/rules/prefer-modern-api.js +232 -0
  112. package/src/rules/prefer-node-protocol.d.ts +13 -1
  113. package/src/rules/prefer-node-protocol.js +5 -0
  114. package/src/rules/prefer-tree-shakeable-imports.d.ts +47 -0
  115. package/src/rules/prefer-tree-shakeable-imports.js +147 -0
  116. package/src/rules/require-import-approval.d.ts +50 -0
  117. package/src/rules/require-import-approval.js +194 -0
  118. package/src/rules/unambiguous.d.ts +13 -1
  119. package/src/rules/unambiguous.js +5 -0
  120. package/src/types/index.d.ts +5 -0
  121. package/src/types/index.js +3 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Documentation
11
+
12
+ - 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
13
+
8
14
  ## [2.0.0] - 2025-12-30
9
15
 
10
16
  ### Changed
package/README.md CHANGED
@@ -1,256 +1,47 @@
1
- # eslint-plugin-import-next
1
+ <p align="center">
2
+ <a href="https://eslint.interlace.tools" target="blank"><img src="https://eslint.interlace.tools/eslint-interlace-logo-light.svg" alt="ESLint Interlace Logo" width="120" /></a>
3
+ </p>
2
4
 
3
- > 🔥 **Drop-in replacement for `eslint-plugin-import`.** 100% backwards compatible, 100x faster, zero false positives, AI-optimized fixes.
5
+ <p align="center">
6
+ Next-generation import sorting, validation, and architectural boundaries.
7
+ </p>
4
8
 
5
- [![npm version](https://img.shields.io/npm/v/eslint-plugin-import-next.svg)](https://www.npmjs.com/package/eslint-plugin-import-next)
6
- [![npm downloads](https://img.shields.io/npm/dm/eslint-plugin-import-next.svg)](https://www.npmjs.com/package/eslint-plugin-import-next)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![codecov](https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=import_next)](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=import_next)
9
- [![Dec 2025](https://img.shields.io/badge/Dec_2025-blue?logo=rocket&logoColor=white)](https://github.com/ofri-peretz/eslint)
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/eslint-plugin-import-next" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-import-next.svg" alt="NPM Version" /></a>
11
+ <a href="https://www.npmjs.com/package/eslint-plugin-import-next" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-import-next.svg" alt="NPM Downloads" /></a>
12
+ <a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
13
+ <a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=import-next" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=import-next" alt="Codecov" /></a>
14
+ <a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
15
+ </p>
10
16
 
11
- ---
12
-
13
- ## 💡 What you get
14
-
15
- - **100x faster cycle detection** - Incremental caching means re-runs are near-instant
16
- - **Zero false positives** - Tested against real-world monorepos with zero noise
17
- - **LLM-optimized messages** - Structured errors with CWE + OWASP + specific fix guidance
18
- - **Unlimited `maxDepth`** - No artificial limits on cycle detection depth
19
- - **ESLint 9 native** - First-class flat config support
20
- - **TypeScript ready** - Works out of the box, no extra resolver config
21
-
22
- ---
23
-
24
- ## 🚀 Migrate from `eslint-plugin-import` in 60 Seconds
25
-
26
- **Step 1: Install**
27
-
28
- ```bash
29
- npm uninstall eslint-plugin-import
30
- npm install --save-dev eslint-plugin-import-next
31
- ```
32
-
33
- **Step 2: Find & Replace in your ESLint config**
34
-
35
- ```diff
36
- - import importPlugin from 'eslint-plugin-import';
37
- + import importPlugin from 'eslint-plugin-import-next';
38
- ```
39
-
40
- ```diff
41
- - 'import/no-cycle': 'error',
42
- + 'import-next/no-cycle': 'error',
43
- ```
44
-
45
- **That's it.** All rule names are identical. All options are compatible. Your existing configuration works out of the box.
46
-
47
- ---
48
-
49
- ## 🎯 The `no-cycle` Problem (Why This Plugin Exists)
50
-
51
- ### The `maxDepth` Limitation in `eslint-plugin-import`
52
-
53
- The original `eslint-plugin-import` has a critical limitation: the `maxDepth` option defaults to `Infinity` in theory, but **in practice, many projects are forced to set `maxDepth: 1` or `maxDepth: 2`** because:
54
-
55
- ```javascript
56
- // eslint.config.js - Common workaround in legacy projects
57
- {
58
- rules: {
59
- // ❌ PROBLEM: Had to limit maxDepth due to performance
60
- 'import/no-cycle': ['error', { maxDepth: 1 }]
61
- }
62
- }
63
- ```
64
-
65
- **Why this happens:**
66
-
67
- 1. **Performance** - Full graph analysis on every lint run (no caching)
68
- 2. **Memory** - Large codebases exhaust memory with deep traversal
69
- 3. **Timeout** - CI/CD pipelines timeout on large monorepos
70
-
71
- **The consequence:** Cycles at depth 3+ go undetected, causing:
72
-
73
- ### Real-World Impact on Bundlers
74
-
75
- | Bundler | Symptom | Cause |
76
- | ----------- | --------------------------------------------------------- | ------------------------------ |
77
- | **Vite** | `ReferenceError: Cannot access 'X' before initialization` | Circular import race condition |
78
- | **Next.js** | Build hangs, OOM errors | Infinite resolution loop |
79
- | **Webpack** | Incorrect tree-shaking, larger bundles | Dependency graph confusion |
80
- | **esbuild** | Silent failures in production | Module order ambiguity |
81
-
82
- ### Example: Hidden Deep Cycle
17
+ ## Description
83
18
 
84
- ```
85
- // With maxDepth: 2, this cycle is UNDETECTED:
86
-
87
- src/
88
- ├── features/
89
- │ └── auth/
90
- │ └── AuthProvider.tsx
91
- │ └── imports useUser from →
92
- │ src/hooks/useUser.ts
93
- │ └── imports fetchUser from →
94
- │ src/api/user.ts
95
- │ └── imports authConfig from →
96
- │ src/config/auth.ts
97
- │ └── imports AuthProvider from → (CYCLE at depth 4!)
98
- │ src/features/auth/AuthProvider.tsx
99
- ```
100
-
101
- **With `import/no-cycle` maxDepth: 2** → ❌ Not detected
102
- **With `import-next/no-cycle`** → ✅ Detected instantly (cached)
103
-
104
- ---
105
-
106
- ## ⚡ Performance: The `no-cycle` Benchmark
107
-
108
- | Scenario | `eslint-plugin-import` | `eslint-plugin-import-next` |
109
- | --------------------------- | ---------------------- | --------------------------- |
110
- | **First run (10k files)** | ~45s | ~45s |
111
- | **Subsequent runs** | ~45s (re-analyzes) | **~0.4s** (cached) |
112
- | **Memory (large monorepo)** | 2-4 GB | ~500 MB |
113
- | **maxDepth: Infinity** | Often crashes | ✅ Works |
114
-
115
- ### How It Works
19
+ This plugin represents the next evolution of import validation, offering advanced features like granular import sorting and strictly enforced architectural boundaries. It is designed to modernize your development workflow by providing tools that prevent circular dependencies and enforce clean module structures. By integrating these rules, you can maintain a scalable and organized codebase that is easy to navigate and refactor.
116
20
 
117
- ```typescript
118
- // Incremental file-system cache
119
- // Only re-analyzes files that changed
120
- import { clearCircularDependencyCache } from 'eslint-plugin-import-next';
21
+ ## Philosophy
121
22
 
122
- // Clear cache on demand (e.g., for CI fresh runs)
123
- clearCircularDependencyCache();
124
- ```
125
-
126
- ---
127
-
128
- ## 🔄 Full Compatibility Matrix
129
-
130
- Every rule from `eslint-plugin-import` is implemented with **the same name** and **compatible options**:
131
-
132
- ### ✅ Static Analysis (13 rules)
133
-
134
- | Rule | Description | 💼 | 🔧 | 💡 |
135
- | ---------------------------- | --------------------------------- | :-: | :-: | :-: |
136
- | `no-unresolved` | Ensure imports resolve | 💼 | | 💡 |
137
- | `named` | Ensure named imports exist | 💼 | | |
138
- | `default` | Ensure default export exists | 💼 | | |
139
- | `namespace` | Ensure namespace properties exist | 💼 | | |
140
- | `no-absolute-path` | Forbid absolute paths | | 🔧 | |
141
- | `no-dynamic-require` | Forbid dynamic require() | | | |
142
- | `no-internal-modules` | Enforce entry points only | | | 💡 |
143
- | `no-relative-packages` | Use package names | | 🔧 | |
144
- | `no-relative-parent-imports` | Prevent `../` imports | | | |
145
- | `no-self-import` | Prevent self-imports | 💼 | | 💡 |
146
- | `no-cycle` | **100x faster** cycle detection | 💼 | | 💡 |
147
- | `no-useless-path-segments` | Simplify paths | | 🔧 | |
148
- | `no-restricted-paths` | Custom path restrictions | | | |
149
-
150
- ### ✅ Helpful Warnings (8 rules)
151
-
152
- | Rule | Description | 💼 | 🔧 | 💡 |
153
- | ---------------------------- | ----------------------------- | :-: | :-: | :-: |
154
- | `export` | Forbid duplicate exports | 💼 | | |
155
- | `no-deprecated` | Warn on `@deprecated` imports | | | |
156
- | `no-empty-named-blocks` | Forbid empty `{}` imports | | 🔧 | 💡 |
157
- | `no-extraneous-dependencies` | Prevent unlisted deps | 💼 | | 💡 |
158
- | `no-mutable-exports` | Forbid `let`/`var` exports | | | |
159
- | `no-named-as-default` | Warn on default shadowing | 💼 | | |
160
- | `no-named-as-default-member` | Warn on property access | 💼 | | |
161
- | `no-unused-modules` | Find dead code | | | 💡 |
162
-
163
- ### ✅ Module Systems (5 rules)
164
-
165
- | Rule | Description | 💼 | 🔧 | 💡 |
166
- | -------------------------- | ------------------------- | :-: | :-: | :-: |
167
- | `no-amd` | Forbid AMD require/define | | | |
168
- | `no-commonjs` | Forbid CommonJS | | | |
169
- | `no-nodejs-modules` | Forbid Node.js builtins | | | |
170
- | `no-import-module-exports` | No mixed ES/CJS | | | |
171
- | `unambiguous` | Warn on ambiguous modules | | | |
172
-
173
- ### ✅ Style Guide (17 rules)
174
-
175
- | Rule | Description | 💼 | 🔧 | 💡 |
176
- | --------------------------------- | --------------------------------- | :-: | :-: | :-: |
177
- | `consistent-type-specifier-style` | Type import style | | 🔧 | |
178
- | `dynamic-import-chunkname` | Require webpack chunk names | | | 💡 |
179
- | `exports-last` | Exports at end of file | | | |
180
- | `extensions` | Enforce file extension usage | | | |
181
- | `first` | Imports must be first | | 🔧 | |
182
- | `group-exports` | Group exports together | | | |
183
- | `max-dependencies` | Limit module dependencies | | | |
184
- | `newline-after-import` | Newline after imports | | 🔧 | |
185
- | `no-anonymous-default-export` | Require named default exports | | | |
186
- | `no-default-export` | Forbid default exports | | | 💡 |
187
- | `no-duplicates` | Merge duplicate imports | 💼 | 🔧 | |
188
- | `no-named-default` | Use default import syntax | | | |
189
- | `no-named-export` | Forbid named exports | | | |
190
- | `no-namespace` | Forbid `* as` imports | | | |
191
- | `no-unassigned-import` | Forbid side-effect imports | | | |
192
- | `order` | Sort and group imports | 💼 | 🔧 | |
193
- | `prefer-default-export` | Prefer default for single exports | | | |
194
-
195
- ### 🆕 Exclusive to `import-next` (3 rules)
196
-
197
- | Rule | Description |
198
- | ------------------------------ | --------------------------------------------------- |
199
- | `no-cross-domain-imports` | Enforce clean architecture boundaries |
200
- | `enforce-dependency-direction` | Enforce layered architecture (UI → Services → Data) |
201
- | `prefer-node-protocol` | Prefer `node:fs` over `fs` |
23
+ **Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
202
24
 
203
- ---
25
+ ## Getting Started
204
26
 
205
- ## 📦 Installation
27
+ - To check out the [guide](https://eslint.interlace.tools/docs/import-next), visit [eslint.interlace.tools](https://eslint.interlace.tools). 📚
28
+ - 要查看中文 [指南](https://eslint.interlace.tools/docs/import-next), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools). 📚
29
+ - [가이드](https://eslint.interlace.tools/docs/import-next) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools)에서 확인하실 수 있습니다. 📚
30
+ - [ガイド](https://eslint.interlace.tools/docs/import-next)は [eslint.interlace.tools](https://eslint.interlace.tools)でご確認ください。 📚
31
+ - Para ver la [guía](https://eslint.interlace.tools/docs/import-next), visita [eslint.interlace.tools](https://eslint.interlace.tools). 📚
32
+ - للاطلاع على [الدليل](https://eslint.interlace.tools/docs/import-next)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools). 📚
206
33
 
207
34
  ```bash
208
- npm install --save-dev eslint-plugin-import-next
209
- # or
210
- pnpm add -D eslint-plugin-import-next
211
- ```
212
-
213
- ## 🚀 Quick Start (Flat Config)
214
-
215
- ```javascript
216
- // eslint.config.js
217
- import importNext from 'eslint-plugin-import-next';
218
-
219
- export default [
220
- // Use recommended preset (most common rules)
221
- importNext.configs.recommended,
222
-
223
- // Or customize individual rules
224
- {
225
- plugins: { 'import-next': importNext },
226
- rules: {
227
- 'import-next/no-cycle': 'error', // No maxDepth needed!
228
- 'import-next/no-duplicates': 'error',
229
- 'import-next/order': 'warn',
230
- },
231
- },
232
- ];
35
+ npm install eslint-plugin-import-next --save-dev
233
36
  ```
234
37
 
235
- ---
236
-
237
- ## � Available Presets
238
-
239
- | Preset | Description |
240
- | ------------------- | -------------------------------------------- |
241
- | `recommended` | Essential rules for most projects |
242
- | `strict` | All rules enabled as errors |
243
- | `typescript` | Optimized for TypeScript projects |
244
- | `module-resolution` | Focus on import resolution |
245
- | `import-style` | Focus on import formatting |
246
- | `esm` | Enforce ES Modules only |
247
- | `architecture` | Clean architecture boundaries |
248
- | `errors` | Matches eslint-plugin-import errors preset |
249
- | `warnings` | Matches eslint-plugin-import warnings preset |
38
+ ## AI-Optimized Messages
250
39
 
251
- ---
40
+ This plugin is optimized for ESLint's [Model Context Protocol (MCP)](https://eslint.org/docs/latest/use/mcp), enabling AI assistants like **Cursor**, **GitHub Copilot**, and **Claude** to:
252
41
 
253
- ## 🤖 Smart Fixes (LLM-Optimized)
42
+ - Understand the exact vulnerability type via CWE references
43
+ - Apply the correct fix using structured guidance
44
+ - Provide educational context to developers
254
45
 
255
46
  Unlike legacy plugins, we analyze the _type_ of issue and suggest the correct fix:
256
47
 
@@ -272,13 +63,8 @@ Unlike legacy plugins, we analyze the _type_ of issue and suggest the correct fi
272
63
  Fix: Introduce an abstraction layer between A and G
273
64
  ```
274
65
 
275
- ---
276
-
277
- ## 🤖 LLM & MCP Integration
278
-
279
- Optimized for **Cursor**, **GitHub Copilot**, and other AI coding tools:
280
-
281
66
  ```json
67
+ // .cursor/mcp.json
282
68
  {
283
69
  "mcpServers": {
284
70
  "eslint": {
@@ -289,26 +75,123 @@ Optimized for **Cursor**, **GitHub Copilot**, and other AI coding tools:
289
75
  }
290
76
  ```
291
77
 
78
+ By providing this structured context (CWE, OWASP, Fix), we enable AI tools to **reason** about the security flaw rather than hallucinating. This allows Copilot/Cursor to suggest the _exact_ correct fix immediately.
79
+
292
80
  ---
293
81
 
294
- ## 🔗 Related Packages
82
+ ## Rules
83
+
84
+ **Legend**
85
+
86
+ | Icon | Description |
87
+ | :--: | :----------------------------------------------------------------- |
88
+ | 💼 | **Recommended**: Included in the recommended preset. |
89
+ | ⚠️ | **Warns**: Set to warn in recommended preset. |
90
+ | 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
91
+ | 💡 | **Suggestions**: Providing code suggestions in IDE. |
92
+ | 🚫 | **Deprecated**: This rule is deprecated. |
93
+
94
+ | Rule | Pattern/Concept | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
95
+ | :------------------------------------------------------------------------------------------------------------------------- | :--------------- | :-------------------------------------------------- | :-: | :-: | :-: | :-: | :-: |
96
+ | [`no-unresolved`](https://eslint.interlace.tools/docs/import-next/rules/no-unresolved) | Static Analysis | Ensure imports resolve | 💼 | | | 💡 | |
97
+ | [`named`](https://eslint.interlace.tools/docs/import-next/rules/named) | Static Analysis | Ensure named imports exist | 💼 | | | | |
98
+ | [`default`](https://eslint.interlace.tools/docs/import-next/rules/default) | Static Analysis | Ensure default export exists | 💼 | | | | |
99
+ | [`namespace`](https://eslint.interlace.tools/docs/import-next/rules/namespace) | Static Analysis | Ensure namespace properties exist | 💼 | | | | |
100
+ | [`no-absolute-path`](https://eslint.interlace.tools/docs/import-next/rules/no-absolute-path) | Static Analysis | Forbid absolute paths | | | 🔧 | | |
101
+ | [`no-dynamic-require`](https://eslint.interlace.tools/docs/import-next/rules/no-dynamic-require) | Static Analysis | Forbid dynamic require() | | | | | |
102
+ | [`no-internal-modules`](https://eslint.interlace.tools/docs/import-next/rules/no-internal-modules) | Static Analysis | Enforce entry points only | | | | 💡 | |
103
+ | [`no-relative-packages`](https://eslint.interlace.tools/docs/import-next/rules/no-relative-packages) | Static Analysis | Use package names | | | 🔧 | | |
104
+ | [`no-relative-parent-imports`](https://eslint.interlace.tools/docs/import-next/rules/no-relative-parent-imports) | Static Analysis | Prevent `../` imports | | | | | |
105
+ | [`no-self-import`](https://eslint.interlace.tools/docs/import-next/rules/no-self-import) | Static Analysis | Prevent self-imports | 💼 | | | 💡 | |
106
+ | [`no-cycle`](https://eslint.interlace.tools/docs/import-next/rules/no-cycle) | Static Analysis | **100x faster** cycle detection | 💼 | | | 💡 | |
107
+ | [`no-useless-path-segments`](https://eslint.interlace.tools/docs/import-next/rules/no-useless-path-segments) | Static Analysis | Simplify paths | | | 🔧 | | |
108
+ | [`no-restricted-paths`](https://eslint.interlace.tools/docs/import-next/rules/no-restricted-paths) | Static Analysis | Custom path restrictions | | | | | |
109
+ | [`export`](https://eslint.interlace.tools/docs/import-next/rules/export) | Helpful Warnings | Forbid duplicate exports | 💼 | | | | |
110
+ | [`no-deprecated`](https://eslint.interlace.tools/docs/import-next/rules/no-deprecated) | Helpful Warnings | Warn on `@deprecated` imports | | | | | |
111
+ | [`no-empty-named-blocks`](https://eslint.interlace.tools/docs/import-next/rules/no-empty-named-blocks) | Helpful Warnings | Forbid empty `{}` imports | | | 🔧 | 💡 | |
112
+ | [`no-extraneous-dependencies`](https://eslint.interlace.tools/docs/import-next/rules/no-extraneous-dependencies) | Helpful Warnings | Prevent unlisted deps | 💼 | | | 💡 | |
113
+ | [`no-mutable-exports`](https://eslint.interlace.tools/docs/import-next/rules/no-mutable-exports) | Helpful Warnings | Forbid `let`/`var` exports | | | | | |
114
+ | [`no-named-as-default`](https://eslint.interlace.tools/docs/import-next/rules/no-named-as-default) | Helpful Warnings | Warn on default shadowing | 💼 | | | | |
115
+ | [`no-named-as-default-member`](https://eslint.interlace.tools/docs/import-next/rules/no-named-as-default-member) | Helpful Warnings | Warn on property access | 💼 | | | | |
116
+ | [`no-unused-modules`](https://eslint.interlace.tools/docs/import-next/rules/no-unused-modules) | Helpful Warnings | Find dead code | | | | 💡 | |
117
+ | [`no-amd`](https://eslint.interlace.tools/docs/import-next/rules/no-amd) | Module Systems | Forbid AMD require/define | | | | | |
118
+ | [`no-commonjs`](https://eslint.interlace.tools/docs/import-next/rules/no-commonjs) | Module Systems | Forbid CommonJS | | | | | |
119
+ | [`no-nodejs-modules`](https://eslint.interlace.tools/docs/import-next/rules/no-nodejs-modules) | Module Systems | Forbid Node.js builtins | | | | | |
120
+ | [`no-import-module-exports`](https://eslint.interlace.tools/docs/import-next/rules/no-import-module-exports) | Module Systems | No mixed ES/CJS | | | | | |
121
+ | [`unambiguous`](https://eslint.interlace.tools/docs/import-next/rules/unambiguous) | Module Systems | Warn on ambiguous modules | | | | | |
122
+ | [`consistent-type-specifier-style`](https://eslint.interlace.tools/docs/import-next/rules/consistent-type-specifier-style) | Style Guide | Type import style | | | 🔧 | | |
123
+ | [`dynamic-import-chunkname`](https://eslint.interlace.tools/docs/import-next/rules/dynamic-import-chunkname) | Style Guide | Require webpack chunk names | | | | 💡 | |
124
+ | [`exports-last`](https://eslint.interlace.tools/docs/import-next/rules/exports-last) | Style Guide | Exports at end of file | | | | | |
125
+ | [`extensions`](https://eslint.interlace.tools/docs/import-next/rules/extensions) | Style Guide | Enforce file extension usage | | | | | |
126
+ | [`first`](https://eslint.interlace.tools/docs/import-next/rules/first) | Style Guide | Imports must be first | | | 🔧 | | |
127
+ | [`group-exports`](https://eslint.interlace.tools/docs/import-next/rules/group-exports) | Style Guide | Group exports together | | | | | |
128
+ | [`max-dependencies`](https://eslint.interlace.tools/docs/import-next/rules/max-dependencies) | Style Guide | Limit module dependencies | | | | | |
129
+ | [`newline-after-import`](https://eslint.interlace.tools/docs/import-next/rules/newline-after-import) | Style Guide | Newline after imports | | | 🔧 | | |
130
+ | [`no-anonymous-default-export`](https://eslint.interlace.tools/docs/import-next/rules/no-anonymous-default-export) | Style Guide | Require named default exports | | | | | |
131
+ | [`no-default-export`](https://eslint.interlace.tools/docs/import-next/rules/no-default-export) | Style Guide | Forbid default exports | | | | 💡 | |
132
+ | [`no-duplicates`](https://eslint.interlace.tools/docs/import-next/rules/no-duplicates) | Style Guide | Merge duplicate imports | 💼 | | 🔧 | | |
133
+ | [`no-named-default`](https://eslint.interlace.tools/docs/import-next/rules/no-named-default) | Style Guide | Use default import syntax | | | | | |
134
+ | [`no-named-export`](https://eslint.interlace.tools/docs/import-next/rules/no-named-export) | Style Guide | Forbid named exports | | | | | |
135
+ | [`no-namespace`](https://eslint.interlace.tools/docs/import-next/rules/no-namespace) | Style Guide | Forbid `* as` imports | | | | | |
136
+ | [`no-unassigned-import`](https://eslint.interlace.tools/docs/import-next/rules/no-unassigned-import) | Style Guide | Forbid side-effect imports | | | | | |
137
+ | [`order`](https://eslint.interlace.tools/docs/import-next/rules/order) | Style Guide | Sort and group imports | 💼 | | 🔧 | | |
138
+ | [`prefer-default-export`](https://eslint.interlace.tools/docs/import-next/rules/prefer-default-export) | Style Guide | Prefer default for single exports | | | | | |
139
+ | [`no-cross-domain-imports`](https://eslint.interlace.tools/docs/import-next/rules/no-cross-domain-imports) | Architecture | Enforce clean architecture boundaries | | | | | |
140
+ | [`enforce-dependency-direction`](https://eslint.interlace.tools/docs/import-next/rules/enforce-dependency-direction) | Architecture | Enforce layered architecture (UI → Services → Data) | | | | | |
141
+ | [`prefer-node-protocol`](https://eslint.interlace.tools/docs/import-next/rules/prefer-node-protocol) | Architecture | Prefer `node:fs` over `fs` | | | | | |
142
+ | [`no-barrel-file`](https://eslint.interlace.tools/docs/import-next/rules/no-barrel-file) | Architecture | Detect barrel files that harm build performance | | | | | |
143
+ | [`no-barrel-import`](https://eslint.interlace.tools/docs/import-next/rules/no-barrel-import) | Architecture | Flag imports from barrel files | | | | | |
144
+ | [`prefer-tree-shakeable-imports`](https://eslint.interlace.tools/docs/import-next/rules/prefer-tree-shakeable-imports) | Architecture | Enforce tree-shakeable import patterns | | | | | |
145
+ | [`prefer-direct-import`](https://eslint.interlace.tools/docs/import-next/rules/prefer-direct-import) | Architecture | Suggest direct imports with autofix | | | | | |
146
+ | [`no-full-package-import`](https://eslint.interlace.tools/docs/import-next/rules/no-full-package-import) | Architecture | Block full imports from large packages | | | | | |
147
+ | [`enforce-team-boundaries`](https://eslint.interlace.tools/docs/import-next/rules/enforce-team-boundaries) | Architecture | Prevent unauthorized cross-team imports | | | | | |
148
+ | [`no-legacy-imports`](https://eslint.interlace.tools/docs/import-next/rules/no-legacy-imports) | Architecture | Detect deprecated imports with autofix | | | | | |
149
+
150
+ ## 🔄 Compatibility Matrix
151
+
152
+ | Rule | Original Plugin | Status | Notes |
153
+ | :-------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------- | :----------------------- |
154
+ | All Rules | [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import) [![npm](https://img.shields.io/npm/v/eslint-plugin-import.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-import) | ✅ Supported | Full drop-in replacement |
295
155
 
296
- Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
156
+ ---
297
157
 
298
- | Plugin | Downloads | Description | Rules |
299
- | ---------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------ | :---: |
300
- | [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-secure-coding.svg)](https://npmjs.com/package/eslint-plugin-secure-coding) | Universal security (OWASP Top 10 Web + Mobile) | 89 |
301
- | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-jwt.svg)](https://npmjs.com/package/eslint-plugin-jwt) | JWT security (algorithm confusion, weak secrets, claims) | 13 |
302
- | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-crypto.svg)](https://npmjs.com/package/eslint-plugin-crypto) | Cryptographic best practices (weak algorithms, key handling) | 24 |
303
- | [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-pg.svg)](https://npmjs.com/package/eslint-plugin-pg) | PostgreSQL/node-postgres security | 13 |
304
- | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-express-security.svg)](https://npmjs.com/package/eslint-plugin-express-security) | Express.js security (CORS, cookies, CSRF, helmet) | 8 |
305
- | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-nestjs-security.svg)](https://npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security (guards, validation pipes, throttler) | 5 |
306
- | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-lambda-security.svg)](https://npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda/Middy security (API Gateway, CORS, secrets) | 5 |
307
- | [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-browser-security.svg)](https://npmjs.com/package/eslint-plugin-browser-security) | Browser security (XSS, postMessage, storage, cookies) | 21 |
308
- | [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-vercel-ai-security.svg)](https://npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security (OWASP LLM + Agentic Top 10) | 19 |
158
+ ## ⚙️ Configuration Presets
309
159
 
310
- ---
160
+ | Preset | Description |
161
+ | :------------------ | :----------------------------------------------- |
162
+ | `recommended` | Warns on import order issues |
163
+ | `strict` | All rules set to error for production-ready code |
164
+ | `typescript` | Optimized for TypeScript projects |
165
+ | `module-resolution` | Focus on import resolution |
166
+ | `import-style` | Focus on import formatting |
167
+ | `esm` | Enforce ES Modules only |
168
+ | `architecture` | Clean architecture boundaries |
169
+ | `performance` | Bundle optimization (barrel detection) |
170
+ | `enterprise` | Team boundaries & legacy import tracking |
171
+ | `errors` | Matches eslint-plugin-import errors preset |
172
+ | `warnings` | Matches eslint-plugin-import warnings preset |
173
+
174
+ ## 🔗 Related ESLint Plugins
175
+
176
+ Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
177
+
178
+ | Plugin | Downloads | Description |
179
+ | :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------ |
180
+ | [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-secure-coding.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
181
+ | [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-pg.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
182
+ | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-crypto.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
183
+ | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-jwt.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
184
+ | [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-browser-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
185
+ | [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-vercel-ai-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security rules. |
186
+ | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-express-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
187
+ | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-lambda-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
188
+ | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-nestjs-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
189
+ | [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-import-next.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
311
190
 
312
191
  ## 📄 License
313
192
 
314
193
  MIT © [Ofri Peretz](https://github.com/ofri-peretz)
194
+
195
+ <p align="center">
196
+ <a href="https://eslint.interlace.tools/docs/import-next"><img src="https://eslint.interlace.tools/images/og-import-next.png" alt="ESLint Interlace Plugin" width="300" /></a>
197
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-import-next",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "Drop-in replacement for eslint-plugin-import. 100x faster no-cycle detection, AI-optimized fixes, zero config migration.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
1
6
  export default function foo(): string;
2
7
  export declare const bar = "baz";
package/src/files/foo.js CHANGED
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.bar = void 0;
4
9
  exports.default = foo;
@@ -1 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
1
6
  export declare const foo = "bar";
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.foo = void 0;
4
9
  exports.foo = 'bar';