mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-11 14:07:46 +01:00
Some checks are pending
crdt-sync pre-commit / pre-commit (push) Waiting to run
crdt-sync tests / test (3.10) (push) Waiting to run
crdt-sync tests / test (3.11) (push) Waiting to run
crdt-sync tests / test (3.12) (push) Waiting to run
design_system tests / test (push) Waiting to run
gatelock pre-commit / pre-commit (push) Waiting to run
gatelock tests / test (3.10) (push) Waiting to run
gatelock tests / test (3.11) (push) Waiting to run
gatelock tests / test (3.12) (push) Waiting to run
palette drift / palette (push) Waiting to run
sync_settings_ui tests / test (push) Waiting to run
web_ui tests / test (push) Waiting to run
A refactor without a gate silently regrows, so this is the part that makes the
cap stick. Until now the repo had no root .pre-commit-config.yaml at all --
`git commit` ran zero hooks, and the five subproject configs only covered their
own directories.
Adds a root config wiring scripts/check_file_length.sh as a local hook, and
carries the same hook in each of the five subproject configs so committing
with one of those is gated too. Staged files only, so an unrelated commit
never breaks on a violation it did not introduce; exit 1, not a warning; no
baseline and no allowlist, since those are suppressions.
Verified in a throwaway worktree, both directions:
- a staged 261-line file fails the commit (exit 1, HEAD unchanged, no
commit object created)
- a staged 200-line file commits normally (exit 0)
The 44 files still over the cap cannot block this: the hook only ever sees
what a commit touches.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
77 lines
2.9 KiB
YAML
77 lines
2.9 KiB
YAML
# Pre-commit Configuration for web_ui
|
|
# Install: pre-commit install && pre-commit install --hook-type pre-push
|
|
# Run: pre-commit run --config web_ui/.pre-commit-config.yaml --all-files
|
|
|
|
# NOTE: this subproject lives inside the ~/utils monorepo, whose git root is
|
|
# one level up. pre-commit always runs hooks from the git root, so every path
|
|
# below is written relative to THAT, not to this directory, and the top-level
|
|
# `files` key keeps these hooks off the sibling subprojects. CI invokes this
|
|
# config exactly the same way. Mirrors design_system/.pre-commit-config.yaml.
|
|
files: ^web_ui/
|
|
# dist/ is generated by tsc and committed for consumers. The whitespace hooks
|
|
# would "fix" it, the next build would revert them, and the dist-fresh hook
|
|
# would fail forever -- so formatting hooks must not see it.
|
|
exclude: ^web_ui/dist/
|
|
|
|
default_stages: [pre-commit]
|
|
fail_fast: false
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.6.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
args: [--markdown-linebreak-ext=md]
|
|
- id: end-of-file-fixer
|
|
- id: check-yaml
|
|
- id: check-json
|
|
# tsconfig*.json are JSONC -- TypeScript allows comments, and this file
|
|
# uses them to explain why the lint config exists. package.json and the
|
|
# lockfile are the real JSON worth validating.
|
|
exclude: ^web_ui/tsconfig.*\.json$
|
|
- id: check-merge-conflict
|
|
- id: mixed-line-ending
|
|
args: [--fix=lf]
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: file-length-cap
|
|
name: file length <= 250 lines
|
|
entry: bash /home/kuhy/utils/scripts/check_file_length.sh
|
|
language: system
|
|
pass_filenames: true
|
|
- id: subproject-scope
|
|
name: subproject scope regex still matches
|
|
entry: scripts/check_subproject_scope.sh web_ui
|
|
language: script
|
|
# always_run so the top-level `files` filter cannot skip the one hook
|
|
# whose job is to notice that filter has stopped matching anything.
|
|
always_run: true
|
|
pass_filenames: false
|
|
|
|
- id: web-ui-lint
|
|
name: tsc --noEmit && eslint
|
|
entry: bash -c 'cd web_ui && pnpm lint'
|
|
language: system
|
|
pass_filenames: false
|
|
|
|
- id: web-ui-dist-fresh
|
|
name: committed dist/ matches src/
|
|
# The tag ships a prebuilt dist/ (Vite does not transpile deps), so a
|
|
# stale dist/ ships old code to every consumer with no error anywhere.
|
|
entry: >-
|
|
bash -c 'cd web_ui && pnpm build &&
|
|
git diff --exit-code -- dist ||
|
|
{ echo "dist/ is stale -- pnpm build in web_ui and commit it"; exit 1; }'
|
|
language: system
|
|
pass_filenames: false
|
|
require_serial: true
|
|
|
|
- id: web-ui-test-coverage
|
|
name: vitest with the 100% coverage gate
|
|
entry: bash -c 'cd web_ui && pnpm coverage'
|
|
language: system
|
|
pass_filenames: false
|
|
require_serial: true
|
|
stages: [pre-push]
|