Skip to content

Add JSON Schemas to tsconfig.json and package.json#2330

Merged
westonruter merged 9 commits intoWordPress:trunkfrom
ShyamGadde:update/add-json-schemas
Jan 8, 2026
Merged

Add JSON Schemas to tsconfig.json and package.json#2330
westonruter merged 9 commits intoWordPress:trunkfrom
ShyamGadde:update/add-json-schemas

Conversation

@ShyamGadde
Copy link
Contributor

@ShyamGadde ShyamGadde commented Jan 7, 2026

Summary

Fixes #2329

This PR adds JSON Schema references to tsconfig.json and package.json so that these files can be validated by the existing validate-json-schema.js script.

It also updates the validator to correctly handle schemas defined using different JSON Schema drafts. In particular, the tsconfig.json schema is defined using draft-04, whereas AJV defaults to draft-07.

Relevant technical choices

  • Introduced separate AJV instances for draft-07 and draft-04 schemas, since AJV cannot mix schema drafts within a single instance.
  • Added ajv-draft-04 as a dependency to support validation of schemas defined using JSON Schema draft-04 (e.g., the tsconfig.json schema).
  • Detect the schema draft based on the referenced schema’s $schema value and route validation to the appropriate AJV instance.
  • Added a small in-memory cache for fetched schemas to avoid repeated network requests during validation.

Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
@ShyamGadde ShyamGadde added [Type] Enhancement A suggestion for improvement of an existing feature no milestone PRs that do not have a defined milestone for release skip changelog PRs that should not be mentioned in changelogs labels Jan 7, 2026
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.17%. Comparing base (11d0f73) to head (934549f).
⚠️ Report is 10 commits behind head on trunk.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2330   +/-   ##
=======================================
  Coverage   69.17%   69.17%           
=======================================
  Files          90       90           
  Lines        7696     7696           
=======================================
  Hits         5324     5324           
  Misses       2372     2372           
Flag Coverage Δ
multisite 69.17% <ø> (ø)
single 35.35% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds JSON Schema references to tsconfig.json and package.json files to enable validation via the existing validate-json-schema.js script. It enhances the validator to support multiple JSON Schema draft versions by introducing separate AJV instances for draft-04 and draft-07, along with schema caching to optimize network requests.

  • Added $schema references to tsconfig.json and package.json
  • Introduced ajv-draft-04 dependency to support draft-04 schema validation
  • Refactored the validator to detect schema drafts and route to appropriate AJV instances

Reviewed changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated 1 comment.

File Description
tsconfig.json Added $schema reference for validation support
package.json Added $schema reference and ajv-draft-04 dependency
package-lock.json Installed ajv-draft-04 package
bin/validate-json-schema.js Refactored to support multiple schema drafts with caching and draft detection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

westonruter and others added 3 commits January 7, 2026 17:11
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@westonruter
Copy link
Member

@ShyamGadde This is great! Any reason why this is still a draft?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

westonruter and others added 2 commits January 7, 2026 17:40
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@westonruter westonruter added this to the performance-lab 4.1.0 milestone Jan 8, 2026
@westonruter westonruter removed the no milestone PRs that do not have a defined milestone for release label Jan 8, 2026
@westonruter westonruter removed this from the performance-lab 4.1.0 milestone Jan 8, 2026
@westonruter westonruter added the no milestone PRs that do not have a defined milestone for release label Jan 8, 2026
@ShyamGadde ShyamGadde marked this pull request as ready for review January 8, 2026 05:57
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

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: ShyamGadde <shyamgadde@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

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

@ShyamGadde
Copy link
Contributor Author

ShyamGadde commented Jan 8, 2026

Any reason why this is still a draft?

@westonruter I left it as a draft initially to get feedback on the AJV draft-handling approach. It should be ready now.

@westonruter westonruter merged commit d6a87bc into WordPress:trunk Jan 8, 2026
58 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no milestone PRs that do not have a defined milestone for release skip changelog PRs that should not be mentioned in changelogs [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Schemas should be added to tsconfig.json and package.json

3 participants