Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 43 additions & 42 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
name: ESLint

on:
pull_request:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
name: Lint updated JavaScript files with ESLint

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Get changed JavaScript files
id: get_files
run: |
CHANGED_FILES=$(git diff --diff-filter=ACMRT --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js')
echo "files<<EOF" >> $GITHUB_ENV
echo "$CHANGED_FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Install dependencies
run: npm ci

- name: Run ESLint on changed files
if: env.files != ''
run: |
echo "Linting the following files:"
echo "$files"
echo "$files" | xargs npx eslint
- name: Run Prettier check on changed files
if: env.files != ''
run: |
echo "Checking formatting for the following files:"
echo "$files"
echo "$files" | xargs npx prettier --check
lint:
name: Lint updated JavaScript files with ESLint

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"

- name: Get changed JavaScript files
id: get_files
run: |
CHANGED_FILES=$(git diff --diff-filter=ACMRT --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js')
echo "files<<EOF" >> $GITHUB_ENV
echo "$CHANGED_FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Install dependencies
run: npm ci

- name: Run ESLint on changed files
if: env.files != ''
run: |
echo "Linting the following files:"
echo "$files"
echo "$files" | xargs npx eslint
- name: Run Prettier check on changed files
if: env.files != ''
run: |
echo "Checking formatting for the following files:"
echo "$files"
echo "$files" | xargs npx prettier --check
Loading