ESLint
is responsible for checking syntax errors and problems, while Prettier
for auto-formatting our JavaScript codes.
Node Project Settings
-
Install all the necessary packages as in
package.json
-
Generate a
.eslintrc.json
file$ eslint --init
{ "extends": [ "airbnb-base", "prettier", "plugin:prettier/recommended" ], "plugins": [ "prettier" ], "rules": { "class-methods-use-this": "off", "func-names": "off", "no-console": "off", "no-unused-vars": "warn", "object-shorthand": "off", "prettier/prettier": [ "error", { "singleQuote": true } ] } }
-
For VSCode integration, install
ESLint
andPrettier
extensions, and useshift + option + F
to setprettier
as the default code formatter.