Skip to content
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

Merged
merged 7 commits into from
Sep 14, 2021

Conversation

bartlomieju
Copy link
Member

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?

"title": "Deno configuration file Schema",
"type": "object",
"properties": {
"compilerOptions": {
Copy link
Member

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.

Copy link
Member Author

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)

Copy link
Contributor

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 Show resolved Hide resolved
cli/schemas/config-file.json Outdated Show resolved Hide resolved
cli/schemas/config-file.json Outdated Show resolved Hide resolved
@@ -0,0 +1,542 @@
{
"$id": "https://deno.land/schemas/config-file.json",
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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).

Copy link
Contributor

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.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 79 to 97
"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",
Copy link
Member Author

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...

@@ -0,0 +1,542 @@
{
"$id": "https://deno.land/schemas/config-file.json",
Copy link
Contributor

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.

"default": "deno.window",
"items": {
"type": "string",
"anyOf": [
Copy link
Contributor

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.

"title": "Deno configuration file Schema",
"type": "object",
"properties": {
"compilerOptions": {
Copy link
Contributor

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.

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JSON Schema for config file to cli/schemas Add JSON schema file for configuration file
3 participants