ESLint Config Webpack
raw JSON → 4.9.5 verified Sat Apr 25 auth: no javascript
Webpack's official ESLint configuration as a shareable config for projects using ESLint 9+ flat config. Version 4.9.5 requires Node >=20.9.0, ESLint >=9.28.0, and TypeScript >=4.8.4 <7.0.0. It provides TypeScript support, regexp rules, and JSDoc type formatting. Actively maintained by the Webpack team with frequent updates. Unlike generic configs like eslint-config-airbnb, it is tailored for webpack ecosystem projects.
Common errors
error Cannot find module 'eslint-config-webpack' ↓
cause Package not installed or used in legacy ESLint config file (e.g., .eslintrc)
fix
Run 'npm i -D eslint-config-webpack' and use import in eslint.config.js flat config.
error ESLint: Failed to load config "webpack" to extend from ↓
cause Using string 'webpack' in extends instead of imported config object
fix
Import the config and use extends: [config] instead of extends: ['webpack'].
error require() of ES Module /path/to/node_modules/eslint-config-webpack/index.js from ... not supported ↓
cause Using CommonJS require() for an ESM-only package
fix
Use import() or set "type": "module" in your package.json.
Warnings
breaking v4.x introduced flat config (eslint.config.js) and dropped support for legacy .eslintrc files ↓
fix Migrate to eslint.config.js using extends with the provided config object.
breaking Requires Node >=20.9.0 ↓
fix Upgrade Node to v20.9.0 or later.
breaking Requires ESLint >=9.28.0 ↓
fix Upgrade ESLint to v9.28.0 or later.
deprecated TypeScript peer dependency: ^4.8.4 || ^5.0.0 || ^6.0.0 (future) but actual releases may enforce <7.0.0 ↓
fix Install TypeScript matching the peer range; v4.8.4+ or v5.x is supported.
gotcha The default export is a flat config object, not an array. Using it directly without extending may cause linting issues if you need multiple configs. ↓
fix Wrap it in defineConfig or spread into an array when using multiple config objects.
gotcha The package does not include react preset by default; you may need to install additional plugins (e.g., eslint-plugin-react) if using React. ↓
fix Install react-related plugins and add them to your config manually.
Install
npm install eslint-config-webpack yarn add eslint-config-webpack pnpm add eslint-config-webpack Imports
- default wrong
const config = require('eslint-config-webpack');correctimport config from 'eslint-config-webpack'; - defineConfig
import { defineConfig } from 'eslint/config';
Quickstart
// eslint.config.js
import { defineConfig } from 'eslint/config';
import config from 'eslint-config-webpack';
import globals from 'globals';
export default defineConfig([
{
extends: [config],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
},
]);