Skip to content

Commit 0119c09

Browse files
authored
(feat) autocompletion schemas for prettier-plugin-svelte options (#770)
Adds autocompletion info for pretter-plugin-svelte options to `.prettierrc` files and `prettier` field inside `package.json`
1 parent 4c0ffd7 commit 0119c09

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"properties": {
4+
"prettier": {
5+
"description": "Prettier-Plugin-Svelte configuration",
6+
"$ref": "./prettier-options-schema.json"
7+
}
8+
}
9+
}

packages/svelte-vscode/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,26 @@
348348
".svelte"
349349
],
350350
"configuration": "./language-configuration.json"
351+
},
352+
{
353+
"id": "json",
354+
"filenames": [
355+
".prettierrc"
356+
]
357+
}
358+
],
359+
"jsonValidation": [
360+
{
361+
"fileMatch": ".prettierrc",
362+
"url": "./prettier-options-schema.json"
363+
},
364+
{
365+
"fileMatch": ".prettierrc.json",
366+
"url": "./prettier-options-schema.json"
367+
},
368+
{
369+
"fileMatch": "package.json",
370+
"url": "./package-json-schema.json"
351371
}
352372
],
353373
"grammars": [
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Prettier-plugin-svelte schema for .prettierrc",
4+
"definitions": {
5+
"optionsDefinition": {
6+
"type": "object",
7+
"properties": {
8+
"svelteSortOrder": {
9+
"description": "Sort order for <svelte:options>, scripts, markup, and styles.",
10+
"default": "options-scripts-markup-styles",
11+
"enum": [
12+
"options-scripts-markup-styles",
13+
"options-scripts-styles-markup",
14+
"options-markup-scripts-styles",
15+
"options-markup-styles-scripts",
16+
"options-styles-scripts-markup",
17+
"options-styles-markup-scripts",
18+
"scripts-options-markup-styles",
19+
"scripts-options-styles-markup",
20+
"scripts-markup-options-styles",
21+
"scripts-markup-styles-options",
22+
"scripts-styles-options-markup",
23+
"scripts-styles-markup-options",
24+
"markup-options-scripts-styles",
25+
"markup-options-styles-scripts",
26+
"markup-scripts-options-styles",
27+
"markup-scripts-styles-options",
28+
"markup-styles-options-scripts",
29+
"markup-styles-scripts-options",
30+
"styles-options-scripts-markup",
31+
"styles-options-markup-scripts",
32+
"styles-scripts-options-markup",
33+
"styles-scripts-markup-options",
34+
"styles-markup-options-scripts",
35+
"styles-markup-scripts-options",
36+
"scripts-markup-styles",
37+
"scripts-styles-markup",
38+
"markup-styles-scripts",
39+
"markup-scripts-styles",
40+
"styles-markup-scripts",
41+
"styles-scripts-markup"
42+
]
43+
},
44+
"svelteStrictMode": {
45+
"description": "More strict HTML syntax: less self-closed tags, quotes in attributes, no attribute shorthand (overrules svelteAllowShorthand).",
46+
"default": true,
47+
"type": "boolean"
48+
},
49+
"svelteBracketNewLine": {
50+
"description": "Put the > of a multiline element on a new line. Roughly the Svelte equivalent of the jsxBracketSameLine rule.",
51+
"default": false,
52+
"type": "boolean"
53+
},
54+
"svelteAllowShorthand": {
55+
"description": "Option to enable/disable component attribute shorthand if attribute name and expression are same.",
56+
"default": false,
57+
"type": "boolean"
58+
},
59+
"svelteIndentScriptAndStyle": {
60+
"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.",
61+
"default": false,
62+
"type": "boolean"
63+
}
64+
}
65+
},
66+
"overridesDefinition": {
67+
"type": "object",
68+
"properties": {
69+
"overrides": {
70+
"type": "array",
71+
"description": "Provide a list of patterns to override prettier configuration.",
72+
"items": {
73+
"type": "object",
74+
"required": ["files"],
75+
"properties": {
76+
"files": {
77+
"description": "Include these files in this override.",
78+
"oneOf": [
79+
{ "type": "string" },
80+
{ "type": "array", "items": { "type": "string" } }
81+
]
82+
},
83+
"excludeFiles": {
84+
"description": "Exclude these files from this override.",
85+
"oneOf": [
86+
{ "type": "string" },
87+
{ "type": "array", "items": { "type": "string" } }
88+
]
89+
},
90+
"options": {
91+
"type": "object",
92+
"description": "The options to apply for this override.",
93+
"$ref": "#/definitions/optionsDefinition"
94+
}
95+
},
96+
"additionalProperties": false
97+
}
98+
}
99+
}
100+
}
101+
},
102+
"oneOf": [
103+
{
104+
"type": "object",
105+
"allOf": [
106+
{ "$ref": "#/definitions/optionsDefinition" },
107+
{ "$ref": "#/definitions/overridesDefinition" }
108+
]
109+
},
110+
{ "type": "string" }
111+
]
112+
}

0 commit comments

Comments
 (0)