Merge changes Id407c76b,I1dafdc91

* changes:
  Simplify installing / running template tests
  Simplify installing and running eslint
This commit is contained in:
Ole Rehmsen
2019-05-16 15:24:04 +00:00
committed by Gerrit Code Review
4 changed files with 30 additions and 25 deletions

View File

@@ -4,10 +4,17 @@
"description": "Gerrit Code Review",
"dependencies": {},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-google": "^0.13.0",
"eslint-plugin-html": "^5.0.5",
"fried-twinkie": "^0.2.2",
"typescript": "^2.x.x",
"web-component-tester": "^6.5.0"
},
"scripts": {
"test": "WCT_HEADLESS_MODE=1 WCT_ARGS='--verbose -l chrome' ./polygerrit-ui/app/run_test.sh"
"test": "WCT_HEADLESS_MODE=1 WCT_ARGS='--verbose -l chrome' ./polygerrit-ui/app/run_test.sh",
"eslint": "./node_modules/eslint/bin/eslint.js --ignore-pattern 'bower_components/' --ignore-pattern 'gr-linked-text' --ignore-pattern 'scripts/vendor' --ext .html,.js polygerrit-ui/app || exit 0",
"test-template": "./polygerrit-ui/app/run_template_test.sh"
},
"repository": {
"type": "git",

View File

@@ -32,13 +32,7 @@ dependencies can be installed with:
```sh
npm install
sudo npm install -g \
eslint \
eslint-config-google \
eslint-plugin-html \
typescript \
fried-twinkie \
polylint
sudo npm install -g polylint
```
It may complain about a missing `typescript@2.3.4` peer dependency, which is
@@ -155,11 +149,22 @@ to supply the `--ext .html` flag.
Some useful commands:
* To run ESLint on the whole app, less some dependency code:
`eslint --ignore-pattern 'bower_components/' --ignore-pattern 'gr-linked-text' --ignore-pattern 'scripts/vendor' --ext .html,.js polygerrit-ui/app`
```sh
npm run eslint
```
* To run ESLint on just the subdirectory you modified:
`eslint --ext .html,.js polygerrit-ui/app/$YOUR_DIR_HERE`
```sh
node_modules/eslint/bin/eslint.js --ext .html,.js polygerrit-ui/app/$YOUR_DIR_HERE
```
* To run the linter on all of your local changes:
`git diff --name-only master | xargs eslint --ext .html,.js`
```sh
git diff --name-only master | xargs node_modules/eslint/bin/eslint.js --ext .html,.js
```
We also use the `polylint` tool to lint use of Polymer. To install polylint,
execute the following command.
@@ -187,6 +192,12 @@ To run on all files, execute the following command:
./polygerrit-ui/app/run_template_test.sh
```
or
```sh
npm run test-template
```
To run on a specific top level directory (ex: change-list)
```sh
TEMPLATE_NO_DEFAULT=true ./polygerrit-ui/app/run_template_test.sh //polygerrit-ui/app:template_test_change-list

View File

@@ -3,7 +3,7 @@
if [[ -z "${TEMPLATE_NO_DEFAULT}" ]]; then
bazel test \
--test_env="HOME=$HOME" \
//polygerrit-ui/app:all
//polygerrit-ui/app:all \
--test_tag_filters=template \
"$@" \
--test_output errors \

View File

@@ -14,19 +14,6 @@ if [[ -z "$npm_bin" ]]; then
exit 1
fi
fried_twinkie_config=$(npm list -g | grep -c fried-twinkie)
if [ -z "$npm_bin" ] || [ "$fried_twinkie_config" -eq "0" ]; then
echo "You must install fried twinkie and its dependencies from NPM."
echo "> npm install -g fried-twinkie"
exit 1
fi
twinkie_version=$(npm list -g fried-twinkie@\>0.1 | grep fried-twinkie || :)
if [ -z "$twinkie_version" ]; then
echo "Outdated version of fried-twinkie found. Bypassing template check."
exit 0
fi
# Have to find where node_modules are installed and set the NODE_PATH
get_node_path() {