Skip to main content

require-inline-project-name

Require inline Vitest project definitions to declare a project name.

Rule catalog ID: R014

Targeted pattern scopeโ€‹

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

What this rule reportsโ€‹

This rule reports inline project definitions that do not declare a project name, usually under test.name.

It covers both plain object entries and wrapped entries such as defineProject({...}).

Why this rule existsโ€‹

Vitest recommends defining a name for inline project configs. When a project name is omitted, Vitest falls back to generated numbering for inline entries, which makes CLI targeting and test output harder to read.

A stable explicit name improves:

  • vitest --project <name> filtering
  • reporter output and debugging
  • multi-project maintenance in monorepos and mixed browser/node setups

โŒ Incorrectโ€‹

import { defineConfig } from "vite";

export default defineConfig({
test: {
projects: [
{
test: {
environment: "happy-dom",
include: ["tests/**/*.browser.test.ts"],
},
},
],
},
});

โœ… Correctโ€‹

import { defineConfig } from "vite";

export default defineConfig({
test: {
projects: [
{
test: {
environment: "happy-dom",
include: ["tests/**/*.browser.test.ts"],
name: {
label: "browser",
color: "green",
},
},
},
],
},
});

Behavior and migration notesโ€‹

  • test.name: "unit" and test.name: { label: "unit", color: "green" } are both accepted
  • this rule only checks inline project objects, not project names inferred from glob patterns or package names
  • the rule accepts legacy top-level name properties when they are already present, but current Vitest examples typically place the name under test.name

ESLint flat config exampleโ€‹

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

export default [vite.configs.recommended, vite.configs.vitest];

When not to use itโ€‹

Disable this rule only if your team intentionally accepts Vitest's generated numeric names for inline project entries and does not rely on stable project labels.

Package documentationโ€‹

Further readingโ€‹