exclude: 'node_modules|.git'
default_stages: [pre-commit]
fail_fast: false

repos:
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v4.0.0-alpha.8
    hooks:
      - id: prettier
        types_or: [javascript, vue]
        # Ignore any files that might contain jinja / bundles
        exclude: |
          (?x)^(
              jcloud/public/dist/.*|
              .*node_modules.*|
              .*boilerplate.*|
              jcloud/www/website_script.js|
              jcloud/templates/includes/.*|
              jcloud/public/js/.*min.js
          )$

  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: debug-statements
      - id: trailing-whitespace
        files: 'jcloud.*'
        exclude: '.*json$|.*txt$|.*csv|.*md|.*svg'
      - id: check-merge-conflict
      - id: check-ast
      - id: check-json
      - id: check-toml
      - id: check-yaml

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.9.6
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

  - repo: local
    hooks:
      - id: commitlint
        name: check commit message format
        entry: npx commitlint --edit .git/COMMIT_EDITMSG
        language: system
        stages: [commit-msg]
        always_run: true

      - id: cspell-commit-msg
        name: check commit message spelling
        entry: npx cspell --config .cspell.json .git/COMMIT_EDITMSG
        language: system
        stages: [commit-msg]
        always_run: true

      - id: cspell-modified-files
        name: check spelling of files
        entry: sh -c "npx cspell --no-must-find-files --config .cspell.json `git diff --cached -p --name-status | cut -c3- | tr '\n' ' '`"
        language: system
        stages: [pre-commit]

      - id: todo-warning
        name: check todos
        entry: .github/hooks/todo-warning.sh
        language: script
        stages: [pre-commit]
        verbose: true
