Overview
eslint-plugin-vite focuses on configuration and runtime patterns that are specific to Vite, Vitest, and Vitest bench.
The current rule set is intentionally biased toward:
- static build correctness
- config-file safety
- client-side
import.meta.*behavior - Vitest workspace and benchmark hygiene
What this plugin coversโ
The plugin currently ships rules in four practical buckets:
- Config rules
- exporting config files with the right helper APIs
- migrating away from deprecated Vite config keys and values
- avoiding unsafe
envPrefixvalues - keeping dev-server host, CORS, and filesystem settings explicit
- keeping
resolve.aliasreplacements Vite-compatible
- Client runtime rules
- catching invalid
import.meta.glob()arguments - catching dynamic
import.meta.env[...]access - preventing accidental reads from non-public env keys in browser code
- catching invalid
- Vitest rules
- enforcing unique workspace project names
- nudging inline workspace projects toward
defineProject(...)
- Vitest bench rules
- preventing mixed correctness tests and benchmark code in the same file
What this plugin does not try to doโ
This plugin does not try to replace:
- ESLint core best-practice rules
- general TypeScript correctness rules
- testing-style rules that are not specific to Vitest or Vite
- framework-specific rules for React, Vue, Svelte, or Solid
Instead, it focuses on things that are easy to get wrong specifically because of how Vite and Vitest work.
Recommended adoption pathโ
- Start with
vite.configs.recommended. - Add
vite.configs.clientif your app usesimport.meta.envorimport.meta.globheavily. - Add
vite.configs.vitestif you use Vitest workspaces or multi-project setups. - Add
vite.configs["vitest-bench"]if you keep benchmark files in the same repository. - Move up to
vite.configs.strictonce the recommended baseline is stable.
Rule docsโ
Each rule page includes:
- the exact pattern it targets
- why the pattern is risky in Vite or Vitest
- incorrect and correct examples
- a flat-config snippet
- links back to the relevant Vite or Vitest documentation