Reputation: 34325
I just installed ESLint and I can successfully run it by doing this at the terminal window:
./node_modules/.bin/eslint app
Note: app
is the root folder I want lint to inspect.
I then put that exact command in my package.json:
"scripts": {
"lint": "./node_modules/.bin/eslint app"
}
I expected to be able to run it in the terminal window like this:
npm run lint
Note: I know how to fix the no-undef error. My question is about the many errors lines after that.
It actually works, but it also produces a bunch of errors after showing me the correct output:
Why is that happening?
Upvotes: 0
Views: 746
Reputation: 8217
This is the default way of how the npm
script runner handles script errors (i.e. non-zero exit codes). This will always happen, even if you only run a script like exit 1
.
I'm not sure why this feature exists, it seems annoying and useless in most cases.
If you don't want to see this, you can add || true
at the end of your script.
Example:
lint: "eslint app || true"
As you might've noticed, I've omitted the part to the eslint binary. The npm
script runner already includes local binaries as part of the path when trying to run the script so there is no need to use the full path.
Upvotes: 3
Reputation: 47289
document
is a global, so eslint
thinks you are missing an import somewhere. For those cases, you can adapt your config so that the error is not reported, Something like this:
module.exports = {
"globals": {
"document": true
}
}
this should be saved as .eslintrc.js
and be at the same level where your package.json
is
Upvotes: 0