-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
chore: add JSON schema for configuration file #12062
Conversation
cli/schemas/config-file.json
Outdated
"title": "Deno configuration file Schema", | ||
"type": "object", | ||
"properties": { | ||
"compilerOptions": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the syntax, but I'm not sure (something along these lines):
"compilerOptions": {
"$ref": "http:https://json.schemastore.org/tsconfig#/definitions/compilerOptionsDefinition/properties/compilerOptions"
}
That said, perhaps we should limit this to only the compiler options we support and I believe that would require copy and paste or at least using a "$ref" like this a bunch of times for each property we support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I went with copy-paste from http:https://json.schemastore.org/tsconfig based on the list here: https://deno.land/[email protected]/typescript/configuration#how-deno-uses-a-configuration-file it still needs updating defaults though (and lib
property needs updating of list)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't think we want to reference the external schema, as it doesn't meet our needs.
cli/schemas/config-file.json
Outdated
@@ -0,0 +1,542 @@ | |||
{ | |||
"$id": "https://deno.land/schemas/config-file.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should version this url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you propose to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess maybe it doesn't matter actually if we're going to be providing this file text to the editor plugins via the LSP (not sure how that's going to work atm).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should version it at least, it is as simple as adding a version to the file. I suggest we use something like config-file_v1.json
and simply increment the number when we make changes, versus a full blown semver scheme. Then in vscode you associate a schema with a file type, and we will just bump it when logical. The other option is we just let git/GitHub manage it, with the raw github with a commitish path be the id we use in vscode to "pin" it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cli/schemas/config-file.json
Outdated
"enum": [ | ||
"deno.window", | ||
"deno.worker", | ||
"deno.shared_globals", | ||
"deno.ns", | ||
"deno.unstable", | ||
"ES5", | ||
"ES6", | ||
"ES2015", | ||
"ES2015.Collection", | ||
"ES2015.Core", | ||
"ES2015.Generator", | ||
"ES2015.Iterable", | ||
"ES2015.Promise", | ||
"ES2015.Proxy", | ||
"ES2015.Reflect", | ||
"ES2015.Symbol.WellKnown", | ||
"ES2015.Symbol", | ||
"ES2016", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is correct...
cli/schemas/config-file.json
Outdated
@@ -0,0 +1,542 @@ | |||
{ | |||
"$id": "https://deno.land/schemas/config-file.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should version it at least, it is as simple as adding a version to the file. I suggest we use something like config-file_v1.json
and simply increment the number when we make changes, versus a full blown semver scheme. Then in vscode you associate a schema with a file type, and we will just bump it when logical. The other option is we just let git/GitHub manage it, with the raw github with a commitish path be the id we use in vscode to "pin" it.
cli/schemas/config-file.json
Outdated
"default": "deno.window", | ||
"items": { | ||
"type": "string", | ||
"anyOf": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just drop this and keep it as a string... it is actually really annoying the behaviour in vscode, because tsc issues diagnostics for this and we now mute them, but the schema still has them, so people get "warnings" in vscode that we can't get rid of because it doesn't "match" the schema. We will end up issuing diagnostics for "bad" or "incorrect" values in config options, so feel free to eliminate any complex "soft" values like this that would be better served by LSP diagnostics, and focus on "structural" validation of the config file.
cli/schemas/config-file.json
Outdated
"title": "Deno configuration file Schema", | ||
"type": "object", | ||
"properties": { | ||
"compilerOptions": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't think we want to reference the external schema, as it doesn't meet our needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #11885
Closes #12061
@kitsonk @dsherret please advise how should I handle
compilerOptions
key; a) copy-paste from http:https://json.schemastore.org/tsconfig b) try to link to http:https://json.schemastore.org/tsconfig somehow?