Adopt prettier#513
Merged
Merged
Conversation
Member
|
[diff-counting] Significant lines: 1839. This diff might be too big! Developer leads are invited to review the code. |
Member
|
[deployment-bot] Deployed to https://staging-pr.samwise.today/513/index.html |
a55610a to
93b505e
Compare
ptwu
approved these changes
Aug 23, 2020
ptwu
left a comment
Member
There was a problem hiding this comment.
Sg. Do you have a particular prettierrc file that you recommend we use? (other than just enable singlequote)
Contributor
Author
I put the config inside the package.json, so we don't need another dotfile in the root directory |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
The airbnb linter config introduces a lot of opinionated style lint rules. It helps us to establish a team wide style guide without fighting over styles, but it also adds significant burden to developers.
For example, a lot of style violations are not autofixable, so devs have to spend extra time to make linter happy. Some rules are even in conflict with each other sometimes, and devs need to find smart ways to work around them. What's worse, even after all these burdens, it's still not guaranteed that each AST corresponds to a unique style-guide approved output, so there can be still fighting over styles.
Therefore, I think it's better to introduce prettier for this case. Prettier formats all the code in an opinionated way, and it can be run in a pre-commit hook. Therefore, even if you code style looks like garbage, the pre-commit hook will fix it automatically for you like:
The diff is big, but almost all the changes are generated by
yarn format.Test Plan
CI, and use you 👀 to decide whether prettier produces nice output.