# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: |
    (?x)
    # NOT INSTALLABLE ADDONS
    # END NOT INSTALLABLE ADDONS
    # Files and folders generated by bots, to avoid loops
    /setup/|/README\.rst$|/static/description/index\.html$|
    # Maybe reactivate this when all README files include prettier ignore tags?
    ^README\.md$|
    # Library files can have extraneous formatting (even minimized)
    /static/(src/)?lib/|
    # Repos using Sphinx to generate docs don't need prettying
    ^docs/_templates/.*\.html$|
    # You don't usually want a bot to modify your legal texts
    (LICENSE.*|COPYING.*)
default_language_version:
    python: python3
    node: "16.17.0"
repos:
    - repo: local
      hooks:
          # These files are most likely copier diff rejection junks; if found,
          # review them manually, fix the problem (if needed) and remove them
          - id: forbidden-files
            name: forbidden files
            entry: found forbidden files; remove them
            language: fail
            files: "\\.rej$"
    - repo: https://github.com/oca/maintainer-tools
      rev: 71aa4caec15e8c1456b4da19e9f39aa0aa7377a9
      hooks:
          # update the NOT INSTALLABLE ADDONS section above
          - id: oca-update-pre-commit-excluded-addons
    - repo: https://github.com/myint/autoflake
      rev: v2.3.1
      hooks:
          - id: autoflake
            args: ["-i", "--ignore-init-module-imports"]
    - repo: https://github.com/psf/black
      rev: 26.1.0
      hooks:
          - id: black
    - repo: https://github.com/pre-commit/mirrors-prettier
      rev: v4.0.0-alpha.8
      hooks:
          - id: prettier
            name: prettier + plugin-xml
            additional_dependencies:
                - "prettier@2.7.1"
                - "@prettier/plugin-xml@2.2.0"
            args:
                - --plugin=@prettier/plugin-xml
            files: \.(css|htm|html|js|json|json5|scss|toml|xml|yaml|yml)$
    - repo: https://github.com/pre-commit/mirrors-eslint
      rev: v10.0.0
      hooks:
          - id: eslint
            verbose: true
            args:
                - --color
                - --fix
    - repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v6.0.0
      hooks:
          - id: trailing-whitespace
            # exclude autogenerated files
            exclude: /README\.rst$|\.pot?$
          - id: end-of-file-fixer
            # exclude autogenerated files
            exclude: /README\.rst$|\.pot?$
          - id: debug-statements
          - id: check-case-conflict
          - id: check-docstring-first
          - id: check-executables-have-shebangs
          - id: check-merge-conflict
            # exclude files where underlines are not distinguishable from merge conflicts
            exclude: /README\.rst$|^docs/.*\.rst$
          - id: check-symlinks
          - id: check-xml
          - id: mixed-line-ending
            args: ["--fix=lf"]
    - repo: https://github.com/asottile/pyupgrade
      rev: v3.21.2
      hooks:
          - id: pyupgrade
            args: ["--py38-plus"]
    - repo: https://github.com/PyCQA/isort
      rev: 7.0.0
      hooks:
          - id: isort
            name: isort except __init__.py
            args:
                - --settings=.
            exclude: /__init__\.py$
    # setuptools-odoo deshabilitado temporalmente (no soporta Odoo 18.0)
    # - repo: https://github.com/acsone/setuptools-odoo
    #   rev: 3.3.2
    #   hooks:
    #     - id: setuptools-odoo-make-default
    #     - id: setuptools-odoo-get-requirements
    #       args:
    #         - --output
    #         - requirements.txt
    #         - --header
    #         - "# generated from manifests external_dependencies"
    - repo: https://github.com/PyCQA/flake8
      rev: 7.3.0
      hooks:
          - id: flake8
            name: flake8
            additional_dependencies: ["flake8-bugbear==23.12.2"]
    # NOTE: mypy is intentionally not configured here. It is not part of the
    # OCA pre-commit standard and breaks on Odoo's migration folder layout
    # (e.g. ".../migrations/18.0.2.1.0/post-migrate.py" -> not a valid package
    # name), because mypy's exclude does not apply to files passed explicitly
    # by pre-commit.
    - repo: https://github.com/PyCQA/pylint
      rev: v4.0.4
      hooks:
          - id: pylint
            name: pylint with optional checks
            args:
                - --rcfile=.pylintrc
                - --exit-zero
            verbose: true
            exclude: ^scripts/
            additional_dependencies: &pylint_deps
                - pylint-odoo==10.0.0
          - id: pylint
            name: pylint with mandatory checks
            args:
                - --rcfile=.pylintrc-mandatory
            exclude: ^scripts/
            additional_dependencies: *pylint_deps
