Formatting and Linting

Formatting

Prettier

npm install --save-dev --save-exact prettier

Linting

XO

npm install --global xo

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

xo --init

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
  }

}

Last updated