Skip to content
Permalink
Browse files

update docs

  • Loading branch information...
schuchard committed Nov 7, 2018
1 parent 003eaf9 commit f53e44b1e8f25fbb3279c68d031ac7564152abda
@@ -23,6 +23,20 @@ ng g @schuchard/prettier:add

## How does Prettier work with Angular

### Angular formatting

Beginning with [1.15](https://prettier.io/blog/2018/11/07/1.15.0.html#html-vue-angular), Prettier supports formatting HTML and Angular files.

#### Format all Angular Files - `{js,json,css,md,ts,html,component.html}`

![format-angular-files](docs/prettier-ng-sm.png)

#### Format only Typescript files

Previous versions of this schematic only formatted Typescript files. That functionality is still available and is configured in the CLI prompts or via the `--formatAllAngularFiles=false` if desired. The default is `true`.

![format-typescript-files](docs/prettier-ts-sm.png)

### Automatically with lint-staged

By default [lint-staged](https://github.com/okonet/lint-staged) is [configured](https://prettier.io/docs/en/precommit.html#option-1-lint-staged-https-githubcom-okonet-lint-staged) along with a pre-commit hook. This will run Prettier against all new files as they are committed according to the settings defined in `prettier.config.json`. Generally speaking, your workflow should remain unchanged - `git add, commit, push`
@@ -39,7 +53,7 @@ ng g @schuchard/prettier:add --lintStaged=false

### Manually

While lint-staged only runs prettier against staged files, you can manually run Prettier against **ALL** typescript files with the script added to the `package.json`
While lint-staged only runs prettier against staged files, you can manually run Prettier against **ALL** [targeted](#Angular-formatting) files with the script added to the `package.json`

`npm run prettier`

@@ -51,7 +65,7 @@ This schematic takes advantage of CLI [prompts](https://github.com/angular/angul

```ng g @schuchard/prettier:add --printWidth=100```
![schematic-cli](docs/prettier-schematic-cli.gif)
![schematic-cli](docs/prettier-cli-sm.png)
### < Angular 7
Binary file not shown.
BIN +269 KB docs/prettier-cli.png
Binary file not shown.
Binary file not shown.
BIN +298 KB docs/prettier-ng.png
Binary file not shown.
Binary file not shown.
BIN +120 KB docs/prettier-ts.png
Binary file not shown.
@@ -16,6 +16,7 @@
"build:clean:launch": "run-s build:once clean launch:schematic:noPrompts",
"build:clean:launch:test": "run-s build:once clean launch:schematic:noPrompts && cd sandbox && yarn prettier",
"link:sandbox": "yarn link && cd sandbox && yarn link \"@schuchard/prettier\"",
"update:sandbox": "cd sandbox && ng update --all",
"cm": "git-cz",
"release": "yarn build:once && yarn np"
},

0 comments on commit f53e44b

Please sign in to comment.
You can’t perform that action at this time.