Skip to content
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 $schema to block and theme JSON #5868

Closed

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Jan 15, 2024

Add $schema to block.json and theme.json files.

Note that not all files are valid according to the schema. I'm working on those fixes in WordPress/gutenberg#57374 and will port those changes when they're finished.

Some of the invalid (according to the schema) block and theme json files are in phpunit tests were invalid due to missing title properties. In those cases I've fixed the json to satisfy the schema. Those changes have no impact on the runtime whatsoever and do not change the result of unit tests.

This is a port of WordPress/gutenberg#57201

Trac ticket: https://core.trac.wordpress.org/ticket/60255

Add $schema to block.json and theme.json files to leverage JSON schema support.

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.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@gziolo
Copy link
Member

gziolo commented Jan 15, 2024

https://github.com/WordPress/wordpress-develop/actions/runs/7529540433/job/20493970875?pr=5868

Files in src/wp-includes/blocks are synced from npm packages so they will get updated next time WordPress packages get updated.

@sirreal sirreal changed the title Add $schema to block,theme JSON Add $schema to block and theme JSON Jan 15, 2024
@sirreal
Copy link
Member Author

sirreal commented Jan 15, 2024

Good to know, thanks! I reverted the changes to src/wp-includes/blocks.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@dmsnell
Copy link
Member

dmsnell commented Jan 19, 2024

@sirreal it looks like some of these should come over through the normal package update process? do you know if this is true?

@sirreal
Copy link
Member Author

sirreal commented Jan 21, 2024

src/wp-includes/blocks changes should be updated automatically (#5868 (comment)) - I had changed those files but reverted the changes.

@ockham
Copy link
Contributor

ockham commented Jan 23, 2024

I've taken the liberty of slightly tweaking the test hooked blocks' names in 126b31b. Hope that's okay! 😊

@sirreal
Copy link
Member Author

sirreal commented Jan 23, 2024

Looks good, thanks @ockham.

@ockham
Copy link
Contributor

ockham commented Jan 23, 2024

Committed to Core in https://core.trac.wordpress.org/changeset/57336.

@ockham ockham closed this Jan 23, 2024
@sirreal sirreal deleted the add/schema-to-block-theme-json branch January 23, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants