no-vitest-globals
Disallow test.globals: true in Vitest configuration.
Rule catalog ID: R023
Targeted pattern scopeโ
vitest.config.*vitest.workspace.*vite.config.*when a Vitesttestblock is used- root and inline project
test.globals
What this rule reportsโ
This rule reports explicit test.globals: true assignments.
Why this rule existsโ
Enabling Vitest globals injects test APIs into global scope (describe, it, expect, ...).
While convenient, this can make test dependencies less explicit, complicate editor/tooling assumptions, and increase accidental coupling to ambient globals.
This plugin focuses on predictable config defaults and explicitness in Vite/Vitest projects, so flagging committed global API mode is a useful project-level guardrail.
โ Incorrectโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
},
});
โ Correctโ
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: false,
},
});
Behavior and migration notesโ
-
this rule only reports explicit
trueassignments -
it does not require setting
globalswhen omitted -
if you disable globals, import APIs explicitly in test files:
import { describe, expect, it } from "vitest";
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 if your team intentionally prefers global Vitest APIs and accepts the associated implicitness trade-offs.