forked from a2aproject/a2a-inspector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
68 lines (65 loc) · 3.27 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
68 lines (65 loc) · 3.27 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
repos:
# ===============================================
# Pre-commit standard hooks (general file cleanup)
# ===============================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 # Use the latest stable version
hooks:
- id: trailing-whitespace # Removes extra whitespace at the end of lines
- id: end-of-file-fixer # Ensures files end with a newline
- id: check-yaml # Checks YAML file syntax (e.g., uv.lock)
- id: check-toml # Checks TOML file syntax (e.g., pyproject.toml)
- id: check-added-large-files # Prevents committing large files
args: ['--maxkb=500'] # Example: Limit to 500KB
- id: check-merge-conflict # Checks for merge conflict strings
- id: detect-private-key # Detects accidental private key commits
# ===============================================
# Python Hooks (aligning with noxfile.py where practical)
# ===============================================
# Pyupgrade for upgrading Python syntax to newer versions
- repo: https://github.com/asottile/pyupgrade
rev: v3.11.0 # Use a specific version for stability
hooks:
- id: pyupgrade
args: ["--py310-plus"] # Target Python 3.10 syntax, matching project's target
# Autoflake for removing unused imports and variables
- repo: https://github.com/pycqa/autoflake
rev: v2.3.1 # Use a specific version for stability
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"] # Match noxfile.py configuration
# Ruff for powerful linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8 # Use the latest stable Ruff version
hooks:
- id: ruff # Linter: applies auto-fixable linting rules
args: [ "--fix", "--exit-zero" ] # Apply fixes, and exit with 0 even if files were modified
- id: ruff-format # Formatter: similar to Black, handles consistent code style
args: [ "--check" ] # Check formatting, but do not auto-fix during commit; fail if not formatted
# TypeScript type checking (runs `tsc --noEmit` to catch type errors)
# This hook leverages pre-commit's Node.js environment management.
- repo: local
hooks:
- id: tsc-check
name: TypeScript Type Check
entry: tsc --noEmit
language: node
# Add TypeScript as a dependency for the hook's Node.js environment
# Use the same version or compatible range as in frontend/package.json
additional_dependencies: ['typescript@^5.4.5']
# Specify the tsconfig.json file for the project context
args: ['--project', 'frontend/tsconfig.json']
# Only run on TypeScript files within the frontend directory
files: '^frontend/.*\.ts$'
# Do not pass individual filenames, `tsc --project` handles the whole project
pass_filenames: false
# Frontend linting and formatting using Google TypeScript Style (gts)
- repo: local
hooks:
- id: frontend-gts-fix
name: frontend-gts-fix
description: "Runs 'gts fix' to lint and format frontend files. Requires 'npm install' in /frontend."
entry: npm run --prefix frontend fix
language: node
files: ^frontend/.*\.(ts|js)$
pass_filenames: false