You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"scripts": {
..."lint": "eslint index.js"/* "eslint ./" if you want it for all .js files */
},
Then in command line:
npm run lint
You should see a message that looks something like this:
# ...
/.../test-google-linter/index.js
7:25 error Missing semicolon semi
# (and a bunch of other messages)
Bonus Bonus: Auto-fix Problems
npm run lint will tell you what problems there are, but eslint --fix <filename.js> will perform fixes that can be automatically done on index.js:
eslint --fix index.js
Yet Another Bonus: Auto-Run Stuff Upon File Edits
If you install nodemon, you can do these cool things:
nodemon -x 'npm run lint' will auto-run the linter checks and print the results to the CLI every time you save index.js
nodemon index.js will auto-run the file every time you save index.js
nodemon -x 'npm run lint; node index.js' will do both of the above.
nodemon -w index.js -x 'npm run lint; plato -r -d report index.js; node index.js; open report/index.html' will auto-rerun all of the above, but also give you a report that includes MI score (after you've run npm install -g plato once).
To install nodemon, do this:
npm i -g nodemon # i = install; -g = globally
or
npm install --save-dev nodemon # <- this saves into dev dependencies