When I lint my code with eslint scripts/**/*.js
I see two linting errors:
» eslint scripts/**/*.js
/Users/user/dev/scripts/application.js
3:8 error "React" is defined but never used no-unused-vars
/Users/user/dev/scripts/components/Header.js
24:2 error Unnecessary semicolon no-extra-semi
✖ 2 problem (2 error, 0 warnings)
That's fine. When I put that command into "scripts"
in my package.json
then I only get one error.
// package.json
// ...
"scripts": {
"lint": "eslint scripts/**/*.js"
}
// ...
» npm run lint
/Users/david.tuite/dev/ui/scripts/components/Header.js
24:2 error Unnecessary semicolon no-extra-semi
✖ 2 problems (2 errors, 0 warnings)
What's happening to the other linting error?
edit
I'm starting to suspect this is a globbing problem. The missing linting error is in a file which isn't in a subdirectory of scripts
.
Globs work differently in the package.json
file.
The trick is to wrap the path matchers in single quotes to have them expanded at the shell level before they're passed to eslint.
// package.json
// ...
"scripts": {
"lint": "eslint 'scripts/**/*.js'"
}
// ...
Sounds like David's answer solved the problem he was encountering. However, I had an identical symptom to the problem described.
In my case the problem was that npm was using the node_modules in the project directory which had a different version of the plugin than the global npm folder had.
Running eslint from command line was using the global version. Reconciling those versions resolved the issue in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With