-
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
Open
devansh016
wants to merge
21
commits into
WordPress:trunk
Choose a base branch
from
devansh016:Format-files-using-npm-run-format-js
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25,285
−25,291
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f101786
Formats json and yml files using npm run format
devansh016 3fed57a
Adds override config for yml and json
devansh016 eaaa59d
Formats json and yml files
devansh016 a3ae0e1
Add singleQuote for yml files
devansh016 d336d2a
Ignores generated lock files
devansh016 90ac758
Updates .editorconfig as per core and Gutenberg
devansh016 1d13a44
Formats using npm run format-js
devansh016 a565773
Updates patterns to ignore
devansh016 afc3339
Overides .yml config to use 2 spaces
devansh016 4a9d135
Adds file end line and update WordPress coding standards URL
devansh016 f9a6838
Merge branch 'trunk' of github.com:devansh016/wp-performance into For…
devansh016 6773f8e
Merge branch 'Format-files-using-npm-run-format-js' of github.com:dev…
devansh016 376b0fd
Merge branch 'trunk' of github.com:devansh016/wp-performance into For…
devansh016 9356e5a
Removes yml file override from prettier config
devansh016 9f687fd
Merge branch 'trunk' into Format-files-using-npm-run-format-js
devansh016 278fd9a
Merge branch 'trunk' into Format-files-using-npm-run-format-js
devansh016 3432198
Merge branch 'trunk' of https://github.com/WordPress/performance into…
westonruter 981e5e5
Update package-lock.json
westonruter 7c0f56c
Ignore build files in plugins and fix path to ignore minified files
westonruter d59caf6
Remove duplicate prettier config file
devansh016 ebeefd3
Update indent size to 4 for yml and yaml
devansh016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
indent_size = 4 | ||
|
||
[*.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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,93 @@ | ||
name: Bump WordPress Tested up to | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
plugin: | ||
type: string | ||
description: 'Plugin slug (leave empty for all plugins)' | ||
required: false | ||
workflow_dispatch: | ||
inputs: | ||
plugin: | ||
type: string | ||
description: 'Plugin slug (leave empty for all plugins)' | ||
required: false | ||
|
||
jobs: | ||
prepare-matrix: | ||
name: Prepare plugins matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.plugins }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
prepare-matrix: | ||
name: Prepare plugins matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.plugins }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure plugin matrix | ||
id: set-matrix | ||
env: | ||
PLUGIN_SLUG: ${{ inputs.plugin }} | ||
run: | | ||
PLUGINS=$(jq -r '.plugins' plugins.json) | ||
if [[ -n "$PLUGIN_SLUG" ]]; then | ||
if echo $PLUGINS | jq -e '.[] | select(. == "'$PLUGIN_SLUG'")' > /dev/null; then | ||
PLUGINS="[ \"$PLUGIN_SLUG\" ]" | ||
else | ||
echo "::error::Plugin '$PLUGIN_SLUG' not found in plugins.json" | ||
exit 1 | ||
fi | ||
fi | ||
echo "::notice::Updating plugins: $(echo ${PLUGINS[@]})" | ||
echo "plugins=$(echo $PLUGINS | jq -c .)" >> $GITHUB_OUTPUT | ||
- name: Configure plugin matrix | ||
id: set-matrix | ||
env: | ||
PLUGIN_SLUG: ${{ inputs.plugin }} | ||
run: | | ||
PLUGINS=$(jq -r '.plugins' plugins.json) | ||
if [[ -n "$PLUGIN_SLUG" ]]; then | ||
if echo $PLUGINS | jq -e '.[] | select(. == "'$PLUGIN_SLUG'")' > /dev/null; then | ||
PLUGINS="[ \"$PLUGIN_SLUG\" ]" | ||
else | ||
echo "::error::Plugin '$PLUGIN_SLUG' not found in plugins.json" | ||
exit 1 | ||
fi | ||
fi | ||
echo "::notice::Updating plugins: $(echo ${PLUGINS[@]})" | ||
echo "plugins=$(echo $PLUGINS | jq -c .)" >> $GITHUB_OUTPUT | ||
|
||
update-compatibility: | ||
name: Update "Tested up to" value for ${{ matrix.plugin }} | ||
needs: prepare-matrix | ||
runs-on: ubuntu-latest | ||
env: | ||
PLUGIN_SLUG: ${{ matrix.plugin }} | ||
strategy: | ||
matrix: | ||
plugin: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
update-compatibility: | ||
name: Update "Tested up to" value for ${{ matrix.plugin }} | ||
needs: prepare-matrix | ||
runs-on: ubuntu-latest | ||
env: | ||
PLUGIN_SLUG: ${{ matrix.plugin }} | ||
strategy: | ||
matrix: | ||
plugin: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download WordPress.org readme | ||
run: | | ||
# Download the current readme.txt from WordPress.org | ||
curl -sSL --retry 3 --retry-delay 5 --retry-all-errors --fail -o /tmp/wp-org-readme.txt "https://plugins.svn.wordpress.org/$PLUGIN_SLUG/trunk/readme.txt" | ||
if [ $? -ne 0 ]; then | ||
echo "::error::Could not fetch readme.txt from WordPress.org for $PLUGIN_SLUG" | ||
exit 1 | ||
fi | ||
- name: Download WordPress.org readme | ||
run: | | ||
# Download the current readme.txt from WordPress.org | ||
curl -sSL --retry 3 --retry-delay 5 --retry-all-errors --fail -o /tmp/wp-org-readme.txt "https://plugins.svn.wordpress.org/$PLUGIN_SLUG/trunk/readme.txt" | ||
if [ $? -ne 0 ]; then | ||
echo "::error::Could not fetch readme.txt from WordPress.org for $PLUGIN_SLUG" | ||
exit 1 | ||
fi | ||
|
||
- name: Extract "Tested up to" version from repository | ||
id: extract-tested-up-to | ||
run: | | ||
LOCAL_TESTED_UP_TO=$(grep -E "^Tested up to:" "./plugins/$PLUGIN_SLUG/readme.txt" | awk -F ': +' '{print $2}') | ||
if [ -z "$LOCAL_TESTED_UP_TO" ]; then | ||
echo "::error::Unable to parse Tested up to version from repository readme.txt" | ||
exit 1 | ||
fi | ||
- name: Extract "Tested up to" version from repository | ||
id: extract-tested-up-to | ||
run: | | ||
LOCAL_TESTED_UP_TO=$(grep -E "^Tested up to:" "./plugins/$PLUGIN_SLUG/readme.txt" | awk -F ': +' '{print $2}') | ||
if [ -z "$LOCAL_TESTED_UP_TO" ]; then | ||
echo "::error::Unable to parse Tested up to version from repository readme.txt" | ||
exit 1 | ||
fi | ||
|
||
echo "version=$LOCAL_TESTED_UP_TO" >> $GITHUB_OUTPUT | ||
echo "version=$LOCAL_TESTED_UP_TO" >> $GITHUB_OUTPUT | ||
|
||
- name: Prepare and update readme.txt | ||
env: | ||
LOCAL_TESTED_UP_TO: ${{ steps.extract-tested-up-to.outputs.version }} | ||
run: | | ||
# Replace local readme.txt with WordPress.org version, updating only the "Tested up to" line. | ||
cp /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" | ||
sed -i -E 's/^(Tested up to:[[:space:]]*).+/\1'"$LOCAL_TESTED_UP_TO"'/' "./plugins/$PLUGIN_SLUG/readme.txt" | ||
- name: Prepare and update readme.txt | ||
env: | ||
LOCAL_TESTED_UP_TO: ${{ steps.extract-tested-up-to.outputs.version }} | ||
run: | | ||
# Replace local readme.txt with WordPress.org version, updating only the "Tested up to" line. | ||
cp /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" | ||
sed -i -E 's/^(Tested up to:[[:space:]]*).+/\1'"$LOCAL_TESTED_UP_TO"'/' "./plugins/$PLUGIN_SLUG/readme.txt" | ||
|
||
# Show the diff of what's being updated. | ||
echo "Changes made to readme.txt:" | ||
diff -u /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" || true | ||
# Show the diff of what's being updated. | ||
echo "Changes made to readme.txt:" | ||
diff -u /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" || true | ||
|
||
- name: Copy readme.txt to workspace root for SVN upload | ||
run: cp "./plugins/$PLUGIN_SLUG/readme.txt" "$GITHUB_WORKSPACE/readme.txt" | ||
- name: Copy readme.txt to workspace root for SVN upload | ||
run: cp "./plugins/$PLUGIN_SLUG/readme.txt" "$GITHUB_WORKSPACE/readme.txt" | ||
|
||
- name: Push to WordPress.org | ||
uses: 10up/action-wordpress-plugin-asset-update@stable | ||
env: | ||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
SLUG: ${{ matrix.plugin }} | ||
SKIP_ASSETS: true | ||
IGNORE_OTHER_FILES: true | ||
- name: Push to WordPress.org | ||
uses: 10up/action-wordpress-plugin-asset-update@stable | ||
env: | ||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
SLUG: ${{ matrix.plugin }} | ||
SKIP_ASSETS: true | ||
IGNORE_OTHER_FILES: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.