Repository navigation
Description
Summary
test/scripts/check-changeset-drift.test.ts fails to load entirely on Windows checkouts — it reports SyntaxError: Invalid or unexpected token and runs 0 of its 8 tests. Green on Linux CI, so it has gone unnoticed since the file landed in #1481 (2026-07-19).
Discovered by Booster while working #1770 (PR #1786). Independently reproduced and root-caused here.
Impact
The changeset-drift gate is a CI enforcement gate (squad-ci.yml:202 runs node scripts/check-changeset-drift.mjs). Its unit tests are silently dead for every Windows developer. A local npm test shows a failure that reads like environment noise, so the natural response is to ignore it — meaning regressions in evaluateDrift / listFragments would not be caught locally.
This is the same failure shape the workstream keeps hitting: something reports nothing and is mistaken for something passing.
Root cause
scripts/check-changeset-drift.mjs begins with a shebang:
#!/usr/bin/env node
It legitimately needs one — CI invokes it directly. But there is no .gitattributes rule for *.mjs, so it checks out CRLF on Windows. Vite/esbuild's shebang stripping does not survive the \r, leaving # as the first token of the module → SyntaxError: Invalid or unexpected token.
Node itself strips shebangs correctly, which is why node -e "import('./scripts/check-changeset-drift.mjs')" succeeds and masks the problem.
Proof — three controlled runs
Working tree restored clean after each.
| Variant | Shebang | Line endings | Result |
|---|---|---|---|
| As committed | present | CRLF (113) | ❌ SyntaxError, 0 tests |
| Shebang stripped | absent | CRLF | ✅ 8/8 pass |
| CRLF → LF, shebang kept | present | LF | ✅ 8/8 pass |
Natural control in the same directory — the three sibling suites in test/scripts/ all import a .mjs too, and all pass:
| Test | Imports | First line | Result |
|---|---|---|---|
check-changeset-drift.test.ts |
scripts/check-changeset-drift.mjs |
#!/usr/bin/env node |
❌ fails |
parse-diff.test.ts |
scripts/impact-utils/parse-diff.mjs |
/** |
✅ passes |
risk-scorer.test.ts |
scripts/impact-utils/risk-scorer.mjs |
/** |
✅ passes |
The shebang is the only differentiator. test/scripts/ overall: 1 failed | 3 passed (4), 33 tests passing.
Why CI never caught it
- The test file is in scope —
vitest.config.tshasinclude: ['test/**/*.test.ts']andnpm testis plainvitest run. - Linux runners check out LF, so the shebang strips cleanly and all 8 tests pass.
- Latest
devCI run32414111495—testjob success. - File is byte-identical to
origin/dev; this is pre-existing, not introduced by any in-flight PR.
Suggested fix — one line
.gitattributes already encodes exactly this lesson for shell scripts:
# Squad: shell scripts must stay LF — CRLF breaks the shebang on Linux/macOS.
*.sh text eol=lfThe same rule was simply never extended to .mjs:
# Squad: CRLF breaks shebang stripping when a .mjs is imported by vitest on Windows.
*.mjs text eol=lfVerified above: with LF and the shebang intact, all 8 tests pass.
Note this needs a re-normalize on existing checkouts (git add --renormalize .) for developers who already have the CRLF copy on disk.
Success criteria
-
npx vitest run test/scripts/check-changeset-drift.test.tsreports 8 passed on a fresh Windows checkout -
scripts/check-changeset-drift.mjsretains its shebang and still runs vianode scripts/check-changeset-drift.mjsin CI - No other
*.mjsregresses —npx vitest run test/scripts/reports 4 files / 41 tests passing - A guard prevents recurrence: any
.mjsimported by a test and carrying a shebang is pinned to LF
Repro
git checkout dev
npx vitest run test/scripts/check-changeset-drift.test.ts
# ❯ test/scripts/check-changeset-drift.test.ts (0 test)
# SyntaxError: Invalid or unexpected token
Activity
ci: add shebang EOL lint and generalize the eol=lf rule (#1788 follow…
test: reword fixture comment that tripped the unsafe-git detector
build: pin *.snap to LF and document the lint's scope boundary
docs(e2e): authoritative Windows test baseline at 369bba8 (#1797)
docs(e2e): correct the Windows baseline - retract a wrong prediction,…
fix(ci): force LF on *.mjs so shebanged scripts stay loadable by vite…
fix: repair CRLF working trees that .gitattributes cannot reach (#1793)
fix: repair CRLF working trees that .gitattributes cannot reach (#1793)…
fix: restore dev .gitattributes and generate-api-docs.mjs, keep inten…
chore: renormalize CRLF blobs to LF per .gitattributes (github#1788)
fix: align model tier routing and catalog (#1749) (#1750)