Simplify installing and running eslint

Add it to package.json so that
 - we can control the version installed locally
 - documentation is less likely to get out of sync
 - the command is shorter and easier to memorize - just run `npm run
 eslint` instead of providing all the command line options

Change-Id: I1dafdc910a50e02ae485323bbdca1cb9b2b8526f
This commit is contained in:
Ole Rehmsen
2019-05-15 15:24:47 +02:00
parent 66c6e5466b
commit 0021ba0062
2 changed files with 19 additions and 7 deletions

View File

@@ -4,10 +4,14 @@
"description": "Gerrit Code Review",
"dependencies": {},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-google": "^0.13.0",
"eslint-plugin-html": "^5.0.5",
"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"
},
"repository": {
"type": "git",

View File

@@ -33,9 +33,6 @@ dependencies can be installed with:
```sh
npm install
sudo npm install -g \
eslint \
eslint-config-google \
eslint-plugin-html \
typescript \
fried-twinkie \
polylint
@@ -155,11 +152,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.