@mace/prettier-schematics

Add Prettier to your Angular CLI projects.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@mace/prettier-schematics
0.5.04 years ago5 years agoMinified + gzip package size for @mace/prettier-schematics in KB

Readme

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

<code>--skip-install</code>

Do not run npm / yarn install after adding the required dependencies.

skip-scripts

<code>--skip-scripts</code>

Do not generate the scripts helping to run prettier on your workspace

hook

<code>--hook</code>

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

single-quote

<code>--single-quote boolean</code>

Set <a href="https://prettier.io/docs/en/options.html#quotes">single-quote</a> Prettier rule value.

Default: true

print-width

<code>--print-width number</code>

Set <a href="https://prettier.io/docs/en/options.html#print-width">print-width</a> Prettier rule value.

Default: 120

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

<code>--skip-install</code>

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.