Skip to content

nikolay-borzov/rollup-plugin-eslint-bundle

Repository files navigation

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

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.

About

Rollup plugin to lint (and fix) bundled code with ESLint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published