Skip to content

Commit ac7c5ab

Browse files
committed
chore: fix JavaScript lint errors (issue #8586)
1 parent 4bbe846 commit ac7c5ab

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.github/workflows/scripts/common/lint_javascript_files

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ fix="${FIX:-0}"
3939
# Files to lint:
4040
files_to_lint="$*"
4141

42+
# Filter out non-existent files:
43+
filter_existing_files() {
44+
echo "$1" | tr ' ' '\n' | while read -r f; do
45+
[ -f "$f" ] && printf '%s ' "$f"
46+
done | sed 's/ $//'
47+
}
48+
4249
# Define the path to ESLint configuration file for linting examples:
4350
eslint_examples_conf="${root}/etc/eslint/.eslintrc.examples.js"
4451

@@ -49,7 +56,7 @@ eslint_tests_conf="${root}/etc/eslint/.eslintrc.tests.js"
4956
eslint_benchmarks_conf="${root}/etc/eslint/.eslintrc.benchmarks.js"
5057

5158
# Lint JavaScript source files:
52-
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -v -e '/examples' -e '/test' -e '/benchmark' -e '^dist/' | tr '\n' ' ' | sed 's/ $//')
59+
files=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -v -e '/examples' -e '/test' -e '/benchmark' -e '^dist/' | tr '\n' ' ')")
5360

5461
# Build native addons if present:
5562
packages=$(echo "${files}" | tr ' ' '\n' | sed 's/^lib\/node_modules\///g' | sed 's/\/lib\/.*//g' | sort | uniq)
@@ -64,25 +71,25 @@ if [[ -n "${files}" ]]; then
6471
fi
6572

6673
# Lint JavaScript command-line interfaces...
67-
file=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -E '/bin/cli$' | tr '\n' ' ' | sed 's/ $//')
74+
file=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -E '/bin/cli$' | tr '\n' ' ')")
6875
if [[ -n "${file}" ]]; then
6976
make lint-javascript-files FIX="${fix}" FAST_FAIL=0 FILES="${file}"
7077
fi
7178

7279
# Lint JavaScript example files:
73-
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/examples/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
80+
files=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/examples/.*\.js$' | tr '\n' ' ')")
7481
if [[ -n "${files}" ]]; then
7582
make lint-javascript-files FIX="${fix}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_examples_conf}"
7683
fi
7784

7885
# Lint JavaScript test files:
79-
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/test/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
86+
files=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/test/.*\.js$' | tr '\n' ' ')")
8087
if [[ -n "${files}" ]]; then
8188
make lint-javascript-files FIX="${fix}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_tests_conf}"
8289
fi
8390

8491
# Lint JavaScript benchmark files:
85-
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
92+
files=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ')")
8693
if [[ -n "${files}" ]]; then
8794
make lint-javascript-files FIX="${fix}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
8895
fi

0 commit comments

Comments
 (0)