.pre-commit-config.yaml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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) and gcode_viewer/ (vendored third-party
  21. # assets — see gcode_viewer/VENDORED.md) so whitespace normalisation
  22. # doesn't drift the files away from upstream.
  23. exclude: ^(static/|gcode_viewer/)
  24. - id: end-of-file-fixer
  25. exclude: ^(static/|gcode_viewer/)
  26. - id: check-yaml
  27. - id: check-json
  28. exclude: ^(static/|frontend/tsconfig\.)
  29. - id: check-added-large-files
  30. args: ['--maxkb=1000']
  31. # CHANGELOG.md is intentionally large (detailed per-release entries over
  32. # many versions); exempt it while keeping the 1 MB guard for everything else.
  33. exclude: ^(static/assets/|CHANGELOG\.md$)
  34. - id: check-merge-conflict
  35. - id: debug-statements
  36. - id: detect-private-key
  37. # Check for import shadowing (custom)
  38. - repo: local
  39. hooks:
  40. - id: check-import-shadowing
  41. name: Check for dangerous import shadowing
  42. entry: python -m pytest backend/tests/unit/test_code_quality.py::TestImportShadowing -v --tb=short
  43. language: system
  44. pass_filenames: false
  45. types: [python]
  46. files: ^backend/app/
  47. - id: frontend-typecheck
  48. name: TypeScript type check
  49. entry: bash -c 'cd frontend && npx tsc --noEmit'
  50. language: system
  51. pass_filenames: false
  52. files: ^frontend/src/
  53. types_or: [ts, tsx]