Wire SchemaStore catalog matching as $schema fallback#32
Wire SchemaStore catalog matching as $schema fallback#32srivastava-diya wants to merge 13 commits into
Conversation
jdesrosiers
left a comment
There was a problem hiding this comment.
Looks pretty good so far. It could use a little cleanup and we're going to have to something more for the file matching logic (details inline).
41c86cd to
58f2191
Compare
|
I added a I also changed the |
3e24aee to
2623379
Compare
jdesrosiers
left a comment
There was a problem hiding this comment.
Looks good. I just did a little promise management cleanup and add a few tests.
|
Looks like there are file pattern matching tests failing on Windows. My understanding is that |
sure, looking into it. |
|
I noticed that validation could happen before the catalog starts loading resulting in the documents that use the catalog not getting validated correctly. I updated it to create the promise immediately using the same trick we use in tests to capture diagnostics. If your load tests seem to still be working, go ahead and merge when ready. |
I was thinking that you would need to use But, those examples are so rare, I'm not sure it's actually necessary. I can't find anywhere it's documented one way or another what the intention is. Given the I think there's a picomatch config that would easily allow us to change the behavior. We should also update the tests that assume the interpretation that it matches from the root. |


Description
This PR wires the SchemaStore catalog matching (getSchemaUri) into JsonDocument as a fallback for documents that don't have an $schema field e.g. package.json, tsconfig.json etc.
Changes made
validate()always callsvalidateSchema()now, regardless of whether $schema is presentvalidateSchema()checks this.schemaUri first if set, validates immediately. If not, it falls back toschemaStore.getSchemaUri(this.uri), which matches the document's filename against the SchemaStore catalog.