-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add missing block/theme json $schema property #57201
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/theme.json ❔ phpunit/data/themedir1/block-theme-child-with-fluid-layout/theme.json ❔ phpunit/data/themedir1/block-theme-child-with-fluid-typography-config/theme.json ❔ phpunit/data/themedir1/block-theme-child-with-fluid-typography/theme.json ❔ phpunit/data/themedir1/block-theme-child/theme.json ❔ phpunit/data/themedir1/block-theme/theme.json ❔ phpunit/data/themedir1/fonts-block-theme/theme.json ❔ phpunit/fixtures/block.json ❔ phpunit/fixtures/hooked-block/block.json |
72fda9a
to
026e764
Compare
I've run JSON schema validation on the project and found that some of the files touched here seem to have violations: check-jsonschema --schemafile 'https://schemas.wp.org/trunk/block.json' $(find . -name block.json -not -path './schemas/**') Results
check-jsonschema --schemafile 'https://schemas.wp.org/trunk/theme.json' $(find . -name theme.json -not -path './schemas/**') Results
|
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.
Nice, that’s helpful 👍
There is an integration test that validates core blocks:
const blockFolders = glob.sync( 'packages/block-library/src/*', { |
It looks like the glob could also cover blocks created in the widgets package.
I'm glad to see we have automation to check schemas, I'll look at enabling it for more places in another PR since that will require changes to the violating schemas. |
@sirreal Please could you confirm whether you believe this PR requires backport for WP 6.5? |
The package changes should be handled by other workflows. For other files I've created https://core.trac.wordpress.org/ticket/60255, I'll handle adding schemas to these JSON files in core. I'll remove the backport label. |
What?
Add $schema to block.json and theme.json files to leverage JSON schema support.
Why?
Schemas help ensure that these files conform to expectations. They can help provide autocomplete and documentation if editors are configured to do so.
We provide and maintain these schemas, we should be using them. This can help to ensure that our own declarations are correct and that the schemas are also correct.
Testing Instructions
If you have an editor configured to show JSON schema information, you can open up one of these files and confirm it works as expected. I believe Visual Studio Code provides this behavior by default.
This change is a developer experience improvement and should not otherwise impact the behavior of Gutenberg or its packages.
Screenshots or screencast