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

Autocompletion schemas for prettier-plugin-svelte options in .prettierrc files #770

Merged
merged 3 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/svelte-vscode/package-json-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"prettier": {
"description": "Prettier-Plugin-Svelte configuration",
"$ref": "./prettier-options-schema.json"
}
}
}
20 changes: 20 additions & 0 deletions packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,26 @@
".svelte"
],
"configuration": "./language-configuration.json"
},
{
"id": "json",
"filenames": [
".prettierrc"
]
}
],
"jsonValidation": [
{
"fileMatch": ".prettierrc",
"url": "./prettier-options-schema.json"
},
{
"fileMatch": ".prettierrc.json",
"url": "./prettier-options-schema.json"
},
{
"fileMatch": "package.json",
"url": "./package-json-schema.json"
}
],
"grammars": [
Expand Down
112 changes: 112 additions & 0 deletions packages/svelte-vscode/prettier-options-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Prettier-plugin-svelte schema for .prettierrc",
"definitions": {
"optionsDefinition": {
"type": "object",
"properties": {
"svelteSortOrder": {
"description": "Sort order for <svelte:options>, scripts, markup, and styles.",
"default": "options-scripts-markup-styles",
"enum": [
"options-scripts-markup-styles",
"options-scripts-styles-markup",
"options-markup-scripts-styles",
"options-markup-styles-scripts",
"options-styles-scripts-markup",
"options-styles-markup-scripts",
"scripts-options-markup-styles",
"scripts-options-styles-markup",
"scripts-markup-options-styles",
"scripts-markup-styles-options",
"scripts-styles-options-markup",
"scripts-styles-markup-options",
"markup-options-scripts-styles",
"markup-options-styles-scripts",
"markup-scripts-options-styles",
"markup-scripts-styles-options",
"markup-styles-options-scripts",
"markup-styles-scripts-options",
"styles-options-scripts-markup",
"styles-options-markup-scripts",
"styles-scripts-options-markup",
"styles-scripts-markup-options",
"styles-markup-options-scripts",
"styles-markup-scripts-options",
"scripts-markup-styles",
"scripts-styles-markup",
"markup-styles-scripts",
"markup-scripts-styles",
"styles-markup-scripts",
"styles-scripts-markup"
]
},
"svelteStrictMode": {
"description": "More strict HTML syntax: less self-closed tags, quotes in attributes, no attribute shorthand (overrules svelteAllowShorthand).",
"default": true,
"type": "boolean"
},
"svelteBracketNewLine": {
"description": "Put the > of a multiline element on a new line. Roughly the Svelte equivalent of the jsxBracketSameLine rule.",
"default": false,
"type": "boolean"
},
"svelteAllowShorthand": {
"description": "Option to enable/disable component attribute shorthand if attribute name and expression are same.",
"default": false,
"type": "boolean"
},
"svelteIndentScriptAndStyle": {
"description": "Whether or not to indent the code inside <script> and <style> tags in Svelte files. This saves an indentation level, but might break code folding in your editor.",
"default": false,
"type": "boolean"
}
}
},
"overridesDefinition": {
"type": "object",
"properties": {
"overrides": {
"type": "array",
"description": "Provide a list of patterns to override prettier configuration.",
"items": {
"type": "object",
"required": ["files"],
"properties": {
"files": {
"description": "Include these files in this override.",
"oneOf": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
]
},
"excludeFiles": {
"description": "Exclude these files from this override.",
"oneOf": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
]
},
"options": {
"type": "object",
"description": "The options to apply for this override.",
"$ref": "#/definitions/optionsDefinition"
}
},
"additionalProperties": false
}
}
}
}
},
"oneOf": [
{
"type": "object",
"allOf": [
{ "$ref": "#/definitions/optionsDefinition" },
{ "$ref": "#/definitions/overridesDefinition" }
]
},
{ "type": "string" }
]
}