Skip to content

Commit

Permalink
build: set prettier as the code formatter with ng-dev tools
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin authored and dgp1130 committed Apr 28, 2021
1 parent b9309c1 commit 40e8a9a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ jobs:
else
echo "This build is not over a PR, nothing to do."
fi
- run:
name: Validate Code Formatting
command: yarn -s ng-dev format changed <<pipeline.git.base_revision>> --check
- run:
command: yarn -s admin validate

Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

yarn -s ng-dev format staged;
1 change: 1 addition & 0 deletions .ng-dev/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { commitMessage } from './commit-message';
export { format } from './format';
export { github } from './github';
export { merge } from './merge';
10 changes: 10 additions & 0 deletions .ng-dev/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FormatConfig } from '@angular/dev-infra-private/format/config';

/**
* Configuration for the `ng-dev format` command.
*/
export const format: FormatConfig = {
'prettier': {
matchers: ['**/*.{ts,js,json,yml,yaml,md}']
},
}
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/bazel-out/
/docs/design/analytics.md
/dist-schema/
/etc/api
/etc/api/
/packages/angular_devkit/build_angular/test/
/packages/angular_devkit/core/src/workspace/json/test/
/tests/
/README.md
/CONTRIBUTING.md
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@angular/compiler": "12.0.0-rc.0",
"@angular/compiler-cli": "12.0.0-rc.0",
"@angular/core": "12.0.0-rc.0",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e",
"@angular/forms": "12.0.0-rc.0",
"@angular/localize": "12.0.0-rc.0",
"@angular/material": "11.2.10",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
dependencies:
tslib "^2.0.0"

"@angular/dev-infra-private@https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f":
"@angular/dev-infra-private@https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e":
version "0.0.0"
resolved "https://github.com/angular/dev-infra-private-builds.git#8e28890cecf2ac5d0d5ca590fafc323dea5f133f"
resolved "https://github.com/angular/dev-infra-private-builds.git#0d0c8c43a08fa6d52540283a607c7289e8165c9e"
dependencies:
"@angular/benchpress" "0.2.1"
"@bazel/buildifier" "^4.0.1"
Expand Down

0 comments on commit 40e8a9a

Please sign in to comment.