Repository navigation
Description
Problem
Neither the pre-commit hook (scripts/pre-commit) nor CI runs a prettier formatting check for TypeScript/JavaScript. As a result, files can be committed prettier-dirty, and drift has already accumulated on main.
The pre-commit hook only checks Rust formatting (the [rust] Checking formatting... step). For TypeScript it runs eslint, but eslint uses eslint-config-prettier solely to disable rules that conflict with prettier (eslint.config.shared.js:68-69, comment: "Disable rules that conflict with prettier") -- it does not enforce prettier formatting. A grep of .github/workflows/ for prettier/format --check/needs-format returns nothing.
Evidence
Two independent observations during Phase 2 of the @simlin/engine wasm backend work confirmed this:
-
Newly-created Phase 2 files were prettier-dirty yet passed the pre-commit hook.
-
A whole-tree check run from
src/enginecurrently flags 6 files that are not touched by theengine-wasm-simbranch and are byte-identical tomain(verified again while filing):$ cd src/engine && npx prettier --check 'src/**/*.ts' 'tests/**/*.ts' [warn] src/internal/project.ts [warn] src/project.ts [warn] src/worker-backend.ts [warn] src/worker-protocol.ts [warn] src/worker-server.ts [warn] tests/direct-backend.test.ts [warn] Code style issues found in 6 files. Run Prettier with --write to fix.
These 6 are pre-existing drift on main, not introduced by the current work; they were intentionally left untouched to avoid mixing unrelated reformatting into the wasm-backend feature's review. There is likely similar drift in other packages (core, diagram, app, server, serve-web) -- the 6 above are just what surfaced from the engine-package check.
Why it matters
- Developer experience / review hygiene: prettier-dirty files merge silently, then unrelated PRs get noisy reformatting diffs (or reviewers flag formatting that the tooling should have caught).
- The repo already intends prettier to be the formatter (
pnpm js-format/pnpm formatexist and write changes), but nothing verifies it on commit or in CI -- so the intent isn't enforced.
Components affected
scripts/pre-commit.github/workflows/(CI)- All TypeScript packages: engine, core, diagram, app, server, serve-web
Suggested resolution
Two parts, ordering matters -- clean up first, then add the gate, or the gate's first run will be noisy:
-
One-time
prettier --writesweep to clear existing drift (the 6 engine files above, plus a whole-repopnpm js-formatpass). Do this as its own commit so the formatting-only churn is isolated. -
Add a
prettier --checkgate to the pre-commit hook and CI. Apnpm js-needs-formatscript already exists in the rootpackage.json(find src -name '*.ts' -o -name '*.tsx' | egrep -v '/(lib(\.(browser|module))?|core)/' | xargs prettier -l) and is currently wired into nothing -- it's the natural gate to reuse, mirroring howpnpm rust-needs-format(cargo fmt -- --check) is already enforced by the Rust formatting step.Caveat to resolve when wiring it: the existing
js-needs-formatscript excludescore/directories via itsegrep -vfilter, so a faithful reuse would skip those. Decide whether to broaden the glob (drop thecoreexclusion, which appears aimed at generatedlib*/output rather thansrc/core) or accept the gap, and document the choice.
Discovered
Identified during Phase 2 of the @simlin/engine wasm simulation backend work (engine-wasm-sim branch). Tracking only -- not fixed as part of that work to keep the feature's diff scoped.
This is distinct from tech-debt.md item #60 ("No CI feature matrix"), which is about a Cargo feature matrix for Rust builds, not TypeScript prettier formatting.
Activity