From 9825dc89fa77051b55fc13ecac3e313114ed2600 Mon Sep 17 00:00:00 2001 From: robyngit Date: Tue, 21 May 2024 12:47:12 -0400 Subject: [PATCH] Add GH action: auto review PRs for lint/format problems Issue #2096 --- .github/workflows/lint-and-format.yml | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/lint-and-format.yml diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml new file mode 100644 index 000000000..f1a334f43 --- /dev/null +++ b/.github/workflows/lint-and-format.yml @@ -0,0 +1,45 @@ +name: Lint and Format Code Base + +on: + pull_request: + paths: + - 'src/**/*.js' + +jobs: + lint_and_format: + name: runner / eslint and prettier + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important to fetch all history for diff + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Run ESLint with reviewdog + uses: reviewdog/action-eslint@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review + eslint_flags: 'src' + filter_mode: 'diff_context' + + - name: Run Prettier with reviewdog + uses: EPMatt/reviewdog-action-prettier@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review + prettier_flags: '--check src/**/*.js' + filter_mode: 'diff_context' +