Skip to content

Commit 2a5e489

Browse files
committed
build: set prettier as the code formatter with ng-dev tools
Code formatting for TypeScript, JavaScript, JSON, YAML, and Markdown files will now be enforced by the ng-dev tools via prettier. A CI check is now in place as well to verify the formatting for PRs. (cherry picked from commit 40e8a9a)
1 parent 54aa4a3 commit 2a5e489

File tree

7 files changed

+293
-119
lines changed

7 files changed

+293
-119
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ jobs:
172172
else
173173
echo "This build is not over a PR, nothing to do."
174174
fi
175+
- run:
176+
name: Validate Code Formatting
177+
command: yarn -s ng-dev format changed <<pipeline.git.base_revision>> --check
175178
- run:
176179
command: yarn -s admin validate
177180

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname $0)/_/husky.sh"
3+
4+
yarn -s ng-dev format staged;

.ng-dev/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { commitMessage } from './commit-message';
2+
export { format } from './format';
23
export { github } from './github';
34
export { merge } from './merge';

.ng-dev/format.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { FormatConfig } from '@angular/dev-infra-private/format/config';
2+
3+
/**
4+
* Configuration for the `ng-dev format` command.
5+
*/
6+
export const format: FormatConfig = {
7+
'prettier': {
8+
matchers: ['**/*.{ts,js,json,yml,yaml,md}']
9+
},
10+
}

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/bazel-out/
2+
/docs/design/analytics.md
23
/dist-schema/
3-
/etc/api
4+
/etc/api/
5+
/packages/angular_devkit/build_angular/test/
6+
/packages/angular_devkit/core/src/workspace/json/test/
47
/tests/
58
/README.md
69
/CONTRIBUTING.md

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,26 @@
6363
]
6464
},
6565
"devDependencies": {
66-
"@angular/animations": "12.0.0-next.9",
67-
"@angular/cdk": "11.2.9",
68-
"@angular/common": "12.0.0-next.9",
69-
"@angular/compiler": "12.0.0-next.9",
70-
"@angular/compiler-cli": "12.0.0-next.9",
71-
"@angular/core": "12.0.0-next.9",
72-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#5b8b7a8b04e205eea784168a511c0258fb9995f3",
73-
"@angular/forms": "12.0.0-next.9",
74-
"@angular/localize": "12.0.0-next.9",
75-
"@angular/material": "11.2.9",
76-
"@angular/platform-browser": "12.0.0-next.9",
77-
"@angular/platform-browser-dynamic": "12.0.0-next.9",
78-
"@angular/platform-server": "12.0.0-next.9",
79-
"@angular/router": "12.0.0-next.9",
80-
"@angular/service-worker": "12.0.0-next.9",
81-
"@babel/core": "7.13.13",
82-
"@babel/generator": "7.13.9",
83-
"@babel/plugin-transform-runtime": "7.13.10",
84-
"@babel/preset-env": "7.13.12",
85-
"@babel/runtime": "7.13.10",
66+
"@angular/animations": "12.0.0-rc.0",
67+
"@angular/cdk": "11.2.10",
68+
"@angular/common": "12.0.0-rc.0",
69+
"@angular/compiler": "12.0.0-rc.0",
70+
"@angular/compiler-cli": "12.0.0-rc.0",
71+
"@angular/core": "12.0.0-rc.0",
72+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e",
73+
"@angular/forms": "12.0.0-rc.0",
74+
"@angular/localize": "12.0.0-rc.0",
75+
"@angular/material": "11.2.10",
76+
"@angular/platform-browser": "12.0.0-rc.0",
77+
"@angular/platform-browser-dynamic": "12.0.0-rc.0",
78+
"@angular/platform-server": "12.0.0-rc.0",
79+
"@angular/router": "12.0.0-rc.0",
80+
"@angular/service-worker": "12.0.0-rc.0",
81+
"@babel/core": "7.13.16",
82+
"@babel/generator": "7.13.16",
83+
"@babel/plugin-transform-runtime": "7.13.15",
84+
"@babel/preset-env": "7.13.15",
85+
"@babel/runtime": "7.13.17",
8686
"@babel/template": "7.12.13",
8787
"@bazel/bazelisk": "1.8.0",
8888
"@bazel/buildifier": "4.0.1",

0 commit comments

Comments
 (0)