1- name : ESLint
1+ name : ESLint & Prettier
22
33on :
44 pull_request :
55 branches : [master]
66
77jobs :
88 lint :
9- name : Lint updated JavaScript files with ESLint
9+ name : Lint and format-check changed JS files
1010
1111 runs-on : ubuntu-latest
1212
@@ -26,23 +26,24 @@ jobs:
2626 - name : Get changed JavaScript files
2727 id : get_files
2828 run : |
29- CHANGED_FILES=$(git diff --diff-filter=ACMRT --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js')
30- echo "files<<EOF" >> $GITHUB_ENV
31- echo "$CHANGED_FILES" >> $GITHUB_ENV
32- echo "EOF" >> $GITHUB_ENV
29+ git diff --diff-filter=ACMRT --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js' '*.mjs' ':!node_modules/**' > changed-js-files.txt
3330
34- - name : Install dependencies
35- run : npm ci
31+ if [ -s changed-js-files.txt ]; then
32+ echo "has_files=true" >> "$GITHUB_OUTPUT"
33+ else
34+ echo "has_files=false" >> "$GITHUB_OUTPUT"
35+ fi
3636
3737 - name : Run ESLint on changed files
38- if : env.files != ' '
38+ if : steps.get_files.outputs.has_files == 'true '
3939 run : |
4040 echo "Linting the following files:"
41- echo "$ files"
42- echo "$files" | xargs npx eslint
41+ cat changed-js- files.txt
42+ xargs -r npx eslint < changed-js-files.txt
4343 - name : Run Prettier check on changed files
44- if : env.files != ' '
44+ if : steps.get_files.outputs.has_files == 'true '
4545 run : |
4646 echo "Checking formatting for the following files:"
47- echo "$files"
48- echo "$files" | xargs npx prettier --check
47+ cat changed-js-files.txt
48+ xargs -r npx prettier --check < changed-js-files.txt
49+
0 commit comments