kibana/.buildkite/scripts/steps/lint.sh
Jon 23b8bef073
[ci] Run linting before tests (#197310)
Linting is a frequent source of build failures. By increasing the cpu
count we can run this check before starting our highly-parallel tests
without impacting total build time.
2024-10-28 12:24:00 -05:00

38 lines
909 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common/util.sh
.buildkite/scripts/bootstrap.sh
echo '--- Lint: stylelint'
node scripts/stylelint
echo "stylelint ✅"
echo '--- Lint: eslint'
# disable "Exit immediately" mode so that we can run eslint, capture it's exit code, and respond appropriately
# after possibly commiting fixed files to the repo
set +e;
if is_pr && ! is_auto_commit_disabled; then
git ls-files | grep -E '\.(js|mjs|ts|tsx)$' | xargs -n 250 -P 8 node scripts/eslint --no-cache --fix
else
git ls-files | grep -E '\.(js|mjs|ts|tsx)$' | xargs -n 250 -P 8 node scripts/eslint --no-cache
fi
eslint_exit=$?
# re-enable "Exit immediately" mode
set -e;
desc="node scripts/eslint --no-cache"
if is_pr && ! is_auto_commit_disabled; then
desc="$desc --fix"
fi
check_for_changed_files "$desc" true
if [[ "${eslint_exit}" != "0" ]]; then
exit 1
fi
echo "eslint ✅"