-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
72 lines (66 loc) · 2.22 KB
/
.pre-commit-config.yaml
File metadata and controls
72 lines (66 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Pre-commit hooks configuration
# Install: pip install pre-commit && pre-commit install
# Run manually: pre-commit run --all-files
repos:
# General hooks
- 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
args: [--unsafe]
- id: check-json
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-merge-conflict
- id: detect-private-key
- id: mixed-line-ending
args: ['--fix=lf']
# Python - Ruff (fast linter and formatter)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
hooks:
- id: ruff
args: [--fix]
files: ^backend/
- id: ruff-format
files: ^backend/
# Backend - Ruff check (强制检查,不允许错误)
# 注意:此 hook 会检查整个 backend 目录,确保没有 lint 错误
- repo: local
hooks:
- id: backend-ruff-check
name: Backend Ruff Check (strict)
entry: bash -c 'cd backend && .venv/bin/ruff check . || exit 1'
language: system
files: ^backend/.*\.py$
pass_filenames: false
always_run: false # 只在有 Python 文件更改时运行
stages: [commit]
# Python - Type checking (mypy runs in Backend CI job only; skipped in pre-commit)
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.13.0
# hooks:
# - id: mypy
# files: ^backend/app/
# args: [--ignore-missing-imports]
# additional_dependencies:
# - types-requests
# - types-PyYAML
# Frontend - ESLint (强制检查,不允许错误)
# 注意:此 hook 会检查整个 frontend 目录,确保没有 lint 错误
- repo: local
hooks:
- id: frontend-lint
name: Frontend ESLint
entry: bash -c 'cd frontend && pnpm run lint || exit 1'
language: system
files: ^frontend/.*\.(ts|tsx|js|jsx)$
pass_filenames: false
always_run: false # 只在有前端文件更改时运行
stages: [commit]
# CI configuration
ci:
autofix_commit_msg: 'style: auto-fix by pre-commit hooks'
autoupdate_commit_msg: 'chore: update pre-commit hooks'