Skip to main content

prefer-define-project

Prefer defineProject(...) over defineConfig(...) for inline Vitest project entries.

Rule catalog ID: R008

Targeted pattern scopeโ€‹

  • vitest.workspace.*
  • vitest.config.*
  • vite.config.* when Vitest uses test.projects
  • inline defineWorkspace([...]) project arrays
  • inline test.projects: [...] arrays

What this rule reportsโ€‹

This rule reports defineConfig(...) calls used directly inside inline Vitest project arrays.

Why this rule existsโ€‹

defineProject(...) communicates that the object is a project entry, not a top-level Vitest config export.

That makes workspace intent easier to read in reviews and keeps the project API explicit.

โŒ Incorrectโ€‹

import { defineConfig, defineWorkspace } from "vitest/config";

export default defineWorkspace([
defineConfig({
test: {
name: "browser",
},
}),
]);

โœ… Correctโ€‹

import { defineProject, defineWorkspace } from "vitest/config";

export default defineWorkspace([
defineProject({
test: {
name: "browser",
},
}),
]);

Behavior and migration notesโ€‹

  • this rule only targets inline project entries
  • top-level vitest.config.* files can still use defineConfig(...)

ESLint flat config exampleโ€‹

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

export default [vite.configs.vitest];

When not to use itโ€‹

Disable this rule if your repository intentionally treats inline workspace entries and top-level configs as the same abstraction.

Package documentationโ€‹

Further readingโ€‹