Skip to content

Commit 5d307ec

Browse files
Fix ESLint workflow to only lint existing files
- Filter out deleted files from linting process - Prevents ESLint errors when files are removed in PR - Fixes jQuery upgrade PR linting failure
1 parent b65b90f commit 5d307ec

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/linter.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Get changed JavaScript files
2626
id: get_files
2727
run: |
28-
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js')
28+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js' | xargs -I {} sh -c 'test -f "{}" && echo "{}"')
2929
echo "files<<EOF" >> $GITHUB_ENV
3030
echo "$CHANGED_FILES" >> $GITHUB_ENV
3131
echo "EOF" >> $GITHUB_ENV
@@ -38,4 +38,8 @@ jobs:
3838
run: |
3939
echo "Linting the following files:"
4040
echo "$files"
41-
echo "$files" | xargs npx eslint
41+
if [ -n "$files" ]; then
42+
echo "$files" | xargs npx eslint
43+
else
44+
echo "No existing JavaScript files to lint."
45+
fi

0 commit comments

Comments
 (0)