-
Notifications
You must be signed in to change notification settings - Fork 128
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?
Changes from 14 commits
f101786
3fed57a
eaaa59d
a3ae0e1
d336d2a
90ac758
1d13a44
a565773
afc3339
4a9d135
f9a6838
6773f8e
376b0fd
9356e5a
9f687fd
278fd9a
3432198
981e5e5
7c0f56c
d59caf6
ebeefd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,24 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
# WordPress Coding Standards | ||
# https://make.wordpress.org/core/handbook/best-practices/coding-standards/ | ||
# https://developer.wordpress.org/coding-standards/wordpress-coding-standards/ | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
tab_width = 4 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
[*.{yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is confusing to me. As far as I can tell, all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're absolutely right about the inconsistency. Looking at the actual formatting changes in this PR, all The For consistency and clarity, we should update this to indent_size = 4 to accurately reflect how the files are actually being formatted. This way, the .editorconfig and the actual file formatting are aligned, even though Prettier is the one enforcing the formatting rules. Would you prefer I update it to indent_size = 4, or we could remove the YAML-specific configuration entirely since Prettier is handling the formatting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably add |
||
|
||
[*.txt] | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[.*rc] | ||
insert_final_newline = false | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.yml] | ||
insert_final_newline = false | ||
quote_type = single | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[.github/CODEOWNERS] | ||
indent_style = space | ||
[*.txt] | ||
end_of_line = crlf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- "no milestone" | ||
- "[Type] Enhancement" | ||
- "github_actions" | ||
- package-ecosystem: github-actions | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- 'no milestone' | ||
- '[Type] Enhancement' | ||
- 'github_actions' | ||
|
||
- package-ecosystem: npm | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- "no milestone" | ||
- "[Type] Enhancement" | ||
- "javascript" | ||
- package-ecosystem: npm | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- 'no milestone' | ||
- '[Type] Enhancement' | ||
- 'javascript' | ||
|
||
- package-ecosystem: composer | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- "no milestone" | ||
- "[Type] Enhancement" | ||
- "php" | ||
- package-ecosystem: composer | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
labels: | ||
- 'no milestone' | ||
- '[Type] Enhancement' | ||
- 'php' |
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.Uh oh!
There was an error while loading. Please reload this page.
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!
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.
Following up on this, I am still not sure about it.
You mention it was removed because it made
.json
and.yml
files use the indent of 4, but that's exactly what is currently happening: All.json
and.yml
files use the indent of 4. So from that perspective, I don't see why having this here would be problematic.Uh oh!
There was an error while loading. Please reload this page.
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.
Looking back at this more carefully, I realize I may have overcomplicated the situation. The global indent_size = 4 shouldn't actually cause issues with .json and .yml files if we have proper Prettier configuration in place, since Prettier takes precedence for formatting.
But still we should keep the .editorconfig aligned with WordPress Core and Gutenberg repositories for consistency.