wp-env: Add JSON Schema for .wp-env.json configuration#76115
wp-env: Add JSON Schema for .wp-env.json configuration#76115kraftbj wants to merge 1 commit intoWordPress:trunkfrom
Conversation
Add a JSON Schema file that enables editor autocomplete and validation for .wp-env.json configuration files. Users can opt in by adding a $schema key pointing to the published schema URL. The schema covers all root-level and per-environment options, including the recently added autoPort option, and rejects unknown keys to catch typos early.
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| @@ -0,0 +1,165 @@ | |||
| { | |||
| "$schema": "http://json-schema.org/draft-07/schema#", | |||
There was a problem hiding this comment.
Might be a naive question, but what the relationship between this schema and https://schemas.wp.org/trunk/wp-env.json (https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/wp-env.json)?
I think autoPort is missing from the existing one. Would updating the existing schema have the same effect?
| To enable editor autocomplete and validation, add a `$schema` key: | ||
|
|
||
| ```json | ||
| { | ||
| "$schema": "https://schemas.wordpress.org/wp-env.schema.json", | ||
| "plugins": [ "." ] | ||
| } | ||
| ``` | ||
|
|
There was a problem hiding this comment.
I think this is a good to have regardless of whether we have a new schema doc or keep on using https://schemas.wp.org/trunk/wp-env.json 👍🏻
What?
Add a JSON Schema file for
.wp-env.jsonconfiguration files, enabling editor autocomplete and validation.Why?
The
.wp-env.jsonconfig supports many options across root-level and per-environment overrides. A JSON Schema lets editors (VS Code, JetBrains, etc.) provide inline autocomplete, type checking, and unknown-key warnings — reducing config errors and improving discoverability.How?
packages/env/lib/config/wp-env.schema.jsonwith all root-level and per-environment properties, including the recently addedautoPortoption.testsPort,autoPort,testsEnvironment,lifecycleScripts,env) are excluded from theenvironmentConfigdefinition so the schema rejects them insideenvoverrides.packages/env/README.mdshowing how to opt in via the$schemakey.packages/env/lib/config/test/wp-env-schema.jswith tests verifying valid configs are accepted and unknown/misplaced keys are rejected.Testing Instructions
.wp-env.jsonfile in any project."$schema": "https://schemas.wordpress.org/wp-env.schema.json"(or use a relative path topackages/env/lib/config/wp-env.schema.json).core,plugins,port,autoPort, etc.).autoPortandtestsPortshow warnings when placed inside anenvoverride.Testing Instructions for Keyboard
N/A — no UI changes.