Skip to content

Commit 40e8a9a

Browse files
clydindgp1130
authored andcommitted
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.
1 parent b9309c1 commit 40e8a9a

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

.circleci/config.yml

+3
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

+4
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

+1
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

+10
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

+4-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@angular/compiler": "12.0.0-rc.0",
7070
"@angular/compiler-cli": "12.0.0-rc.0",
7171
"@angular/core": "12.0.0-rc.0",
72-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f",
72+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e",
7373
"@angular/forms": "12.0.0-rc.0",
7474
"@angular/localize": "12.0.0-rc.0",
7575
"@angular/material": "11.2.10",

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
dependencies:
8585
tslib "^2.0.0"
8686

87-
"@angular/dev-infra-private@https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f":
87+
"@angular/dev-infra-private@https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e":
8888
version "0.0.0"
89-
resolved "https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f"
89+
resolved "https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e"
9090
dependencies:
9191
"@angular/benchpress" "0.2.1"
9292
"@bazel/buildifier" "^4.0.1"

0 commit comments

Comments
 (0)