README
editor-config
How to use Prettier
- Add the following line in the target service's package.json:
"prettier": "@sixfold/editor-config/prettier"
- Add the following scripts to your package.json
"prettier": "prettier \"./src/**/**\"",
"prettier:check": "yarn prettier --check",
"prettier:fix": "yarn prettier --write",
- Add a
.prettierignore
file at the source of the repository, containing at least the following:
package.json
.DS_Store
Make sure to include .prettierignore
in your docker (test) if you check prettier formatting as part of the tests.
- Configure your IDE to use
Prettier
:
- Add
yarn prettier:check
as part of thetest
orbuild
script to ensure that code is consistently formatted
Using prettier config with prettier APIs
When generating code programmatically, same configuration can be used to format generated output:
import * as prettier from 'prettier';
import * as prettierConfig from '@sixfold/editor-config';
const source = 'function main(){console.log("Hello")};main()';
console.log(prettier.format(source, prettierConfig));