# Shared hooks. Consumers: `extends: [node_modules/@visorian/code-standards/lefthook.yml]`, installed by `lefthook install`.
pre-commit:
  piped: true
  jobs:
    - name: format
      glob: '*.{js,mjs,cjs,ts,mts,cts,vue,json,jsonc,md,yml,yaml,css}'
      run: bunx oxfmt --no-error-on-unmatched-pattern {staged_files}
      stage_fixed: true
    - name: oxlint
      glob: '*.{js,mjs,cjs,ts,mts,cts,vue}'
      run: bunx oxlint {staged_files}
    # No --max-warnings here: warnings are legacy debt and are capped by `lint:vue` in CI.
    - name: eslint
      glob: '*.vue'
      # Only Vue projects have an ESLint config (see `defineVueEslintConfig`).
      skip:
        - run: '! ls eslint.config.* >/dev/null 2>&1'
      run: bunx eslint --cache --cache-location node_modules/.cache/eslint/ {staged_files}

commit-msg:
  jobs:
    - name: commitlint
      run: bunx commitlint --edit {1}

pre-push:
  jobs:
    - name: typecheck
      run: bun run --if-present typecheck
