Files
hyperframes/lefthook.yml
T
James Russo b6b7bcb51a ci: run fallow audit in lefthook pre-commit (#948)
Mirrors the same `fallow audit --base ... --fail-on-issues` check that
runs in CI, but locally against HEAD so issues surface at commit time
instead of after the push round-trip.

Scoped to `packages/**` source files via the glob — non-code edits
(README, docs, top-level configs) skip the hook entirely.

Measured locally: ~5s in parallel with the existing lint/format/typecheck
checks. Doesn't extend wall-clock time because typecheck (~11s) is the
long pole, and lefthook runs commands in parallel.

The default `--gate new-only` means inherited findings don't block the
commit — same gate behavior as CI, so local pre-commit and PR audit
agree.
2026-05-18 19:39:34 -07:00

44 lines
1.9 KiB
YAML

pre-commit:
parallel: true
commands:
lint:
glob: "*.{js,jsx,ts,tsx}"
run: bunx oxlint {staged_files}
format:
glob: "*.{js,jsx,ts,tsx,json,md,yaml,yml}"
# --no-error-on-unmatched-pattern: don't fail when staged files all
# fall under .prettierignore (e.g. docs-only changes to docs/docs.json).
run: bunx oxfmt --check --no-error-on-unmatched-pattern {staged_files}
typecheck:
glob: "*.{ts,tsx}"
run: cd packages/core && bunx tsc --noEmit && cd ../studio && bunx tsc --noEmit
# Mirrors the CI gate (same `--base origin/main` so the local hook can't
# pass on a branch CI would fail). Audits the working tree, which means
# unstaged WIP in `packages/**` is part of the diff — stash before
# committing if that surprises you. `--gate new-only` (the default) only
# fails on issues introduced by the branch, not inherited findings.
fallow:
glob: "packages/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"
run: bunx fallow audit --base origin/main --fail-on-issues
filesize:
# Scoped to packages/studio — the 500 LOC limit is a studio architecture
# standard enforced as part of the App.tsx decomposition work. Player and
# other packages enforce size discipline via code review and convention.
# Files temporarily over the limit are listed in .filesize-allowlist.
glob: "packages/studio/**/*.{ts,tsx}"
exclude: "(\\.test\\.(ts|tsx)$|\\.generated\\.)"
run: |
for f in {staged_files}; do
if grep -qxF "$f" .filesize-allowlist 2>/dev/null; then continue; fi
lines=$(wc -l < "$f")
if [ "$lines" -gt 500 ]; then
echo "ERROR: $f has $lines lines (max 500) — add to .filesize-allowlist if temporarily needed"
exit 1
fi
done
commit-msg:
commands:
commitlint:
run: bunx commitlint --edit "{1}"