Skip to main content

no-vitest-default-cache-dir-in-monorepo

Disallow default or missing Vitest cache directories in likely monorepos.

Rule catalog ID: R068

Targeted pattern scopeโ€‹

  • cacheDir
  • test.cacheDir
  • test.cache.dir

What this rule reportsโ€‹

This rule reports likely monorepo config when cache dir is missing or set to a default-style path like node_modules/.vitest.

Why this rule existsโ€‹

Shared default cache locations in monorepos can cause cross-package cache collisions and hard-to-reproduce failures.

โŒ Incorrectโ€‹

export default {
test: {
cacheDir: "node_modules/.vitest",
},
};

โœ… Correctโ€‹

export default {
test: {
cacheDir: ".cache/vitest/app",
},
};

Behavior and migration notesโ€‹

  • Detects likely monorepo contexts via workspace config kind or common monorepo path segments.
  • Accepts dynamic non-literal cache-dir expressions as explicit configuration.

ESLint flat config exampleโ€‹

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

export default [vite.configs.vitest];

When not to use itโ€‹

Disable if you intentionally standardize on default cache location and accept cross-project sharing.

Package documentationโ€‹

Further readingโ€‹