Knowledge Base
rsclarke.dev
Search…
Knowledge Base
README
JAMStack
Gridsome
Javascript
Formatting and Linting
stacks
MantisBT/CentOS7/FastCGI/Caddy
Links
rsclarke.dev
github
dev.to
twitter
keybase
Powered By
GitBook
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!
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
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!
JAMStack - Previous
Gridsome
Next - stacks
MantisBT/CentOS7/FastCGI/Caddy
Last modified
2yr ago
Copy link
Contents
Formatting
Linting
Configure