-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Prettify docs files #2275
Prettify docs files #2275
Conversation
facebook-github-bot
left a comment
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.
@yangshun has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Oh this is cool. Ideally yeah, let's enforce it in |
facebook-github-bot
left a comment
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.
@yangshun has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
package.json
Outdated
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.
Not sure if prettier differences are considered part of linting?
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.
Yep that's legit, the && enforces a clean Alex pass before Prettier
prettier.config.js
Outdated
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.
Use Flow only for JS so that other filetypes can be formatted by Prettier using their respective parsers.
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.
Are there other files that should be formatted by flow? e.g. .json or inlined into .html files?
facebook-github-bot
left a comment
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.
@yangshun has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
website/README.md
Outdated
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.
🎉
facebook-github-bot
left a comment
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.
@yangshun has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: **Summary** Prettier can also be used to format more than just JS files, it can format Markdown files too. Instead of using Flow parser for all files in `prettier.config.js`, we can just limit Flow parser for JS files and let Prettier find the default parsers for the various file formats. Hence I tweaked the Prettier config and added overrides for: - JS format - Use Flow parser - Markdown format - Restrict to 80 characters so that it's easier to read I then ran Prettier on all the docs. I've added a `prettier:diff` command into the `lint-docs` step, ran alongside with Alex that will fail when there are unformatted docs. It's not part of the CI step as I think that might be a bit too strict given that some people (including myself) edit docs in the GitHub UI and that might cause formatting issues which can be fixed by running the `format-docs` command every now and then. The formatting is only restricted to the docs now and not code as it's potentially dangerous to format code that gets synced with internal FB repos. **Test Plan** Load website. Pull Request resolved: facebookarchive#2275 Reviewed By: mrkev Differential Revision: D18807420 Pulled By: yangshun fbshipit-source-id: b3f34282c2a2cad8e89cd90e8f3f6b3860b747fc
Summary: **Summary** Prettier can also be used to format more than just JS files, it can format Markdown files too. Instead of using Flow parser for all files in `prettier.config.js`, we can just limit Flow parser for JS files and let Prettier find the default parsers for the various file formats. Hence I tweaked the Prettier config and added overrides for: - JS format - Use Flow parser - Markdown format - Restrict to 80 characters so that it's easier to read I then ran Prettier on all the docs. I've added a `prettier:diff` command into the `lint-docs` step, ran alongside with Alex that will fail when there are unformatted docs. It's not part of the CI step as I think that might be a bit too strict given that some people (including myself) edit docs in the GitHub UI and that might cause formatting issues which can be fixed by running the `format-docs` command every now and then. The formatting is only restricted to the docs now and not code as it's potentially dangerous to format code that gets synced with internal FB repos. **Test Plan** Load website. Pull Request resolved: facebookarchive#2275 Reviewed By: mrkev Differential Revision: D18807420 Pulled By: yangshun fbshipit-source-id: b3f34282c2a2cad8e89cd90e8f3f6b3860b747fc
Summary: **Summary** Prettier can also be used to format more than just JS files, it can format Markdown files too. Instead of using Flow parser for all files in `prettier.config.js`, we can just limit Flow parser for JS files and let Prettier find the default parsers for the various file formats. Hence I tweaked the Prettier config and added overrides for: - JS format - Use Flow parser - Markdown format - Restrict to 80 characters so that it's easier to read I then ran Prettier on all the docs. I've added a `prettier:diff` command into the `lint-docs` step, ran alongside with Alex that will fail when there are unformatted docs. It's not part of the CI step as I think that might be a bit too strict given that some people (including myself) edit docs in the GitHub UI and that might cause formatting issues which can be fixed by running the `format-docs` command every now and then. The formatting is only restricted to the docs now and not code as it's potentially dangerous to format code that gets synced with internal FB repos. **Test Plan** Load website. Pull Request resolved: facebookarchive/draft-js#2275 Reviewed By: mrkev Differential Revision: D18807420 Pulled By: yangshun fbshipit-source-id: b3f34282c2a2cad8e89cd90e8f3f6b3860b747fc
Summary
Prettier can also be used to format more than just JS files, it can format Markdown files too. Instead of using Flow parser for all files in
prettier.config.js, we can just limit Flow parser for JS files and let Prettier find the default parsers for the various file formats.Hence I tweaked the Prettier config and added overrides for:
I then ran Prettier on all the docs. I've added a
prettier:diffcommand into thelint-docsstep, ran alongside with Alex that will fail when there are unformatted docs. It's not part of the CI step as I think that might be a bit too strict given that some people (including myself) edit docs in the GitHub UI and that might cause formatting issues which can be fixed by running theformat-docscommand every now and then.The formatting is only restricted to the docs now and not code as it's potentially dangerous to format code that gets synced with internal FB repos.
Test Plan
Load website.