eslint-plugin-import. Rules are grouped into four categories: static analysis, helpful warnings, module system constraints, and style.
Source: eslint-config-airbnb-base/rules/imports
Resolver configuration
The config pre-configures the import resolver for Node.js module resolution. The following file extensions are recognized:node_modules- Files matching
\.(coffee|scss|css|less|hbs|svg|json)$
Static analysis
These rules verify that imports actually resolve at lint time.import/no-unresolved — require resolvable import paths
import/no-unresolved — require resolvable import paths
import/named — require named imports to match named exports
import/named — require named imports to match named exports
import/no-absolute-path — disallow absolute paths
import/no-absolute-path — disallow absolute paths
import/no-dynamic-require — disallow dynamic require()
import/no-dynamic-require — disallow dynamic require()
require() calls (with a variable or expression as the argument) cannot be statically analyzed and make tree-shaking impossible.Helpful warnings
import/export — disallow invalid exports
import/export — disallow invalid exports
import/no-named-as-default — disallow using a named export as a default import
import/no-named-as-default — disallow using a named export as a default import
foo, importing it as the default (import foo from './module') is likely a mistake.import/no-named-as-default-member — warn when accessing default export by named export name
import/no-named-as-default-member — warn when accessing default export by named export name
import/no-extraneous-dependencies — disallow unlisted dependencies
import/no-extraneous-dependencies — disallow unlisted dependencies
dependencies or devDependencies in package.json. Dev dependencies are permitted in:- Test files (
test/**,**/__tests__/**,**/*.test.js, etc.) - Config files (
jest.config.js,webpack.config.js,rollup.config.js,.eslintrc.js, etc.)
import/no-mutable-exports — disallow mutable exports
import/no-mutable-exports — disallow mutable exports
let or var declarations allows callers to mutate the exported binding, which is almost never intentional.import/no-self-import — disallow a module importing itself
import/no-self-import — disallow a module importing itself
import/no-cycle — disallow circular dependencies
import/no-cycle — disallow circular dependencies
Module system
import/no-amd — disallow AMD-style imports
import/no-amd — disallow AMD-style imports
define() and require([]) calls are not allowed. Use ES module syntax instead.import/no-import-module-exports — disallow mixing import and module.exports
import/no-import-module-exports — disallow mixing import and module.exports
import statements alongside CommonJS module.exports in the same file is not allowed. Choose one module system per file.Style
import/first — imports must come before other statements
import/first — imports must come before other statements
import statements must appear at the top of the file, before any other code.import/no-duplicates — disallow duplicate imports
import/no-duplicates — disallow duplicate imports
import/extensions — omit file extensions for JS files
import/extensions — omit file extensions for JS files
ignorePackages)File extensions for .js, .mjs, and .jsx files must be omitted from import paths. Extensions for other file types (e.g., .json, .png) are still required.import/order — enforce import grouping order
import/order — enforce import grouping order
import/newline-after-import — blank line after import block
import/newline-after-import — blank line after import block
import or require statement in the import block.import/prefer-default-export — prefer default export when only one export
import/prefer-default-export — prefer default export when only one export
import/no-named-default — disallow default imports using named export syntax
import/no-named-default — disallow default imports using named export syntax
import/no-webpack-loader-syntax — disallow Webpack loader syntax in imports
import/no-webpack-loader-syntax — disallow Webpack loader syntax in imports
import foo from 'loader!./file') couples source code to the build tool configuration.import/no-useless-path-segments — disallow unnecessary path segments
import/no-useless-path-segments — disallow unnecessary path segments
./ or ../ that do not change the resolved path must be removed.import/no-relative-packages — disallow relative imports of other packages
import/no-relative-packages — disallow relative imports of other packages