Skip to content

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.

RuleSettingFilesWhat it checksWhy
import-x/consistent-type-specifier-styleerror, "prefer-top-level"JS + TSEnforce 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/defaultoffJS + TSEnsure a default export is present, given a default import.Off: TypeScript checks it.
import-x/dynamic-import-chunknameoffJS + TSEnforce a leading comment with the webpackChunkName for dynamic imports.Off: webpack only (builds use esbuild).
import-x/exporterrorJS + TSForbid any invalid exports, i.e. re-export of the same name.—
import-x/exports-lastoffJS + TSEnsure all exports appear after other statements.Off: non-standard.
import-x/extensionserror, ["never",{"ignorePackages":true,"checkTypeImports":true}]JS + TSEnsure consistent use of file extension within the import path.Custom: no extension in relative imports (./format-count): the bundler resolves it.
import-x/firsterrorJS + TSEnsure all imports appear before other statements.—
import-x/group-exportsoffJS + TSPrefer named exports to be grouped together in a single export declaration.Off: non-standard.
import-x/imports-firstoffJS + TSReplaced by import-x/first.Deprecated: replaced by import-x/first.
import-x/max-dependenciesoffJS + TSEnforce 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/namedoffJS + TSEnsure named imports correspond to a named export in the remote file.Off: TypeScript checks it.
import-x/namespaceoffJS + TSEnsure imported namespaces contain dereferenced properties as they are dereferenced.Off: TypeScript checks it.
import-x/newline-after-importerrorJS + TSEnforce a newline after import statements.—
import-x/no-absolute-patherrorJS + TSForbid import of modules using absolute paths.—
import-x/no-amdwarnJS + TSForbid AMD require and define calls.—
import-x/no-anonymous-default-exportwarnJS + TSForbid anonymous values as default exports.—
import-x/no-commonjswarnJS + TSForbid CommonJS require calls and module.exports or exports.*.—
import-x/no-cycleerrorJS + TSForbid a module from importing a module with a dependency path back to itself.—
import-x/no-default-exportwarnJS + TSForbid default exports.Named exports only; tool configs are the exception.
import-x/no-deprecatedoffJS + TSForbid imported names marked with @deprecated documentation tag.Off: duplicate of @typescript-eslint/no-deprecated.
import-x/no-duplicateserrorJS + TSForbid repeated import of the same module in multiple places.—
import-x/no-dynamic-requirewarnJS + TSForbid require() calls with expressions.—
import-x/no-empty-named-blockserrorJS + TSForbid empty named import blocks.—
import-x/no-extraneous-dependencieserror, {"devDependencies":false,"optionalDependencies":false,"pe…JS + TSForbid 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-exportserrorJS + TSForbid import statements with CommonJS module.exports.—
import-x/no-internal-modulesoffJS + TSForbid importing the submodules of other modules.Off: would flag every nested relative path (./components/button/button.component).
import-x/no-mutable-exportswarnJS + TSForbid the use of mutable exports with var or let.—
import-x/no-named-as-defaultoffJS + TSForbid use of exported name as identifier of default export.Off: default exports are forbidden (no-default-export).
import-x/no-named-as-default-memberoffJS + TSForbid use of exported name as property of default export.Off: TypeScript checks it.
import-x/no-named-defaultwarnJS + TSForbid named default exports.—
import-x/no-named-exportoffJS + TSForbid named exports.Off: contradicts no-default-export.
import-x/no-namespaceerrorJS + TSForbid namespace (a.k.a. "wildcard" *) imports.—
import-x/no-nodejs-moduleswarnJS + TSForbid Node.js builtin modules.Browser code; tool configs are the exception.
import-x/no-relative-packageserrorJS + TSForbid importing packages through relative paths.—
import-x/no-relative-parent-importsoffJS + TSForbid importing modules from parent directories.Off: modules import shared code from parent folders.
import-x/no-rename-defaultoffJS + TSForbid importing a default export by a different name.Off: default exports are forbidden (no-default-export).
import-x/no-restricted-pathsoffJS + TSEnforce which files can be imported in a given folder.Off: a single package, no module boundary to enforce.
import-x/no-self-importerrorJS + TSForbid a module from importing itself.—
import-x/no-unassigned-importwarnJS + TSForbid unassigned imports.—
import-x/no-unresolvedoffJS + TSEnsure imports point to a file/module that can be resolved.Off: TypeScript checks it.
import-x/no-unused-modulesoffJS + TSForbid 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-segmentserrorJS + TSForbid unnecessary path segments in import and require statements.—
import-x/no-webpack-loader-syntaxerrorJS + TSForbid webpack loader syntax in imports.—
local/import-folderserror, {"mode":"require"}JS + TSRequire 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/ordererror, {"groups":["builtin","external","internal","parent","sibl…JS + TSEnforce a convention in module import order.Custom: packages first, relative files last (import type included), never sorted alphabetically.
import-x/prefer-default-exportoffJS + TSPrefer a default export if module exports a single name or multiple names.Off: contradicts no-default-export.
import-x/prefer-namespace-importoffJS + TSEnforce using namespace imports for specific modules, like react/react-dom, etc.Off: needs a per-library list.
import-x/unambiguousoffJS + TSForbid potentially ambiguous parse goal (script vs. module).Off: every file is parsed as a module; it would flag a spec that imports nothing.

Generated from the JSDoc of the sources.