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.
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
Formats json and yml files using npm run format #1605
base: trunk
Are you sure you want to change the base?
Formats json and yml files using npm run format #1605
Changes from 9 commits
f101786
3fed57a
eaaa59d
a3ae0e1
d336d2a
90ac758
1d13a44
a565773
afc3339
4a9d135
f9a6838
6773f8e
376b0fd
9356e5a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
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.
Why do we need this override?
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.
@swissspidy When both
.editorconfig
and.prettierrc
are present, Prettier gives precedence to.prettierrc
. Further the recommended indentation for YAML files is two spaces per level, so we override it here.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.
But the default Prettier config should be correct for our needs, and the editorconfig should match the Prettier config 🤔
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.
@swissspidy The default Prettier configuration should suffice for our needs, and ensuring that the
.editorconfig
aligns with it eliminates the need for overrides. I have remove this overrides and now the .yml files formating looks similar to one in gutenberg project ref.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.
Per https://github.com/WordPress/performance/blob/trunk/.editorconfig#L23-L25 the json config it should use two space not tab 🤔
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.
It seems that when running
npm run format-js
, the.editorconfig
settings are not being applied, which is causing JSON files to use tabs instead of 2 spaces as specified in the.editorconfig
. It appears the command is currently using the .prettierrc configuration instead.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.
When both
.editorconfig
and.prettierrc
are present, Prettier gives precedence to.prettierrc
. You can override config for yml and json to change this behavior from the Prettier config file - https://prettier.io/docs/en/configuration.html#configuration-overridesThere 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.
Seems strange that we have to apply a manual override for the default Prettier configuration used by wp-scripts, as that is the de facto standard.
Our
.editorconfig
file looks quite different from what's in core or Gutenberg. They both use tabs for JSON files for example.So I think we should rather update our
.editorconfig
rather than the Prettier config.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.
Yeah, I noticed that too the other week. FWIW the
.editorconfig
we use is old, and a long time ago I believe this was common in WP land to use two spaces for those kinds of files. But since Gutenberg provides centralized tooling that dictates otherwise, I feel like it would make sense to align with that.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 have updated the
.editorconfig
file to align with the settings used in Core and Gutenberg, where JSON files use tabs instead of 2 spaces. This should prevent conflicts with the existing Prettier configuration and ensure consistency across the project.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.
Thanks. Can we then remove this
.prettierrc.js
override for yml files? We should be able to use the default config for those too, no?