CMP Node.js - ESLint & Prettier Setup
Fixes linting & code formatting errors on SAVE (CTRL + S)
Enforces strict coding standard by making code more consistent & avoiding bugs across the team & all repositories.
Linting JavaScript is based on the latest standards using eslint-config-airbnb-base
npx install-peerdeps --dev eslint-config-cmp-node
{
"extends" : [" cmp-node" ]
}
3. VS Code Setup. This will help us fix most of the linting & prettier issues ON SAVE (CTRL + S)
Install ESLint VSCode Extension
Now we need to setup some VS Code settings via Code/File
โ Preferences
โ Settings
.
OR
Create settings.json
in .vscode
folder and add the below settings.
{
"editor.formatOnSave" : true ,
"eslint.autoFixOnSave" : true
}
5. To overwrite eslint or prettier settings, just extend the rules in your .eslintrc
file like this.
{
"extends" : [
" cmp-node"
],
"rules" : {
"prettier/prettier" : [ // Prettier Rules.
" error" ,
{
"singleQuote" : true ,
"tabWidth" : 8 ,
}
],
"no-console" : 2 , // EsLint Rules.
}
}