# Apply to all files without committing:
#   pre-commit run --all-files
# Update this file:
#   pre-commit autoupdate

# Set the default language versions for the hooks
default_language_version:
  python: python3  # Force all Python hooks to use Python 3
  node: 22.12.0  # Force all Node hooks to use Node 22.12.0

# Globally exclude files
# https://pre-commit.com/#top_level-exclude
exclude: |
  (?x)(
    LICENSE|
    allianceauth\/static\/allianceauth\/css\/themes\/bootstrap-locals.less|
    \.min\.css|
    \.min\.js|
    \.po|
    \.mo|
    swagger\.json|
    static/(.*)/libs/
  )

repos:
  # Code Upgrades
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.20.0
    hooks:
      - id: pyupgrade
        args: [--py38-plus]
  - repo: https://github.com/adamchainz/django-upgrade
    rev: 1.25.0
    hooks:
      - id: django-upgrade
        args: [--target-version=4.2]

  # Formatting
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      # Identify invalid files
      - id: check-ast
      - id: check-yaml
      - id: check-json
      - id: check-toml
      - id: check-xml
      # git checks
      - id: check-merge-conflict
      - id: check-added-large-files
        args: [--maxkb=1000]
      - id: detect-private-key
      - id: check-case-conflict
      # Python checks
#      - id: check-docstring-first
      - id: debug-statements
#      - id: requirements-txt-fixer
      - id: fix-encoding-pragma
        args: [--remove]
      - id: fix-byte-order-marker
      # General quality checks
      - id: mixed-line-ending
        args: [--fix=lf]
      - id: trailing-whitespace
        args: [--markdown-linebreak-ext=md]
      - id: check-executables-have-shebangs
      - id: end-of-file-fixer
  - repo: https://github.com/editorconfig-checker/editorconfig-checker.python
    rev: 3.2.1
    hooks:
      - id: editorconfig-checker
  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.45.0
    hooks:
      - id: markdownlint
        language: node
        args:
          - --disable=MD013
  # Infrastructure
  - repo: https://github.com/tox-dev/pyproject-fmt
    rev: v2.6.0
    hooks:
      - id: pyproject-fmt
        name: pyproject.toml formatter
        description: "Format the pyproject.toml file."
        args:
          - --indent=4
        additional_dependencies:
          - tox==4.24.1 # https://github.com/tox-dev/tox/releases/latest
  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.24.1
    hooks:
      - id: validate-pyproject
        name: Validate pyproject.toml
        description: "Validate the pyproject.toml file."
