| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # Pre-commit hooks for BamBuddy
- # Install with: pip install pre-commit && pre-commit install
- repos:
- # Ruff - Fast Python linter and formatter
- - repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.14.11
- hooks:
- # Linter
- - id: ruff
- args: [--fix, --exit-non-zero-on-fix]
- types_or: [python, pyi]
- # Formatter
- - id: ruff-format
- types_or: [python, pyi]
- # Standard pre-commit hooks
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v5.0.0
- hooks:
- - id: trailing-whitespace
- # Exclude static/ (build output) so whitespace normalisation
- # doesn't drift the files away from upstream.
- exclude: ^static/
- - id: end-of-file-fixer
- exclude: ^static/
- - id: check-yaml
- - id: check-json
- exclude: ^(static/|frontend/tsconfig\.)
- - id: check-added-large-files
- args: ['--maxkb=1000']
- # CHANGELOG.md is intentionally large (detailed per-release entries over
- # many versions); exempt it while keeping the 1 MB guard for everything else.
- #
- # backend/tests/.test_durations is ~1.5 MB and cannot be made smaller:
- # its 11703 pytest node IDs are 1160 kB of keys before a single duration
- # value is written, so no encoding fits under the guard (compact JSON
- # with 3-decimal values still measures 1263 kB). Pruning fast tests is
- # worse than useless -- pytest-split gives a test missing from the file
- # the AVERAGE of the entries that remain, so dropped 1 ms tests come back
- # weighted at ~89 ms and the balance it exists to provide degrades.
- # It compresses to ~314 kB in the object store. Regenerate with
- # --store-durations; see the backend test job in .github/workflows/ci.yml.
- exclude: ^(static/assets/|CHANGELOG\.md$|backend/tests/\.test_durations$)
- - id: check-merge-conflict
- - id: debug-statements
- - id: detect-private-key
- # Check for import shadowing (custom)
- - repo: local
- hooks:
- - id: check-import-shadowing
- name: Check for dangerous import shadowing
- entry: python -m pytest backend/tests/unit/test_code_quality.py::TestImportShadowing -v --tb=short
- language: system
- pass_filenames: false
- types: [python]
- files: ^backend/app/
- - id: frontend-typecheck
- name: TypeScript type check
- entry: bash -c 'cd frontend && npx tsc --noEmit'
- language: system
- pass_filenames: false
- files: ^frontend/src/
- types_or: [ts, tsx]
|