Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
/ vite-eslint Public archive

Vite 2 plugin that works with the dev server and rollup build.

License

Notifications You must be signed in to change notification settings

ehutch79/vite-eslint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-eslint

Vite 2 plugin that works with the dev server and rollup build.

Any errors from eslint should appear in the Vite overlay.

Warning

You probably don't need this plugin. But I'm leaving it as an example, as it does use the up to date api.

You probably want to use something like this in your vite config:

import eslint from '@rollup/plugin-eslint';


...SNIPPED
    {
        ...eslint({
        'include': ['./src/**/*.vue', './src/**/*.js'],
        }),
        'enforce': 'pre',
    },
...SNIPPED

Installation

npm install --save-dev @ehutch79/vite-eslint

Usage

Add it to vite.config.js

import viteESLint from '@ehutch79/vite-eslint'

export default {
  plugins: [viteESLint()]
}

As long as you can run eslint from your command line, this should work for you.

configuration

You can pass an options object to the plugin, it takes two parameters, include and exclude.

for example:

import viteESLint from '@ehutch79/vite-eslint'

export default {
  plugins: [viteESLint({ 'include': ['src/**/*.vue', 'src/**/*.js'] })]
}

will only scan js and vue files in the src/ directory.

Why?

I had a horrible time trying to get the official rollup eslint plugin working. The issue is that the source was transformed before being passed to the plugin. This works by scanning the files directly.

It also uses the new API, rather than the deprecated one most plugins are still using.

About

Vite 2 plugin that works with the dev server and rollup build.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published