no-vitest-unstub-envs-false
Disallow test.unstubEnvs: false in shared Vitest config.
Rule catalog ID: R056
Targeted pattern scopeโ
vitest.config.*vitest.workspace.*vite.config.*when Vitest test options are configuredtest.unstubEnvs
What this rule reportsโ
This rule reports explicit test.unstubEnvs: false assignments in supported config files.
Why this rule existsโ
Stubbed environment variables should be restored between tests to avoid state leakage across suites. Disabling env unstubbing can create order-dependent behavior.
โ Incorrectโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
unstubEnvs: false,
},
});
โ Correctโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
unstubEnvs: true,
},
});
Behavior and migration notesโ
- this rule checks static boolean assignments only
- it targets committed config files, not arbitrary source modules
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 env stubbing lifecycle is handled externally and this flag is intentionally false.