Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
eslint-import-resolver-webpack
Advanced tools
Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.
The eslint-import-resolver-webpack package is an ESLint plugin that allows you to use Webpack's module resolution in your ESLint configuration. This is particularly useful for projects that use Webpack aliases or custom module resolution paths, ensuring that ESLint can correctly resolve and lint your imports.
Webpack Configuration Integration
This feature allows you to specify a Webpack configuration file in your ESLint settings. ESLint will use this configuration to resolve modules, ensuring that your import statements are correctly validated.
{"settings":{"import/resolver":{"webpack":{"config":"webpack.config.js"}}}}
Custom Webpack Configuration
You can also provide a custom Webpack configuration directly within the ESLint settings. This is useful if you have a simple configuration or want to override specific settings for ESLint.
{"settings":{"import/resolver":{"webpack":{"config":{"resolve":{"alias":{"@components":"./src/components"}}}}}}}
Multiple Webpack Configurations
This feature allows you to specify multiple Webpack configuration files. ESLint will try to resolve modules using each configuration in the order they are provided.
{"settings":{"import/resolver":{"webpack":{"config":["webpack.config.dev.js","webpack.config.prod.js"]}}}}
The eslint-import-resolver-alias package allows you to define custom path aliases for module resolution in ESLint. Unlike eslint-import-resolver-webpack, it does not rely on a Webpack configuration file but instead uses a simpler alias configuration directly in the ESLint settings.
The eslint-import-resolver-node package is a simple resolver for Node.js-style module resolution. It does not support Webpack-specific features like aliases or custom module resolution paths, making it less flexible than eslint-import-resolver-webpack for projects that use Webpack.
The eslint-import-resolver-typescript package is designed for projects using TypeScript. It allows ESLint to resolve modules based on the TypeScript configuration file (tsconfig.json). This package is more suitable for TypeScript projects compared to eslint-import-resolver-webpack, which is more general-purpose.
Webpack-literate module resolution plugin for eslint-plugin-import
.
:boom: Only "synchronous" Webpack configs are supported at the moment. If your config returns a
Promise
, this will cause problems. Consider splitting your asynchronous configuration to a separate config.
Published separately to allow pegging to a specific version in case of breaking changes.
To use with eslint-plugin-import
, run:
npm i eslint-import-resolver-webpack -g
or if you manage ESLint as a dev dependency:
# inside your project's working tree
npm install eslint-import-resolver-webpack --save-dev
Will look for webpack.config.js
as a sibling of the first ancestral package.json
,
or a config
parameter may be provided with another filename/path either relative to the
package.json
, or a complete, absolute path.
If multiple webpack configurations are found the first configuration containing a resolve section will be used. Optionally, the config-index
(zero-based) setting can be used to select a specific configuration.
---
settings:
import/resolver: webpack # take all defaults
or with explicit config file name:
---
settings:
import/resolver:
webpack:
config: 'webpack.dev.config.js'
or with explicit config file index:
---
settings:
import/resolver:
webpack:
config: 'webpack.multiple.config.js'
config-index: 1 # take the config at index 1
or with explicit config file path relative to your projects's working directory:
---
settings:
import/resolver:
webpack:
config: './configs/webpack.dev.config.js'
or with explicit config object:
---
settings:
import/resolver:
webpack:
config:
resolve:
extensions:
- .js
- .jsx
If your config relies on environment variables, they can be specified using the env
parameter. If your config is a function, it will be invoked with the value assigned to env
:
---
settings:
import/resolver:
webpack:
config: 'webpack.config.js'
env:
NODE_ENV: 'local'
production: true
If your config is set as a function, it will be evaluated at every resolution. You have an option to prevent this by caching it using the cache
parameter:
---
settings:
import/resolver:
webpack:
config: 'webpack.config.js'
cache: true
Get supported eslint-import-resolver-webpack with the Tidelift Subscription
FAQs
Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.
We found that eslint-import-resolver-webpack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.