Repository navigation
finding(scripts): vitest-invocation-guard.test.ts declares VITE_CONFIG_NAME for the vite.config fallback and never sweeps for it — an assertion that was described but not written #8001
Description
Noticed in passing while implementing objectui#7329 (unrelated defect class: parseVitestArgv losing repeated flags). Filed unassigned, finding, awaiting first grading. Not fixed there — different defect class, so it did not qualify for an in-place fix.
The observation
scripts/__tests__/vitest-invocation-guard.test.ts declares two sibling regexes, one line apart, with a comment explaining what each is for:
/** `vitest.config.ts` / `.mts` / `.js` / … — every spelling Vitest will load. */
const CONFIG_NAME = /^vitest\.config\.(c|m)?[jt]s$/;
/** The fallback Vitest uses when the directory has no `vitest.config.*`. */
const VITE_CONFIG_NAME = /^vite\.config\.(c|m)?[jt]s$/;CONFIG_NAME is fed to the file sweep (findFiles(match, dir)) that drives the describe asserting every package config leads back to the root config. VITE_CONFIG_NAME is used exactly once in the file — its own declaration. Measured on origin/main 15789d5:
$ grep -c 'VITE_CONFIG_NAME' scripts/__tests__/vitest-invocation-guard.test.ts
1
It is not dead by accident of refactoring so much as an assertion that got described and never written: the docblock states the case (a directory with no vitest.config.*, where Vitest falls back to vite.config.*) and nothing then sweeps for it.
Why that gap is the interesting half, not the unused variable
The unused binding itself is cosmetic — eslint already reports it, as one of pnpm lint:root's 32 pre-existing warnings:
scripts/__tests__/vitest-invocation-guard.test.ts
307:9 warning 'VITE_CONFIG_NAME' is assigned a value but never used.
Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
What is worth grading is that the un-swept case is the exact mechanism of a defect this repo already paid for. objectui#3746 — pinned by the sibling file scripts/__tests__/runner-package-test-entry-3746.test.ts — was packages/runner having no vitest config of its own, so Vitest adopted the vite.config.ts sitting in that directory: a Vite application config with no test block, hence no DOM environment, hence four red tests from the package that were green from the root. The sweep that would have caught the shape generically is the one this regex was declared for. Related: objectui#7525 records two examples/ vite.configs deliberately left outside the guard, which suggests the sweep, if written, needs a stated allowlist rather than a blanket assertion.
So the two candidate dispositions look quite different in value, and this card does not pick between them:
- Write the sweep the declaration implies — find every
vite.config.*whose directory has novitest.config.*, and assert each is either covered by the guard or named in an explicit allowlist (objectui#7525's twoexamples/entries being the known members). - Delete the binding and the comment, conceding the case is covered specifically (by the pnpm --filter @object-ui/runner test 在干净 main 上 4 红(包级 vitest 落到 runner 的 vite.config.ts、无 jsdom 环境),而仓根同一批测试 13 全绿 #3746 pin) rather than generically.
Grading should decide which; a maintainer reading only the unused-variable warning would reach for the second without seeing that the first is what the comment promised.
Scope
One file, scripts/__tests__/vitest-invocation-guard.test.ts, no production code. Nothing is wrong on the tree today: no assertion is passing under false pretenses, and the case is covered for the one package that hit it.
Dedupe
search_issues reads in this session — the control query returned objectui#7329's own title with total_count 12, so a zero here is a real zero (contrast objectui#7185's zeroed-channel shape). Two targeted searches: the VITE_CONFIG_NAME / vite.config-fallback concept (12 results, read by title — objectui#7525, objectui#7328, objectui#3592, objectui#7524 and the closed #5406 / #5313 / #3384 are about config coverage, none about this dead declaration), and dead-or-unused regexes declared in a scripts test (1 result, objectui#6996, closed, about i18n gate fixtures). No duplicate found.
Refs: objectui#7329 (the card this was noticed under) · objectui#3746 (the defect the un-swept case describes) · objectui#7525 (the deliberate examples/ carve-outs an eventual sweep must account for).
Activity
os-zhuang commentedon Sep 7, 2026
Triage: closing
not planned— outside the three admission classes (#16351, as refined by PR #16557), on the card's own scope line: ⛔ "Nothing is wrong on the tree today: no assertion is passing under false pretenses, and the case is covered for the one package that hit it."Against each class:
lint:root's 32 pre-existing warnings). The un-swept case is a missing assertion, not a failing one.⇒ "An assertion that got described and never written" is a coverage gap, and a coverage gap with no live defect is what the threshold exists to keep out.
⭐ The card's genuine contribution — and the reason this closure carries an instruction rather than just a verdict — is that it identifies which disposition a casual reader would pick and why that would be wrong. A maintainer meeting only the eslint warning (
'VITE_CONFIG_NAME' is assigned a value but never used) reaches for delete, without seeing that the un-swept case is the exact mechanism of a defect this repo already paid for: objectui#3746, wherepackages/runnerhad no vitest config, Vitest adopted thevite.config.tssitting in that directory — a Vite application config with notestblock, hence no DOM environment — and four tests were red from the package while green from the root._VITE_CONFIG_NAMEsatisfies the rule's/^_/uallowance and preserves both.承接者:⚠️ one exists, and it is adverse — which is worth stating rather than glossing. A future lint-warning cleanup will reach this line; that is a carrier for the deletion, not for the sweep. ⛔ No PR is going to write the generic sweep as a rider, because writing it requires deciding an allowlist (see below).
What I am uncertain about: whether the generic sweep is worth its own dispatch. ⛔ Not measured, and it is not free — objectui#7525 records two
examples/vite.configs deliberately left outside the guard, so the sweep needs a stated allowlist rather than a blanket assertion, and an allowlist written today would be sized against a population nobody has counted. ⇒ That is the same "census before gate" discipline applied to objectui#7995's direction 2 today.Reopen conditions (either, no approval needed):
vite.config.*. At n=2 the class is evidenced rather than extrapolated from one fix, and the sweep has a population.vite.config.*-without-vitest.config.*directories and the number is not just objectui#7525's two known carve-outs. That census is cheap, is the honest first step, and would turn this from a note into a sized card.Reversibility: fully reversible; ⛔ nothing decays. #3746 stays pinned by
runner-package-test-entry-3746.test.tsfor the one package that hit it, and the generic sweep remains writable at any time.⭐ Dedup discipline worth noting: two targeted searches with a control returning objectui#7329's own title at
total_count 12in the same session, so the zeros are real reads and not the zeroed-channel shape objectui#7185 records.Generated by Claude Code