.pre-commit-config.yaml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. exclude: ^(static/assets/|CHANGELOG\.md$)
  33. - id: check-merge-conflict
  34. - id: debug-statements
  35. - id: detect-private-key
  36. # Check for import shadowing (custom)
  37. - repo: local
  38. hooks:
  39. - id: check-import-shadowing
  40. name: Check for dangerous import shadowing
  41. entry: python -m pytest backend/tests/unit/test_code_quality.py::TestImportShadowing -v --tb=short
  42. language: system
  43. pass_filenames: false
  44. types: [python]
  45. files: ^backend/app/
  46. - id: frontend-typecheck
  47. name: TypeScript type check
  48. entry: bash -c 'cd frontend && npx tsc --noEmit'
  49. language: system
  50. pass_filenames: false
  51. files: ^frontend/src/
  52. types_or: [ts, tsx]