Formatting and Linting

Formatting

Prettier

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

Linting

XO

npm install --global xo
Then add xo to your project with (note, installed globally so no npx)
xo --init
GitHub - xojs/xo: ❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults
GitHub
https://marketplace.visualstudio.com/items?itemname=samverschueren.linter-xo
marketplace.visualstudio.com
vscode extension

Configure

Within package.json add the following;
package.json
{
"scripts": {
"format": "prettier --write '**/*.js' && xo --fix"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false
}
}
Copy link
On this page
Formatting
Linting
Configure