|
| 1 | +# Pre-commit configuration using prek's built-in fast hooks |
| 2 | +# See https://github.com/j178/prek for more information |
| 3 | + |
| 4 | +repos: |
| 5 | + # Built-in Rust hooks (fast, zero-setup) |
| 6 | + - repo: builtin |
| 7 | + hooks: |
| 8 | + # Fix trailing whitespace (preserve markdown line breaks) |
| 9 | + - id: trailing-whitespace |
| 10 | + args: ['--markdown-linebreak-ext=md,markdown'] |
| 11 | + |
| 12 | + # Ensure files end with newline |
| 13 | + - id: end-of-file-fixer |
| 14 | + |
| 15 | + # Check for accidentally committed large files |
| 16 | + - id: check-added-large-files |
| 17 | + args: ['--maxkb=500'] |
| 18 | + |
| 19 | + # Validate YAML files |
| 20 | + - id: check-yaml |
| 21 | + |
| 22 | + # Validate TOML files |
| 23 | + - id: check-toml |
| 24 | + |
| 25 | + # Normalize line endings to LF |
| 26 | + - id: mixed-line-ending |
| 27 | + args: ['--fix=lf'] |
| 28 | + |
| 29 | + # Detect accidentally committed private keys |
| 30 | + - id: detect-private-key |
| 31 | + |
| 32 | + # Prevent direct commits to main/master |
| 33 | + - id: no-commit-to-branch |
| 34 | + args: ['--branch=main', '--branch=master'] |
| 35 | + |
| 36 | + # Detect merge conflict markers |
| 37 | + - id: check-merge-conflict |
| 38 | + |
| 39 | + # Check for case conflicts (macOS/Windows compatibility) |
| 40 | + - id: check-case-conflict |
| 41 | + |
| 42 | + # Remove UTF-8 byte order marker |
| 43 | + - id: fix-byte-order-marker |
| 44 | + |
| 45 | + # Local hooks using make commands |
| 46 | + - repo: local |
| 47 | + hooks: |
| 48 | + # Run linting via make |
| 49 | + - id: make-lint |
| 50 | + name: Run make lint |
| 51 | + entry: make lint |
| 52 | + language: system |
| 53 | + types: [python] |
| 54 | + pass_filenames: false |
| 55 | + stages: [pre-commit] |
| 56 | + |
| 57 | + # Run formatting via make |
| 58 | + - id: make-format |
| 59 | + name: Run make format |
| 60 | + entry: make format |
| 61 | + language: system |
| 62 | + pass_filenames: false |
| 63 | + stages: [pre-commit] |
| 64 | + |
| 65 | + # Commitizen for conventional commit validation |
| 66 | + - repo: https://github.com/commitizen-tools/commitizen |
| 67 | + rev: v4.2.0 |
| 68 | + hooks: |
| 69 | + - id: commitizen |
| 70 | + stages: [commit-msg] |
| 71 | + |
| 72 | +# Global configuration |
| 73 | +fail_fast: false |
| 74 | +default_stages: [pre-commit] |
0 commit comments