pretierr 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/LICENSE +4379 -0
  2. package/README.md +109 -0
  3. package/bin/prettier.cjs +64 -0
  4. package/doc.d.ts +243 -0
  5. package/doc.js +1319 -0
  6. package/doc.mjs +1291 -0
  7. package/index.cjs +648 -0
  8. package/index.d.ts +941 -0
  9. package/index.mjs +22795 -0
  10. package/internal/cli.mjs +3884 -0
  11. package/package.json +206 -0
  12. package/plugins/acorn.d.ts +6 -0
  13. package/plugins/acorn.js +15 -0
  14. package/plugins/acorn.mjs +15 -0
  15. package/plugins/angular.d.ts +8 -0
  16. package/plugins/angular.js +1 -0
  17. package/plugins/angular.mjs +1 -0
  18. package/plugins/babel.d.ts +18 -0
  19. package/plugins/babel.js +15 -0
  20. package/plugins/babel.mjs +15 -0
  21. package/plugins/estree.d.ts +1 -0
  22. package/plugins/estree.js +36 -0
  23. package/plugins/estree.mjs +36 -0
  24. package/plugins/flow.d.ts +5 -0
  25. package/plugins/flow.js +19 -0
  26. package/plugins/flow.mjs +19 -0
  27. package/plugins/glimmer.d.ts +5 -0
  28. package/plugins/glimmer.js +30 -0
  29. package/plugins/glimmer.mjs +30 -0
  30. package/plugins/graphql.d.ts +5 -0
  31. package/plugins/graphql.js +29 -0
  32. package/plugins/graphql.mjs +29 -0
  33. package/plugins/html.d.ts +8 -0
  34. package/plugins/html.js +22 -0
  35. package/plugins/html.mjs +22 -0
  36. package/plugins/markdown.d.ts +7 -0
  37. package/plugins/markdown.js +62 -0
  38. package/plugins/markdown.mjs +62 -0
  39. package/plugins/meriyah.d.ts +5 -0
  40. package/plugins/meriyah.js +4 -0
  41. package/plugins/meriyah.mjs +4 -0
  42. package/plugins/postcss.d.ts +7 -0
  43. package/plugins/postcss.js +52 -0
  44. package/plugins/postcss.mjs +52 -0
  45. package/plugins/typescript.d.ts +5 -0
  46. package/plugins/typescript.js +20 -0
  47. package/plugins/typescript.mjs +20 -0
  48. package/plugins/yaml.d.ts +5 -0
  49. package/plugins/yaml.js +161 -0
  50. package/plugins/yaml.mjs +161 -0
  51. package/standalone.d.ts +33 -0
  52. package/standalone.js +35 -0
  53. package/standalone.mjs +35 -0
  54. package/te24xjoq.cjs +1 -0
package/index.d.ts ADDED
@@ -0,0 +1,941 @@
1
+ // Copied from `@types/prettier`
2
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5bb07fc4b087cb7ee91084afa6fe750551a7bbb1/types/prettier/index.d.ts
3
+
4
+ // Minimum TypeScript Version: 4.2
5
+
6
+ // Add `export {}` here to shut off automatic exporting from index.d.ts. There
7
+ // are quite a few utility types here that don't need to be shipped with the
8
+ // exported module.
9
+ export {};
10
+
11
+ import { builders, printer, utils } from "./doc.js";
12
+
13
+ export namespace doc {
14
+ export { builders, printer, utils };
15
+ }
16
+
17
+ // This utility is here to handle the case where you have an explicit union
18
+ // between string literals and the generic string type. It would normally
19
+ // resolve out to just the string type, but this generic LiteralUnion maintains
20
+ // the intellisense of the original union.
21
+ //
22
+ // It comes from this issue: microsoft/TypeScript#29729:
23
+ // https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227
24
+ export type LiteralUnion<T extends U, U = string> =
25
+ | T
26
+ | (Pick<U, never> & { _?: never | undefined });
27
+
28
+ export type AST = any;
29
+ export type Doc = doc.builders.Doc;
30
+
31
+ // The type of elements that make up the given array T.
32
+ type ArrayElement<T> = T extends Array<infer E> ? E : never;
33
+
34
+ // A union of the properties of the given object that are arrays.
35
+ type ArrayProperties<T> = {
36
+ [K in keyof T]: NonNullable<T[K]> extends readonly any[] ? K : never;
37
+ }[keyof T];
38
+
39
+ // A union of the properties of the given array T that can be used to index it.
40
+ // If the array is a tuple, then that's going to be the explicit indices of the
41
+ // array, otherwise it's going to just be number.
42
+ type IndexProperties<T extends { length: number }> =
43
+ IsTuple<T> extends true ? Exclude<Partial<T>["length"], T["length"]> : number;
44
+
45
+ // Effectively performing T[P], except that it's telling TypeScript that it's
46
+ // safe to do this for tuples, arrays, or objects.
47
+ type IndexValue<T, P> = T extends any[]
48
+ ? P extends number
49
+ ? T[P]
50
+ : never
51
+ : P extends keyof T
52
+ ? T[P]
53
+ : never;
54
+
55
+ // Determines if an object T is an array like string[] (in which case this
56
+ // evaluates to false) or a tuple like [string] (in which case this evaluates to
57
+ // true).
58
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
+ type IsTuple<T> = T extends []
60
+ ? true
61
+ : T extends [infer First, ...infer Remain]
62
+ ? IsTuple<Remain>
63
+ : false;
64
+
65
+ type CallProperties<T> = T extends any[] ? IndexProperties<T> : keyof T;
66
+ type IterProperties<T> = T extends any[]
67
+ ? IndexProperties<T>
68
+ : ArrayProperties<T>;
69
+
70
+ type CallCallback<T, U> = (path: AstPath<T>, index: number, value: any) => U;
71
+ type EachCallback<T> = (
72
+ path: AstPath<ArrayElement<T>>,
73
+ index: number,
74
+ value: any,
75
+ ) => void;
76
+ type MapCallback<T, U> = (
77
+ path: AstPath<ArrayElement<T>>,
78
+ index: number,
79
+ value: any,
80
+ ) => U;
81
+
82
+ // https://github.com/prettier/prettier/blob/next/src/common/ast-path.js
83
+ export class AstPath<T = any> {
84
+ constructor(value: T);
85
+
86
+ get key(): string | null;
87
+ get index(): number | null;
88
+ get node(): T;
89
+ get parent(): T | null;
90
+ get grandparent(): T | null;
91
+ get isInArray(): boolean;
92
+ get siblings(): T[] | null;
93
+ get next(): T | null;
94
+ get previous(): T | null;
95
+ get isFirst(): boolean;
96
+ get isLast(): boolean;
97
+ get isRoot(): boolean;
98
+ get root(): T;
99
+ get ancestors(): T[];
100
+
101
+ stack: T[];
102
+
103
+ callParent<U>(callback: (path: this) => U, count?: number): U;
104
+
105
+ /**
106
+ * @deprecated Please use `AstPath#key` or `AstPath#index`
107
+ */
108
+ getName(): PropertyKey | null;
109
+
110
+ /**
111
+ * @deprecated Please use `AstPath#node` or `AstPath#siblings`
112
+ */
113
+ getValue(): T;
114
+
115
+ getNode(count?: number): T | null;
116
+
117
+ getParentNode(count?: number): T | null;
118
+
119
+ match(
120
+ ...predicates: Array<
121
+ (node: any, name: string | null, number: number | null) => boolean
122
+ >
123
+ ): boolean;
124
+
125
+ // For each of the tree walk functions (call, each, and map) this provides 5
126
+ // strict type signatures, along with a fallback at the end if you end up
127
+ // calling more than 5 properties deep. This helps a lot with typing because
128
+ // for the majority of cases you're calling fewer than 5 properties, so the
129
+ // tree walk functions have a clearer understanding of what you're doing.
130
+ //
131
+ // Note that resolving these types is somewhat complicated, and it wasn't
132
+ // even supported until TypeScript 4.2 (before it would just say that the
133
+ // type instantiation was excessively deep and possibly infinite).
134
+
135
+ call<U>(callback: CallCallback<T, U>): U;
136
+ call<U, P1 extends CallProperties<T>>(
137
+ callback: CallCallback<IndexValue<T, P1>, U>,
138
+ prop1: P1,
139
+ ): U;
140
+ call<U, P1 extends keyof T, P2 extends CallProperties<T[P1]>>(
141
+ callback: CallCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
142
+ prop1: P1,
143
+ prop2: P2,
144
+ ): U;
145
+ call<
146
+ U,
147
+ P1 extends keyof T,
148
+ P2 extends CallProperties<T[P1]>,
149
+ P3 extends CallProperties<IndexValue<T[P1], P2>>,
150
+ >(
151
+ callback: CallCallback<
152
+ IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
153
+ U
154
+ >,
155
+ prop1: P1,
156
+ prop2: P2,
157
+ prop3: P3,
158
+ ): U;
159
+ call<
160
+ U,
161
+ P1 extends keyof T,
162
+ P2 extends CallProperties<T[P1]>,
163
+ P3 extends CallProperties<IndexValue<T[P1], P2>>,
164
+ P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
165
+ >(
166
+ callback: CallCallback<
167
+ IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
168
+ U
169
+ >,
170
+ prop1: P1,
171
+ prop2: P2,
172
+ prop3: P3,
173
+ prop4: P4,
174
+ ): U;
175
+ call<U, P extends PropertyKey>(
176
+ callback: CallCallback<any, U>,
177
+ prop1: P,
178
+ prop2: P,
179
+ prop3: P,
180
+ prop4: P,
181
+ ...props: P[]
182
+ ): U;
183
+
184
+ each(callback: EachCallback<T>): void;
185
+ each<P1 extends IterProperties<T>>(
186
+ callback: EachCallback<IndexValue<T, P1>>,
187
+ prop1: P1,
188
+ ): void;
189
+ each<P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
190
+ callback: EachCallback<IndexValue<IndexValue<T, P1>, P2>>,
191
+ prop1: P1,
192
+ prop2: P2,
193
+ ): void;
194
+ each<
195
+ P1 extends keyof T,
196
+ P2 extends IterProperties<T[P1]>,
197
+ P3 extends IterProperties<IndexValue<T[P1], P2>>,
198
+ >(
199
+ callback: EachCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>>,
200
+ prop1: P1,
201
+ prop2: P2,
202
+ prop3: P3,
203
+ ): void;
204
+ each<
205
+ P1 extends keyof T,
206
+ P2 extends IterProperties<T[P1]>,
207
+ P3 extends IterProperties<IndexValue<T[P1], P2>>,
208
+ P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
209
+ >(
210
+ callback: EachCallback<
211
+ IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>
212
+ >,
213
+ prop1: P1,
214
+ prop2: P2,
215
+ prop3: P3,
216
+ prop4: P4,
217
+ ): void;
218
+ each(
219
+ callback: EachCallback<any[]>,
220
+ prop1: PropertyKey,
221
+ prop2: PropertyKey,
222
+ prop3: PropertyKey,
223
+ prop4: PropertyKey,
224
+ ...props: PropertyKey[]
225
+ ): void;
226
+
227
+ map<U>(callback: MapCallback<T, U>): U[];
228
+ map<U, P1 extends IterProperties<T>>(
229
+ callback: MapCallback<IndexValue<T, P1>, U>,
230
+ prop1: P1,
231
+ ): U[];
232
+ map<U, P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
233
+ callback: MapCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
234
+ prop1: P1,
235
+ prop2: P2,
236
+ ): U[];
237
+ map<
238
+ U,
239
+ P1 extends keyof T,
240
+ P2 extends IterProperties<T[P1]>,
241
+ P3 extends IterProperties<IndexValue<T[P1], P2>>,
242
+ >(
243
+ callback: MapCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, U>,
244
+ prop1: P1,
245
+ prop2: P2,
246
+ prop3: P3,
247
+ ): U[];
248
+ map<
249
+ U,
250
+ P1 extends keyof T,
251
+ P2 extends IterProperties<T[P1]>,
252
+ P3 extends IterProperties<IndexValue<T[P1], P2>>,
253
+ P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
254
+ >(
255
+ callback: MapCallback<
256
+ IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
257
+ U
258
+ >,
259
+ prop1: P1,
260
+ prop2: P2,
261
+ prop3: P3,
262
+ prop4: P4,
263
+ ): U[];
264
+ map<U>(
265
+ callback: MapCallback<any[], U>,
266
+ prop1: PropertyKey,
267
+ prop2: PropertyKey,
268
+ prop3: PropertyKey,
269
+ prop4: PropertyKey,
270
+ ...props: PropertyKey[]
271
+ ): U[];
272
+ }
273
+
274
+ /** @deprecated `FastPath` was renamed to `AstPath` */
275
+ export type FastPath<T = any> = AstPath<T>;
276
+
277
+ export type BuiltInParser = (text: string, options?: any) => AST;
278
+ export type BuiltInParserName =
279
+ | "acorn"
280
+ | "angular"
281
+ | "babel-flow"
282
+ | "babel-ts"
283
+ | "babel"
284
+ | "css"
285
+ | "espree"
286
+ | "flow"
287
+ | "glimmer"
288
+ | "graphql"
289
+ | "html"
290
+ | "json-stringify"
291
+ | "json"
292
+ | "json5"
293
+ | "jsonc"
294
+ | "less"
295
+ | "lwc"
296
+ | "markdown"
297
+ | "mdx"
298
+ | "meriyah"
299
+ | "scss"
300
+ | "typescript"
301
+ | "vue"
302
+ | "yaml";
303
+ export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
304
+
305
+ /**
306
+ * For use in `.prettierrc.js`, `.prettierrc.cjs`, `prettierrc.mjs`, `prettier.config.js`, `prettier.config.cjs`, `prettier.config.mjs`
307
+ */
308
+ export interface Config extends Options {
309
+ overrides?: Array<{
310
+ files: string | string[];
311
+ excludeFiles?: string | string[];
312
+ options?: Options;
313
+ }>;
314
+ }
315
+
316
+ export interface Options extends Partial<RequiredOptions> {}
317
+
318
+ export interface RequiredOptions extends doc.printer.Options {
319
+ /**
320
+ * Print semicolons at the ends of statements.
321
+ * @default true
322
+ */
323
+ semi: boolean;
324
+ /**
325
+ * Use single quotes instead of double quotes.
326
+ * @default false
327
+ */
328
+ singleQuote: boolean;
329
+ /**
330
+ * Use single quotes in JSX.
331
+ * @default false
332
+ */
333
+ jsxSingleQuote: boolean;
334
+ /**
335
+ * Print trailing commas wherever possible.
336
+ * @default "all"
337
+ */
338
+ trailingComma: "none" | "es5" | "all";
339
+ /**
340
+ * Print spaces between brackets in object literals.
341
+ * @default true
342
+ */
343
+ bracketSpacing: boolean;
344
+ /**
345
+ * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
346
+ * alone on the next line (does not apply to self closing elements).
347
+ * @default false
348
+ */
349
+ bracketSameLine: boolean;
350
+ /**
351
+ * Format only a segment of a file.
352
+ * @default 0
353
+ */
354
+ rangeStart: number;
355
+ /**
356
+ * Format only a segment of a file.
357
+ * @default Number.POSITIVE_INFINITY
358
+ */
359
+ rangeEnd: number;
360
+ /**
361
+ * Specify which parser to use.
362
+ */
363
+ parser: LiteralUnion<BuiltInParserName>;
364
+ /**
365
+ * Specify the input filepath. This will be used to do parser inference.
366
+ */
367
+ filepath: string;
368
+ /**
369
+ * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
370
+ * This is very useful when gradually transitioning large, unformatted codebases to prettier.
371
+ * @default false
372
+ */
373
+ requirePragma: boolean;
374
+ /**
375
+ * Prettier can insert a special @format marker at the top of files specifying that
376
+ * the file has been formatted with prettier. This works well when used in tandem with
377
+ * the --require-pragma option. If there is already a docblock at the top of
378
+ * the file then this option will add a newline to it with the @format marker.
379
+ * @default false
380
+ */
381
+ insertPragma: boolean;
382
+ /**
383
+ * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
384
+ * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
385
+ * @default "preserve"
386
+ */
387
+ proseWrap: "always" | "never" | "preserve";
388
+ /**
389
+ * Include parentheses around a sole arrow function parameter.
390
+ * @default "always"
391
+ */
392
+ arrowParens: "avoid" | "always";
393
+ /**
394
+ * Provide ability to support new languages to prettier.
395
+ */
396
+ plugins: Array<string | Plugin>;
397
+ /**
398
+ * How to handle whitespaces in HTML.
399
+ * @default "css"
400
+ */
401
+ htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
402
+ /**
403
+ * Which end of line characters to apply.
404
+ * @default "lf"
405
+ */
406
+ endOfLine: "auto" | "lf" | "crlf" | "cr";
407
+ /**
408
+ * Change when properties in objects are quoted.
409
+ * @default "as-needed"
410
+ */
411
+ quoteProps: "as-needed" | "consistent" | "preserve";
412
+ /**
413
+ * Whether or not to indent the code inside <script> and <style> tags in Vue files.
414
+ * @default false
415
+ */
416
+ vueIndentScriptAndStyle: boolean;
417
+ /**
418
+ * Control whether Prettier formats quoted code embedded in the file.
419
+ * @default "auto"
420
+ */
421
+ embeddedLanguageFormatting: "auto" | "off";
422
+ /**
423
+ * Enforce single attribute per line in HTML, Vue and JSX.
424
+ * @default false
425
+ */
426
+ singleAttributePerLine: boolean;
427
+ /**
428
+ * Use curious ternaries, with the question mark after the condition, instead
429
+ * of on the same line as the consequent.
430
+ * @default false
431
+ */
432
+ experimentalTernaries: boolean;
433
+ /**
434
+ * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
435
+ * @default false
436
+ * @deprecated use bracketSameLine instead
437
+ */
438
+ jsxBracketSameLine?: boolean;
439
+ /**
440
+ * Arbitrary additional values on an options object are always allowed.
441
+ */
442
+ [_: string]: unknown;
443
+ }
444
+
445
+ export interface ParserOptions<T = any> extends RequiredOptions {
446
+ locStart: (node: T) => number;
447
+ locEnd: (node: T) => number;
448
+ originalText: string;
449
+ }
450
+
451
+ export interface Plugin<T = any> {
452
+ languages?: SupportLanguage[] | undefined;
453
+ parsers?: { [parserName: string]: Parser<T> } | undefined;
454
+ printers?: { [astFormat: string]: Printer<T> } | undefined;
455
+ options?: SupportOptions | undefined;
456
+ defaultOptions?: Partial<RequiredOptions> | undefined;
457
+ }
458
+
459
+ export interface Parser<T = any> {
460
+ parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;
461
+ astFormat: string;
462
+ hasPragma?: ((text: string) => boolean) | undefined;
463
+ locStart: (node: T) => number;
464
+ locEnd: (node: T) => number;
465
+ preprocess?:
466
+ | ((text: string, options: ParserOptions<T>) => string)
467
+ | undefined;
468
+ }
469
+
470
+ export interface Printer<T = any> {
471
+ print(
472
+ path: AstPath<T>,
473
+ options: ParserOptions<T>,
474
+ print: (path: AstPath<T>) => Doc,
475
+ args?: unknown,
476
+ ): Doc;
477
+ embed?:
478
+ | ((
479
+ path: AstPath,
480
+ options: Options,
481
+ ) =>
482
+ | ((
483
+ textToDoc: (text: string, options: Options) => Promise<Doc>,
484
+ print: (
485
+ selector?: string | number | Array<string | number> | AstPath,
486
+ ) => Doc,
487
+ path: AstPath,
488
+ options: Options,
489
+ ) => Promise<Doc | undefined> | Doc | undefined)
490
+ | Doc
491
+ | null)
492
+ | undefined;
493
+ preprocess?:
494
+ | ((ast: T, options: ParserOptions<T>) => T | Promise<T>)
495
+ | undefined;
496
+ insertPragma?: (text: string) => string;
497
+ /**
498
+ * @returns `null` if you want to remove this node
499
+ * @returns `void` if you want to use modified `cloned`
500
+ * @returns anything if you want to replace the node with it
501
+ */
502
+ massageAstNode?:
503
+ | ((original: any, cloned: any, parent: any) => any)
504
+ | undefined;
505
+ hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
506
+ canAttachComment?: ((node: T) => boolean) | undefined;
507
+ isBlockComment?: ((node: T) => boolean) | undefined;
508
+ willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
509
+ printComment?:
510
+ | ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
511
+ | undefined;
512
+ /**
513
+ * By default, Prettier searches all object properties (except for a few predefined ones) of each node recursively.
514
+ * This function can be provided to override that behavior.
515
+ * @param node The node whose children should be returned.
516
+ * @param options Current options.
517
+ * @returns `[]` if the node has no children or `undefined` to fall back on the default behavior.
518
+ */
519
+ getCommentChildNodes?:
520
+ | ((node: T, options: ParserOptions<T>) => T[] | undefined)
521
+ | undefined;
522
+ handleComments?:
523
+ | {
524
+ ownLine?:
525
+ | ((
526
+ commentNode: any,
527
+ text: string,
528
+ options: ParserOptions<T>,
529
+ ast: T,
530
+ isLastComment: boolean,
531
+ ) => boolean)
532
+ | undefined;
533
+ endOfLine?:
534
+ | ((
535
+ commentNode: any,
536
+ text: string,
537
+ options: ParserOptions<T>,
538
+ ast: T,
539
+ isLastComment: boolean,
540
+ ) => boolean)
541
+ | undefined;
542
+ remaining?:
543
+ | ((
544
+ commentNode: any,
545
+ text: string,
546
+ options: ParserOptions<T>,
547
+ ast: T,
548
+ isLastComment: boolean,
549
+ ) => boolean)
550
+ | undefined;
551
+ }
552
+ | undefined;
553
+ getVisitorKeys?:
554
+ | ((node: T, nonTraversableKeys: Set<string>) => string[])
555
+ | undefined;
556
+ }
557
+
558
+ export interface CursorOptions extends Options {
559
+ /**
560
+ * Specify where the cursor is.
561
+ */
562
+ cursorOffset: number;
563
+ }
564
+
565
+ export interface CursorResult {
566
+ formatted: string;
567
+ cursorOffset: number;
568
+ }
569
+
570
+ /**
571
+ * `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
572
+ */
573
+ export function format(source: string, options?: Options): Promise<string>;
574
+
575
+ /**
576
+ * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
577
+ * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
578
+ */
579
+ export function check(source: string, options?: Options): Promise<boolean>;
580
+
581
+ /**
582
+ * `formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code.
583
+ * This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
584
+ *
585
+ * The `cursorOffset` option should be provided, to specify where the cursor is.
586
+ */
587
+ export function formatWithCursor(
588
+ source: string,
589
+ options: CursorOptions,
590
+ ): Promise<CursorResult>;
591
+
592
+ export interface ResolveConfigOptions {
593
+ /**
594
+ * If set to `false`, all caching will be bypassed.
595
+ */
596
+ useCache?: boolean | undefined;
597
+ /**
598
+ * Pass directly the path of the config file if you don't wish to search for it.
599
+ */
600
+ config?: string | undefined;
601
+ /**
602
+ * If set to `true` and an `.editorconfig` file is in your project,
603
+ * Prettier will parse it and convert its properties to the corresponding prettier configuration.
604
+ * This configuration will be overridden by `.prettierrc`, etc. Currently,
605
+ * the following EditorConfig properties are supported:
606
+ * - indent_style
607
+ * - indent_size/tab_width
608
+ * - max_line_length
609
+ */
610
+ editorconfig?: boolean | undefined;
611
+ }
612
+
613
+ /**
614
+ * `resolveConfig` can be used to resolve configuration for a given source file,
615
+ * passing its path or url as the first argument. The config search will start at
616
+ * the directory of the file location and continue to search up the directory.
617
+ *
618
+ * A promise is returned which will resolve to:
619
+ *
620
+ * - An options object, providing a [config file](https://prettier.io/docs/en/configuration.html) was found.
621
+ * - `null`, if no file was found.
622
+ *
623
+ * The promise will be rejected if there was an error parsing the configuration file.
624
+ */
625
+ export function resolveConfig(
626
+ fileUrlOrPath: string | URL,
627
+ options?: ResolveConfigOptions,
628
+ ): Promise<Options | null>;
629
+
630
+ /**
631
+ * `resolveConfigFile` can be used to find the path of the Prettier configuration file,
632
+ * that will be used when resolving the config (i.e. when calling `resolveConfig`).
633
+ *
634
+ * A promise is returned which will resolve to:
635
+ *
636
+ * - The path of the configuration file.
637
+ * - `null`, if no file was found.
638
+ *
639
+ * The promise will be rejected if there was an error parsing the configuration file.
640
+ */
641
+ export function resolveConfigFile(
642
+ fileUrlOrPath?: string | URL,
643
+ ): Promise<string | null>;
644
+
645
+ /**
646
+ * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache.
647
+ * Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
648
+ */
649
+ export function clearConfigCache(): Promise<void>;
650
+
651
+ export interface SupportLanguage {
652
+ name: string;
653
+ since?: string | undefined;
654
+ parsers: BuiltInParserName[] | string[];
655
+ group?: string | undefined;
656
+ tmScope?: string | undefined;
657
+ aceMode?: string | undefined;
658
+ codemirrorMode?: string | undefined;
659
+ codemirrorMimeType?: string | undefined;
660
+ aliases?: string[] | undefined;
661
+ extensions?: string[] | undefined;
662
+ filenames?: string[] | undefined;
663
+ linguistLanguageId?: number | undefined;
664
+ vscodeLanguageIds?: string[] | undefined;
665
+ interpreters?: string[] | undefined;
666
+ }
667
+
668
+ export interface SupportOptionRange {
669
+ start: number;
670
+ end: number;
671
+ step: number;
672
+ }
673
+
674
+ export type SupportOptionType =
675
+ | "int"
676
+ | "string"
677
+ | "boolean"
678
+ | "choice"
679
+ | "path";
680
+
681
+ export type CoreCategoryType =
682
+ | "Config"
683
+ | "Editor"
684
+ | "Format"
685
+ | "Other"
686
+ | "Output"
687
+ | "Global"
688
+ | "Special";
689
+
690
+ export interface BaseSupportOption<Type extends SupportOptionType> {
691
+ readonly name?: string | undefined;
692
+ /**
693
+ * Usually you can use {@link CoreCategoryType}
694
+ */
695
+ category: string;
696
+ /**
697
+ * The type of the option.
698
+ *
699
+ * When passing a type other than the ones listed below, the option is
700
+ * treated as taking any string as argument, and `--option <${type}>` will
701
+ * be displayed in --help.
702
+ */
703
+ type: Type;
704
+ /**
705
+ * Indicate that the option is deprecated.
706
+ *
707
+ * Use a string to add an extra message to --help for the option,
708
+ * for example to suggest a replacement option.
709
+ */
710
+ deprecated?: true | string | undefined;
711
+ /**
712
+ * Description to be displayed in --help. If omitted, the option won't be
713
+ * shown at all in --help.
714
+ */
715
+ description?: string | undefined;
716
+ }
717
+
718
+ export interface IntSupportOption extends BaseSupportOption<"int"> {
719
+ default?: number | undefined;
720
+ array?: false | undefined;
721
+ range?: SupportOptionRange | undefined;
722
+ }
723
+
724
+ export interface IntArraySupportOption extends BaseSupportOption<"int"> {
725
+ default?: Array<{ value: number[] }> | undefined;
726
+ array: true;
727
+ }
728
+
729
+ export interface StringSupportOption extends BaseSupportOption<"string"> {
730
+ default?: string | undefined;
731
+ array?: false | undefined;
732
+ }
733
+
734
+ export interface StringArraySupportOption extends BaseSupportOption<"string"> {
735
+ default?: Array<{ value: string[] }> | undefined;
736
+ array: true;
737
+ }
738
+
739
+ export interface BooleanSupportOption extends BaseSupportOption<"boolean"> {
740
+ default?: boolean | undefined;
741
+ array?: false | undefined;
742
+ description: string;
743
+ oppositeDescription?: string | undefined;
744
+ }
745
+
746
+ export interface BooleanArraySupportOption
747
+ extends BaseSupportOption<"boolean"> {
748
+ default?: Array<{ value: boolean[] }> | undefined;
749
+ array: true;
750
+ }
751
+
752
+ export interface ChoiceSupportOption<Value = any>
753
+ extends BaseSupportOption<"choice"> {
754
+ default?: Value | Array<{ value: Value }> | undefined;
755
+ description: string;
756
+ choices: Array<{
757
+ since?: string | undefined;
758
+ value: Value;
759
+ description: string;
760
+ }>;
761
+ }
762
+
763
+ export interface PathSupportOption extends BaseSupportOption<"path"> {
764
+ default?: string | undefined;
765
+ array?: false | undefined;
766
+ }
767
+
768
+ export interface PathArraySupportOption extends BaseSupportOption<"path"> {
769
+ default?: Array<{ value: string[] }> | undefined;
770
+ array: true;
771
+ }
772
+
773
+ export type SupportOption =
774
+ | IntSupportOption
775
+ | IntArraySupportOption
776
+ | StringSupportOption
777
+ | StringArraySupportOption
778
+ | BooleanSupportOption
779
+ | BooleanArraySupportOption
780
+ | ChoiceSupportOption
781
+ | PathSupportOption
782
+ | PathArraySupportOption;
783
+
784
+ export interface SupportOptions extends Record<string, SupportOption> {}
785
+
786
+ export interface SupportInfo {
787
+ languages: SupportLanguage[];
788
+ options: SupportOption[];
789
+ }
790
+
791
+ export interface FileInfoOptions {
792
+ ignorePath?: string | URL | (string | URL)[] | undefined;
793
+ withNodeModules?: boolean | undefined;
794
+ plugins?: Array<string | Plugin> | undefined;
795
+ resolveConfig?: boolean | undefined;
796
+ }
797
+
798
+ export interface FileInfoResult {
799
+ ignored: boolean;
800
+ inferredParser: string | null;
801
+ }
802
+
803
+ export function getFileInfo(
804
+ file: string | URL,
805
+ options?: FileInfoOptions,
806
+ ): Promise<FileInfoResult>;
807
+
808
+ export interface SupportInfoOptions {
809
+ plugins?: Array<string | Plugin> | undefined;
810
+ showDeprecated?: boolean | undefined;
811
+ }
812
+
813
+ /**
814
+ * Returns an object representing the parsers, languages and file types Prettier supports for the current version.
815
+ */
816
+ export function getSupportInfo(
817
+ options?: SupportInfoOptions,
818
+ ): Promise<SupportInfo>;
819
+
820
+ /**
821
+ * `version` field in `package.json`
822
+ */
823
+ export const version: string;
824
+
825
+ // https://github.com/prettier/prettier/blob/next/src/utils/public.js
826
+ export namespace util {
827
+ interface SkipOptions {
828
+ backwards?: boolean | undefined;
829
+ }
830
+
831
+ type Quote = "'" | '"';
832
+
833
+ function getMaxContinuousCount(text: string, searchString: string): number;
834
+
835
+ function getStringWidth(text: string): number;
836
+
837
+ function getAlignmentSize(
838
+ text: string,
839
+ tabWidth: number,
840
+ startIndex?: number | undefined,
841
+ ): number;
842
+
843
+ function getIndentSize(value: string, tabWidth: number): number;
844
+
845
+ function skipNewline(
846
+ text: string,
847
+ startIndex: number | false,
848
+ options?: SkipOptions | undefined,
849
+ ): number | false;
850
+
851
+ function skipInlineComment(
852
+ text: string,
853
+ startIndex: number | false,
854
+ ): number | false;
855
+
856
+ function skipTrailingComment(
857
+ text: string,
858
+ startIndex: number | false,
859
+ ): number | false;
860
+
861
+ function skipTrailingComment(
862
+ text: string,
863
+ startIndex: number | false,
864
+ ): number | false;
865
+
866
+ function hasNewline(
867
+ text: string,
868
+ startIndex: number,
869
+ options?: SkipOptions | undefined,
870
+ ): boolean;
871
+
872
+ function hasNewlineInRange(
873
+ text: string,
874
+ startIndex: number,
875
+ endIndex: number,
876
+ ): boolean;
877
+
878
+ function hasSpaces(
879
+ text: string,
880
+ startIndex: number,
881
+ options?: SkipOptions | undefined,
882
+ ): boolean;
883
+
884
+ function getNextNonSpaceNonCommentCharacterIndex(
885
+ text: string,
886
+ startIndex: number,
887
+ ): number | false;
888
+
889
+ function getNextNonSpaceNonCommentCharacter(
890
+ text: string,
891
+ startIndex: number,
892
+ ): string;
893
+
894
+ function isNextLineEmpty(text: string, startIndex: number): boolean;
895
+
896
+ function isPreviousLineEmpty(text: string, startIndex: number): boolean;
897
+
898
+ function makeString(
899
+ rawText: string,
900
+ enclosingQuote: Quote,
901
+ unescapeUnnecessaryEscapes?: boolean | undefined,
902
+ ): string;
903
+
904
+ function skip(
905
+ characters: string | RegExp,
906
+ ): (
907
+ text: string,
908
+ startIndex: number | false,
909
+ options?: SkipOptions,
910
+ ) => number | false;
911
+
912
+ const skipWhitespace: (
913
+ text: string,
914
+ startIndex: number | false,
915
+ options?: SkipOptions,
916
+ ) => number | false;
917
+
918
+ const skipSpaces: (
919
+ text: string,
920
+ startIndex: number | false,
921
+ options?: SkipOptions,
922
+ ) => number | false;
923
+
924
+ const skipToLineEnd: (
925
+ text: string,
926
+ startIndex: number | false,
927
+ options?: SkipOptions,
928
+ ) => number | false;
929
+
930
+ const skipEverythingButNewLine: (
931
+ text: string,
932
+ startIndex: number | false,
933
+ options?: SkipOptions,
934
+ ) => number | false;
935
+
936
+ function addLeadingComment(node: any, comment: any): void;
937
+
938
+ function addDanglingComment(node: any, comment: any, marker: any): void;
939
+
940
+ function addTrailingComment(node: any, comment: any): void;
941
+ }