Skip to content

Commit e3a353e

Browse files
committed
fix(ui): keep vitest coverage config out of vite.config.ts
vue-tsc typechecks vite.config.ts, and importing vitest/config's defineConfig there pulled vitest's transitive vite 6 types into a hard conflict with the app's vite-5-typed plugins (the pnpm tree resolves both vite 5 and 6), breaking `pnpm build` and every job that runs it. Move the coverage block to a dedicated ui/vitest.config.ts, which tsconfig does not include (so vue-tsc never sees it). vitest auto-loads it ahead of vite.config.ts and mergeConfig keeps the vue/i18n plugins. vite.config.ts returns to its pristine, type-clean state. Also ignore the generated coverage/ report dir in eslint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WvXMHHbYGddVPpmQR2XmK1
1 parent fad6dc4 commit e3a353e

3 files changed

Lines changed: 41 additions & 24 deletions

File tree

ui/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default [
1313
{
1414
ignores: [
1515
"dist/**",
16+
"coverage/**",
1617
"node_modules/**",
1718
"src-tauri/**",
1819
"*.config.js",

ui/vite.config.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// <reference types="vitest/config" />
2-
import { defineConfig } from "vitest/config";
1+
import { defineConfig } from "vite";
32
import vue from "@vitejs/plugin-vue";
43
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
54
import path from "node:path";
@@ -19,28 +18,6 @@ export default defineConfig({
1918
alias: { "@": path.resolve(__dirname, "./src") },
2019
},
2120
clearScreen: false,
22-
// Vitest config. Per-file `// @vitest-environment jsdom` docblocks still
23-
// select jsdom where a test needs the DOM; the default stays node.
24-
test: {
25-
coverage: {
26-
provider: "v8",
27-
// `json-summary` feeds the CI coverage-gate (.total.lines.pct); `lcov`
28-
// is for local HTML drilldown; `text` prints the table in the run log.
29-
reporter: ["text", "json-summary", "lcov"],
30-
reportsDirectory: "./coverage",
31-
// Count the shipped app code. `all: true` so an untested NEW file lands
32-
// as 0%-covered and drags the total DOWN, which is what the coverage
33-
// gate (CONTRIBUTING.md) needs to catch a regression.
34-
all: true,
35-
include: ["src/**/*.{ts,vue}"],
36-
exclude: [
37-
"src/**/*.d.ts",
38-
"src/main.ts",
39-
"src/locales/**",
40-
"src/**/__tests__/**",
41-
],
42-
},
43-
},
4421
server: {
4522
port: 5173,
4623
strictPort: true,

ui/vitest.config.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { defineConfig, mergeConfig } from "vitest/config";
2+
import viteConfig from "./vite.config";
3+
4+
// Coverage / test config lives HERE, not in vite.config.ts, on purpose.
5+
// vue-tsc typechecks vite.config.ts (it is in tsconfig "include") but NOT this
6+
// file, so putting the `test` block here keeps vitest's vite-6 types from
7+
// clashing with the app's vite-5-typed plugins - the pnpm tree resolves both
8+
// vite 5 and vite 6, and importing vitest/config's defineConfig into a
9+
// typechecked file makes that clash a hard `vue-tsc` error.
10+
//
11+
// vitest auto-loads vitest.config.* ahead of vite.config.*; mergeConfig folds
12+
// in the vue / i18n plugins + alias so component tests keep working. The
13+
// `// @vitest-environment jsdom` per-file docblocks still select jsdom where a
14+
// test needs the DOM; the default stays node.
15+
export default mergeConfig(
16+
viteConfig,
17+
defineConfig({
18+
test: {
19+
coverage: {
20+
provider: "v8",
21+
// `json-summary` feeds the CI coverage gate (.total.lines.pct); `lcov`
22+
// is for local HTML drilldown; `text` prints the table in the run log.
23+
reporter: ["text", "json-summary", "lcov"],
24+
reportsDirectory: "./coverage",
25+
// Count the shipped app code. `all: true` so an untested NEW file lands
26+
// as 0%-covered and drags the total DOWN, which is what the coverage
27+
// gate (CONTRIBUTING.md) needs to catch a regression.
28+
all: true,
29+
include: ["src/**/*.{ts,vue}"],
30+
exclude: [
31+
"src/**/*.d.ts",
32+
"src/main.ts",
33+
"src/locales/**",
34+
"src/**/__tests__/**",
35+
],
36+
},
37+
},
38+
}),
39+
);

0 commit comments

Comments
 (0)