#                                                                                #
#                          Lefthook configuration file:                          #
#   This file is used to configure Lefthook, a tool for managing Git hooks.      #
#                                                                                #
#   https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md   #

$schema: https://raw.githubusercontent.com/evilmartians/lefthook/refs/heads/master/schema.json
extends:
  - ./recommended.yml

pre-commit:
  commands:
    lint:
      glob:
        - "*.js"
        - "*.ts"
        - "*.cjs"
        - "*.mjs"
        - "*.d.cts"
        - "*.d.mts"
        - "*.jsx"
        - "*.tsx"
        - "*.json"
        - "*.jsonc"
        - "*.yaml"
        - "*.yml"
        - "*.md"
        - "*.mdx"
        - "*.markdown"
        - "*.css"
        - "*.scss"
        - "*.sass"
        - "*.less"
        - "*.stylus"
        - "*.graphql"
        - "*.gql"
        - "*.xml"
        - "*.svg"
        - "*.env"
        - ".env.{local,development,test,production,staging}"
      run: pnpm lint --files {staged_files}
      stage_fixed: true
    eslint:
      glob:
        - "*.js"
        - "*.ts"
        - "*.cjs"
        - "*.mjs"
        - "*.d.cts"
        - "*.d.mts"
        - "*.jsx"
        - "*.tsx"
        - "*.json"
        - "*.jsonc"
        - "*.yaml"
        - "*.yml"
        - "*.md"
        - "*.mdx"
        - "*.markdown"
        - "*.css"
        - "*.scss"
        - "*.sass"
        - "*.less"
        - "*.stylus"
        - "*.graphql"
        - "*.gql"
        - "*.xml"
        - "*.svg"
        - "*.env"
        - ".env.{local,development,test,production,staging}"
      run: "pnpm exec eslint --fix --color --no-warn-ignored --cache --cache-location
        \"./node_modules/.cache/storm/eslint-cache\" --config
        \"./eslint.config.mjs\" {staged_files}"
      stage_fixed: true

pre-push:
  commands:
    prettier:
      files: git diff --name-only HEAD @{push}
      glob: "!**/generators/*/files/**/*"
      run: "pnpm exec prettier {files} --check --ignore-unknown
        --no-error-on-unmatched-pattern --cache && git update-index"
    sherif:
      files: git diff --name-only HEAD @{push}
      glob: "**/*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
      run: pnpm exec sherif -i typescript react react-dom --files {files} --cache
