Home

Awesome

ru

NPM version install size build JavaScript Style Guide npm type definitions

rollup-plugin-eslint-bundle

🍣 A Rollup plugin to lint and fix bundled code with ESLint.

Requirements

This plugin requires an Node.js v20.x, Rollup v4.x and ESLint v8.x

Install

npm i -D rollup-plugin-eslint-bundle

Usage

// 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()

Options

Description
eslintOptionsESLint class options object
throwOnWarningboolean (Default: false)<br>If true, will throw an error if any ESLint warnings were found.
throwOnErrorboolean (Default: false)<br>If true, will throw an error if any ESLint errors were found.
formatterstring (Default: undefined)<br>Value to be passed to eslint.loadFormatter()

License

MIT License (MIT)

Contributing

If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.