lint-webpack-plugin

raw JSON →
0.1.1 verified Fri May 01 auth: no javascript abandoned

A webpack plugin that runs custom lint shell commands before or during webpack build/watch. Version 0.1.1 is the latest release (no recent updates). It integrates with webpack's build and watch modes: during build, errors halt the webpack process; during watch, errors are ignored and the process continues. Simpler than alternatives like webpack-shell-plugin, but limited to running shell commands without advanced lifecycle hooks.

error TypeError: LintPlugin is not a constructor
cause Incorrect import: using ESM import syntax with a CommonJS module.
fix
Use const LintPlugin = require('lint-webpack-plugin'); instead of import.
error Error: spawn ENOENT
cause The shell command specified does not exist in PATH.
fix
Ensure the linting tool (e.g., eslint) is installed locally or globally and available in PATH.
error Module not found: Error: Can't resolve 'lint-webpack-plugin'
cause Plugin not installed in the project.
fix
Run npm install --save-dev lint-webpack-plugin.
breaking Empty array input causes plugin to run no commands but still attaches hooks, potentially causing no-op builds.
fix Pass at least one command or omit the plugin entirely.
deprecated Package has not been updated since 2018 and has no ESM support. Webpack 5 may have compatibility issues.
fix Consider using webpack-shell-plugin or a modern alternative.
gotcha Command failures during watch mode are silently ignored; errors in lint might not be noticed by the developer.
fix Add explicit console logging or use a plugin that supports error reporting.
gotcha The plugin runs commands via child_process.exec() which can be a security risk if commands include user input.
fix Sanitize command strings, especially if they contain data from external sources.
npm install lint-webpack-plugin
yarn add lint-webpack-plugin
pnpm add lint-webpack-plugin

Shows how to set up lint-webpack-plugin in a webpack config to run ESLint and Prettier checks.

const path = require('path');
const webpack = require('webpack');
const LintPlugin = require('lint-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  plugins: [
    new LintPlugin([
      'eslint --ext .js,.jsx src/',
      'prettier --check "src/**/*.js"'
    ])
  ]
};