rollup-plugin-eslint-bundle
raw JSON → 9.0.0 verified Mon Apr 27 auth: no javascript
Rollup plugin that runs ESLint validation on the final bundled output rather than individual source files, allowing you to check and auto-fix the generated bundle. Current stable version is 9.0.0, targeting Node >=20, Rollup 4.x, and ESLint >=8.x. The plugin works as a build-time step, useful for enforcing lint rules on the bundle itself (e.g., code style, prohibited patterns). Differentiators: operates on the bundle, not sources; supports ESLint's fix mode; includes both Rollup config and JavaScript API usage. This plugin is actively maintained.
Common errors
error ERR_REQUIRE_ESM: require() of ES Module /path/to/rollup-plugin-eslint-bundle not supported ↓
cause Using require() on an ESM-only package.
fix
Switch to import { eslintBundle } from 'rollup-plugin-eslint-bundle' and ensure your project is ESM.
error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'rollup-plugin-eslint-bundle' ↓
cause Missing dependency or incorrect import path.
fix
Run npm install rollup-plugin-eslint-bundle and check the import statement.
error TypeError: eslintBundle is not a function ↓
cause Using default import instead of named import.
fix
Use import { eslintBundle } from 'rollup-plugin-eslint-bundle'.
error Error: ESLint configuration error: No configuration found ↓
cause Missing ESLint config file or overrideConfig in eslintOptions.
fix
Provide an ESLint config file (e.g., .eslintrc) or set overrideConfig in eslintOptions.
Warnings
breaking Version 9.0.0 drops support for Node <20 and requires Rollup 4.x. ↓
fix Upgrade to Node >=20 and Rollup 4.x.
breaking Version 9.0.0 switches to named export (eslintBundle). Previously used default export in v8. ↓
fix Use import { eslintBundle } from 'rollup-plugin-eslint-bundle'. Remove default import.
breaking Version 9.0.0 removes CommonJS support. Plugin is ESM-only. ↓
fix Ensure your project uses ESM (e.g., type: 'module' or .mjs extension).
deprecated ESLint v8 is the minimum peer dep. ESLint v9 may have breaking changes; check compatibility. ↓
fix Stay on ESLint 8.x until plugin explicitly supports 9.x.
Install
npm install rollup-plugin-eslint-bundle yarn add rollup-plugin-eslint-bundle pnpm add rollup-plugin-eslint-bundle Imports
- eslintBundle wrong
const eslintBundle = require('rollup-plugin-eslint-bundle')correctimport { eslintBundle } from 'rollup-plugin-eslint-bundle' - eslintBundle wrong
import eslintBundle from 'rollup-plugin-eslint-bundle'correctimport { eslintBundle } from 'rollup-plugin-eslint-bundle' - EslintBundleOptions wrong
import { EslintBundleOptions } from 'rollup-plugin-eslint-bundle'correctimport type { EslintBundleOptions } from 'rollup-plugin-eslint-bundle'
Quickstart
import { rollup } from 'rollup';
import { eslintBundle } from 'rollup-plugin-eslint-bundle';
const bundle = await rollup.rollup({
input: 'main.js',
plugins: [
eslintBundle({
eslintOptions: {
fix: true,
overrideConfig: {
rules: { 'no-console': 'error' }
}
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact'
})
]
});
await bundle.write({
file: 'dist/bundle.js',
format: 'esm'
});
await bundle.close();