# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
      - id: check-yaml
      - id: check-added-large-files
        args: ["--maxkb=600"]
  - repo: https://github.com/Yelp/detect-secrets
    rev: v1.5.0
    hooks:
      - id: detect-secrets
        exclude: ^dbt/package-lock\.yml$|^qfdmo/migrations/fixtures/objets\.json$
        name: Detect secrets
        language: python
        entry: detect-secrets-hook
        args: ["--baseline", ".secrets.baseline"]
  - repo: local
    hooks:
      # Ruff hooks
      # Mirror https://github.com/astral-sh/ruff-pre-commit/blob/main/.pre-commit-hooks.yaml
      - id: ruff
        name: ruff (lint)
        entry: uv run ruff check --force-exclude
        language: python
        types: [python]
        args: [--fix]
      # Black hook
      # Mirrors https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml#L6
      - id: black
        name: black (format)
        entry: uv run black
        language: python
        types: [python]
      # Djade hook (webapp only — Django template tag rewriter)
      # Mirrors https://github.com/adamchainz/djade-pre-commit/blob/main/.pre-commit-hooks.yaml
      - id: djade
        name: djade
        entry: uv run djade
        language: python
        types: [python]
        files: ^webapp/
        args: [--target-version, "5.1"]
      # Prettier hook
      - id: prettier
        name: prettier
        entry: npx prettier --write
        language: system
        files: \.(js|ts|css|md)$
      # OpenTofu hooks
      - id: tofu_fmt
        name: tofu fmt
        entry: tofu fmt -recursive infrastructure
        language: system
        types: [hcl]
        pass_filenames: false
        exclude: \.lock\.hcl$
      - id: tofu_docs
        name: tofu docs
        entry: tofu fmt -recursive infrastructure
        language: system
        types: [hcl]
        pass_filenames: false
        exclude: \.lock\.hcl$
