Files
kandev/.pre-commit-config.yaml
T
2026-08-01 23:14:50 +01:00

65 lines
2.6 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
# 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; base=$(git merge-base HEAD origin/main 2>/dev/null || git rev-parse HEAD); 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