Skip to content

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

@westonruter

Description

@westonruter

In #2325, JSON Schema validation was introduced for the project. This is currently doing:

Validating .wp-env.json against schema: https://schemas.wp.org/trunk/wp-env.json
Validating .wp-env.override.json against schema: https://schemas.wp.org/trunk/wp-env.json
Validating plugins/performance-lab/.wordpress-org/blueprints/blueprint.json against schema: https://playground.wordpress.net/blueprint-schema.json

I thought about adding a Schema to tsconfig.json as well:

diff --git a/tsconfig.json b/tsconfig.json
index 70c47f9e..c40ded42 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,4 +1,5 @@
 {
+	"$schema": "https://www.schemastore.org/tsconfig.json",
 	"compilerOptions": {
 		"checkJs": true,
 		"noEmit": true,

But for some reason this just hangs indefinitely:

npm run lint-json tsconfig.json

I found it seems work endlessly at this line:

const validate = await ajv.compileAsync( { $ref: data.$schema } );

However, it works for the package.json when I do this:

diff --git a/tsconfig.json b/tsconfig.json
index 70c47f9e..c40ded42 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,4 +1,5 @@
 {
+	"$schema": "https://www.schemastore.org/tsconfig.json",
 	"compilerOptions": {
 		"checkJs": true,
 		"noEmit": true,

This would be a nice if all the JSON files with JSON Schemas available could be validated.

Metadata

Metadata

Assignees

Labels

[Type] EnhancementA suggestion for improvement of an existing feature
No fields configured for Enhancement.

Projects

Status

Done 😃

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions