From fd5921f62eb88ea605bf7f0893870af3f88d1fd2 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Wed, 14 Oct 2026 09:31:47 +0200 Subject: [PATCH] fix: make fmt refuses to run without the repo's own prettier (closes #509) In a clone where script/bootstrap has not run, node_modules/ is empty and yarn falls back to whatever prettier is on the PATH, which can format files differently from the version yarn.lock pins. script/fmt and script/fmt-check now stop with a message telling the user to run script/bootstrap when node_modules/.bin/prettier is missing. After bootstrap they behave as before. The README Entrypoints entries say so. Model: opus-5-5 --- README.md | 8 ++++++-- script/fmt | 7 +++++++ script/fmt-check | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 751d174..ef7347b 100644 --- a/README.md +++ b/README.md @@ -239,8 +239,12 @@ provide: `make check` stays non-mutating. Linting runs only in the container, because an ESLint result that depends on whichever ESLint the host happens to have is not a result, so docker is required to lint. -- `script/fmt` — format all files (writes), on the host -- `script/fmt-check` — check formatting (read-only), on the host +- `script/fmt` — format all files (writes), on the host, with the `prettier` + that `script/bootstrap` installs in `node_modules/`; when that one is missing + it fails and says to run `script/bootstrap`, instead of using a `prettier` + from the `PATH` +- `script/fmt-check` — check formatting (read-only), on the host, with the same + `prettier` and the same refusal - `script/check` — run `script/test`, `script/lint` and `script/fmt-check` - `script/check-censored` — assert the competitor name RULES.md bars appears nowhere in the working tree or under `dist/` outside its documented diff --git a/script/fmt b/script/fmt index 36593a4..f680a97 100755 --- a/script/fmt +++ b/script/fmt @@ -25,6 +25,13 @@ run_yarn() { main() { cd "$ROOT" + # Without the repo's own prettier, yarn runs whatever prettier is on + # the PATH, which may be a version that formats files differently. + if [ ! -x node_modules/.bin/prettier ]; then + echo "fmt: this repo's prettier is not installed in node_modules/," \ + "so run script/bootstrap first." >&2 + exit 1 + fi echo "Formatting..." run_yarn run fmt } diff --git a/script/fmt-check b/script/fmt-check index bba0ff6..46487ed 100755 --- a/script/fmt-check +++ b/script/fmt-check @@ -26,6 +26,13 @@ run_yarn() { main() { cd "$ROOT" + # Without the repo's own prettier, yarn runs whatever prettier is on + # the PATH, which may be a version that formats files differently. + if [ ! -x node_modules/.bin/prettier ]; then + echo "fmt-check: this repo's prettier is not installed in" \ + "node_modules/, so run script/bootstrap first." >&2 + exit 1 + fi echo "Checking formatting..." run_yarn run fmt-check }