Skip to content

Commit

Permalink
do not show errors for trailing commas in web JSON editors (#4100)
Browse files Browse the repository at this point in the history
fix #4008

All JSON documents we use (for settings, site config, external services, and extension manifests) support trailing commas on the frontend and backend. However, an upgrade to monaco-editor unexpectedly caused the Monaco JSON editors in our UI to show red squiggly errors for trailing commas.

The (undocumented) way to do this is to add `allowComments` to the root of the JSON Schema. It is not sufficient to set `allowComments: true` in a `monaco.languages.json.jsonDefaults.setDiagnosticsOptions` call. I found this secret fix by finding microsoft/vscode#19992 (comment) and then inferring what changes that might entail, to discover `allowComments` in the JSON Schema is responsible for ignoring trailing comma errors.
  • Loading branch information
sqs committed May 17, 2019
1 parent c1a143b commit 82776ae
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions schema/aws_codecommit.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "aws_codecommit.schema.json#",
"title": "AWSCodeCommitConnection",
"description": "Configuration for a connection to AWS CodeCommit.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["region", "accessKeyID", "secretAccessKey", "gitCredentials"],
Expand Down
1 change: 1 addition & 0 deletions schema/aws_codecommit_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/bitbucket_server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "bitbucket_server.schema.json#",
"title": "BitbucketServerConnection",
"description": "Configuration for a connection to Bitbucket Server.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["username", "url", "repositoryQuery"],
Expand Down
1 change: 1 addition & 0 deletions schema/bitbucket_server_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/critical.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "critical.schema.json#",
"title": "Critical configuration",
"description": "Critical configuration for a Sourcegraph site.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
1 change: 1 addition & 0 deletions schema/critical_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/github.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "github.schema.json#",
"title": "GitHubConnection",
"description": "Configuration for a connection to GitHub or GitHub Enterprise.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["url", "token", "repositoryQuery"],
Expand Down
1 change: 1 addition & 0 deletions schema/github_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/gitlab.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "gitlab.schema.json#",
"title": "GitLabConnection",
"description": "Configuration for a connection to GitLab (GitLab.com or GitLab self-managed).",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["url", "token", "projectQuery"],
Expand Down
1 change: 1 addition & 0 deletions schema/gitlab_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/gitolite.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "gitolite.schema.json#",
"title": "GitoliteConnection",
"description": "Configuration for a connection to Gitolite.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["prefix", "host"],
Expand Down
1 change: 1 addition & 0 deletions schema/gitolite_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/other_external_service.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "other_external_service.schema.json#",
"title": "OtherExternalServiceConnection",
"description": "Configuration for a Connection to Git repositories for which an external service integration isn't yet available.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["repos"],
Expand Down
1 change: 1 addition & 0 deletions schema/other_external_service_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/phabricator.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "phabricator.schema.json#",
"title": "PhabricatorConnection",
"description": "Configuration for a connection to Phabricator.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"anyOf": [{ "required": ["token"] }, { "required": ["repos"] }],
Expand Down
1 change: 1 addition & 0 deletions schema/phabricator_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "settings.schema.json#",
"title": "Settings",
"description": "Configuration settings for users and organizations on Sourcegraph.",
"allowComments": true,
"type": "object",
"properties": {
"search.savedQueries": {
Expand Down
1 change: 1 addition & 0 deletions schema/settings_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/site.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "site.schema.json#",
"title": "Site configuration",
"description": "Configuration for a Sourcegraph site.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
1 change: 1 addition & 0 deletions schema/site_stringdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82776ae

Please sign in to comment.