Home

Awesome

vite-plugin-eslint

npm npm peer dependency version npm peer dependency version GitHub license

ESLint plugin for vite.

Install

npm install eslint vite-plugin-eslint --save-dev
# or
yarn add eslint vite-plugin-eslint -D

Usage

import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'

export default defineConfig({
  plugins: [eslint()]
})

If you do not want the plugin to break dev, you can configure the plugin this way:

import { defineConfig } from 'vite';
import eslint from 'vite-plugin-eslint';

export default defineConfig({
  plugins: [
    { // default settings on build (i.e. fail on error)
      ...eslint(),
      apply: 'build',
    },
    { // do not fail on serve (i.e. local development)
      ...eslint({
        failOnWarning: false,
        failOnError: false,
      }),
      apply: 'serve',
      enforce: 'post'
    }
  ],
});

Options

You can pass eslint options.

cache

Decrease execution time, Beta Cache now correctly recognizes file changes, you can try it out.

fix

Auto fix source code.

eslintPath

Path to eslint instance that will be used for linting.

lintOnStart

Check all matching files on project startup, too slow, turn on discreetly.

include

A single file, or array of files, to include when linting.

exclude

A single file, or array of files, to exclude when linting.

formatter

Custom error formatter or the name of a built-in formatter.

emitWarning

The warings found will be printed.

emitError

The errors found will be printed.

failOnWarning

Will cause the module build to fail if there are any warnings, based on emitWarning.

failOnError

Will cause the module build to fail if there are any errors, based on emitError.

License

MIT