eslint-import-resolver-webpack
raw JSON → 0.13.11 verified Sat Apr 25 auth: no javascript maintenance
Webpack-aware module resolution plugin for eslint-plugin-import, version 0.13.11. Resolves import paths using a webpack configuration (webpack.config.js by default) to support custom resolve aliases, extensions, and modules. Released as part of the eslint-plugin-import ecosystem. Stable but limited to synchronous configs; async configs will break. Supports config file path, index, inline object, environment variables, and caching. Last major release in 2019; no active development, but still functional with webpack >=1.11.0 and eslint-plugin-import >=1.4.0.
Common errors
error Error: No webpack configuration found in ... ↓
cause Resolver cannot locate webpack.config.js in the project root or specified path.
fix
Ensure webpack.config.js exists or provide an absolute path via the 'config' setting.
error Cannot read property 'resolve' of undefined ↓
cause Webpack config function returns undefined or doesn't export an object with 'resolve'.
fix
Check that webpack config exports a valid configuration object with a 'resolve' section.
error TypeError: webpackConfig is not a function ↓
cause Config setting is a function, but the resolver expects an object (if env not provided).
fix
Provide an 'env' setting to invoke the function, or use an object config.
Warnings
breaking Synchronous Webpack configs only; async configs cause resolution failures. ↓
fix Split async parts into a separate config file or use a synchronous wrapper.
deprecated Package is in maintenance mode with no active development; may not support future ESLint or Webpack versions. ↓
fix Consider migrating to eslint-import-resolver-alias or custom resolver if issues arise.
gotcha Multiple webpack configurations: only first config with 'resolve' section is used by default; use 'configIndex' for selection. ↓
fix Specify config-index in settings to pick the desired config.
gotcha Environment variables must be passed via the 'env' setting; process.env values are not inherited. ↓
fix Set env parameter in resolver config to pass required env vars.
Install
npm install eslint-import-resolver-webpack yarn add eslint-import-resolver-webpack pnpm add eslint-import-resolver-webpack Imports
- default wrong
const resolver = require('eslint-import-resolver-webpack')correctimport resolver from 'eslint-import-resolver-webpack' - createResolver wrong
const { createResolver } = require('eslint-import-resolver-webpack')correctimport { createResolver } from 'eslint-import-resolver-webpack' - ResolverConfig wrong
import { ResolverConfig } from 'eslint-import-resolver-webpack'correctimport type { ResolverConfig } from 'eslint-import-resolver-webpack'
Quickstart
// .eslintrc.js
module.exports = {
settings: {
'import/resolver': {
webpack: {
config: './webpack.config.js',
configIndex: 0,
env: {
NODE_ENV: 'development'
},
cache: true
}
}
},
rules: {
'import/no-unresolved': 'error'
}
};