forked from HKUDS/DeepTutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
105 lines (91 loc) · 3.59 KB
/
.pre-commit-config.yaml
File metadata and controls
105 lines (91 loc) · 3.59 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Pre-commit hooks configuration for AI-Tutor project
# This configuration ensures code quality and consistency across the team
#
# Installation:
# pip install pre-commit
# pre-commit install
#
# Usage:
# pre-commit run --all-files # Run on all files
# git commit # Hooks run automatically on commit
repos:
# ============================================
# General file checks
# ============================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# Remove trailing whitespace
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: ^(.*\.min\.(js|css)|.*\.lock|.*\.log|.*\.pdf|.*\.zip|.*\.tar\.gz)
# Ensure files end with a newline
- id: end-of-file-fixer
exclude: ^(.*\.min\.(js|css)|.*\.lock|.*\.log|.*\.pdf|.*\.zip|.*\.tar\.gz)
# Check YAML files for syntax errors
- id: check-yaml
args: [--unsafe] # Allow custom tags in YAML
# Check JSON files for syntax errors
- id: check-json
exclude: ^(.*\.lock|.*\.log)
# Prevent committing large files
- id: check-added-large-files
args: [--maxkb=6144]
# Detect merge conflict markers
- id: check-merge-conflict
# Detect case conflicts in file names
- id: check-case-conflict
# Check for files that would conflict in case-insensitive filesystems
- id: check-toml
# ============================================
# Python code formatting and linting
# ============================================
# Note: 使用 ruff format 替代 black,避免格式化工具冲突
# ruff format 更快且与 ruff linter 配合更好
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.7
hooks:
# Ruff linting (只自动修复,不阻止提交)
- id: ruff
args: [--fix, --exit-zero]
files: ^(src/|scripts/).*\.py$
# --exit-zero: 即使有错误也不阻止提交,只自动修复
# Ruff import sorting (replaces isort)
- id: ruff-format
files: ^(src/|scripts/).*\.py$
# Note: python-check-docstring-first hook removed as it's not available
# Ruff already handles most code quality checks including import ordering
# ============================================
# Frontend code formatting and linting
# ============================================
# Note: ESLint 暂时禁用,因为 Next.js 项目通常有自己的 ESLint 配置
# 如果需要启用,可以取消下面的注释并配置 ESLint
# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v10.0.0-alpha.1
# hooks:
# - id: eslint
# files: ^web/.*\.(js|jsx|ts|tsx)$
# exclude: ^web/(node_modules|\.next|out|dist|build)/
# additional_dependencies:
# - eslint@^8.57.0
# - '@typescript-eslint/parser@^6.0.0'
# - '@typescript-eslint/eslint-plugin@^6.0.0'
# - eslint-config-next@14.0.3
# args: [--fix]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: ^web/.*\.(css|scss|json|jsonc|yaml|yml|md|graphql|html|ts|tsx|js|jsx)$
exclude: ^web/(node_modules|\.next|out|dist|build)/
# ============================================
# Security checks
# ============================================
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: package-lock.json
# Only scan staged files for performance
pass_filenames: false