Repository navigation
Description
Summary
#289 found that new URL(<literal>, import.meta.url) is a landmine in a spec: Vite compiles that
form, and a client transform resolves it to the dev server's http://localhost/@fs/… rather than
a file URL. fileURLToPath then throws at import, so the whole spec file dies before one
assertion runs. It cost src/test-support/source-tree.ts exactly that, and
src/styles/sheet.adopt.test.ts had recorded the wrong root cause for it for as long as the
comment existed.
Four live sites remain, each one // @vitest-environment jsdom away from the same crash:
src/styles/sheet.test.ts:13—vite.config.tssrc/styles/sheet.test.ts:53—scripts/assert-css-scoped.mjssrc/styles/host-reset.test.ts:58—docs/embedding.mdsrc/config/translations.test.ts:170—scripts/sync-translations.mjs
All four are node-only today, so none is a defect. The cost is that the trap is held by prose in
one module's docblock, and #286's sibling hazard is held by a lint rule instead —
no-restricted-imports in eslint.config.js bans readdirSync under src/ outside
test-support/, and docs/testing.md praises it for being "caught at the import instead of by a
grep nobody runs". The reader rule got the grep.
Approach
A lint rule alone cannot close this: the four reads have nowhere else to go, because
readSource (src/test-support/source-tree.ts:66) joins against SRC_DIR and is src/-relative
by contract. Widening it would void the one thing its docblock protects.
So the two halves go together:
- A repo-root reader beside it —
readRepoSource('docs/embedding.md'), resolved off the same
SRC_DIR-derived root, memoised through the existingmemo. test(build): the private spec readersreadRepoSourcesupersedes #289 deliberately left the four
reads local rather than reverse its own ticket's decision, so this is the decision to make
first: does the repo want a second rooted reader, or does it prefer the reads local and the
trap held by prose? - Then the rule —
no-restricted-syntaxforNewExpression[callee.name='URL']taking
import.meta.urlas its second argument, undersrc/**/*.{ts,tsx}, with a message naming
this issue. Only reachable once (1) gives every legitimate read somewhere to go.
Seven sites write the same one-liner today, so the reader has callers beyond the four:
sheet.test.ts ×2, host-reset.test.ts:58, config/translations.test.ts:170,
scripts/ci-workflows.test.ts:11, scripts/postcss-scope-widget.test.ts:285,
scripts/deploy-headers.test.ts:23, scripts/wrangler-config.test.ts:15. ⚠ The scripts/ four
are outside the src/ lint scope and outside test-support/'s import rule — decide whether they
are in scope rather than assuming it.
Acceptance criteria
- A decision is recorded on whether the repo wants a repo-root reader at all. A "no" closes
this ticket, with the reason indocs/testing.mdbeside the grep. - On a "yes": every read of a path outside
src/from asrc/spec goes through it, and no
src/spec writesnew URL(…, import.meta.url). -
eslint.config.jsfails on that form undersrc/, with a message naming the issue. - The rule was watched failing: add the form to a spec, see
pnpm lintgo red, remove it. -
docs/testing.md'ssrc/test-support/section replaces the grep with the rule, and drops
the "four live sites" warning test(build): the private spec readersreadRepoSourcesupersedes #289 left there.
Verification checklist
-
grep -rn "new URL(.*import.meta.url" src/ --include='*.test.ts' --include='*.test.tsx'
returns nothing but prose -
pnpm lint && pnpm typecheck && pnpm test:rungreen - The per-edit walker set is still 12 and the widest selection still 24
(scripts/select-unit-specs.test.ts) — a new shared module must not become a walker route
Notes
Raised by the altitude lens on the #289 PR, as a finding outside that ticket's scope: #289's own
body ruled the out-of-src/ reads stay local, and reversing that is a decision rather than a
cleanup. Six-plus files and outside prAllowlistGlobs, so a ticket rather than a commit there.
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.
sydevs-bot commentedon Oct 16, 2026
The session for this item did not finish after 3 attempts. I have stopped retrying. A
@sydevs-botverb or mention from you starts me again.🤖 sydevs dispatcher
Merge origin/main into claude/ci-282-own-preview
fix(lint): drop the no-op specs ignore