Skip to content

Instantly share code, notes, and snippets.

@MarvinJWendt
Last active November 26, 2018 10:04
Show Gist options
  • Save MarvinJWendt/a042ab38bc51664add08e2fdf8a04efc to your computer and use it in GitHub Desktop.
Save MarvinJWendt/a042ab38bc51664add08e2fdf8a04efc to your computer and use it in GitHub Desktop.
Prettier config for TypeScript and JavaScript
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
{
"singleQuote": true,
"endOfLine": "lf"
}

Install via NPM

npm i -D prettier

JavaScript linter
npm i -D eslint
npm i -D eslint-plugin-prettier

TypeScript linter
npm i -D tslint
npm i -D tslint-plugin-prettier

One-liner
npm i -D prettier eslint eslint-plugin-prettier tslint tslint-plugin-prettier

Usage

npm run format

//Add this to 'scripts'
"format": "./node_modules/.bin/prettier --write *",
"formatjs": "./node_modules/.bin/prettier --write *.js",
"formatts": "./node_modules/.bin/prettier --write *.ts",
"compile": "tsc && npm run formatjs"
{
"rulesDirectory": ["tslint-plugin-prettier"],
"rules": {
"prettier": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment