Based on the comment added to an associated issue in angular-cli.
With Angular CLI v6+
The main goal of this package is to permit to add Prettier dependencies, scripts and default configuration to your Angular CLI workspace in just one command :
ng add @mace/prettier-schematics
Without Angular CLI v6+
You can also install prettier-schematics with npm or yarn, using :
npm i [-g] @mace/prettier-schematics
yarn [global] add @mace/prettier-schematics
In order to run one of the following schematics, you could either use :
ng generate <schematic> --collection=@mace/prettier-schematics
or the Schematics CLI
To do so, you'll have to install it globally, along with prettier-schematics :
npm i -g @angular-devkit/schematics-cli
yarn global add @angular-devkit/schematics-cli
For more informations about Schematics, go to Schematics — An Introduction.
Initialize your project to allow the use of prettier.
The following schematics are also run when using this one :
This is the schematic Angular CLI will run when using
Do not run npm / yarn install after adding the required dependencies.skip-scripts
Do not generate the scripts helping to run prettier on your workspacehook
Also run the prettier-hook schematic in order to add the associated pre-commit hook.
Generate prettier config files.
Set single-quote Prettier rule value.
Set print-width Prettier rule value.
Generate a git pre-commit hook (thanks to husky and lint-staged) which auto-format your staged files with prettier before any commit.
Do not run npm / yarn install after adding the required dependencies.
Scripts are generated by the
prettier-init schematic. You'll need to run it before using this scripts.
Run prettier on all your workspace files.
npm run prettify
See my current TO-DO List for more informations on upcoming features.