rollup-plugin-eslint-bundle

9.0.0 • Public • Published

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.

Package Sidebar

Install

npm i rollup-plugin-eslint-bundle

Weekly Downloads

41

Version

9.0.0

License

MIT

Unpacked Size

18 kB

Total Files

7

Last publish

Collaborators

  • nikolay-borzov