-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathprettier.ts
336 lines (335 loc) · 8.27 KB
/
prettier.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
const completionSpec: Fig.Spec = {
name: "prettier",
description: "Run Prettier from the command line",
icon: "https://prettier.io/icon.png",
options: [
{
name: ["-c", "--check"],
description: "Check if your files are formatted",
args: {
name: "file, dir, or glob",
template: ["filepaths", "folders"],
isVariadic: true,
},
},
{
name: ["-l", "--list-different"],
description:
"Print the names of files that are different from Prettier's formatting",
},
{
name: ["-w", "--write"],
description: "Edit files in-place",
isDangerous: true,
},
{
name: "--arrow-parens",
description: "Include parentheses around a sole arrow function parameter",
args: {
name: "mode",
default: "always",
suggestions: ["always", "avoid"],
},
},
{
name: "--no-bracket-spacing",
description: "Do not print spaces between brackets",
},
{
name: "--embedded-language-formatting",
description:
"Control how Prettier formats quoted code embedded in the file",
args: {
name: "mode",
default: "auto",
suggestions: ["auto", "off"],
},
},
{
name: "--end-of-line",
description: "Which end of line characters to apply",
args: {
name: "choice",
default: "lf",
suggestions: ["lf", "crlf", "cr", "auto"],
},
},
{
name: "--html-whitespace-sensitivity",
description: "How to handle whitespaces in HTML",
args: {
name: "choice",
default: "css",
suggestions: ["css", "strict", "ignore"],
},
},
{
name: "--jsx-bracket-same-line",
description: "Put > on the last line instead of at a new line",
},
{
name: "--jsx-single-quote",
description: "Use single quotes in JSX",
},
{
name: "--parser",
description: "Which parser to use",
args: {
name: "parser",
suggestions: [
"flow",
"babel",
"babel-flow",
"babel-ts",
"typescript",
"espree",
"meriyah",
"css",
"less",
"scss",
"json",
"json5",
"json-stringify",
"graphql",
"markdown",
"mdx",
"vue",
"yaml",
"html",
"angular",
"lwc",
],
},
},
{
name: "--print-width",
description: "The line length where Prettier will try wrap",
args: {
name: "int",
default: "80",
},
},
{
name: "--prose-wrap",
description: "How to wrap prose",
args: {
default: "preserve",
suggestions: ["always", "never", "preserve"],
},
},
{
name: "--quote-props",
description: "Change when properties in objects are quoted",
args: {
name: "when",
default: "as-needed",
suggestions: ["as-needed", "consistent", "preserve"],
},
},
{
name: "--no-semi",
description:
"Do not print semicolons, except at the beginning of lines which may need them",
},
{
name: "--single-quote",
description: "Use single quotes instead of double quotes",
},
{
name: "--tab-width",
description: "Number of spaces per indentation level",
args: {
name: "int",
default: "2",
},
},
{
name: "--trailing-comma",
description: "Print trailing commas wherever possible when multi-line",
args: {
name: "type",
default: "es5",
suggestions: ["es5", "none", "all"],
},
},
{
name: "--use-tabs",
description: "Indent with tabs instead of spaces",
},
{
name: "--vue-indent-script-and-style",
description: "Indent script and style tags in Vue files",
},
{
name: "--config",
description:
"Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js)",
exclusiveOn: ["--no-config"],
args: {
name: "path",
template: "filepaths",
},
},
{
name: "--no-config",
description: "Do not look for a configuration file",
exclusiveOn: ["--config"],
},
{
name: "--config-precedence",
description:
"Define in which order config files and CLI options should be evaluated",
args: {
name: "precedence",
default: "cli-override",
suggestions: ["cli-override", "file-override", "prefer-file"],
},
},
{
name: "--no-editorconfig",
description:
"Don't take .editorconfig into account when parsing configuration",
},
{
name: "--find-config-path",
description:
"Finds a path to the configuration file for the given input file",
args: {
name: "file",
template: "filepaths",
},
},
{
name: "--ignore-path",
description: "Path to a file with patterns describing files to ignore",
args: {
name: "path",
template: "filepaths",
default: ".prettierignore",
},
},
{
name: "--plugin",
description: "Add a plugin",
args: {
name: "path",
template: "folders",
},
},
{
name: "--plugin-search-dir",
description:
"Custom directory that contains prettier plugins in node_modules subdirectory",
args: {
name: "path",
template: "folders",
isVariadic: true,
},
},
{
name: "--with-node-modules",
description: "Process files inside 'node_modules' directory",
},
{
name: "--cursor-offset",
description:
"Print (to stderr) where a cursor at the given position would move to after formatting",
exclusiveOn: ["--range-start", "--range-end"],
args: {
name: "int",
default: "-1",
},
},
{
name: "--range-end",
description: "Format code ending at a given character offset (exclusive)",
exclusiveOn: ["--cursor-offset"],
args: {
name: "int",
default: "Infinity",
},
},
{
name: "--range-start",
description: "Format code starting at a given character offset",
args: {
name: "int",
default: "0",
},
},
{
name: "--no-color",
description: "Do not colorize error messages",
},
{
name: "--file-info",
description: "Extract the following info (as JSON) for a given file path",
args: {
name: "path",
template: "filepaths",
},
},
{
name: ["-h", "--help"],
description: "Show CLI usage, or details about the given flag",
args: {
name: "flag",
isOptional: true,
},
},
{
name: ["-u", "--ignore-unknown"],
description: "Ignore unknown files",
},
{
name: "--insert-pragma",
description: "Insert @format pragma into file's first docblock comment",
},
{
name: "--loglevel",
description: "What level of logs to report",
args: {
name: "level",
default: "log",
suggestions: ["silent", "error", "warn", "log", "debug"],
},
},
{
name: "--require-pragma",
description:
"Require either '@prettier' or '@format' to be present in the file's first docblock comment in order for it to be formatted",
},
{
name: "--stdin-filepath",
description: "Path to the file to pretend that stdin comes from",
args: {
name: "path",
template: "filepaths",
},
},
{
name: "--support-info",
description: "Print support information as JSON",
},
{
name: ["-v", "--version"],
description: "Print Prettier version",
},
{
name: "--debug-check",
description:
"This will cause Prettier to print an error message if it detects that code correctness might have changed",
},
{
name: "--no-error-on-unmatched-pattern",
description: "Prevent errors when pattern is unmatched",
},
],
args: {
name: "file, dir or glob",
template: ["filepaths", "folders"],
isOptional: true,
isVariadic: true,
},
};
export default completionSpec;