[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names. All the goodness that the ES2015+ static module syntax intends to provide, marked up in your editor.
IF YOU ARE USING THIS WITH SUBLIME: see the bottom section for important info.
💼 Configurations enabled in.\
⚠️ Configurations set to warn in.\
🚫 Configurations disabled in.\
❗ Set in the errors configuration.\
☑️ Set in the recommended configuration.\
⌨️ Set in the typescript configuration.\
🚸 Set in the warnings configuration.\
🔧 Automatically fixable by the --fix CLI option.\
💡 Manually fixable by editor suggestions.\
❌ Deprecated.
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
|---|---|---|---|---|---|---|---|
| export | Forbid any invalid exports, i.e. re-export of the same name. | ❗ ☑️ | |||||
| no-deprecated | Forbid imported names marked with @deprecated documentation tag. |
||||||
| no-empty-named-blocks | Forbid empty named import blocks. | 🔧 | 💡 | ||||
| no-extraneous-dependencies | Forbid the use of extraneous packages. | ||||||
| no-mutable-exports | Forbid the use of mutable exports with var or let. |
||||||
| no-named-as-default | Forbid use of exported name as identifier of default export. | ☑️ 🚸 | |||||
| no-named-as-default-member | Forbid use of exported name as property of default export. | ☑️ 🚸 | |||||
| no-unused-modules | Forbid modules without exports, or exports without matching import in another module. |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
|---|---|---|---|---|---|---|---|
| no-amd | Forbid AMD require and define calls. |
||||||
| no-commonjs | Forbid CommonJS require calls and module.exports or exports.*. |
||||||
| no-import-module-exports | Forbid import statements with CommonJS module.exports. | 🔧 | |||||
| no-nodejs-modules | Forbid Node.js builtin modules. | ||||||
| unambiguous | Forbid potentially ambiguous parse goal (script vs. module). |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
|---|---|---|---|---|---|---|---|
| default | Ensure a default export is present, given a default import. | ❗ ☑️ | |||||
| enforce-node-protocol-usage | Enforce either using, or omitting, the node: protocol when importing Node.js builtin modules. |
🔧 | |||||
| named | Ensure named imports correspond to a named export in the remote file. | ❗ ☑️ | ⌨️ | ||||
| namespace | Ensure imported namespaces contain dereferenced properties as they are dereferenced. | ❗ ☑️ | |||||
| no-absolute-path | Forbid import of modules using absolute paths. | 🔧 | |||||
| no-cycle | Forbid a module from importing a module with a dependency path back to itself. | ||||||
| no-dynamic-require | Forbid require() calls with expressions. |
||||||
| no-internal-modules | Forbid importing the submodules of other modules. | ||||||
| no-relative-packages | Forbid importing packages through relative paths. | 🔧 | |||||
| no-relative-parent-imports | Forbid importing modules from parent directories. | ||||||
| no-restricted-paths | Enforce which files can be imported in a given folder. | ||||||
| no-self-import | Forbid a module from importing itself. | ||||||
| no-unresolved | Ensure imports point to a file/module that can be resolved. | ❗ ☑️ | |||||
| no-useless-path-segments | Forbid unnecessary path segments in import and require statements. | 🔧 | |||||
| no-webpack-loader-syntax | Forbid webpack loader syntax in imports. |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
|---|---|---|---|---|---|---|---|
| consistent-type-specifier-style | Enforce or ban the use of inline type-only markers for named imports. | 🔧 | |||||
| dynamic-import-chunkname | Enforce a leading comment with the webpackChunkName for dynamic imports. | 💡 | |||||
| exports-last | Ensure all exports appear after other statements. | ||||||
| extensions | Ensure consistent use of file extension within the import path. | ||||||
| first | Ensure all imports appear before other statements. | 🔧 | |||||
| group-exports | Prefer named exports to be grouped together in a single export declaration | ||||||
| imports-first | Replaced by import/first. |
🔧 | ❌ | ||||
| max-dependencies | Enforce the maximum number of dependencies a module can have. | ||||||
| newline-after-import | Enforce a newline after import statements. | 🔧 | |||||
| no-anonymous-default-export | Forbid anonymous values as default exports. | ||||||
| no-default-export | Forbid default exports. | ||||||
| no-duplicates | Forbid repeated import of the same module in multiple places. | ☑️ 🚸 | 🔧 | ||||
| no-named-default | Forbid named default exports. | ||||||
| no-named-export | Forbid named exports. | ||||||
| no-namespace | Forbid namespace (a.k.a. "wildcard" *) imports. |
🔧 | |||||
| no-unassigned-import | Forbid unassigned imports | ||||||
| order | Enforce a convention in module import order. | 🔧 | |||||
| prefer-default-export | Prefer a default export if module exports a single name or multiple names. |
eslint-plugin-import for enterpriseAvailable as part of the Tidelift Subscription.
The maintainers of eslint-plugin-import and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
# inside your project's working tree
npm install eslint-plugin-import --save-dev
.eslintrc)All rules are off by default. However, you may extend one of the preset configs, or configure them manually in your .eslintrc.(yml|json|js).
{
"extends": [
"eslint:recommended",
"plugin:import/recommended",
],
}
{
"rules": {
"import/no-unresolved": ["error", { "commonjs": true, "amd": true }],
"import/named": "error",
"import/namespace": "error",
"import/default": "error",
"import/export": "error",
// etc...
},
},
eslint.config.js)All rules are off by default. However, you may configure them manually in your eslint.config.(js|cjs|mjs), or extend one of the preset configs:
```js import importPlugin from 'eslint-plugin-import'; import js from '@eslint/js';
export default [ js.configs.recommended, importPlugin.flatConfigs.recommended, { files: ['*/.{js,mjs,cjs}'], languageOptions: {
$ claude mcp add eslint-plugin-import \
-- python -m otcore.mcp_server <graph>