Skip to main content

no-vitest-coverage-clean-false

Disallow test.coverage.clean: false in shared Vitest config.

Rule catalog ID: R048

Targeted pattern scopeโ€‹

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

What this rule reportsโ€‹

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

Why this rule existsโ€‹

Disabling coverage cleanup can leave stale artifacts from previous runs. In CI or shared repo workflows, stale output can mislead diagnostics and artifact consumers.

โŒ Incorrectโ€‹

import { defineConfig } from "vitest/config";

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

โœ… Correctโ€‹

import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
coverage: {
clean: 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 your pipeline intentionally preserves coverage output between runs and you manage stale artifacts elsewhere.

Package documentationโ€‹

Further readingโ€‹