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 Vitesttestblock is used- root and inline project
testoption objects
What this rule reportsโ
This rule reports:
test.allowOnly: truetest.dangerouslyIgnoreUnhandledErrors: true
Why this rule existsโ
These flags weaken core test safety guarantees:
allowOnly: truecan allow focused tests (.only) to pass while silently skipping the rest of the suitedangerouslyIgnoreUnhandledErrors: truecan 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
truetoggles 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.