Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 12 additions & 5 deletions .github/workflows/scripts/common/lint_javascript_files
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ fix="${FIX:-0}"
# Files to lint:
files_to_lint="$*"

# Filter out non-existent files:
filter_existing_files() {
echo "$1" | tr ' ' '\n' | while read -r f; do
[ -f "$f" ] && printf '%s ' "$f"
done | sed 's/ $//'
}

# Define the path to ESLint configuration file for linting examples:
eslint_examples_conf="${root}/etc/eslint/.eslintrc.examples.js"

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

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

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

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

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

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

# Lint JavaScript benchmark files:
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
files=$(filter_existing_files "$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ')")
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${fix}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ int main( void ) {

</section>


</section>
<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
Expand Down
Loading