vite-plugin-eslint
vite-plugin-eslint copied to clipboard
No error on `vite serve` but errors on `vite build`
I cannot get an error out of vite serve
on an empty project with a linter error purposely build in, but vite build
does display the error (twice).
Versions
vite: 4.5.0
vite-plugin-eslint 1.8.1
eslint 8.53.0
Vite config
import eslint from 'vite-plugin-eslint';
/** @type {import('vite').UserConfig} */
export default {
root: './src',
envDir: '../',
build: { outDir: '../dist', emptyOutDir: true },
plugins: [eslint()],
};
index.js
const foo = 'bar'; // shows ESLint `no-unused-vars` error
console.log("Hello world!"); // shows ESLint `no-console` warning
Vite console output
> vite build
vite v4.5.0 building for production...
✓ 2 modules transformed.
✓ built in 1.66s
[vite-plugin-eslint]
/Users/dedacted/src/index.js
1:7 error 'foo' is assigned a value but never used no-unused-vars
2:1 warning Unexpected console statement no-console
✖ 2 problems (1 error, 1 warning)
but...
> vite serve
VITE v4.5.0 ready in 564 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
What am I missing here?
Came here for the very same problem. I'd love to know what to do as well.
Right now, I activated
plugins: [eslint({ lintOnStart: true })],
in the vite.config.js
because my project is still small and there's no noticeable latency on server start yet.
This is obviously not a long-term solution...
I saw similar behavior! Did navigating to http://localhost:5173/ make the error show up? That works for me.
@tthornton3-chwy For me, the local server only shows an error if one of the files changes and this change produces the error.