Add .prettierrc/.prettierignore, stop reformatting REPO_POLICIES.md, and make fmt-check cover markdown #69
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The repo has no
.prettierrcand no.prettierignore, andscript/fmt:23runs
prettier -w *.md || trueover every root markdown file with prettier'sdefault settings.
Policy requires prettier with two deviations from default: four-space
indents and
proseWrap: always. Because neither is configured,make fmtwrites markdown that does not match policy — and it has already done damage:
main'sREPO_POLICIES.mdis byte-identical to the authoritative copy inthe
promptsrepo.list indentation to 2-space and stripping code-fence indentation. Content
is unchanged; only formatting drifted. The front-matter
last_modifiedstill matches, so the drift is silent.
REPO_POLICIES.mdis a verbatim fetch of an authoritative upstreamdocument. Local tooling must not rewrite it, for the same reason
.golangci.ymlmust not be rewritten.Compounding this:
script/fmt-checkchecks onlygofmt. It never checksmarkdown at all. So
make fmtwrites markdown changes thatmake checkwillnever notice, in either direction — the formatter and the gate disagree, and
the gate is silent.
Definition of done
.prettierrcexists with the policy settings (four-space indent,proseWrap: always) and.prettierignoreexists.REPO_POLICIES.mdis excluded from the prettier pass via.prettierignore, and the copy in the repo is restored to bebyte-identical to
https://git.eeqj.de/sneak/prompts/raw/branch/main/prompts/REPO_POLICIES.md.script/fmt-checkverifies markdown formatting (prettier --check) inaddition to Go, so
make checkfails ifmake fmtwould change anything.script/fmtandscript/fmt-checkcover the same file set. Runningmake fmtthenmake fmt-checkis clean; runningmake fmt-checkon adeliberately misformatted file fails.
|| true. A formatter that silentlydoes nothing when it is missing is worse than one that fails loudly.
make checkpasses.TODO.mdupdated in the same commit.Implementation requirements
REPO_POLICIES.mdby fetching the authoritative copy, not byhand-editing the diff back. Verify byte-identity explicitly before
committing.
.golangci.ymlhandling here — it is not markdown and prettierdoes not touch it. But do add it to
.prettierignoreanyway if theprettier pass is widened beyond
*.md.prettier -w *.jsonon line 22 has the same|| trueproblem and thesame glob-only-root limitation; fix both invocations consistently.
*.mdglob only matches root-level files. Decide deliberately whethermarkdown in subdirectories (
docs/, once it exists) should be formatted,and make
fmtandfmt-checkagree on the answer.prettiermust be installed byscript/bootstrapfor any of this to workon a fresh clone — that is tracked in #68 and this issue depends on it.
If #68 has not landed, still make
script/fmt-checkfail loudly ratherthan skip.
(closes #69).Implementation plan
Branch
prettier-fmt-checkofforigin/main.Verified first:
REPO_POLICIES.mdonmainis already byte-identicalto the authoritative copy
(
sha256 117dde7f148ed3cd693b333312f6345a0a0ee84fadbbe5cca559ca6fed4a1775),so the drift on PR #59 never reached
main. The work here is to make itimpossible for
make fmtto churn it again, and byte-identity will bere-verified after
make fmtruns on the branch.1. Config files
.prettierrc:tabWidth: 4,proseWrap: "always"— the two policydeviations from prettier defaults, nothing else.
.prettierignore:REPO_POLICIES.md(verbatim upstream document,tooling must not rewrite it), plus
.golangci.yml(user-owned),node_modules/,vendor/,bin/.2. One canonical prettier file set, used by both fmt and fmt-check
New
script/prettierentrypoint takes--writeor--checkand appliesthe same patterns in both modes, so
script/fmtandscript/fmt-checkcannot drift apart by construction. Patterns:
**/*.md(recursive, sodocs/is covered when it exists — deliberate answer to theroot-glob-only question in the issue) and
**/*.json(tolerant of nomatch, since the repo currently has no tracked JSON; the markdown pattern
is not tolerant, so a broken glob fails loudly).
|| trueis gone from both invocations. If prettier cannot be found,script/prettierexits non-zero with an actionable message namingscript/bootstrap.3. Pinned prettier
package.json+yarn.lockpinning an exact prettier version; thelockfile carries the integrity hashes, so this is hash-pinned per policy
and identical in CI and on a dev box.
script/prettierprefersnode_modules/.bin/prettierand only falls back to aPATHprettier witha warning on stderr.
script/bootstrapgains node/yarn/yarn install(pinned
NODE_VERSION/YARN_VERSIONconstants already exist there).This is the prettier slice of #68 only; the rest of #68 (gofumpt,
hash-pinned Go tool installs) is deliberately left for #68.
4. The Docker gate — the actual hard part
The lint stage is
golangci/golangci-lint, and I confirmed by running itthat the image has no node, npm, or yarn (
command -v nodeexits127). So
script/fmt-checkcannot be hard-required there without breakingdocker build ..Resolution: the markdown check gets its own build stage on a node image
rather than being weakened.
script/fmt-check-go— the existing gofmt check, extracted. The lintstage runs this.
mdfmtstageFROM node@sha256:...(node 22.17.0 bookworm-slim,which ships node 22.17.0 and yarn 1.22.22 — exactly the versions
script/bootstrapalready pins), runsyarn install --frozen-lockfilethen
script/prettier --check. That image has nomake, so it callsthe
script/entrypoint directly.COPY --from=mdfmtdependency, the same trickalready used to force the lint stage to run, so BuildKit cannot skip it.
Net effect: a markdown formatting violation fails
docker build ., whichis the authoritative gate. Nothing silently skips anywhere.
script/fmt-check(and thereforemake checklocally) runs both halves:script/fmt-check-goandscript/prettier --check.5. Verification
make fmt, thengit diff --exit-code REPO_POLICIES.mdclean andsha256 still matching the authoritative copy.
make fmtthenmake fmt-checkclean.make checkfails, andconfirm
docker build .fails on themdfmtstage.make checkgreen,docker build .green.README.mdEntrypoints section andTODO.mdupdated in the samecommit;
.dockerignore/.gitignoregainnode_modules.Out of scope, not touched:
.golangci.yml(user-owned), the rest of #68,and the
ensure_pbduplication betweenscript/fmtandscript/fmt-check.