Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Improve the precommit hook (Azure#11107)
Browse files Browse the repository at this point in the history
* Create rush-prettier autoinstaller

* Update the hook script to use rush command

* do not restage formatted files

* update .prettierignore to work with pretty-quick
  • Loading branch information
deyaaeldeen authored and sadasant committed Sep 10, 2020
1 parent 035d73f commit a5fe4ba
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
src/generated/
review/*.api.md
*.yml
*.yaml
*.d.ts
**/src/generated/
**/review/*.api.md
**/*.yml
**/*.yaml
**/*.d.ts
9 changes: 9 additions & 0 deletions common/autoinstallers/rush-prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "rush-prettier",
"version": "1.0.0",
"private": true,
"dependencies": {
"prettier": "^1.16.4",
"pretty-quick": "^3.0.0"
}
}
330 changes: 330 additions & 0 deletions common/autoinstallers/rush-prettier/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@
"summary": "Unlink dependencies and purge downloaded node_modules",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "rush unlink && rush purge"
},
{
"name": "prettier",
"commandKind": "global",
"summary": "Used by the pre-commit Git hook. This command invokes Prettier to reformat staged changes.",

"autoinstallerName": "rush-prettier",

// This will invoke common/autoinstallers/rush-prettier/node_modules/.bin/pretty-quick
"shellCommand": "pretty-quick --staged --no-restage"
}
],

Expand Down
3 changes: 1 addition & 2 deletions common/config/rush/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* When someone asks for "^1.0.0" make sure they get "1.2.3" when working in this repo,
* instead of the latest version.
*/
"prettier": "^1.16.4",
"precise-commits": "^1.0.2"
// "some-library": "1.2.3"
},
/**
* When set to true, for all projects in the repo, all dependencies will be automatically added as preferredVersions,
Expand Down

0 comments on commit a5fe4ba

Please sign in to comment.