Prettier-schematics
@angular/devkit Schematics for Prettier.
Motivation
Based on the comment added to an associated issue in angular-cli.
Installation
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
- or
yarn [global] add @mace/prettier-schematics
Schematics
In order to run one of the following schematics, you could either use :
-
Angular CLI
ng generate <schematic> --collection=@mace/prettier-schematics
-
or the Schematics CLI
schematics @mace/prettier-schematics:<schematic>
To do so, you'll have to install it globally, along with prettier-schematics :
npm i -g @angular-devkit/schematics-cli
- or
yarn global add @angular-devkit/schematics-cli
For more informations about Schematics, go to Schematics — An Introduction.
prettier-init
Initialize your project to allow the use of prettier.
Alias :
ng-add
The following schematics are also run when using this one :
prettier-config
This is the schematic Angular CLI will run when using ng add
.
Options
skip-install
--skip-install
Do not run npm / yarn install after adding the required dependencies.
skip-scripts
--skip-scripts
Do not generate the scripts helping to run prettier on your workspace
hook
--hook
Also run the prettier-hook schematic in order to add the associated pre-commit hook.
Default: true
+ all prettier-config
and prettier-hook
options
prettier-config
Generate prettier config files.
Options
prettier-hook
Generate a git pre-commit hook (thanks to husky and lint-staged) which auto-format your staged files with prettier before any commit.
Options
skip-install
--skip-install
Do not run npm / yarn install after adding the required dependencies.
Scripts
Scripts are generated by the prettier-init
schematic. You'll need to run it before using this scripts.
Prettify
Run prettier on all your workspace files.
Command : npm run prettify
Misc
See my current TO-DO List for more informations on upcoming features.