How to setup Github Actions workflow lint

Configure a workflow to execute your linter when pushing code


Apr 25, 2021
featured image

package.json

      
 "scripts": {
    (...)
    "lint": "eslint --ignore-path .gitignore . --ext .js"
  },

      
    

Create a file at ./github/workflows/lint.yml

Paste this content:

      
name: lint

on: push

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache node modules
        uses: actions/cache@v2
        env:
          cache-name: cache-node-modules
        with:
          path: ~/.npm
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-build-${{ env.cache-name }}-
            ${{ runner.os }}-build-
            ${{ runner.os }}-
      - name: Install Dependencies
        run: npm install

      - name: Lint
        run: npm run lint

      
    

Photo by Jakob Owens on Unsplash


js eslint github dev