# This is the workflow to lint the source code
name: NPM Lint

# Controls when the action will run.
on:
  # Allows you to call this workflow from other workflows
  workflow_call:

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  contents: read

jobs:
  lint:
    name: '🕵️‍♂️ NPM Lint'
    runs-on: ubuntu-latest

    steps:
      - name: '☁️ Checkout repository'
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event.workflow_run.head_branch || github.event.pull_request.base.ref }}
          persist-credentials: false

      - name: '⚙️ Use Node.js'
        uses: actions/setup-node@v6
        with:
          node-version-file: '.nvmrc'
          check-latest: true
          cache: 'npm'

      - name: '⛓️ Install dependencies'
        run: npm ci --audit=false --prefer-offline --progress=false

      - name: '✅ Lint code'
        run: npm run lint

      - name: '🔏 Audit NPM dependencies signatures'
        run: npm audit signatures
