-
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 9 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://make.wordpress.org/core/handbook/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 | ||
Comment on lines
-9
to
+14
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. 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 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. @felixarntz 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 commentThe 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 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. 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. |
||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.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 | ||
devansh016 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Files and folders related to build | ||
/build | ||
/node_modules | ||
/vendor | ||
/dist | ||
|
||
# Minified files | ||
/*.min.js | ||
|
||
# Ignore Composer lock file | ||
composer.lock | ||
|
||
# Ignore npm package lock file | ||
package-lock.json |
This file was deleted.
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. Is this any different than 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. No, functionally they're identical in this case. Both .prettierrc.js and .prettierrc contain the same configuration options and produce the same formatting results. 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. Alternatively, it could be added to "prettier": "@wordpress/prettier-config", |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Import the default config file and expose it in the project root. | ||
// Useful for editor integrations. | ||
const wpPrettierConfig = require( '@wordpress/prettier-config' ); | ||
|
||
module.exports = { | ||
...wpPrettierConfig, | ||
overrides: [ | ||
{ | ||
files: '*.yml', | ||
options: { | ||
useTabs: false, | ||
tabWidth: 2, | ||
}, | ||
}, | ||
], | ||
}; | ||
swissspidy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
{ | ||
"core": null, | ||
"plugins": [ | ||
"./plugins/optimization-detective", | ||
"./plugins/auto-sizes", | ||
"./plugins/dominant-color-images", | ||
"./plugins/embed-optimizer", | ||
"./plugins/image-prioritizer", | ||
"./plugins/performance-lab", | ||
"./plugins/speculation-rules", | ||
"./plugins/web-worker-offloading", | ||
"./plugins/webp-uploads" | ||
], | ||
"env": { | ||
"tests": { | ||
"config": { | ||
"FS_METHOD": "direct" | ||
}, | ||
"mappings": { | ||
"/wp-content/plugins/performance": "." | ||
} | ||
} | ||
} | ||
"core": null, | ||
swissspidy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"plugins": [ | ||
"./plugins/optimization-detective", | ||
"./plugins/auto-sizes", | ||
"./plugins/dominant-color-images", | ||
"./plugins/embed-optimizer", | ||
"./plugins/image-prioritizer", | ||
"./plugins/performance-lab", | ||
"./plugins/speculation-rules", | ||
"./plugins/web-worker-offloading", | ||
"./plugins/webp-uploads" | ||
], | ||
"env": { | ||
"tests": { | ||
"config": { | ||
"FS_METHOD": "direct" | ||
}, | ||
"mappings": { | ||
"/wp-content/plugins/performance": "." | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.