DEV Community

Cover image for ESLinter - for all JavaScript projects
Adhiraj Dutta
Adhiraj Dutta

Posted on

ESLinter - for all JavaScript projects

What I built

I built a Github workflow that lints every pull request and checks for errors using the rules set up in the project's .eslintrc.json file. This is very useful for maintainer's as contributor's may not follow the rules setup by the project which can lead to a messy codebase that can become difficult to maintain as it scales.

Category Submission: Maintainer Must-Haves

App Link

Github repository

Description

name: eslinter

on:
  pull_request:
    branches:
      - "**"
    types: [opened]

jobs:
  linter:
    name: eslint runner
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v2
      - uses: reviewdog/action-eslint@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          reporter: github-pr-review
          eslint_flags: "src/"

Enter fullscreen mode Exit fullscreen mode

This is the simple workflow. The eslint_flags: can be changed to the specific directory required.

Link to Source Code

Github Repo

Permissive License

MIT

Background (What made you decide to build this particular app? What inspired you?)

Working on team projects where eslint is not used by someone can make the whole project messy. Implementing this action will make the lives of maintainers easier as they can rest assured that no unlinted code will be pushed to the codebase.

How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)

I finally made a CI tool that will be helpful for people. This is certainly a first for me. I took help of the official docs for Github Actions and reviewdog and cooked it up in a few hours, as I only got to know about the hackathon on it's last day. A huge thank you to the awesome actions by reviewdog!
Testing it was a bit of a problem with new PRs everytime something broke. I hope there will be a way of testing actions offline in the future.

Additional Resources/Info

Top comments (0)