-
Notifications
You must be signed in to change notification settings - Fork 945
Adding Prettier on Commit #580
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
], | ||
"scripts": { | ||
"dev": "lerna run --parallel --scope @firebase/* --scope firebase dev", | ||
"precommit": "lint-staged", | ||
"prepare": "lerna run --scope @firebase/* --scope firebase prepare", | ||
"prepush": "node tools/gitHooks/prepush.js", | ||
"link:packages": "lerna exec --scope @firebase/* --scope firebase -- yarn link", | ||
|
@@ -52,6 +53,7 @@ | |
"istanbul-instrumenter-loader": "^3.0.0", | ||
"lcov-result-merger": "^2.0.0", | ||
"lerna": "^2.9.0", | ||
"lint-staged": "^7.0.0", | ||
"listr": "^0.13.0", | ||
"merge2": "^1.2.1", | ||
"mkdirp": "^0.5.1", | ||
|
@@ -62,5 +64,15 @@ | |
"semver": "^5.5.0", | ||
"simple-git": "^1.91.0", | ||
"yargs": "^11.0.0" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"prettier --write", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier.js references repo-root/.prettierrc. Are we losing that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just verified that this still works. |
||
"git add" | ||
], | ||
"*.js": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh boy... I don't know if I trust prettier enough to let it silently modify my commits. Then I can't tell what it did and I might not notice problems. Today I always run "yarn prepush" manually, check what it did, and then if I'm satisfied, I'll clean up the git history via "git rebase -i master" or whatever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the staged files makes it really easy to figure out what files to re-format. A while ago, I tried something similar to what you suggested in #531 (diff against origin & upstream) but wasn't able to get it to work properly in between my other work.
I personally don't like the Prettier commits but I also don't want to take them away from you (since I can just rebase if need be). Maybe there is some way we can still stage them in a separate commit (by not passing
--write
, or not doinggit add
?). Do you have suggestions for this, @jshcrowthe?I do want to ask though if it is even possible to disagree with prettier. If you manually re-format prettier's changes, doesn't it just revert these changes on the next run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what this would entail, but we could do a
post-commit
hook and just try and format the last diff? I dunno what it would require/look like, but it seems doable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sometimes choose to wrap lines differently (or restructure code to avoid wrapping, etc.). And I just like to know what prettier is doing. We've run into cases where it just does wonky reformatting (either due to bugs or poor design) and I like to notice those when they happen.