Migrate from vite-plugin-eslint
vite-plugin-eslint2 is forked from gxmari007/vite-plugin-eslint and is still maintained. It adds features, supports more versions and fixes bugs. These are the steps to move over.
Install
Update the import
Option changes
Defaults
cache is now on out of the box. include is limited to src/, so override it if your sources live elsewhere.
Removed options
New options
Type changes
formatter no longer takes a function. Pass the name or path of a formatter.
cacheLocation
vite-plugin-eslint defaults it to Vite's cacheDir + '/.eslintcache'. vite-plugin-eslint2 defaults to .eslintcache in the project root, which is ESLint's own default.
Behaviour changes
The apply hook
vite-plugin-eslint runs in every mode. vite-plugin-eslint2 uses apply to decide when it is active:
To lint during a build, set build: true:
Virtual modules
vite-plugin-eslint2 always ignores virtual modules: virtual:, the \0 prefix, and module IDs without a /. You no longer have to exclude them yourself.
Version compatibility
After the migration
To lint during a build, which is what the old plugin did by default:
A good starting point for day-to-day work: