# To enable this pre-commit hook run:
# `pip install pre-commit` or `brew install pre-commit`
# Then run `pre-commit install`

# Learn more about this config here: https://pre-commit.com/
default_language_version:
  python: python3.12

ci:
  submodules: true

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: check-toml
      - id: check-yaml
      - id: detect-private-key
      - id: end-of-file-fixer
        types_or: [python]
      - id: mixed-line-ending
        args:
          - --fix=lf
      - id: requirements-txt-fixer
      - id: trailing-whitespace
        args:
          - --markdown-linebreak-ext=md

  - repo: https://github.com/MarcoGorelli/auto-walrus
    rev: 0.3.4
    hooks:
      - id: auto-walrus

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.6.7
    hooks:
      - id: ruff

  - repo: https://github.com/psf/black
    rev: 24.8.0
    hooks:
      - id: black  # See pyproject.toml for args

  - repo: https://github.com/codespell-project/codespell
    rev: v2.3.0
    hooks:
      - id: codespell  # See pyproject.toml for args
        additional_dependencies:
          - tomli
        args: ["--skip", "*.mjs"]

  - repo: https://github.com/MarcoGorelli/cython-lint
    rev: v0.16.2
    hooks:
    - id: cython-lint

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy  # See pyproject.toml for args
        additional_dependencies:
          - types-PyYAML
          - types-aiofiles
          - types-python-dateutil
          - types-requests
          - types-simplejson

  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.19
    hooks:
      - id: validate-pyproject

  - repo: https://github.com/pre-commit/mirrors-eslint
    rev: v9.11.0
    hooks:
      - id: eslint
        types: [file]
        types_or: [javascript, vue]
        additional_dependencies:
          - eslint@8.49.0
          - eslint-plugin-no-jquery@2.6.0
          - eslint-plugin-vue@9.17.0
          - "@babel/eslint-parser@7.22.15"
          - "@babel/plugin-syntax-dynamic-import@7.8.3"
          - "@babel/preset-env@7.22.20"
        args: [--fix]

  - repo: https://github.com/awebdeveloper/pre-commit-stylelint
    rev: 0.0.2
    hooks:
    - id: stylelint
      files: \.(css|less)$
      additional_dependencies:
        - stylelint@15.10.1
        - stylelint-declaration-strict-value@1.9.2
        - postcss-less@3.1.4
      args: [--fix]

  - repo: local
    hooks:
    - id: generate-pot
      name: Generate POT
      description: This hook generates the .pot file for internationalization.
      entry: python ./scripts/i18n-messages extract --skip-untracked
      types_or: [python, html]
      language: python
      pass_filenames: false
      # Dependencies must be manually updated to match versions in requirements.txt
      additional_dependencies:
        - Babel==2.12.1
        - multipart==0.2.4
        - "git+https://github.com/webpy/webpy.git@d3649322b85777b291ac2b7b3699fb6fc839e382"

  - repo: local
    hooks:
    - id: detect-missing-i18n
      name: Detect missing i18n
      description: This hook checks .html files for i18n strings that might be missing.
      entry: python ./scripts/detect_missing_i18n.py
      types: [html]
      language: python
      verbose: true
      require_serial: true
