A webpack plugin that integrates ESLint into the build process to lint JavaScript code with extensive configuration options, caching, and multi-threading support.
npx @tessl/cli install tessl/npm-eslint-webpack-plugin@5.0.0ESLint Webpack Plugin integrates ESLint into the Webpack build process to automatically lint JavaScript code during compilation. It provides comprehensive linting capabilities with advanced features including caching, multi-threading support, custom formatters, and flexible error/warning handling.
npm install eslint-webpack-plugin --save-devconst ESLintPlugin = require('eslint-webpack-plugin');ESM import:
import ESLintPlugin from 'eslint-webpack-plugin';TypeScript:
import ESLintPlugin from 'eslint-webpack-plugin';const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = {
// ... other webpack configuration
plugins: [
new ESLintPlugin({
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
fix: true,
}),
],
};ESLint Webpack Plugin is built around several key components:
ESLintWebpackPlugin class that implements the webpack plugin interfaceMain plugin class that integrates ESLint into the webpack build process with extensive configuration options and performance optimizations. This is the default export of the package.
export = ESLintWebpackPlugin;
declare class ESLintWebpackPlugin {
constructor(options?: Options);
key: string;
options: PluginOptions;
apply(compiler: Compiler): void;
run(
compiler: Compiler,
options: Omit<Options, 'resourceQueryExclude'> & {
resourceQueryExclude: RegExp[];
},
wanted: string[],
exclude: string[]
): Promise<void>;
getContext(compiler: Compiler): string;
}
type Compiler = import('webpack').Compiler;Comprehensive configuration system supporting both plugin-specific options and all ESLint options with intelligent defaults and validation.
interface Options extends PluginOptions, ESLintOptions {}
interface PluginOptions {
context?: string;
emitError?: boolean;
emitWarning?: boolean;
eslintPath?: string;
exclude?: string | string[];
extensions?: string | string[];
failOnError?: boolean;
failOnWarning?: boolean;
files?: string | string[];
fix?: boolean;
formatter?: string | FormatterFunction;
lintDirtyModulesOnly?: boolean;
quiet?: boolean;
outputReport?: OutputReport;
threads?: number | boolean;
resourceQueryExclude?: RegExp | RegExp[];
configType?: string;
}interface OutputReport {
filePath?: string;
formatter?: string | FormatterFunction;
}
type FormatterFunction = (results: LintResult[]) => string;
type ESLintOptions = import('eslint').ESLint.Options;
type LintResult = import('eslint').ESLint.LintResult;