Formatting and Linting

Formatting

Prettier

1
npm install --save-dev --save-exact prettier
Copied!
Prettier · Opinionated Code Formatter
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
marketplace.visualstudio.com
vscode extension

Linting

XO

1
npm install --global xo
Copied!
Then add xo to your project with (note, installed globally so no npx)
1
xo --init
Copied!
vscode extension

Configure

Within package.json add the following;
package.json
1
{
2
"scripts": {
3
"format": "prettier --write '**/*.js' && xo --fix"
4
},
5
"prettier": {
6
"tabWidth": 2,
7
"useTabs": false,
8
"singleQuote": true,
9
"bracketSpacing": false,
10
"semi": false,
11
"trailingComma": "none"
12
},
13
"xo": {
14
"prettier": true,
15
"esnext": false
16
}
17
}
Copied!
Last modified 2yr ago