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 block.json schema defintion to core blocks #35900

Merged
merged 3 commits into from
Nov 9, 2021
Merged

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Oct 24, 2021

Description

Adds the schema defintion to the top of each core block to help development, in
supported editors the schema definition will show validation errors, offer
tooltips and autocomplete.

Schema definition:

"$schema": "https://json.schemastore.org/block.json",

How has this been tested?

Types of changes

Adds schema to top of each block.json file in core blocks. While going through and adding Prettier did format a couple of files so some minor whitespace, and array changes, nothing functional.

I did not correct any validation issues in this PR, I will create a new one with details on issues found by adding the schema. I'm not necessarily sure if the issues are with the schema definition or the block.json file.

@mkaz mkaz added [Package] Blocks /packages/blocks [Type] Code Quality Issues or PRs that relate to code quality labels Oct 24, 2021
@mkaz mkaz added [Package] Block library /packages/block-library and removed [Package] Blocks /packages/blocks labels Oct 24, 2021
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is a good direction that should help improve the experience for maintaining block.json files in the project. We should land this PR after the issues listed in #35902 get resolved to avoid confusion for those contributors who might see violations reported in their IDEs.

@mkaz
Copy link
Member Author

mkaz commented Nov 3, 2021

We likely will want to wait on this merge as hopefully we can change it over to our own URLs based on this request:
https://make.wordpress.org/systems/2021/11/03/redirects-for-json-schemas/

@aristath
Copy link
Member

aristath commented Nov 8, 2021

I'm not familiar with SchemaStore... Out of curiosity, how is the schema maintained/updated there? 🤔

@mkaz
Copy link
Member Author

mkaz commented Nov 8, 2021

@aristath Via GitHub PR at: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/block.json

mkaz and others added 2 commits November 8, 2021 05:32
Adds the schema defintion to the top of each core block to help
development, in supported editors the schema definition will show
validation errors, offer tooltips and autocomplete.

Schema definition:

	"$schema": "https://json.schemastore.org/block.json",
Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@gziolo gziolo merged commit bc78b2c into trunk Nov 9, 2021
@gziolo gziolo deleted the add/block-schema-core branch November 9, 2021 08:25
@github-actions github-actions bot added this to the Gutenberg 12.0 milestone Nov 9, 2021
@gziolo
Copy link
Member

gziolo commented Nov 9, 2021

Opened #36351 as a follow-up to add a missing $schema field to a few more blocks. I also wrote integration tests to enforce that every block has block.json with the $schema field and the metadata validates against the local schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block library /packages/block-library [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants