Format the Markdown with prettier in make fmt and make fmt-check (closes #215)

make fmt and make fmt-check covered only Go, so Markdown formatting was
checked by eye. prettier, pinned in package.json and yarn.lock beside
ESLint and installed by the same js-deps stage, now formats every
Markdown file with the settings in .prettierrc (4-space tabs, prose
wrapped). It runs only in Docker: make fmt writes the formatted files
back from the markdown-output stage, and make fmt-check and the image
build run the markdown-check stage. The Dockerfile's lint stage now
runs the gofmt check itself, since make fmt-check needs a docker daemon.

Model: opus-5-5
This commit is contained in:
2026-10-03 04:08:38 +00:00
committed by sneak
parent 7e779f7fce
commit 1a8fe557ff
12 changed files with 103 additions and 53 deletions
+40 -26
View File
@@ -19,16 +19,16 @@ before deploying one.
### Prerequisites
- Go 1.26.1+ (the version in `go.mod`)
- Docker (for `make lint` and `make css`, and so for `make check`, for the
browser test in `make test-browser`, for the CI gate, and for
containerized deployment)
- Docker (for `make lint`, `make fmt` and `make css`, and so for
`make check`, for the browser test in `make test-browser`, for the CI
gate, and for containerized deployment)
golangci-lint is not a prerequisite and must not be installed on the
host: `script/bootstrap` does not install it, and `make lint` runs the
digest-pinned linter image via `Dockerfile.lint`. The same holds for
tailwindcss (see [Stylesheet](#stylesheet)). ESLint, node and yarn are
not prerequisites either, and `make lint` never uses a host copy of them
(see [Linting](#linting)).
tailwindcss (see [Stylesheet](#stylesheet)). ESLint, prettier, node and
yarn are not prerequisites either, and `make lint` and `make fmt` never
use a host copy of them (see [Linting](#linting)).
### Quick Start
@@ -58,8 +58,8 @@ make docker
make bootstrap # Install all dependencies (idempotent)
make setup # Bootstrap + install git pre-commit hook
make assets # Extract Alpine.js from 3p/ (test, check, build, dev run it)
make fmt # Format code (gofmt + goimports)
make fmt-check # Fail if gofmt would change anything (writes nothing)
make fmt # Format Go (gofmt + goimports) and Markdown (prettier, in Docker)
make fmt-check # Fail if gofmt or prettier would change anything (writes nothing)
make lint # Run golangci-lint and ESLint in Docker
make test # Run tests with race detection
make test-browser # Run the browser test in Docker (Dockerfile.browser)
@@ -1325,7 +1325,8 @@ We provide:
[Third-party browser assets](#third-party-browser-assets))
- `script/lint` — run golangci-lint and ESLint in Docker (see Linting
below)
- `script/fmt` — format all code (writes)
- `script/fmt` — format the Go code and, in Docker, the Markdown
(writes)
- `script/fmt-check` — check formatting (read-only)
- `script/css` — regenerate `static/css/tailwind.css` in Docker (writes;
see [Stylesheet](#stylesheet))
@@ -3256,13 +3257,14 @@ webhooker/
│ └── js/alpine.min.js # Alpine.js CSP build, extracted from 3p/ by make assets, not committed
├── templates/ # Go HTML templates (base, login, sources, etc.)
├── script/ # Scripts to Rule Them All entrypoints
├── Dockerfile # Stages: lint, stylesheet, JavaScript lint, test+build, Alpine runtime
├── Dockerfile # Stages: lint, stylesheet, JavaScript lint, Markdown, test+build, Alpine runtime
├── Dockerfile.lint # Lint-only image built by script/lint
├── Dockerfile.browser # Browser test image built by script/test-browser
├── Makefile # 13 of 19 targets shim script/; 6 are inline
├── go.mod / go.sum
├── package.json / yarn.lock # ESLint, pinned, for the JavaScript lint stage
├── package.json / yarn.lock # ESLint and prettier, pinned, for the JavaScript lint and Markdown stages
├── eslint.config.mjs # ESLint configuration for static/js/
├── .prettierrc # prettier settings for the Markdown
└── .golangci.yml # golangci-lint configuration
```
@@ -3587,6 +3589,14 @@ summary line to look for; it names the stage once for both `--target`
and `--no-cache-filter`, and `--target` fails on a name that matches no
stage.
prettier formats the Markdown, and it never runs on the host either. It
is pinned in `package.json` and `yarn.lock` beside ESLint, installed by
the same `js-deps` stage, and reads its settings from `.prettierrc`.
`make fmt` builds the `markdown-output` stage and writes the formatted
files back into the tree; `make fmt-check` and the image build run the
`markdown-check` stage, which fails on any Markdown file prettier would
change.
### Docker
The Dockerfile uses a multi-stage build. Each stage is pinned by
@@ -3594,8 +3604,8 @@ digest, and the lint and builder stages are separate images so the
linter's version is fixed independently of the compiler's:
1. **Lint stage** (`golangci/golangci-lint:v2.12.2`, Debian-based) —
installs `make`, downloads dependencies, copies the source, and runs
`make fmt-check`, then `script/assets` to extract Alpine.js from
downloads dependencies, copies the source, and runs the `gofmt`
check, then `script/assets` to extract Alpine.js from
`3p/`, then `golangci-lint config verify` and `golangci-lint run`,
both with `--network=none`.
2. **Stylesheet stages** (`debian:bookworm-slim`, with the Tailwind
@@ -3606,11 +3616,14 @@ linter's version is fixed independently of the compiler's:
one, and `make css` writes the generated file out from `css-output`
(see [Stylesheet](#stylesheet)).
3. **JavaScript lint stages** (`node:24.21.0-alpine`, with yarn) —
`js-deps` installs ESLint from `yarn.lock` and `js-lint` runs it over
`static/js/` (see [Linting](#linting)).
4. **Builder stage** (`golang:1.26.1-bookworm`) — depends on the lint,
`css-check` and `js-lint` stages passing (it copies a file from
each), runs
`js-deps` installs ESLint and prettier from `yarn.lock` and `js-lint`
runs ESLint over `static/js/` (see [Linting](#linting)).
4. **Markdown stages** (on `js-deps`) — `markdown-check` runs prettier
over the Markdown and fails on any file it would change, and
`make fmt` writes the formatted files out from `markdown-output`.
5. **Builder stage** (`golang:1.26.1-bookworm`) — depends on the lint,
`css-check`, `js-lint` and `markdown-check` stages passing (it copies
a file from each), runs
`make test` and `make build` (both extract Alpine.js from `3p/`
first), and finally
rebuilds the binary with `CGO_ENABLED=1` and static linking so it
@@ -3620,7 +3633,7 @@ linter's version is fixed independently of the compiler's:
given, otherwise derived from the `.git` in the context, and the
stage fails if a context with `.git` would stamp `unknown` (see
[Version stamping](#version-stamping)).
5. **Runtime stage** (`alpine:3.21`) — copies the static binary and
6. **Runtime stage** (`alpine:3.21`) — copies the static binary and
`deploy/docker-entrypoint.sh`, creates the `/var/lib/webhooker`
directory for all SQLite databases, exposes port 8080, and includes
a health check against `/.well-known/healthcheck`. It sets no
@@ -3628,9 +3641,10 @@ linter's version is fixed independently of the compiler's:
directory's owner and mode, and runs the app as the non-root
`webhooker` user (UID 1000) through `su-exec`.
The lint stage invokes `golangci-lint` directly rather than `make lint`:
it is already the pinned linter image, and `make lint` builds
`Dockerfile.lint`, which would need a docker daemon inside this build.
The lint stage invokes `gofmt` and `golangci-lint` directly rather than
`make fmt-check` and `make lint`: it is already the pinned linter image,
and both targets build docker stages, which would need a docker daemon
inside this build.
The lint and builder stages use Debian rather than Alpine because
`gorm.io/driver/sqlite` pulls in `mattn/go-sqlite3`, which needs CGO
@@ -3643,8 +3657,8 @@ linted, tested and compiled, with a current stylesheet. `script/lint`
also uses Docker (`Dockerfile.lint` and the `js-lint` stage, see Linting
above), so `make lint` and `make check` run the same pinned linter
versions the gate does; of
the steps `make check` runs, only `script/test` and `script/fmt-check`
run on the host.
the steps `make check` runs, only `script/test` and the `gofmt` check in
`script/fmt-check` run on the host.
#### CI gate honesty
@@ -3655,8 +3669,8 @@ check meaningless. The `check` workflow therefore writes
the hash of the commit being checked, so every commit, docs-only ones
and a squash merge whose tree matches an already-built branch included,
gets a new fingerprint, invalidates the `COPY . .` layer of every check
stage, and really runs `make fmt-check`, `golangci-lint`, the stylesheet
check, ESLint, `make test`, and `make build`. A run that reports success
stage, and really runs the `gofmt` check, `golangci-lint`, the stylesheet
check, ESLint, the Markdown check, `make test`, and `make build`. A run that reports success
ran them.
The module download layer sits above `COPY . .` and stays cached.