Files
yellowjacket/lefthook.yml
logan 7f8e185d7c build(frontend): fail css-check on a nested rule the phone drops
The device renders in Chrome 113, which predates relaxed CSS nesting, so
a nested rule whose selector starts with an element name is not a parse
error anyone would notice -- the rule simply does not exist, there and
nowhere else. Three were live in `index.css`, and the one that mattered
was the `text-overflow: ellipsis` on the bottom bar's title and artist,
which had therefore never truncated on the device. No tier here can see
the class at all: the component tier, the e2e tier and `make ui-visual`
all run a current engine, where the rule applies normally.

So `make css-check` carries a second script. It reads `index.css` and
the `css` literals in `src/**/*.ts` alike, since a shadow-root
stylesheet is parsed by the same engine, and it names the file, the line
and the fix -- a leading `&`, which is valid in both syntaxes.

The detection walks blocks rather than matching lines, and both things
it has to get right fall out of one rule: a rule is nested when a
*style* rule is somewhere above it, not when its immediate parent is a
block. That leaves `@media (...) { bottom-nav { ... } }` at the top
level alone, which is the majority of what a regex over the file would
report, and still flags the same rule inside an at-rule that is itself
inside a style rule. Strings and comments are read through, so a brace
in a `url()` is not a block.

The tree has no violation left, so the check would pass just as happily
over an empty glob: it refuses one, and `test/utils/css-nesting.test.ts`
pins the semantics that make the sweep mean something. The literal
scanner the two checks share is lifted into `css-literals.mjs`
unchanged, except that a `${}` substitution is now blanked keeping its
newlines so a line number survives it.

Closes #154
2026-08-21 15:16:47 +00:00

94 lines
3.3 KiB
YAML

# lefthook.yml — local git hooks for yellowjacket
# Install with: lefthook install
# Docs: https://github.com/evilmartians/lefthook
# Conventional Commits. CI runs the same script over every commit in a
# push, so skipping this locally only defers the failure.
commit-msg:
commands:
commit-check:
run: ./scripts/commit-check.sh {1}
pre-commit:
parallel: true
commands:
go-vet:
glob: "*.go"
run: go vet ./...
golangci-lint:
glob: "*.go"
run: go tool golangci-lint run --timeout 5m ./...
# Snapshots the tree either side of the generators and reports only
# what moved across them. This used to be `go generate` plus a bare
# `git diff --name-only`, which is the *whole unstaged worktree* — so
# any unrelated edit sitting there was reported as stale generated
# code, and `make generate` then fixed nothing. See the script.
codegen-check:
glob: "*.{go,sql,templ}"
run: ./scripts/codegen-check.sh
# frontend/bindings is generated by `wails3`, not `go generate`, so
# the check above does not cover it. ~3.5s warm, ~20s on a cold
# build cache: v3's generator is a static analyser over the whole
# package graph, where v2's built the app with a `bindings` tag and
# ran it.
bindings-check:
glob: "*.go"
run: ./scripts/bindings-check.sh
# .pi/ documents make targets; a stale one sends an agent off a
# cliff with total confidence. Instant.
skill-check:
glob: "{Makefile,.pi/**/*.md}"
run: ./scripts/skill-check.sh
frontend-typecheck:
glob: "frontend/**/*.{ts,tsx}"
root: "frontend/"
run: ./node_modules/.bin/tsc --noEmit
# A backtick in a comment inside a css`` literal ends the literal.
# tsc does catch it, as "Class static side incorrectly extends base
# class static side" pointing at a line of prose; this says what
# actually happened. Instant.
css-literals:
glob: "frontend/**/*.ts"
root: "frontend/"
run: node scripts/check-css-literals.mjs
# A nested rule whose selector starts with an element name is
# silently dropped by the device's Chrome 113, and by nothing else --
# so every tier here renders it correctly and only a screenshot of
# the phone disagrees. Instant.
css-nesting:
glob: "frontend/**/*.{ts,css}"
root: "frontend/"
run: node scripts/check-css-nesting.mjs
# Deliberately sequential, unlike pre-commit. `go test -race`
# saturates every core for the better part of a minute and the UI tier
# is a real browser with wall-clock timeouts, so run together the
# browser loses: setup took 106s inside the hook against 63s
# standalone, and a different suite failed each time -- three suites
# failing to fetch setup.ts from Vitest's own dev server on one run, a
# 15s "did not mount itself" on the next, against a suite that passes
# 898/898 on its own. A gate that fails at random is not a gate. The
# ~15s saved is not worth it.
pre-push:
parallel: false
commands:
go-test:
glob: "*.go"
run: go test -race -count=1 -timeout 120s ./...
go-mod-verify:
run: go mod verify
# The component and store tier: a real browser, no app. ~2s.
ui-test:
glob: "frontend/**/*.ts"
root: "frontend/"
run: ./node_modules/.bin/vitest run