Files
kandev/.pre-commit-config.yaml
T
2026-08-12 11:13:25 +01:00

81 lines
3.2 KiB
YAML

repos:
# Commit message validation (Conventional Commits via commitlint)
- repo: local
hooks:
- id: commitlint
name: Validate commit message (Conventional Commits)
entry: bash -c 'cd apps && pnpm exec commitlint --edit "$1"' --
language: system
stages: [commit-msg]
always_run: true
# Harness guidance hooks
- repo: local
hooks:
- id: harness-lint
name: Harness file lint
entry: python3 .github/scripts/lint-harness-files.py
language: system
pass_filenames: true
- id: architecture-lint
name: Architecture lint and compatibility expiry
entry: python3 scripts/lint-architecture.py --all
language: system
pass_filenames: false
# Backend (Go) hooks
- repo: local
hooks:
- id: gofmt
name: gofmt (backend)
entry: bash -c 'gofmt -w "$@"' --
language: system
files: ^apps/backend/.*\.go$
pass_filenames: true
- id: go-lint
name: Go lint (PR changed code)
entry: bash -c 'unset GIT_DIR GIT_WORK_TREE; merge_head=$(git rev-parse --verify MERGE_HEAD 2>/dev/null || true); base_tip=$(git rev-parse --verify origin/main 2>/dev/null || true); if [[ -n "$merge_head" && "$merge_head" == "$base_tip" ]]; then base="$merge_head"; else base=$(git merge-base HEAD origin/main 2>/dev/null || git rev-parse HEAD); fi; cd apps/backend && golangci-lint run ./... --new-from-rev="$base" --timeout=5m'
language: system
files: ^apps/backend/.*\.go$
pass_filenames: false
# Web app (TypeScript/React) hooks
- repo: local
hooks:
- id: prettier-format
name: Prettier format (web/cli/packages)
entry: bash -c 'cd apps || exit 1; args=(); for f in "$@"; do args+=("${f#apps/}"); done; pnpm exec prettier --write --ignore-unknown "${args[@]}"' --
language: system
files: ^apps/(web|cli|packages)/.*\.(ts|tsx|js|jsx|mjs|cjs|json|md|mdx|yml|yaml|css|scss)$
pass_filenames: true
- id: web-lint
name: Web lint (changed files only)
entry: bash -c 'cd apps/web || exit 1; args=(); for f in "$@"; do args+=("${f#apps/web/}"); done; pnpm exec eslint --max-warnings 0 "${args[@]}"' --
language: system
files: ^apps/web/.*\.(ts|tsx|js|jsx)$
pass_filenames: true
# New user-facing copy must go through t()/<Trans>, even in a directory the
# i18n migration has not reached. Judges the change, not the file: added
# files whole, modified files only on touched lines — so it never asks you
# to migrate code you did not write. Mirrors the go-lint hook above.
- id: i18n-new-code
name: i18n guard (new code only)
entry: bash -c 'unset GIT_DIR GIT_WORK_TREE; cd apps/web && node scripts/check-new-code-i18n.mjs && node scripts/check-guard-allowlist.mjs'
language: system
files: ^apps/web/(components|app|hooks|lib|src)/.*\.tsx?$|^apps/web/eslint\.i18n\.options\.mjs$
pass_filenames: false
# Public copy hooks
- repo: local
hooks:
- id: public-copy-em-dash
name: Public copy em-dash guard
entry: node apps/web/scripts/check-no-em-dash-ui.mjs
language: system
pass_filenames: false
always_run: true