https://github.com/rajat2502/eslint-github-action
A Simple GitHub Action that runs the linter(ESlint) on a JavaScript project
https://github.com/rajat2502/eslint-github-action
ci-cd eslintrc github github-actions
Last synced: 10 months ago
JSON representation
A Simple GitHub Action that runs the linter(ESlint) on a JavaScript project
- Host: GitHub
- URL: https://github.com/rajat2502/eslint-github-action
- Owner: rajat2502
- Created: 2020-11-19T20:35:04.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-20T07:04:24.000Z (about 5 years ago)
- Last Synced: 2025-02-02T00:42:26.317Z (12 months ago)
- Topics: ci-cd, eslintrc, github, github-actions
- Homepage:
- Size: 10.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ESlint-GitHub-Action
A Simple GitHub Action that runs the linter(ESlint) on a JavaScript project. This runs ESlint on any file with an extension of .js,.jsx,.ts, and .tsx.
### How to use this action in my project?
- Copy the below code:
```
on: [push]
jobs:
build:
name: Linter
# This job runs on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Install ESlint
run: sudo yarn global add eslint
- name: Run ESlint
run: eslint . --ext .js,.jsx,.ts,.tsx --fix
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Rajat Verma'
git config --global user.email 'rajatverma5885045@gmail.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "lint: file(s) linted"
git push
```
- Replace the name and email Address with your own email address.
- Create a file in the `.github/workflows` folder of your project.
- Name the file `lint.yml` or any other name (The extension of the file should be .yml or .yaml).
- Make any commit to see it in Action!
**Note:**
- To run this Action, your project must have at least one file with the listed extenstions.
- The project should also have eslint configuration file i.e eslintrc.json (To make one for your project run `npx eslint --init`).