name: Lint

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  markdownlint:
    name: markdownlint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run markdownlint
        uses: DavidAnson/markdownlint-cli2-action@v10
        with:
          globs: |
            *.md
            docs/**/*.md

  shellcheck:
    name: ShellCheck
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run ShellCheck
        uses: ludeeus/action-shellcheck@2.0.0
        with:
          severity: error

  prettier:
    name: Prettier
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install Yarn v3
        run: corepack enable && corepack prepare yarn@stable --activate

      - name: Install Node packages
        run: yarn install --immutable

      - name: Run Prettier
        run: yarn prettier --check .

  eslint:
    name: ESLint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install Yarn v3
        run: corepack enable && corepack prepare yarn@stable --activate

      - name: Install Node packages
        run: yarn install --immutable

      - name: Run ESLint
        run: yarn eslint .

  stylelint:
    name: Stylelint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install Yarn v3
        run: corepack enable && corepack prepare yarn@stable --activate

      - name: Install Node packages
        run: yarn install --immutable

      - name: Run Stylelint
        run: yarn stylelint web/css/src/**/*.css
