name: Lint and Format Check

on:
  push:
    branches-ignore:
      - 'build'
    paths:
      - '**/*.cjs'
      - '**/*.html'
      - '**/*.js'
      - '**/*.json'
      - '**/*.md'
      - '**/*.mdx'
      - '**/*.ts'
      - '**/*.css'
      - 'eslint.config.mjs'
      - '.prettierrc.json'
      - '.prettierignore'
      - 'package.json'
      - 'package-lock.json'
      - '.github/workflows/lint-format-check.yml'
  pull_request:

permissions:
  contents: read

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          persist-credentials: false

      - name: Setup Node.js
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          node-version: '24'
          cache: 'npm'

      - name: Cache Node Modules
        id: cache-node-modules
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
        with:
          path: node_modules
          key: ${{ runner.os }}-node-root-${{ hashFiles('package-lock.json') }}

      - name: Install dependencies
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
        run: npm ci

      - name: Run ESLint check
        run: npm run lint

      - name: Run Prettier check
        run: npm run format:check
