Files
trailofbits-buttercup/.pre-commit-config.yaml
Dan Guido 236083a9fe feat: add minimal pre-commit infrastructure
- Add pre-commit configuration with essential checks only
- Check YAML, TOML, JSON syntax
- Check for merge conflicts and large files
- Enforce LF line endings (fix 2 test files with CRLF)
- Add debug statement detection
- Integrate ruff for Python formatting and linting
- Add GitHub workflow for pre-commit CI
- No unnecessary Python code changes
2025-08-22 15:27:16 -04:00

53 lines
1.2 KiB
YAML

# Pre-commit hooks for Buttercup CRS
# See https://pre-commit.com for more information
repos:
# Standard file fixes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
args: [--allow-multiple-documents]
exclude: 'deployment/k8s/.*\.(yaml|yml)$'
- id: check-added-large-files
args: [--maxkb=1000]
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
- id: check-toml
- id: check-json
- id: debug-statements
# Ruff - Python linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
hooks:
# Run the formatter first
- id: ruff-format
types_or: [python, pyi]
# Then run the linter with auto-fix
- id: ruff
types_or: [python, pyi]
args: [--fix, --exit-non-zero-on-fix]
# Global exclusions for files that should never be checked
exclude: |
(?x)^(
external/.*|
.*\.pb\.py|
.*_pb2\.py|
.*_pb2_grpc\.py|
.*/\.venv/.*|
.*/\.mypy_cache/.*|
.*/\.ruff_cache/.*|
.*/\.pytest_cache/.*|
__pycache__/.*|
.*\.egg-info/.*
)$
# Configuration
fail_fast: false
ci:
autofix_prs: true
autoupdate_schedule: weekly