performance icon indicating copy to clipboard operation
performance copied to clipboard

Formats json and yml files using npm run format

Open devansh016 opened this issue 1 year ago • 10 comments

Summary

Fixes https://github.com/WordPress/performance/issues/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.

.github/dependabot.yml
.github/workflows/codeql-analysis.yml
.github/workflows/deploy-plugins.yml
.github/workflows/js-lint.yml
.github/workflows/php-lint.yml
.github/workflows/php-test-plugins.yml
.github/workflows/pr-validation.yml
.github/workflows/props-bot.yml
.github/workflows/spell-check.yml
.wp-env.json
composer.json
package-lock.json
package.json
plugins.json
plugins/performance-lab/.wordpress-org/blueprints/blueprint.json
tsconfig.json

devansh016 avatar Oct 18 '24 05:10 devansh016

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: devansh016 <[email protected]>
Co-authored-by: westonruter <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>
Co-authored-by: thelovekesh <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: felixarntz <[email protected]>
Co-authored-by: phanduynam <[email protected]>
Co-authored-by: dilipom13 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

github-actions[bot] avatar Oct 18 '24 05:10 github-actions[bot]

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?

westonruter avatar Oct 18 '24 05:10 westonruter

Will Dependabot updates undo the changes to composer.json, package-lock.json, and package.json?

westonruter avatar Oct 18 '24 05:10 westonruter

Also, why isn't the formatting not causing a failure on the GHA checks?

npm run lint-js doesn't check for .yml and .json file and hence not causing a failure on the GHA checks.

devansh016 avatar Oct 18 '24 07:10 devansh016

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.

thelovekesh avatar Oct 18 '24 07:10 thelovekesh

We should exclude generated lock files from Prettier, just to avoid conflicts

swissspidy avatar Oct 18 '24 07:10 swissspidy

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?

thelovekesh avatar Oct 18 '24 07:10 thelovekesh

See also https://github.com/WordPress/gutenberg/pull/30714 in which Gutenberg started applying formatting to JSON files.

westonruter avatar Oct 18 '24 14:10 westonruter

Will Dependabot updates undo the changes to composer.json, package-lock.json, and package.json?

I think we still need to confirm Dependabot's behavior. We wouldn't want it constantly reverting tabs back to spaces.

westonruter avatar Oct 21 '24 19:10 westonruter

Will Dependabot updates undo the changes to composer.json, package-lock.json, and package.json?

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 package.json when updating the lockfile so it should not revert tabs back to spaces. Ref

devansh016 avatar Oct 22 '24 14:10 devansh016

This issue has been resolved, please close it admin

phanduynam avatar Apr 03 '25 13:04 phanduynam

Note that there are now some merge conflicts too

swissspidy avatar Apr 15 '25 13:04 swissspidy

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 68.02%. Comparing base (d1663c9) to head (ebeefd3). :warning: Report is 437 commits behind head on trunk.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #1605   +/-   ##
=======================================
  Coverage   68.02%   68.02%           
=======================================
  Files          92       92           
  Lines        7627     7627           
=======================================
  Hits         5188     5188           
  Misses       2439     2439           
Flag Coverage Δ
multisite 68.02% <ø> (ø)
single 36.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 03 '25 07:06 codecov[bot]

The following files are now being formatted when running npm run format-js:

.eslintrc.js 19ms
.github/dependabot.yml 11ms
.github/workflows/bump-wordpress-tested-up-to.yml 3ms
.github/workflows/codeql-analysis.yml 2ms
.github/workflows/deploy-plugins.yml 5ms
.github/workflows/e2e-test.yml 1ms
.github/workflows/js-lint.yml 1ms
.github/workflows/php-lint.yml 2ms
.github/workflows/php-test-plugins.yml 4ms
.github/workflows/pr-validation.yml 1ms
.github/workflows/props-bot.yml 2ms
.github/workflows/spell-check.yml 0ms
.prettierrc.js 2ms
.wp-env.json 1ms
.wp-env.override.json 1ms
bin/plugin/cli.js 6ms
bin/plugin/commands/changelog.js 11ms
bin/plugin/commands/readme.js 4ms
bin/plugin/commands/since.js 4ms
bin/plugin/commands/versions.js 2ms
bin/plugin/config.js 0ms
bin/plugin/lib/logger.js 1ms
bin/plugin/lib/milestone.js 2ms
codecov.yml 0ms
composer.json 1ms
lint-staged.config.js 1ms
package.json 0ms
plugins.json 0ms
plugins/auto-sizes/tests/e2e/specs/improve-calculate-sizes.spec.js 2ms
plugins/embed-optimizer/detect.js 1ms
plugins/embed-optimizer/lazy-load.js 1ms
plugins/image-prioritizer/detect.js 2ms
plugins/image-prioritizer/lazy-load-bg-image.js 1ms
plugins/image-prioritizer/lazy-load-video.js 1ms
plugins/image-prioritizer/tests/test-cases/preload-links-with-one-half-stale-group/url-metrics.json 6ms
plugins/optimization-detective/detect.js 11ms
plugins/optimization-detective/tests/data/url-metrics/tablet-viewport-half-stale.json 5ms
plugins/optimization-detective/types.ts 58ms
plugins/performance-lab/.wordpress-org/blueprints/blueprint.json 0ms
plugins/performance-lab/includes/admin/plugin-activate-ajax.js 2ms
plugins/view-transitions/js/types.ts 2ms
plugins/view-transitions/js/view-transitions.js 3ms
tools/e2e/playwright.config.ts 2ms
tools/webpack/utils.js 2ms
tsconfig.json 0ms
webpack.config.js 4ms

westonruter avatar Jun 10 '25 14:06 westonruter

Same here.

Happy to take another look once those changes are (partially) reverted and the merge conflicts resolved.

swissspidy avatar Jul 07 '25 15:07 swissspidy