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.jsonfile$ 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
ESLintandPrettierextensions, and useshift + option + Fto setprettieras the default code formatter.