Skip to content

Commit 9cc1792

Browse files
authored
Add Taplo config file (SchemaStore#4664)
1 parent ac86660 commit 9cc1792

File tree

3 files changed

+269
-0
lines changed

3 files changed

+269
-0
lines changed

src/api/json/catalog.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7935,6 +7935,12 @@
79357935
"description": "Stylua configuration",
79367936
"fileMatch": [".stylua.toml", "stylua.toml"],
79377937
"url": "https://json.schemastore.org/stylua.json"
7938+
},
7939+
{
7940+
"name": "Taplo",
7941+
"description": "Taplo configuration file",
7942+
"fileMatch": [".taplo.toml", "taplo.toml"],
7943+
"url": "https://json.schemastore.org/taplo.json"
79387944
}
79397945
]
79407946
}

src/schemas/json/taplo.json

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://json.schemastore.org/taplo.json",
4+
"title": "Taplo Configuration Schema",
5+
"type": "object",
6+
"properties": {
7+
"exclude": {
8+
"description": "Files to exclude (ignore).\n\nA list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns. Globstars (`**`) are supported.\n\nRelative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.\n\nThis has priority over `include`.",
9+
"type": ["array", "null"],
10+
"items": {
11+
"type": "string"
12+
}
13+
},
14+
"formatting": {
15+
"description": "Formatting options.",
16+
"anyOf": [
17+
{
18+
"$ref": "#/definitions/OptionsIncomplete"
19+
},
20+
{
21+
"type": "null"
22+
}
23+
]
24+
},
25+
"include": {
26+
"description": "Files to include.\n\nA list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns. Globstars (`**`) are supported.\n\nRelative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.\n\nOmitting this property includes all files, **however an empty array will include none**.",
27+
"type": ["array", "null"],
28+
"items": {
29+
"type": "string"
30+
}
31+
},
32+
"plugins": {
33+
"type": ["object", "null"],
34+
"additionalProperties": {
35+
"$ref": "#/definitions/Plugin"
36+
}
37+
},
38+
"rule": {
39+
"description": "Rules are used to override configurations by path and keys.",
40+
"type": "array",
41+
"items": {
42+
"$ref": "#/definitions/Rule"
43+
}
44+
},
45+
"schema": {
46+
"description": "Schema validation options.",
47+
"anyOf": [
48+
{
49+
"$ref": "#/definitions/SchemaOptions"
50+
},
51+
{
52+
"type": "null"
53+
}
54+
]
55+
}
56+
},
57+
"additionalProperties": false,
58+
"definitions": {
59+
"OptionsIncomplete": {
60+
"description": "All the formatting options.",
61+
"type": "object",
62+
"properties": {
63+
"align_comments": {
64+
"description": "Align consecutive comments after entries and items vertically.\n\nThis applies to comments that are after entries or array items.",
65+
"type": ["boolean", "null"]
66+
},
67+
"align_entries": {
68+
"description": "Align entries vertically.\n\nEntries that have table headers, comments, or blank lines between them are not aligned.",
69+
"type": ["boolean", "null"]
70+
},
71+
"align_single_comments": {
72+
"description": "If `align_comments` is true, apply the alignment in cases where there's only one comment.",
73+
"type": ["boolean", "null"]
74+
},
75+
"allowed_blank_lines": {
76+
"description": "The maximum amount of consecutive blank lines allowed.",
77+
"type": ["integer", "null"],
78+
"minimum": 0.0
79+
},
80+
"array_auto_collapse": {
81+
"description": "Automatically collapse arrays if they fit in one line.\n\nThe array won't be collapsed if it contains a comment.",
82+
"type": ["boolean", "null"]
83+
},
84+
"array_auto_expand": {
85+
"description": "Automatically expand arrays to multiple lines once they exceed the configured `column_width`.",
86+
"type": ["boolean", "null"]
87+
},
88+
"array_trailing_comma": {
89+
"description": "Put trailing commas for multiline arrays.",
90+
"type": ["boolean", "null"]
91+
},
92+
"column_width": {
93+
"description": "Target maximum column width after which arrays are expanded into new lines.\n\nThis is best-effort and might not be accurate.",
94+
"type": ["integer", "null"],
95+
"minimum": 0.0
96+
},
97+
"compact_arrays": {
98+
"description": "Omit whitespace padding inside single-line arrays.",
99+
"type": ["boolean", "null"]
100+
},
101+
"compact_entries": {
102+
"description": "Omit whitespace around `=`.",
103+
"type": ["boolean", "null"]
104+
},
105+
"compact_inline_tables": {
106+
"description": "Omit whitespace padding inside inline tables.",
107+
"type": ["boolean", "null"]
108+
},
109+
"crlf": {
110+
"description": "Use CRLF line endings",
111+
"type": ["boolean", "null"]
112+
},
113+
"indent_entries": {
114+
"description": "Indent entries under tables.",
115+
"type": ["boolean", "null"]
116+
},
117+
"indent_string": {
118+
"description": "Indentation to use, should be tabs or spaces but technically could be anything.",
119+
"type": ["string", "null"]
120+
},
121+
"indent_tables": {
122+
"description": "Indent subtables if they come in order.",
123+
"type": ["boolean", "null"]
124+
},
125+
"inline_table_expand": {
126+
"description": "Expand values (e.g.) inside inline tables where possible.",
127+
"type": ["boolean", "null"]
128+
},
129+
"reorder_arrays": {
130+
"description": "Alphabetically reorder array values that are not separated by blank lines.",
131+
"type": ["boolean", "null"]
132+
},
133+
"reorder_keys": {
134+
"description": "Alphabetically reorder keys that are not separated by blank lines.",
135+
"type": ["boolean", "null"]
136+
},
137+
"trailing_newline": {
138+
"description": "Add trailing newline to the source.",
139+
"type": ["boolean", "null"]
140+
}
141+
}
142+
},
143+
"Plugin": {
144+
"description": "A plugin to extend Taplo's capabilities.",
145+
"type": "object",
146+
"properties": {
147+
"settings": {
148+
"description": "Optional settings for the plugin.",
149+
"default": null
150+
}
151+
}
152+
},
153+
"Rule": {
154+
"description": "A rule to override options by either name or file.",
155+
"type": "object",
156+
"properties": {
157+
"exclude": {
158+
"description": "Files that are excluded from this rule.\n\nA list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns.\n\nRelative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.\n\nThis has priority over `include`.",
159+
"type": ["array", "null"],
160+
"items": {
161+
"type": "string"
162+
}
163+
},
164+
"formatting": {
165+
"description": "Formatting options.",
166+
"anyOf": [
167+
{
168+
"$ref": "#/definitions/OptionsIncomplete"
169+
},
170+
{
171+
"type": "null"
172+
}
173+
]
174+
},
175+
"include": {
176+
"description": "Files this rule is valid for.\n\nA list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns.\n\nRelative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.\n\nOmitting this property includes all files, **however an empty array will include none**.",
177+
"type": ["array", "null"],
178+
"items": {
179+
"type": "string"
180+
}
181+
},
182+
"keys": {
183+
"description": "Keys the rule is valid for in a document.\n\nA list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) dotted key patterns.\n\nThis allows enabling the rule for specific paths in the document.\n\nFor example:\n\n- `package.metadata` will enable the rule for everything inside the `package.metadata` table, including itself.\n\nIf omitted, the rule will always be valid for all keys.",
184+
"type": ["array", "null"],
185+
"items": {
186+
"type": "string"
187+
}
188+
},
189+
"name": {
190+
"description": "The name of the rule.\n\nUsed in `taplo::<name>` comments.",
191+
"type": ["string", "null"]
192+
},
193+
"schema": {
194+
"description": "Schema validation options.",
195+
"anyOf": [
196+
{
197+
"$ref": "#/definitions/SchemaOptions"
198+
},
199+
{
200+
"type": "null"
201+
}
202+
]
203+
}
204+
},
205+
"additionalProperties": false
206+
},
207+
"SchemaOptions": {
208+
"description": "Options for schema validation and completion.\n\nSchemas in rules with defined keys are ignored.",
209+
"type": "object",
210+
"properties": {
211+
"enabled": {
212+
"description": "Whether the schema should be enabled or not.\n\nDefaults to true if omitted.",
213+
"type": ["boolean", "null"]
214+
},
215+
"path": {
216+
"description": "A local file path to the schema, overrides `url` if set.\n\nURLs are also accepted here, but it's not a guarantee and might change in newer releases. Please use the `url` field instead whenever possible.",
217+
"type": ["string", "null"]
218+
},
219+
"url": {
220+
"description": "A full absolute URL to the schema.\n\nThe url of the schema, supported schemes are `http`, `https`, `file` and `taplo`.",
221+
"type": ["string", "null"],
222+
"format": "uri"
223+
}
224+
},
225+
"additionalProperties": false
226+
}
227+
}
228+
}

src/test/taplo/config.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#:schema ../../schemas/json/taplo.json
2+
include = ["Cargo.toml", "directory/**/*.toml"]
3+
exclude = ["excluded.toml"]
4+
5+
[formatting]
6+
align_entries = false
7+
align_comments = true
8+
array_trailing_comma = true
9+
array_auto_expand = true
10+
array_auto_collapse = true
11+
compact_arrays = true
12+
compact_inline_tables = false
13+
inline_table_expand = true
14+
compact_entries = false
15+
column_width = 80
16+
indent_tables = false
17+
indent_entries = false
18+
indent_string = " "
19+
trailing_newline = true
20+
reorder_keys = false
21+
reorder_arrays = false
22+
reorder_inline_tables = false
23+
allowed_blank_lines = 2
24+
crlf = false
25+
26+
[[rule]]
27+
include = ["Cargo.toml"]
28+
keys = ["dependencies"]
29+
30+
[rule.formatting]
31+
reorder_keys = true
32+
33+
[schema]
34+
path = "some-external-schema.json"
35+
enabled = true

0 commit comments

Comments
 (0)