Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the precommit hook #11107

Merged
merged 4 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also curious if this makes a difference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty-quick applies the rules in .prettierignore file in a way different from prettier. The former applies the rules relative to the root of source control tree (see here) but the latter applies the rules relative to the ignore path (see here). It is confusing and there is an issue opened for it here: prettier/pretty-quick#95 (comment).

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks cool!

}
],

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