A horrible introduction to using modern JavaScript tooling with D3
Chapter 8
Are you sick of typing ./node_modules/.bin/eslint
again and again? Yeah, me too.
Windows: Tired of forgetting the quotation marks?
Let’s open up package.json
and make a little change. See the "scripts"
part?
Right now there’s one script - it’s supposed to run tests, but it looks like it does a pretty bad job of it. For now, let’s just add a new test called lint
that runs eslint
for us.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint --fix graph.js"
},
Windows: No more quotation marks for this one! You’re free!
Be sure to add a comma at the end of the test
line!
We can now have eslint
run by just typing npm run lint
. npm
knows that even though we just type eslint
that it needs to go into node_modules/.bin
and find the secret eslint
hiding in there.
So: never again type ./node_modules/.bin/
for anything! If you need to run a tool, add it to scripts
to make your life so much easier.
Now, let’s get back to our code!