refactor(layering): R84 requires each new unit test to be named for a module beside it
Merged
TH
4h ago+320+320+012345678901234567890123456789-19-19-01234567890123456789
Stacked on #3667 (test-kit single entry) on #3659 (R11 devDependencies) on #3645 (R83).
What
R84 test-colocation: every *.test.ts under root src/ and packages/<pkg>/src/ sits in the directory of a module (or in that directory's __tests__/) and is named <module>.test.ts or <module>-<aspect>.test.ts. It measures its offenders against the merge-base and keeps no baseline file, the same way R83 does: 202 unmatched tests at head against 202 at the merge-base. Growth fails; moving or renaming a test into place needs no edit (base entries are carried to head coordinates through renamedSince, so a rename is the same entry). Burn-down belongs to the package and root workers; this PR only lands the rule.
Conventions (stated in the rule's doc comment, so it needs no exemptions)
- Cross-module package tests (conformance drivers, package-surface tests) are named for the package entry:
index-<aspect>.test.ts, besideindex.ts.indexis an ordinary module to the rule. - Repo-level guards (tests that assert on Swift sources, manifests, docs or scripts) move to
test/repo-guards/, under the exempttest/tree, and run inunit-core. - Exempt:
test/,scripts/, package-localtest/trees. The rule reads onlysrc/andpackages/*/src/, and not test-kit, whose sources are test support. - A module is any production source file (
isProductionSourceFile): fixtures and__tests__/helpers never count as the module a test is named for.
Evidence
test-colocation.test.ts: matched by module and by-aspect; unmatched for a different name, a glued suffix or a dotted suffix;__tests__judged against the parent directory (and not against modules inside__tests__);index-<aspect>matched only with anindex.tsbeside it; fixtures never the module;test/,scripts/and package test trees unmeasured; growth fails, a cleanup or unchanged set passes; the message names both conventions.- Planted
src/__tests__/planted-unmatched.test.tsin the real tree:check:layeringnamed it under R84. Removed. - The measurement runs through
mergeBaseRatchets(LayeringRatchets.unmatchedTests);measureRatchetsnow takes the tracked tree ({ manifests, files }) that R83 and R84 share. - Gates:
pnpm check:quick,check:layering(384 node tests),check:fallow,check:gate-manifest,check:affected --run, repo-widepnpm format.
🤖 Generated with Claude Code