-
Notifications
You must be signed in to change notification settings - Fork 115
Improve formatting of .json
and .yml
files
#1605
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
base: trunk
Are you sure you want to change the base?
Improve formatting of .json
and .yml
files
#1605
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Let's also do linting of JSON and YML files in the lint-staged config so this doesn't happen again. Also, why isn't the formatting not causing a failure on the GHA checks? |
Will Dependabot updates undo the changes to |
|
I think we squash and merge this one and include an ignore commit for the merge commit to hide it in git blame. Ref: https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view. |
We should exclude generated lock files from Prettier, just to avoid conflicts |
Yes, we should ignore any auto-generated files. @devansh016 can you please add a https://prettier.io/docs/en/ignore.html with such files? |
See also WordPress/gutenberg#30714 in which Gutenberg started applying formatting to JSON files. |
Co-authored-by: Mukesh Panchal <[email protected]>
I think we still need to confirm Dependabot's behavior. We wouldn't want it constantly reverting tabs back to spaces. |
Dependabot generally respects the indentation style in |
…mat-files-using-npm-run-format-js
…ansh016/wp-performance into Format-files-using-npm-run-format-js
…mat-files-using-npm-run-format-js
This comment was marked as spam.
This comment was marked as spam.
indent_size = 4 | ||
tab_width = 4 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = 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.
Why this change? The tab width for actual code (PHP and JS) should be 4, so I don't see why this needs to be removed here.
It doesn't apply to .json
and .yml
, but then we should have specific rules for these file types.
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.
@felixarntz
When both .editorconfig and .prettierrc are present, Prettier gives precedence to .prettierrc, which ensures PHP and JS files retain their intended 4-space/tab indentation.
I removed the global indent_size = 4 from .editorconfig since it was unintentionally being inherited by .json and .yml files. These files conventionally follow 2-space indentation, so I added specific overrides for them instead.
These updates follow the coding standards defined in the WordPress Core and Gutenberg repositories to stay aligned with WordPress development practices.
Please let me know if you'd like me to make any adjustments or if there's anything I might have missed. Thanks!
.json
and .yml
files
Note that there are now some merge conflicts too |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #1605 +/- ##
=======================================
Coverage 68.06% 68.06%
=======================================
Files 92 92
Lines 7626 7626
=======================================
Hits 5191 5191
Misses 2435 2435
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes #1603
Relevant technical choices
The following files have been formatted by using
npm run format-js
Note: .yml and .json files were not ignored to ensure they are properly formatted as well.