Knowledge Base
search
Ctrlk
Knowledge Base
  • README
  • JAMStack
    • Gridsome
  • Javascript
    • Formatting and Linting
  • stacks
    • MantisBT/CentOS7/FastCGI/Caddy
  • Links
    • rsclarke.devarrow-up-right
    • githubarrow-up-right
    • dev.toarrow-up-right
    • twitterarrow-up-right
    • keybasearrow-up-right
gitbookPowered by GitBook
block-quoteOn this pagechevron-down
  1. Javascript

Formatting and Linting

hashtag
Formatting

hashtag
Prettier

npm install --save-dev --save-exact prettier
LogoPrettier · Opinionated Code Formatter · Prettierprettier.iochevron-right
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscodemarketplace.visualstudio.comchevron-right
vscode extension

hashtag
Linting

hashtag
XO

Then add xo to your project with (note, installed globally so no npx)

LogoGitHub - xojs/xo: ❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaultsGitHubchevron-right
https://marketplace.visualstudio.com/items?itemname=samverschueren.linter-xomarketplace.visualstudio.comchevron-right
vscode extension

hashtag
Configure

Within package.json add the following;

PreviousGridsomechevron-leftNextMantisBT/CentOS7/FastCGI/Caddychevron-right

Last updated 6 years ago

  • Formatting
  • Linting
  • Configure
npm install --global xo
xo --init
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
  }

}