🍣 A Rollup plugin to lint and fix bundled code with ESLint.
This plugin requires an Node.js v20.x, Rollup v4.x and ESLint v8.x
npm i -D rollup-plugin-eslint-bundle
// rollup.config.js ESM
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'
const root = path.dirname(url.fileURLToPath(import.meta.url))
export default {
input: path.resolve(root, './main.js'),
plugins: [
eslintBundle({
eslintOptions: {
fix: true,
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact',
}),
],
output: {
file: path.resolve(root, './dist/bundle.js'),
format: 'es',
},
}
// Rollup JavaScript API
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'
// ...
const bundle = await rollup.rollup({
input: 'main.js',
plugins: [
eslintBundle({
eslintOptions: {
fix: true,
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact',
}),
],
})
await bundle.write({
file: 'dist/bundle.js',
format: 'es',
})
await bundle.close()
Description | |
---|---|
eslintOptions |
ESLint class options object |
throwOnWarning |
boolean (Default: false )If true, will throw an error if any ESLint warnings were found. |
throwOnError |
boolean (Default: false )If true, will throw an error if any ESLint errors were found. |
formatter |
string (Default: undefined )Value to be passed to eslint.loadFormatter() |
MIT License (MIT)
If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.