Skip to main content

no-vitest-unstub-globals-false

Disallow test.unstubGlobals: false in shared Vitest config.

Rule catalog ID: R055

Targeted pattern scopeโ€‹

  • vitest.config.*
  • vitest.workspace.*
  • vite.config.* when Vitest test options are configured
  • test.unstubGlobals

What this rule reportsโ€‹

This rule reports explicit test.unstubGlobals: false assignments in supported config files.

Why this rule existsโ€‹

Stubbed globals should be restored between tests to avoid hidden state coupling. Disabling global unstubbing can increase flakiness and order dependence.

โŒ Incorrectโ€‹

import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
unstubGlobals: false,
},
});

โœ… Correctโ€‹

import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
unstubGlobals: 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 global stubbing lifecycle is controlled by external harness behavior and this flag is intentionally false.

Package documentationโ€‹

Further readingโ€‹