yincrash / gh-action-eslint-changeset

Github action that lints only the files within a particular commit to a branch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Github Action ESLint Changesest

Github action that lints only the files within a particular commit to a branch, when a pull request is established.

Notes:

  • Github workflow must be configured with Checkout V3.
  • ESLint must be part of the devDependencies section of the package.json file.

Inputs

  • main-branch (default: 'master')
  • file-extension (default: 'js')

Example usage

In order for this action to work properly, it must be set up along with Checkout V3. Also make sure you include the run section which is used to include the main repo branch to perform the comparison.

.github/workflows/main.yml:
on:
  pull_request:
    types: [opened, edited, reopened, synchronize]
    paths: # make sure this action only runs when specific file extensions have been added/modified
      - '**.js'
      - '**.jsx'

jobs:
  test_job:
    runs-on: ubuntu-latest
    name: A job to test eslint-changeset action
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          ref: ${{ github.head_ref }}
      - run: |
          git fetch --no-tags --depth=1 origin main
          git checkout main 
          git checkout ${{ github.head_ref }}
      - name: Eslint Changeset Step
        uses: esrimo/gh-action-eslint-changeset@v1
        id: eslint-changeset
        with:
          main-branch: 'main'
          file-extension: 'js'

In essence, you could copy/paste the above sample and only change the following according to your repo config:

main-branch: 'your_main_repo_branch'
file-extension: 'ts|tsx|json' #make sure you divide by '|' with no spaces in between

About

Github action that lints only the files within a particular commit to a branch

License:GNU General Public License v3.0


Languages

Language:Shell 76.1%Language:Dockerfile 23.9%