We'll setup eslint to help us know if our code's syntax is broken
To install eslint:
npx eslint --init
Now it will ask us a few questions - for this project, using arrow keys and the space bar, we'll answer them as follows :
How would you like to use ESLint?
What type of modules does your project use?
Which framework does your project use?
Does your project use TypeScript?
Where does your code run?
What format do you want your config file to be in?
Would you like to install them now with npm?
To check syntax and find problems
CommonJS (require/exports)
None of these
No
node
onlyJSON
Yes
This should have created a file called .eslintrc.json
with the following contents:
{
"env": {
"commonjs": true,
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
}
}
It should have also added an eslint
entry in your package.json
under devDependencies
Every time we complete a step is a good time to commit
git add .
git commit -am 'added eslint'