Skip to main content

no-unsafe-vitest-flags

Disallow unsafe Vitest execution flags that can hide failing tests or runtime errors.

Rule catalog ID: R018

Targeted pattern scopeโ€‹

  • vitest.config.*
  • vitest.workspace.*
  • vite.config.* when a Vitest test block is used
  • root and inline project test option objects

What this rule reportsโ€‹

This rule reports:

  • test.allowOnly: true
  • test.dangerouslyIgnoreUnhandledErrors: true

Why this rule existsโ€‹

These flags weaken core test safety guarantees:

  • allowOnly: true can allow focused tests (.only) to pass while silently skipping the rest of the suite
  • dangerouslyIgnoreUnhandledErrors: true can hide asynchronous failures and produce misleading green runs

This plugin is focused on robust Vite/Vitest configuration quality, so catching these config-level hazards is a repository-specific, high-signal check.

โŒ Incorrectโ€‹

import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
allowOnly: true,
dangerouslyIgnoreUnhandledErrors: true,
},
});

โœ… Correctโ€‹

import { defineConfig } from "vitest/config";

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

Behavior and migration notesโ€‹

  • this rule only reports explicit true toggles for unsafe flags
  • if these options are omitted, Vitest defaults still apply
  • if you need temporary local overrides, prefer ephemeral CLI/dev-only config branching rather than committed repository config

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 test strategy intentionally allows focused test execution or ignored unhandled errors in committed config and you accept that risk.

Package documentationโ€‹

Further readingโ€‹