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

build: add prettier to format JSON, MD and YAML files #41880

Closed
wants to merge 2 commits into from
Closed

build: add prettier to format JSON, MD and YAML files #41880

wants to merge 2 commits into from

Conversation

alan-agius4
Copy link
Contributor

Currently there are 1419 JSON, MD and YAML files which are not formatted, with this change we add prettier to format them when a file is changed.

@alan-agius4 alan-agius4 added area: build & ci Related the build and CI infrastructure of the project action: review The PR is still awaiting reviews from at least one requested reviewer action: time-zone target: rc This PR is targeted for the next release-candidate labels Apr 29, 2021
@ngbot ngbot bot modified the milestone: Backlog Apr 29, 2021
@google-cla google-cla bot added the cla: yes label Apr 29, 2021
@josephperrott
Copy link
Member

This change will require a larger conversation as we have a few different teams as stakeholders, notably the docs team whose main medium is the .md files.

third_party/
aio/content/examples/
aio/tools/transforms/templates/
/CHANGELOG.md
Copy link
Member

Choose a reason for hiding this comment

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

We should ignore all CHANGELOG.md files as we have one in zone.js as well

Currently there are 1419 JSON, MD and YAML files which are not formatted, with this change we add prettier to format them when a file is changed.
@@ -0,0 +1,6 @@
{
"printWidth": 100,
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, currently we refrain from wrapping Markdown files at 100 chars (as it makes diffs quite verbose).
We try to keep one sentence per line, but I am not sure if prettier supports that 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @gkalpak here (as I think will @IgorMinar) - but LOL @jelbourn was just saying in a stand-up this week how he dislikes long lines in markdown. (Clearly does not have wrapping turned on in his IDE).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The printWidth setting doesn't apply to MarkDown files.

Copy link
Member

Choose a reason for hiding this comment

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

The printWidth setting doesn't apply to MarkDown files.

Are you sure? The prettier playground seems to indicate otherwise 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm.. for some reason locally it didn’t have any effect when I tried it earlier. Will take another look later on.

That said, if this is applied to markdowns I believe there is no way to have different print widths for different file types. (Example: 100 for TS and JS and unlimited for MD).

Copy link
Member

Choose a reason for hiding this comment

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

I do feel pretty strongly about line breaking. I find having overflowing lines more difficult to read, edit, and review than breaking. Our internal markdown docs tool also enforces breaking at 100 columns and I've never found that difficult to review.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jelbourn Have you tried soft wrap? https://www.jetbrains.com/webstorm/guide/tips/soft-wraps/

GitHub automatically soft wraps as well. So if you configure your editor the file contents look great.

The biggest benefit of sentence per line formating is that if you add or remove a word in a sentence you don't trigger reformatting of the entire paragraph, instead all code review tools will highlight only the modified sentence with the added/removed word with extra emphasis.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I just have a preference for not using soft wraps (since I don't like there being a disconnect between what I see and actual text-in-file).

Maybe I'm weird, but when a paragraph changes, I feel like you would generally re-read the surrounding text as well anyway to make sure the whole thing still makes sense. I don't see a reformatting as meaningfully changing the review burden in any way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be the best if the folks that do edit and review these docs the most - @aikidave and the tech writing crew - made this decision.

I think there is a lot of value in keeping the diffs minimal and clean, but Dave is the ultimate stakeholder here so we should adjust to his preferences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to wait on @aikidave response before doing any changes.

.prettierignore Outdated Show resolved Hide resolved
.prettierignore Show resolved Hide resolved
.prettierignore Show resolved Hide resolved
"printWidth": 100,
"quoteProps": "preserve",
"singleQuote": true,
"trailingComma": "all"
Copy link
Contributor

Choose a reason for hiding this comment

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

another one to consider is "bracketSpacing": false: https://prettier.io/docs/en/options.html#bracket-spacing

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: build & ci Related the build and CI infrastructure of the project cla: yes state: blocked target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants