Files
gerrit/polygerrit-ui/app/lint_test.sh
Tao Zhou 13a83f1804 Fix linter errors under eslint 6.x
Also changed the lint_test to only run within ui folder to speed it up.

Change-Id: Ib65ae53176d7a6eece12bd85bcae3bb402d5ade8
2019-12-13 13:55:34 +01:00

34 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -ex
npm_bin=$(which npm) && true
if [ -z "$npm_bin" ]; then
echo "NPM must be on the path."
exit 1
fi
eslint_bin=$(which eslint) && true
eslint_config=$(npm list -g | grep -c eslint-config-google) && true
eslint_plugin=$(npm list -g | grep -c eslint-plugin-html) && true
if [ -z "$eslint_bin" ] || [ "$eslint_config" -eq "0" ] || [ "$eslint_plugin" -eq "0" ]; then
echo "You must install ESLint and its dependencies from NPM."
echo "> npm install -g eslint eslint-config-google eslint-plugin-html"
echo "For more information, view the README:"
echo "https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/#Style-guide"
exit 1
fi
# get absolute path to lint_test.sh path
SCRIPT=$(readlink -f "$0")
UI_PATH=$(dirname "$SCRIPT")
# To make sure npm link happens in the right place
cd ${UI_PATH}
# Linking global eslint packages to the local project. Required to use eslint plugins with a global
# eslint installation.
npm link eslint eslint-config-google eslint-plugin-html
${eslint_bin} -c ${UI_PATH}/.eslintrc.json --ignore-pattern 'node_modules/' --ignore-pattern 'bower_components/' --ignore-pattern 'gr-linked-text' --ignore-pattern 'scripts/vendor' --ext .html,.js ${UI_PATH}