-
Notifications
You must be signed in to change notification settings - Fork 5
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
Check $schema
key inside the document to know what schema to validate against
#574
Comments
As an aside to this, it would be really nice if {
"$schema": "./node_modules/v8r/config-schema.json",
"customCatalog": {
"schemas": [
{
"name": "JSON schema for WebExtensions manifest files",
"fileMatch": [
"manifest.json"
],
"location": "https://json.schemastore.org/webextension.json"
}
]
}
} Currently this cannot be done as v8r (correctly) validates its config file before using it, leading to an additional properties error because of
|
If you've got files where SchemaStore doesn't know how to validate them, you can use a custom catalog to tell v8r which schemas to use for which files. This idea of files that contain a $schema key has come up once before a few years ago in #129 |
Thanks for linking the closed PR. I had looked through the repo before, but clearly still managed to somehow miss that one. I am not sure how wide-spread the usage is. Like I described above, I mostly do it because it makes VSCode’s linting work and delivers auto-complete. It would not surprise me if this is how most people use it, which might be hard to track. I will do some discovery work this weekend and see if I can find any projects that explicitly use or call out the use of |
Sometimes there are files where multiple schemas from the catalogue might match, e.g. a
manifest.json
file:As I also depend on JSON schemas when editing these type of files, I often supply a specific
$schema
within the file so VSCode can manage. See the following screenshots showing how VSCode is warning me about all the keys before I add$schema
:$schema
member?$schema
member over the catalogue?In case of 2, it could save the entire round trip to schemastore.org. If all files in a repository include
$schema
it will not need to check a catalogue at all.The text was updated successfully, but these errors were encountered: