fix(tooling): stop worktree commits from skipping prettier

The pre-commit frontend formatter resolved prettier at
REPO_ROOT/frontend-modern/node_modules/.bin/prettier, where REPO_ROOT is
derived from the script's own path. In a linked worktree that is the
worktree root, which never runs npm install, so prettier_bin() returned
None and the formatter silently returned 0. Every frontend commit made
from a Claude or Codex agent worktree skipped formatting entirely, and
the drift accumulated in already-committed files until someone ran
`make format` and picked up 14 files of unrelated churn.

The skip path's comment claimed "CI's prettier check still catches drift
that slips through here." No such check existed -- nothing under
.github/workflows referenced prettier -- so there was no backstop at all.

- Fall back to the primary worktree's node_modules, resolved via
  `git rev-parse --git-common-dir`, and say so in the hook output so a
  version mismatch between the two checkouts stays visible.
- Add the whole-tree "Check frontend formatting" step to the frontend CI
  job that the comment already promised. Staged-only formatting cannot
  see drift in untouched files; this can.
- Pin prettier exactly. "^3.3.0" let the tracked package-lock.json land
  on 3.9.5 while the gitignored pnpm-lock.yaml resolved 3.9.6, so CI and
  the dev machine were free to run different formatters.
- Resolve the test suite's prettier the same way, so its two real
  coverage tests stop silently skipping in worktrees.

Contract-Neutral: devDependency prettier version pin plus pre-commit/CI formatter tooling; no runtime, API, or deployment-surface delta
This commit is contained in:
rcourtman
2026-08-06 21:38:26 +01:00
parent dd894bd1f7
commit ff58c33cfb
5 changed files with 117 additions and 17 deletions
+7
View File
@@ -122,6 +122,13 @@ jobs:
working-directory: frontend-modern
run: npm ci
# Whole-tree, not staged-only: the pre-commit formatter only ever sees
# staged files, so drift in untouched files is invisible to it. This is
# the backstop that keeps `make format` a no-op on a clean tree.
- name: Check frontend formatting
working-directory: frontend-modern
run: npm run format:check
- name: Lint frontend
working-directory: frontend-modern
run: npm run lint