# Local pre-commit hooks. Install once with:
#   pip install pre-commit
#   pre-commit install
#
# After install: every `git commit` runs these checks against staged files.
# Failures abort the commit.

repos:
  # Generic hygiene
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
        exclude: ^backend/alembic/script.py.mako$
      - id: check-toml
      - id: check-added-large-files
        args: ["--maxkb=512"]
      - id: check-merge-conflict
      - id: detect-private-key

  # Python — ruff (lint + format) on backend/ + tradein-mvp/backend/
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.7.4
    hooks:
      - id: ruff
        args: [--fix]
        files: ^(backend|tradein-mvp/backend)/
      - id: ruff-format
        files: ^(backend|tradein-mvp/backend)/

  # Frontend — prettier on TS/TSX/JSON
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v4.0.0-alpha.8
    hooks:
      - id: prettier
        files: ^frontend/.*\.(ts|tsx|js|jsx|json|css|md)$
        exclude: ^frontend/(node_modules|\.next|package-lock\.json)/
