Repository navigation
Description
Summary
#286 gave the nine specs that inventory src/ one walk. #302 (merged as #303, f09ac88) gave
every other spec one rooted reader — readRepoSource in src/test-support/repo-source.ts — and
a lint rule that bans the new URL(…, import.meta.url) root. Four specs still resolve a private
root with dirname(fileURLToPath(import.meta.url)), the form the rule leaves alone.
This is cleanup, not a defect: all four work. The cost is that the pattern a tenth spec author
copies is still the hand-rolled one, and nothing says so — #303's rule cannot see this form,
because repo-source.ts itself and six scripts/*.mjs need it.
Decisions
- Which reader do these specs migrate to? →
readRepoSourcefrom test(build): a repo-root reader, so thenew URL(…, import.meta.url)trap can be linted #302, narrowing this ticket
to the specs test(build): a repo-root reader, so thenew URL(…, import.meta.url)trap can be linted #303 did not already take (Ardnived, 2026-10-16)
Approach
readRepoSource clears both walls the original three options were weighed against, and #303
measured each one:
- jsdom is safe.
REPO_ROOTisdirname(fileURLToPath(import.meta.url)), which Vite's web
transform leaves alone.src/test-support/repo-source.jsdom.test.tsis the live proof. - It is not a walker route.
scripts/select-unit-specs.mjs:61marks a walker by the import of
src/test-support/source-tree.tsalone, so these specs do not join the set that runs on every
lane edit. That is whyrepo-source.tsis a module of its own, which its docblock states.
readSource is still the wrong reader for all four, even for a path under src/: it lives behind
the walk.
The four readers
| Spec | Carries | Becomes |
|---|---|---|
src/views/MapFrame.test.tsx:222 |
SRC plus a read helper, over 5 reads (:227, :251, :254, :258, :264) |
readRepoSource('src/views/FullInterface.tsx') and the rest, src/-prefixed |
src/Widget.theme-root.test.tsx:98 |
the same reader, inline in the describe |
readRepoSource('src/Widget.tsx') |
src/components/organisms/EventsList/DynamicEventsList.test.ts:15 |
FILE plus its own comment strip |
readRepoSource('src/components/organisms/EventsList/DynamicEventsList.tsx'), strip unchanged |
src/Widget.translate.test.ts:19 |
FILE, read once at :26 and passed to ts.createSourceFile as its fileName |
readRepoSource('src/Widget.tsx'), with a path literal kept for the fileName argument |
Two more things these four do not change:
DynamicEventsList.test.ts's comment strip stays local.readSourceWithoutCommentsis the
deduped version and it is behind the walk, so taking it would cost the walker.Widget.translate.test.tskeeps its ownts.createSourceFile.parseSource
(src/test-support/source-ast.ts:3) importssource-tree, so it is a walker route too.
src/lib/brand.test.ts — the third shape
:64 and :68 read 'src/config/translations.en.json' and the seven COPY_FILES paths as
cwd-relative strings. They work only because vitest runs from the repo root. Those paths are
already repo-relative, so readRepoSource(copySnapshot()) and readRepoSource(file) are the
whole change, and the cwd dependency goes with it.
⚠ Keep COPY_FILES and copySnapshot() as quoted path literals. docs/testing.md names this
file as the spec that reaches src/App.tsx through the quoted repo-relative specifier form, which
scripts/select-unit-specs.mjs resolves. Inlining them would drop it from that selection.
The #156 contract is unchanged: readRepoSource returns raw text, comments included.
The lint rule that stops regrowth
After the migrations, exactly one spec writes fileURLToPath(import.meta.url):
src/Widget.standalone.test.ts:43, which needs an absolute root because importGraph resolves
module specifiers on disk (:77). So the form can be banned in specs with one
eslint-disable-next-line there naming the reason.
⚠ Add it as a second config object scoped to specs alone, and re-state #303's new URL
selector inside it. ESLint flat config replaces a rule's options rather than merging them, so a
later block matching **/*.{test,spec}.{ts,tsx} would silently drop the new URL ban for every
spec. Widening #303's own block instead is not an option: src/test-support/repo-source.ts and
six scripts/*.mjs are in its scope and legitimately write the form.
{
files: ['**/*.{test,spec}.{ts,tsx}'],
rules: {
'no-restricted-syntax': [
'error',
/* #303's NewExpression selector, restated verbatim */,
{
selector:
'CallExpression[callee.name="fileURLToPath"][arguments.0.type="MetaProperty"][arguments.0.property.name="url"]',
message: 'Read a repo file with readRepoSource (src/test-support/repo-source.ts) (#289).',
},
],
},
}docs/testing.md
#303's new paragraph reads "A spec reading a file the walk cannot reach goes through
readRepoSource". All four specs here read files the walk can reach and come here anyway,
because the walk is what marks a walker. repo-source.ts's docblock already says it the right
way — "a spec reading a file or two comes here, whichever directory it sits in". Bring the doc in
line, and name the new rule beside #303's.
Acceptance criteria
- The four specs in the table read through
readRepoSource, and none declares a root or a
reader of its own. -
src/lib/brand.test.tsreads throughreadRepoSource, andCOPY_FILESand
copySnapshot()still hold quoted repo-relative path literals. -
eslint.config.jsfails a spec that writesfileURLToPath(import.meta.url), and still
fails one that writesnew URL(…, import.meta.url). -
src/Widget.standalone.test.ts:43keeps its root, under aneslint-disable-next-linewhose
comment says the graph walk needs an absolute path. - Every migrated spec still fails when its own defect is reintroduced at the causing site.
-
docs/testing.mdsays a single-file read comes toreadRepoSourcewhatever directory the
spec sits in, and names both lint rules.
Verification checklist
-
git grep -n "fileURLToPath(import.meta.url)" -- '*.test.ts' '*.test.tsx'returns only
src/Widget.standalone.test.ts:43 - Both bans watched going red: add
fileURLToPath(import.meta.url)to a spec, then
new URL('./x', import.meta.url)to a different one, runpnpm lintafter each, remove both -
pnpm lint && pnpm typecheck && pnpm test:rungreen - For each of the five specs changed, reintroduce its own defect at the site that causes it
and watch it go red -
pnpm test:run scripts/select-unit-specs.test.tsgreen — the walker set is still 12 and the
widest selection still ≤ 26. An edit torepo-source.tsitself selected 20 onf09ac88;
five more importers put it near 25, so measure rather than assume
Notes
Why four of #303's five "stay as they are" specs move here. #303's Detail lists
Widget.standalone, MapFrame, Widget.theme-root, Widget.translate and DynamicEventsList
as safe under both transforms and leaves them. That call was about the crash its lint rule
closes. This ticket is about the duplicate reader, which is why four of them move and
Widget.standalone does not.
Out of scope, and why:
src/Widget.standalone.test.ts:43—importGraphresolves specifiers withexistsSync/
statSync(:77), so it works in absolute paths by construction. test(build): one source walker for the nine specs that inventorysrc/#286 measured the memo it
misses at ~10ms over 231 files.src/lib/shadow-patches.test.ts:147— its root iscreateRequire(...).resolve()into
node_modules, which no repo-relative reader can serve.
Two corrections to the body this replaces. src/Widget.translate.test.ts carries the same
private reader and was missed by the original survey; it predates this ticket (#240).
src/lib/brand.test.ts was ruled out for reading no src/-relative path, which was right for
readSource and is wrong for a repo-relative reader. src/styles/sheet.test.ts,
src/config/theme/palette.defaults.test.ts and src/styles/host-reset.test.ts are done — #303
took all three.
Raised by the cleanup lenses on the #286 PR as a finding outside that ticket's walk. Five files is
past the direct-fix bound, and these specs are outside prAllowlistGlobs, so it is a ticket rather
than a commit on that PR.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
Ardnived commentedon Oct 15, 2026
@sydevs-bot implement
sydevs-bot commentedon Oct 15, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
11 remaining items
Ardnived commentedon Oct 16, 2026
@sydevs-bot Revise the ticket to take your recommended approach. #303 is merged or in the merge queue
[-]test(build): the per-file `src/` readers the shared walker now supersedes[/-][+]test(build): the private spec readers `readRepoSource` supersedes[/+]sydevs-bot commentedon Oct 16, 2026
Revised to option 1. #303 merged as
f09ac88, soreadRepoSourceis onmainand nothing blocks this.Narrowed and corrected against that merge:
new URL(…, import.meta.url)trap can be linted #303 tooksheet,palette.defaultsandhost-reset.Widget.translate.test.ts:19joins — same private reader, missed by the first survey.brand.test.ts:64joins. I ruled it out for reading nosrc/-relative path. That was right forreadSourceand wrong for a repo-relative reader: its paths are already repo-relative, read off the cwd.fileURLToPath(import.meta.url)in specs. OnlyWidget.standalone.test.ts:43then writes it, under one disable. Without the rule the hand-rolled root is still what the next author copies.The jsdom wall is gone —
REPO_ROOTsurvives the web transform. The walker wall stands, andrepo-source.tssits outside it.Title now names the reader, not the walker.
@sydevs-bot implementstarts the work.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Oct 16, 2026
@sydevs-bot implement
docs: hold #442's guides to the documentation rule