Skip to main content

require-vitest-explicit-environment

Require explicit test.environment in committed Vitest config.

Rule catalog ID: R070

Targeted pattern scopeโ€‹

  • test.environment

What this rule reportsโ€‹

This rule reports Vitest-oriented config where test.environment is omitted.

Why this rule existsโ€‹

Explicit environment declarations reduce ambiguity and prevent accidental behavior changes between Node and browser-like runners.

โŒ Incorrectโ€‹

export default {
test: {},
};

โœ… Correctโ€‹

export default {
test: {
environment: "node",
},
};

Behavior and migration notesโ€‹

  • Applies to Vitest config files and Vite config files that define a test block.
  • Checks key presence; does not enforce a specific environment value.

ESLint flat config exampleโ€‹

import vite from "@typpi/eslint-plugin-vite";

export default [vite.configs.vitest];

When not to use itโ€‹

Disable if your project intentionally depends on implicit Vitest environment defaults.

Package documentationโ€‹

Further readingโ€‹