Files
scaffold/template/.pre-commit-config.yaml.jinja
T
baozaotumao 4c7dbb56eb fix: pre-commit 任务容错 + gitleaks 钩子 + pnpm 构建门禁
- _tasks 的 pre-commit install 改为容错:未装时跳过而非让 copier 失败
- .pre-commit-config 增加 gitleaks 钩子(git-workflow/security 规则均已声明)
- 新增 frontend/pnpm-workspace.yaml 的 allowBuilds: esbuild,解决 pnpm 11
  ERR_PNPM_IGNORED_BUILDS 致 install 非零退出而中断生成的问题

端到端验证:copier 退出 0,git/uv.lock/pnpm-lock/node_modules 齐全,
verify.sh 零失败。
2026-06-01 21:38:12 -07:00

74 lines
1.8 KiB
Django/Jinja
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 提交前自动跑的质量门禁。安装:pre-commit install
# 手动全量:pre-commit run --all-files
repos:
# 通用
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
# 密钥扫描(防密钥误入库,配合 detect-private-key
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
# 提交信息规范(Conventional Commits
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
{%- if include_backend or include_agent %}
# Pythonruff 同时做 lint + format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
{%- endif %}
{%- if include_backend %}
- repo: local
hooks:
- id: mypy-backend
name: mypy (backend)
entry: bash -c 'cd backend && uv run mypy src'
language: system
files: ^backend/.*\.py$
pass_filenames: false
{%- endif %}
{%- if include_agent %}
- repo: local
hooks:
- id: mypy-agent
name: mypy (agent)
entry: bash -c 'cd agent && uv run mypy src'
language: system
files: ^agent/.*\.py$
pass_filenames: false
{%- endif %}
{%- if include_frontend %}
# 前端:lint + 类型检查
- repo: local
hooks:
- id: frontend-lint
name: eslint + tsc (frontend)
entry: bash -c 'cd frontend && pnpm lint && pnpm typecheck'
language: system
files: ^frontend/.*\.(ts|tsx)$
pass_filenames: false
{%- endif %}