esbuild-plugin-eslint

raw JSON →
0.3.12 verified Sat Apr 25 auth: no javascript

Integrates ESLint linting into esbuild bundles as a plugin. Current stable version is 0.3.12, requires Node >=18, esbuild >=0.20, and ESLint ^8 || ^9. Provides configurable options like filter, throwOnError, throwOnWarning, and fix. Ships TypeScript types and is actively maintained. Differentiators: lightweight, supports modern ESLint flat config, and works seamlessly with esbuild's onLoad hooks.

error Cannot find module 'esbuild-plugin-eslint'
cause Package not installed or symlink issue
fix
npm install esbuild-plugin-eslint eslint --save-dev
error The plugin 'eslint' must be a function
cause Using require() in ESM context
fix
Use import eslint from 'esbuild-plugin-eslint'
error TypeError: eslint is not a function
cause Incorrect import (e.g., default import syntax used with CJS module)
fix
Ensure you are using import eslint from 'esbuild-plugin-eslint' in an ESM project
breaking Dropped support for Node <18, esbuild <0.20, and eslint <8 in v0.3.0
fix Upgrade Node to >=18, esbuild to >=0.20, and eslint to ^8 || ^9.
breaking Default export changed from CommonJS to ESM in v0.3.0 – require() no longer works
fix Use import eslint from 'esbuild-plugin-eslint' instead of require().
gotcha Option 'include' deprecated in favor of 'filter' in v0.2.0
fix Rename include to filter; note that filter accepts a RegExp, not a string.
gotcha Plugin only runs on files matching the filter regex; files outside filter (e.g., .css) are not linted
fix Explicitly set filter to /.*/ to lint all files, or adjust regex to cover desired extensions.
deprecated Option 'formats' was removed; use eslint's built-in configuration for format in v0.3.0
fix Remove formats option; configure output format via ESLint's --format or formatter options.
npm install esbuild-plugin-eslint
yarn add esbuild-plugin-eslint
pnpm add esbuild-plugin-eslint

Shows minimal setup using esbuild with the eslint plugin, filtering JS/TS files and throwing on errors.

import { build } from 'esbuild';
import eslint from 'esbuild-plugin-eslint';

await build({
  entryPoints: ['src/index.js'],
  outfile: 'dist/bundle.js',
  bundle: true,
  plugins: [
    eslint({
      filter: /\.(?:jsx?|tsx?|mjs|cjs)$/,
      throwOnError: true,
      fix: true
    })
  ]
});
console.log('Build complete');