no-vitest-env-leakage-combo
Disallow risky Vitest state-leakage combos that mix globals: true, isolate: false, and disabled unstub flags.
Rule catalog ID: R057
Targeted pattern scopeโ
vitest.config.*vitest.workspace.*vite.config.*when Vitest test options are configuredtest.globalstest.isolatetest.unstubGlobalstest.unstubEnvs
What this rule reportsโ
This rule reports test scopes that statically configure:
test.globals: truetest.isolate: false- and at least one of:
test.unstubGlobals: falsetest.unstubEnvs: false
Why this rule existsโ
That combination makes global/environment state carry-over more likely across tests. In shared config, this often increases flakiness and order dependence.
โ Incorrectโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
isolate: false,
unstubGlobals: false,
},
});
โ Correctโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
isolate: true,
unstubGlobals: false,
},
});
Behavior and migration notesโ
- this rule checks static boolean assignments only
- it reports once per affected test scope
ESLint flat config exampleโ
import vite from "@typpi/eslint-plugin-vite";
export default [vite.configs.strict, vite.configs.vitest];
When not to use itโ
Disable this rule only if your harness intentionally relies on cross-test global/env state behavior.