eslint/rules/imports
Imports (eslint-plugin-import-x): module boundaries, declared dependencies, cycles, order. import-x/no-cycle is the costliest rule of the block: it follows every import.
48 rules, 27 on. Source: lint/eslint/rules/imports.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
import-x/consistent-type-specifier-style | error, "prefer-top-level" | JS + TS | Enforce or ban the use of inline type-only markers for named imports. | import type { A } on its own line, like consistent-type-imports. |
import-x/default | off | JS + TS | Ensure a default export is present, given a default import. | Off: TypeScript checks it. |
import-x/dynamic-import-chunkname | off | JS + TS | Enforce a leading comment with the webpackChunkName for dynamic imports. | Off: webpack only (builds use esbuild). |
import-x/export | error | JS + TS | Forbid any invalid exports, i.e. re-export of the same name. | — |
import-x/exports-last | off | JS + TS | Ensure all exports appear after other statements. | Off: non-standard. |
import-x/extensions | error, ["never",{"ignorePackages":true,"checkTypeImports":true}] | JS + TS | Ensure consistent use of file extension within the import path. | Custom: no extension in relative imports (./format-count): the bundler resolves it. |
import-x/first | error | JS + TS | Ensure all imports appear before other statements. | — |
import-x/group-exports | off | JS + TS | Prefer named exports to be grouped together in a single export declaration. | Off: non-standard. |
import-x/imports-first | off | JS + TS | Replaced by import-x/first. | Deprecated: replaced by import-x/first. |
import-x/max-dependencies | off | JS + TS | Enforce the maximum number of dependencies a module can have. | Custom: a single-function file with many imports should be split. Off: an index.ts re-exports a whole folder; max-lines already bounds the size of a file. |
import-x/named | off | JS + TS | Ensure named imports correspond to a named export in the remote file. | Off: TypeScript checks it. |
import-x/namespace | off | JS + TS | Ensure imported namespaces contain dereferenced properties as they are dereferenced. | Off: TypeScript checks it. |
import-x/newline-after-import | error | JS + TS | Enforce a newline after import statements. | — |
import-x/no-absolute-path | error | JS + TS | Forbid import of modules using absolute paths. | — |
import-x/no-amd | warn | JS + TS | Forbid AMD require and define calls. | — |
import-x/no-anonymous-default-export | warn | JS + TS | Forbid anonymous values as default exports. | — |
import-x/no-commonjs | warn | JS + TS | Forbid CommonJS require calls and module.exports or exports.*. | — |
import-x/no-cycle | error | JS + TS | Forbid a module from importing a module with a dependency path back to itself. | — |
import-x/no-default-export | warn | JS + TS | Forbid default exports. | Named exports only; tool configs are the exception. |
import-x/no-deprecated | off | JS + TS | Forbid imported names marked with @deprecated documentation tag. | Off: duplicate of @typescript-eslint/no-deprecated. |
import-x/no-duplicates | error | JS + TS | Forbid repeated import of the same module in multiple places. | — |
import-x/no-dynamic-require | warn | JS + TS | Forbid require() calls with expressions. | — |
import-x/no-empty-named-blocks | error | JS + TS | Forbid empty named import blocks. | — |
import-x/no-extraneous-dependencies | error, {"devDependencies":false,"optionalDependencies":false,"pe… | JS + TS | Forbid the use of extraneous packages. | Custom: no devDependency by default; rules/node allows them in tools, rules/browser in the specs and stories. |
import-x/no-import-module-exports | error | JS + TS | Forbid import statements with CommonJS module.exports. | — |
import-x/no-internal-modules | off | JS + TS | Forbid importing the submodules of other modules. | Off: would flag every nested relative path (./components/button/button.component). |
import-x/no-mutable-exports | warn | JS + TS | Forbid the use of mutable exports with var or let. | — |
import-x/no-named-as-default | off | JS + TS | Forbid use of exported name as identifier of default export. | Off: default exports are forbidden (no-default-export). |
import-x/no-named-as-default-member | off | JS + TS | Forbid use of exported name as property of default export. | Off: TypeScript checks it. |
import-x/no-named-default | warn | JS + TS | Forbid named default exports. | — |
import-x/no-named-export | off | JS + TS | Forbid named exports. | Off: contradicts no-default-export. |
import-x/no-namespace | error | JS + TS | Forbid namespace (a.k.a. "wildcard" *) imports. | — |
import-x/no-nodejs-modules | warn | JS + TS | Forbid Node.js builtin modules. | Browser code; tool configs are the exception. |
import-x/no-relative-packages | error | JS + TS | Forbid importing packages through relative paths. | — |
import-x/no-relative-parent-imports | off | JS + TS | Forbid importing modules from parent directories. | Off: modules import shared code from parent folders. |
import-x/no-rename-default | off | JS + TS | Forbid importing a default export by a different name. | Off: default exports are forbidden (no-default-export). |
import-x/no-restricted-paths | off | JS + TS | Enforce which files can be imported in a given folder. | Off: a single package, no module boundary to enforce. |
import-x/no-self-import | error | JS + TS | Forbid a module from importing itself. | — |
import-x/no-unassigned-import | warn | JS + TS | Forbid unassigned imports. | — |
import-x/no-unresolved | off | JS + TS | Ensure imports point to a file/module that can be resolved. | Off: TypeScript checks it. |
import-x/no-unused-modules | off | JS + TS | Forbid modules without exports, or exports without matching import in another module. | Off: a no-op on ESLint 10 (no FileEnumerator API); knip reports unused files and exports instead. |
import-x/no-useless-path-segments | error | JS + TS | Forbid unnecessary path segments in import and require statements. | — |
import-x/no-webpack-loader-syntax | error | JS + TS | Forbid webpack loader syntax in imports. | — |
local/import-folders | error, {"mode":"require"} | JS + TS | Require imports through the index of a folder, and simplify the paths an index allows. | Custom: a relative import names a neighbour file or a folder (its index.ts), never a file of another folder. |
import-x/order | error, {"groups":["builtin","external","internal","parent","sibl… | JS + TS | Enforce a convention in module import order. | Custom: packages first, relative files last (import type included), never sorted alphabetically. |
import-x/prefer-default-export | off | JS + TS | Prefer a default export if module exports a single name or multiple names. | Off: contradicts no-default-export. |
import-x/prefer-namespace-import | off | JS + TS | Enforce using namespace imports for specific modules, like react/react-dom, etc. | Off: needs a per-library list. |
import-x/unambiguous | off | JS + TS | Forbid potentially ambiguous parse goal (script vs. module). | Off: every file is parsed as a module; it would flag a spec that imports nothing. |