MCPcopy Index your code
hub / github.com/import-js/eslint-plugin-import

github.com/import-js/eslint-plugin-import @v2.32.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.32.0 ↗
643 symbols 1,901 edges 532 files 79 documented · 12% 345 cross-repo links
README

eslint-plugin-import

[![github actions][actions-image]][actions-url] travis-ci [![coverage][codecov-image]][codecov-url] win32 build status npm npm downloads

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.

Rules

💼 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.

Helpful warnings

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.

Module systems

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).

Static analysis

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.

Style guide

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 enterprise

Available 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.

Installation

# inside your project's working tree
npm install eslint-plugin-import --save-dev

Config - Legacy (.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).

  • Extending a preset config:
{
  "extends": [
     "eslint:recommended",
     "plugin:import/recommended",
  ],
}
  • Configuring manually:
{
  "rules": {
    "import/no-unresolved": ["error", { "commonjs": true, "amd": true }],
    "import/named": "error",
    "import/namespace": "error",
    "import/default": "error",
    "import/export": "error",
    // etc...
  },
},

Config - Flat (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: {

Extension points exported contracts — how you extend this code

Foo (Interface)
(no doc)
tests/files/typescript-export-assign-namespace-merged.d.ts
foo (Interface)
(no doc)
tests/files/typescript-declare-interface.d.ts
Foo (Interface)
(no doc)
tests/files/typescript-declare.d.ts
NotExported (Interface)
(no doc)
tests/files/typescript-declare.d.ts
Foo (Interface)
(no doc)
tests/files/typescript.ts

Core symbols most depended-on inside this repo

testFilePath
called by 342
tests/src/utils.js
forEach
called by 146
src/exportMap/index.js
withoutAutofixOutput
called by 132
tests/src/rule-tester.js
run
called by 131
tests/src/rule-tester.js
resolve
called by 120
utils/resolve.js
has
called by 95
src/exportMap/index.js
get
called by 83
src/exportMap/index.js
resolve
called by 83
src/exportMap/remotePath.js

Shape

Function 513
Class 52
Method 50
Interface 20
Enum 8

Languages

TypeScript100%

Modules by API surface

src/rules/order.js52 symbols
src/rules/no-unused-modules.js28 symbols
src/core/importType.js18 symbols
src/rules/no-extraneous-dependencies.js16 symbols
src/rules/no-restricted-paths.js15 symbols
src/rules/no-duplicates.js15 symbols
src/rules/newline-after-import.js15 symbols
src/rules/export.js11 symbols
utils/resolve.js10 symbols
tests/src/utils.js10 symbols
src/rules/no-commonjs.js10 symbols
src/rules/enforce-node-protocol-usage.js10 symbols

Dependencies from manifests, versioned

@angular-eslint/template-parser13.5.0 · 1×
@arethetypeswrong/cli0.18.2 · 1×
@eslint/import-test-order-redirect-scopedfile:./tests/files/o · 1×
@eslint/js9.5.0 · 1×
@ljharb/tsconfig0.3.2 · 1×
@org/package1.0.0 · 1×
@rtsao/scc1.1.0 · 1×
@test-scope/some-modulefile:./tests/files/s · 1×
@types/debug4.1.12 · 1×
@types/eslint8.56.12 · 1×
@types/node20.19.1 · 1×
@typescript-eslint/parser2.23.0 || ^3.3.0 || · 1×

For agents

$ claude mcp add eslint-plugin-import \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact