.pre-commit-config.yaml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Pre-commit hooks for BamBuddy
  2. # Install with: pip install pre-commit && pre-commit install
  3. repos:
  4. # Ruff - Fast Python linter and formatter
  5. - repo: https://github.com/astral-sh/ruff-pre-commit
  6. rev: v0.14.11
  7. hooks:
  8. # Linter
  9. - id: ruff
  10. args: [--fix, --exit-non-zero-on-fix]
  11. types_or: [python, pyi]
  12. # Formatter
  13. - id: ruff-format
  14. types_or: [python, pyi]
  15. # Standard pre-commit hooks
  16. - repo: https://github.com/pre-commit/pre-commit-hooks
  17. rev: v5.0.0
  18. hooks:
  19. - id: trailing-whitespace
  20. # Exclude static/ (build output) so whitespace normalisation
  21. # doesn't drift the files away from upstream.
  22. exclude: ^static/
  23. - id: end-of-file-fixer
  24. exclude: ^static/
  25. - id: check-yaml
  26. - id: check-json
  27. exclude: ^(static/|frontend/tsconfig\.)
  28. - id: check-added-large-files
  29. args: ['--maxkb=1000']
  30. # CHANGELOG.md is intentionally large (detailed per-release entries over
  31. # many versions); exempt it while keeping the 1 MB guard for everything else.
  32. #
  33. # backend/tests/.test_durations is ~1.5 MB and cannot be made smaller:
  34. # its 11703 pytest node IDs are 1160 kB of keys before a single duration
  35. # value is written, so no encoding fits under the guard (compact JSON
  36. # with 3-decimal values still measures 1263 kB). Pruning fast tests is
  37. # worse than useless -- pytest-split gives a test missing from the file
  38. # the AVERAGE of the entries that remain, so dropped 1 ms tests come back
  39. # weighted at ~89 ms and the balance it exists to provide degrades.
  40. # It compresses to ~314 kB in the object store. Regenerate with
  41. # --store-durations; see the backend test job in .github/workflows/ci.yml.
  42. exclude: ^(static/assets/|CHANGELOG\.md$|backend/tests/\.test_durations$)
  43. - id: check-merge-conflict
  44. - id: debug-statements
  45. - id: detect-private-key
  46. # Check for import shadowing (custom)
  47. - repo: local
  48. hooks:
  49. - id: check-import-shadowing
  50. name: Check for dangerous import shadowing
  51. entry: python -m pytest backend/tests/unit/test_code_quality.py::TestImportShadowing -v --tb=short
  52. language: system
  53. pass_filenames: false
  54. types: [python]
  55. files: ^backend/app/
  56. - id: frontend-typecheck
  57. name: TypeScript type check
  58. entry: bash -c 'cd frontend && npx tsc --noEmit'
  59. language: system
  60. pass_filenames: false
  61. files: ^frontend/src/
  62. types_or: [ts, tsx]