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:

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '24'
          cache: 'npm'

      - name: Cache Node Modules
        id: cache-node-modules
        uses: actions/cache@v5
        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
