@umijs/utils 4.0.0-beta.7 → 4.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/compiled/axios/index.d.ts +29 -14
  2. package/compiled/axios/index.js +1 -1
  3. package/compiled/chalk/LICENSE +1 -1
  4. package/compiled/chalk/index.js +1 -1
  5. package/compiled/chalk/package.json +1 -1
  6. package/compiled/chalk/source/index.d.ts +318 -0
  7. package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
  8. package/compiled/color/color-convert/conversions.d.ts +87 -87
  9. package/compiled/color/color-convert/index.d.ts +75 -60
  10. package/compiled/color/color-convert/route.d.ts +271 -271
  11. package/compiled/color/index.d.ts +118 -121
  12. package/compiled/color/index.js +1 -1
  13. package/compiled/color/package.json +1 -4
  14. package/compiled/debug/LICENSE +10 -9
  15. package/compiled/debug/index.js +1 -1
  16. package/compiled/debug/package.json +1 -1
  17. package/compiled/execa/index.d.ts +467 -445
  18. package/compiled/execa/index.js +1 -1
  19. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  20. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
  21. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  22. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  23. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  24. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  25. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
  26. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  27. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
  28. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  29. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
  30. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  31. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  32. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  33. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
  34. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  35. package/compiled/globby/LICENSE +9 -0
  36. package/compiled/globby/fast-glob/out/index.d.ts +27 -0
  37. package/compiled/globby/fast-glob/out/managers/tasks.d.ts +22 -0
  38. package/compiled/globby/fast-glob/out/settings.d.ts +164 -0
  39. package/compiled/globby/fast-glob/out/types/index.d.ts +31 -0
  40. package/compiled/globby/index.d.ts +206 -0
  41. package/compiled/globby/index.js +37 -0
  42. package/compiled/globby/package.json +1 -0
  43. package/compiled/pirates/LICENSE +21 -0
  44. package/compiled/pirates/index.d.ts +82 -0
  45. package/compiled/pirates/index.js +1 -0
  46. package/compiled/pirates/package.json +1 -0
  47. package/compiled/pkg-up/LICENSE +1 -1
  48. package/compiled/pkg-up/index.d.ts +55 -44
  49. package/compiled/pkg-up/index.js +1 -1
  50. package/compiled/pkg-up/package.json +1 -1
  51. package/compiled/prettier/index.d.ts +568 -679
  52. package/compiled/prettier/index.js +62 -274
  53. package/compiled/prettier/package.json +1 -5
  54. package/compiled/resolve/index.js +1 -1
  55. package/compiled/strip-ansi/LICENSE +1 -1
  56. package/compiled/strip-ansi/index.d.ts +2 -4
  57. package/compiled/strip-ansi/index.js +1 -1
  58. package/compiled/strip-ansi/package.json +1 -1
  59. package/compiled/yargs-parser/index.js +1 -1
  60. package/dist/getCorejsVersion.d.ts +1 -0
  61. package/dist/getCorejsVersion.js +11 -0
  62. package/dist/index.d.ts +5 -3
  63. package/dist/index.js +6 -5
  64. package/dist/installDeps.js +20 -4
  65. package/dist/isStyleFile.d.ts +5 -0
  66. package/dist/isStyleFile.js +16 -0
  67. package/dist/logger.d.ts +8 -6
  68. package/dist/logger.js +8 -1
  69. package/dist/register.js +22 -22
  70. package/dist/tryPaths.d.ts +1 -0
  71. package/dist/tryPaths.js +11 -0
  72. package/package.json +32 -31
@@ -18,9 +18,7 @@
18
18
  //
19
19
  // It comes from this issue: microsoft/TypeScript#29729:
20
20
  // https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227
21
- export type LiteralUnion<T extends U, U = string> =
22
- | T
23
- | (Pick<U, never> & { _?: never | undefined });
21
+ export type LiteralUnion<T extends U, U = string> = T | (Pick<U, never> & { _?: never | undefined });
24
22
 
25
23
  export type AST = any;
26
24
  export type Doc = doc.builders.Doc;
@@ -28,27 +26,17 @@ export type Doc = doc.builders.Doc;
28
26
  // https://github.com/prettier/prettier/blob/main/src/common/ast-path.js
29
27
 
30
28
  export class AstPath<T = any> {
31
- constructor(value: T);
32
- stack: T[];
33
- getName(): PropertyKey | null;
34
- getValue(): T;
35
- getNode(count?: number): T | null;
36
- getParentNode(count?: number): T | null;
37
- call<U>(callback: (path: this) => U, ...names: PropertyKey[]): U;
38
- callParent<U>(callback: (path: this) => U, count?: number): U;
39
- each(
40
- callback: (path: this, index: number, value: any) => void,
41
- ...names: PropertyKey[]
42
- ): void;
43
- map<U>(
44
- callback: (path: this, index: number, value: any) => U,
45
- ...names: PropertyKey[]
46
- ): U[];
47
- match(
48
- ...predicates: Array<
49
- (node: any, name: string | null, number: number | null) => boolean
50
- >
51
- ): boolean;
29
+ constructor(value: T);
30
+ stack: T[];
31
+ getName(): PropertyKey | null;
32
+ getValue(): T;
33
+ getNode(count?: number): T | null;
34
+ getParentNode(count?: number): T | null;
35
+ call<U>(callback: (path: this) => U, ...names: PropertyKey[]): U;
36
+ callParent<U>(callback: (path: this) => U, count?: number): U;
37
+ each(callback: (path: this, index: number, value: any) => void, ...names: PropertyKey[]): void;
38
+ map<U>(callback: (path: this, index: number, value: any) => U, ...names: PropertyKey[]): U[];
39
+ match(...predicates: Array<(node: any, name: string | null, number: number | null) => boolean>): boolean;
52
40
  }
53
41
 
54
42
  /** @deprecated `FastPath` was renamed to `AstPath` */
@@ -56,254 +44,238 @@ export type FastPath<T = any> = AstPath<T>;
56
44
 
57
45
  export type BuiltInParser = (text: string, options?: any) => AST;
58
46
  export type BuiltInParserName =
59
- | 'angular'
60
- | 'babel-flow'
61
- | 'babel-ts'
62
- | 'babel'
63
- | 'css'
64
- | 'espree'
65
- | 'flow'
66
- | 'glimmer'
67
- | 'graphql'
68
- | 'html'
69
- | 'json-stringify'
70
- | 'json'
71
- | 'json5'
72
- | 'less'
73
- | 'lwc'
74
- | 'markdown'
75
- | 'mdx'
76
- | 'meriyah'
77
- | 'scss'
78
- | 'typescript'
79
- | 'vue'
80
- | 'yaml';
47
+ | 'angular'
48
+ | 'babel-flow'
49
+ | 'babel-ts'
50
+ | 'babel'
51
+ | 'css'
52
+ | 'espree'
53
+ | 'flow'
54
+ | 'glimmer'
55
+ | 'graphql'
56
+ | 'html'
57
+ | 'json-stringify'
58
+ | 'json'
59
+ | 'json5'
60
+ | 'less'
61
+ | 'lwc'
62
+ | 'markdown'
63
+ | 'mdx'
64
+ | 'meriyah'
65
+ | 'scss'
66
+ | 'typescript'
67
+ | 'vue'
68
+ | 'yaml';
81
69
  export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
82
70
 
83
- export type CustomParser = (
84
- text: string,
85
- parsers: BuiltInParsers,
86
- options: Options,
87
- ) => AST;
71
+ export type CustomParser = (text: string, parsers: BuiltInParsers, options: Options) => AST;
88
72
 
89
73
  export interface Options extends Partial<RequiredOptions> {}
90
74
  export interface RequiredOptions extends doc.printer.Options {
91
- /**
92
- * Print semicolons at the ends of statements.
93
- * @default true
94
- */
95
- semi: boolean;
96
- /**
97
- * Use single quotes instead of double quotes.
98
- * @default false
99
- */
100
- singleQuote: boolean;
101
- /**
102
- * Use single quotes in JSX.
103
- * @default false
104
- */
105
- jsxSingleQuote: boolean;
106
- /**
107
- * Print trailing commas wherever possible.
108
- * @default 'es5'
109
- */
110
- trailingComma: 'none' | 'es5' | 'all';
111
- /**
112
- * Print spaces between brackets in object literals.
113
- * @default true
114
- */
115
- bracketSpacing: boolean;
116
- /**
117
- * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
118
- * alone on the next line (does not apply to self closing elements).
119
- * @default false
120
- */
121
- bracketSameLine: boolean;
122
- /**
123
- * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
124
- * @default false
125
- * @deprecated use bracketSameLine instead
126
- */
127
- jsxBracketSameLine: boolean;
128
- /**
129
- * Format only a segment of a file.
130
- * @default 0
131
- */
132
- rangeStart: number;
133
- /**
134
- * Format only a segment of a file.
135
- * @default Infinity
136
- */
137
- rangeEnd: number;
138
- /**
139
- * Specify which parser to use.
140
- */
141
- parser: LiteralUnion<BuiltInParserName> | CustomParser;
142
- /**
143
- * Specify the input filepath. This will be used to do parser inference.
144
- */
145
- filepath: string;
146
- /**
147
- * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
148
- * This is very useful when gradually transitioning large, unformatted codebases to prettier.
149
- * @default false
150
- */
151
- requirePragma: boolean;
152
- /**
153
- * Prettier can insert a special @format marker at the top of files specifying that
154
- * the file has been formatted with prettier. This works well when used in tandem with
155
- * the --require-pragma option. If there is already a docblock at the top of
156
- * the file then this option will add a newline to it with the @format marker.
157
- * @default false
158
- */
159
- insertPragma: boolean;
160
- /**
161
- * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
162
- * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
163
- * @default 'preserve'
164
- */
165
- proseWrap: 'always' | 'never' | 'preserve';
166
- /**
167
- * Include parentheses around a sole arrow function parameter.
168
- * @default 'always'
169
- */
170
- arrowParens: 'avoid' | 'always';
171
- /**
172
- * Provide ability to support new languages to prettier.
173
- */
174
- plugins: Array<string | Plugin>;
175
- /**
176
- * Specify plugin directory paths to search for plugins if not installed in the same `node_modules` where prettier is located.
177
- */
178
- pluginSearchDirs: string[];
179
- /**
180
- * How to handle whitespaces in HTML.
181
- * @default 'css'
182
- */
183
- htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
184
- /**
185
- * Which end of line characters to apply.
186
- * @default 'lf'
187
- */
188
- endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
189
- /**
190
- * Change when properties in objects are quoted.
191
- * @default 'as-needed'
192
- */
193
- quoteProps: 'as-needed' | 'consistent' | 'preserve';
194
- /**
195
- * Whether or not to indent the code inside <script> and <style> tags in Vue files.
196
- * @default false
197
- */
198
- vueIndentScriptAndStyle: boolean;
199
- /**
200
- * Control whether Prettier formats quoted code embedded in the file.
201
- * @default 'auto'
202
- */
203
- embeddedLanguageFormatting: 'auto' | 'off';
75
+ /**
76
+ * Print semicolons at the ends of statements.
77
+ * @default true
78
+ */
79
+ semi: boolean;
80
+ /**
81
+ * Use single quotes instead of double quotes.
82
+ * @default false
83
+ */
84
+ singleQuote: boolean;
85
+ /**
86
+ * Use single quotes in JSX.
87
+ * @default false
88
+ */
89
+ jsxSingleQuote: boolean;
90
+ /**
91
+ * Print trailing commas wherever possible.
92
+ * @default 'es5'
93
+ */
94
+ trailingComma: 'none' | 'es5' | 'all';
95
+ /**
96
+ * Print spaces between brackets in object literals.
97
+ * @default true
98
+ */
99
+ bracketSpacing: boolean;
100
+ /**
101
+ * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
102
+ * alone on the next line (does not apply to self closing elements).
103
+ * @default false
104
+ */
105
+ bracketSameLine: boolean;
106
+ /**
107
+ * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
108
+ * @default false
109
+ * @deprecated use bracketSameLine instead
110
+ */
111
+ jsxBracketSameLine: boolean;
112
+ /**
113
+ * Format only a segment of a file.
114
+ * @default 0
115
+ */
116
+ rangeStart: number;
117
+ /**
118
+ * Format only a segment of a file.
119
+ * @default Infinity
120
+ */
121
+ rangeEnd: number;
122
+ /**
123
+ * Specify which parser to use.
124
+ */
125
+ parser: LiteralUnion<BuiltInParserName> | CustomParser;
126
+ /**
127
+ * Specify the input filepath. This will be used to do parser inference.
128
+ */
129
+ filepath: string;
130
+ /**
131
+ * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
132
+ * This is very useful when gradually transitioning large, unformatted codebases to prettier.
133
+ * @default false
134
+ */
135
+ requirePragma: boolean;
136
+ /**
137
+ * Prettier can insert a special @format marker at the top of files specifying that
138
+ * the file has been formatted with prettier. This works well when used in tandem with
139
+ * the --require-pragma option. If there is already a docblock at the top of
140
+ * the file then this option will add a newline to it with the @format marker.
141
+ * @default false
142
+ */
143
+ insertPragma: boolean;
144
+ /**
145
+ * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
146
+ * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
147
+ * @default 'preserve'
148
+ */
149
+ proseWrap: 'always' | 'never' | 'preserve';
150
+ /**
151
+ * Include parentheses around a sole arrow function parameter.
152
+ * @default 'always'
153
+ */
154
+ arrowParens: 'avoid' | 'always';
155
+ /**
156
+ * Provide ability to support new languages to prettier.
157
+ */
158
+ plugins: Array<string | Plugin>;
159
+ /**
160
+ * Specify plugin directory paths to search for plugins if not installed in the same `node_modules` where prettier is located.
161
+ */
162
+ pluginSearchDirs: string[];
163
+ /**
164
+ * How to handle whitespaces in HTML.
165
+ * @default 'css'
166
+ */
167
+ htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
168
+ /**
169
+ * Which end of line characters to apply.
170
+ * @default 'lf'
171
+ */
172
+ endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
173
+ /**
174
+ * Change when properties in objects are quoted.
175
+ * @default 'as-needed'
176
+ */
177
+ quoteProps: 'as-needed' | 'consistent' | 'preserve';
178
+ /**
179
+ * Whether or not to indent the code inside <script> and <style> tags in Vue files.
180
+ * @default false
181
+ */
182
+ vueIndentScriptAndStyle: boolean;
183
+ /**
184
+ * Control whether Prettier formats quoted code embedded in the file.
185
+ * @default 'auto'
186
+ */
187
+ embeddedLanguageFormatting: 'auto' | 'off';
204
188
  }
205
189
 
206
190
  export interface ParserOptions<T = any> extends RequiredOptions {
207
- locStart: (node: T) => number;
208
- locEnd: (node: T) => number;
209
- originalText: string;
191
+ locStart: (node: T) => number;
192
+ locEnd: (node: T) => number;
193
+ originalText: string;
210
194
  }
211
195
 
212
196
  export interface Plugin<T = any> {
213
- languages?: SupportLanguage[] | undefined;
214
- parsers?: { [parserName: string]: Parser<T> } | undefined;
215
- printers?: { [astFormat: string]: Printer<T> } | undefined;
216
- options?: SupportOptions | undefined;
217
- defaultOptions?: Partial<RequiredOptions> | undefined;
197
+ languages?: SupportLanguage[] | undefined;
198
+ parsers?: { [parserName: string]: Parser<T> } | undefined;
199
+ printers?: { [astFormat: string]: Printer<T> } | undefined;
200
+ options?: SupportOptions | undefined;
201
+ defaultOptions?: Partial<RequiredOptions> | undefined;
218
202
  }
219
203
 
220
204
  export interface Parser<T = any> {
221
- parse: (
222
- text: string,
223
- parsers: { [parserName: string]: Parser },
224
- options: ParserOptions<T>,
225
- ) => T;
226
- astFormat: string;
227
- hasPragma?: ((text: string) => boolean) | undefined;
228
- locStart: (node: T) => number;
229
- locEnd: (node: T) => number;
230
- preprocess?:
231
- | ((text: string, options: ParserOptions<T>) => string)
232
- | undefined;
205
+ parse: (text: string, parsers: { [parserName: string]: Parser }, options: ParserOptions<T>) => T;
206
+ astFormat: string;
207
+ hasPragma?: ((text: string) => boolean) | undefined;
208
+ locStart: (node: T) => number;
209
+ locEnd: (node: T) => number;
210
+ preprocess?: ((text: string, options: ParserOptions<T>) => string) | undefined;
233
211
  }
234
212
 
235
213
  export interface Printer<T = any> {
236
- print(
237
- path: AstPath<T>,
238
- options: ParserOptions<T>,
239
- print: (path: AstPath<T>) => Doc,
240
- ): Doc;
241
- embed?:
242
- | ((
243
- path: AstPath<T>,
244
- print: (path: AstPath<T>) => Doc,
245
- textToDoc: (text: string, options: Options) => Doc,
246
- options: ParserOptions<T>,
247
- ) => Doc | null)
248
- | undefined;
249
- insertPragma?: ((text: string) => string) | undefined;
250
- /**
251
- * @returns `null` if you want to remove this node
252
- * @returns `void` if you want to use modified newNode
253
- * @returns anything if you want to replace the node with it
254
- */
255
- massageAstNode?: ((node: any, newNode: any, parent: any) => any) | undefined;
256
- hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
257
- canAttachComment?: ((node: T) => boolean) | undefined;
258
- willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
259
- printComment?:
260
- | ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
261
- | undefined;
262
- handleComments?:
263
- | {
264
- ownLine?:
265
- | ((
266
- commentNode: any,
267
- text: string,
268
- options: ParserOptions<T>,
269
- ast: T,
270
- isLastComment: boolean,
271
- ) => boolean)
272
- | undefined;
273
- endOfLine?:
274
- | ((
275
- commentNode: any,
276
- text: string,
277
- options: ParserOptions<T>,
278
- ast: T,
279
- isLastComment: boolean,
280
- ) => boolean)
281
- | undefined;
282
- remaining?:
283
- | ((
284
- commentNode: any,
285
- text: string,
214
+ print(path: AstPath<T>, options: ParserOptions<T>, print: (path: AstPath<T>) => Doc): Doc;
215
+ embed?:
216
+ | ((
217
+ path: AstPath<T>,
218
+ print: (path: AstPath<T>) => Doc,
219
+ textToDoc: (text: string, options: Options) => Doc,
286
220
  options: ParserOptions<T>,
287
- ast: T,
288
- isLastComment: boolean,
289
- ) => boolean)
290
- | undefined;
291
- }
292
- | undefined;
221
+ ) => Doc | null)
222
+ | undefined;
223
+ insertPragma?: ((text: string) => string) | undefined;
224
+ /**
225
+ * @returns `null` if you want to remove this node
226
+ * @returns `void` if you want to use modified newNode
227
+ * @returns anything if you want to replace the node with it
228
+ */
229
+ massageAstNode?: ((node: any, newNode: any, parent: any) => any) | undefined;
230
+ hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
231
+ canAttachComment?: ((node: T) => boolean) | undefined;
232
+ willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
233
+ printComment?: ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc) | undefined;
234
+ handleComments?:
235
+ | {
236
+ ownLine?:
237
+ | ((
238
+ commentNode: any,
239
+ text: string,
240
+ options: ParserOptions<T>,
241
+ ast: T,
242
+ isLastComment: boolean,
243
+ ) => boolean)
244
+ | undefined;
245
+ endOfLine?:
246
+ | ((
247
+ commentNode: any,
248
+ text: string,
249
+ options: ParserOptions<T>,
250
+ ast: T,
251
+ isLastComment: boolean,
252
+ ) => boolean)
253
+ | undefined;
254
+ remaining?:
255
+ | ((
256
+ commentNode: any,
257
+ text: string,
258
+ options: ParserOptions<T>,
259
+ ast: T,
260
+ isLastComment: boolean,
261
+ ) => boolean)
262
+ | undefined;
263
+ }
264
+ | undefined;
293
265
  }
294
266
 
295
267
  export interface CursorOptions extends Options {
296
- /**
297
- * Specify where the cursor is.
298
- */
299
- cursorOffset: number;
300
- rangeStart?: never;
301
- rangeEnd?: never;
268
+ /**
269
+ * Specify where the cursor is.
270
+ */
271
+ cursorOffset: number;
272
+ rangeStart?: never;
273
+ rangeEnd?: never;
302
274
  }
303
275
 
304
276
  export interface CursorResult {
305
- formatted: string;
306
- cursorOffset: number;
277
+ formatted: string;
278
+ cursorOffset: number;
307
279
  }
308
280
 
309
281
  /**
@@ -323,30 +295,27 @@ export function check(source: string, options?: Options): boolean;
323
295
  *
324
296
  * The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`.
325
297
  */
326
- export function formatWithCursor(
327
- source: string,
328
- options: CursorOptions,
329
- ): CursorResult;
298
+ export function formatWithCursor(source: string, options: CursorOptions): CursorResult;
330
299
 
331
300
  export interface ResolveConfigOptions {
332
- /**
333
- * If set to `false`, all caching will be bypassed.
334
- */
335
- useCache?: boolean | undefined;
336
- /**
337
- * Pass directly the path of the config file if you don't wish to search for it.
338
- */
339
- config?: string | undefined;
340
- /**
341
- * If set to `true` and an `.editorconfig` file is in your project,
342
- * Prettier will parse it and convert its properties to the corresponding prettier configuration.
343
- * This configuration will be overridden by `.prettierrc`, etc. Currently,
344
- * the following EditorConfig properties are supported:
345
- * - indent_style
346
- * - indent_size/tab_width
347
- * - max_line_length
348
- */
349
- editorconfig?: boolean | undefined;
301
+ /**
302
+ * If set to `false`, all caching will be bypassed.
303
+ */
304
+ useCache?: boolean | undefined;
305
+ /**
306
+ * Pass directly the path of the config file if you don't wish to search for it.
307
+ */
308
+ config?: string | undefined;
309
+ /**
310
+ * If set to `true` and an `.editorconfig` file is in your project,
311
+ * Prettier will parse it and convert its properties to the corresponding prettier configuration.
312
+ * This configuration will be overridden by `.prettierrc`, etc. Currently,
313
+ * the following EditorConfig properties are supported:
314
+ * - indent_style
315
+ * - indent_size/tab_width
316
+ * - max_line_length
317
+ */
318
+ editorconfig?: boolean | undefined;
350
319
  }
351
320
 
352
321
  /**
@@ -362,15 +331,9 @@ export interface ResolveConfigOptions {
362
331
  *
363
332
  * The promise will be rejected if there was an error parsing the configuration file.
364
333
  */
365
- export function resolveConfig(
366
- filePath: string,
367
- options?: ResolveConfigOptions,
368
- ): Promise<Options | null>;
334
+ export function resolveConfig(filePath: string, options?: ResolveConfigOptions): Promise<Options | null>;
369
335
  export namespace resolveConfig {
370
- function sync(
371
- filePath: string,
372
- options?: ResolveConfigOptions,
373
- ): Options | null;
336
+ function sync(filePath: string, options?: ResolveConfigOptions): Options | null;
374
337
  }
375
338
 
376
339
  /**
@@ -386,7 +349,7 @@ export namespace resolveConfig {
386
349
  */
387
350
  export function resolveConfigFile(filePath?: string): Promise<string | null>;
388
351
  export namespace resolveConfigFile {
389
- function sync(filePath?: string): string | null;
352
+ function sync(filePath?: string): string | null;
390
353
  }
391
354
 
392
355
  /**
@@ -396,147 +359,135 @@ export namespace resolveConfigFile {
396
359
  export function clearConfigCache(): void;
397
360
 
398
361
  export interface SupportLanguage {
399
- name: string;
400
- since?: string | undefined;
401
- parsers: BuiltInParserName[] | string[];
402
- group?: string | undefined;
403
- tmScope?: string | undefined;
404
- aceMode?: string | undefined;
405
- codemirrorMode?: string | undefined;
406
- codemirrorMimeType?: string | undefined;
407
- aliases?: string[] | undefined;
408
- extensions?: string[] | undefined;
409
- filenames?: string[] | undefined;
410
- linguistLanguageId?: number | undefined;
411
- vscodeLanguageIds?: string[] | undefined;
362
+ name: string;
363
+ since?: string | undefined;
364
+ parsers: BuiltInParserName[] | string[];
365
+ group?: string | undefined;
366
+ tmScope?: string | undefined;
367
+ aceMode?: string | undefined;
368
+ codemirrorMode?: string | undefined;
369
+ codemirrorMimeType?: string | undefined;
370
+ aliases?: string[] | undefined;
371
+ extensions?: string[] | undefined;
372
+ filenames?: string[] | undefined;
373
+ linguistLanguageId?: number | undefined;
374
+ vscodeLanguageIds?: string[] | undefined;
412
375
  }
413
376
 
414
377
  export interface SupportOptionRange {
415
- start: number;
416
- end: number;
417
- step: number;
378
+ start: number;
379
+ end: number;
380
+ step: number;
418
381
  }
419
382
 
420
383
  export type SupportOptionType = 'int' | 'boolean' | 'choice' | 'path';
421
384
 
422
- export type CoreCategoryType =
423
- | 'Config'
424
- | 'Editor'
425
- | 'Format'
426
- | 'Other'
427
- | 'Output'
428
- | 'Global'
429
- | 'Special';
385
+ export type CoreCategoryType = 'Config' | 'Editor' | 'Format' | 'Other' | 'Output' | 'Global' | 'Special';
430
386
 
431
387
  export interface BaseSupportOption<Type extends SupportOptionType> {
432
- readonly name?: string | undefined;
433
- since: string;
434
- /**
435
- * Usually you can use {@link CoreCategoryType}
436
- */
437
- category: string;
438
- /**
439
- * The type of the option.
440
- *
441
- * When passing a type other than the ones listed below, the option is
442
- * treated as taking any string as argument, and `--option <${type}>` will
443
- * be displayed in --help.
444
- */
445
- type: Type;
446
- /**
447
- * Indicate that the option is deprecated.
448
- *
449
- * Use a string to add an extra message to --help for the option,
450
- * for example to suggest a replacement option.
451
- */
452
- deprecated?: true | string | undefined;
453
- /**
454
- * Description to be displayed in --help. If omitted, the option won't be
455
- * shown at all in --help.
456
- */
457
- description?: string | undefined;
388
+ readonly name?: string | undefined;
389
+ since: string;
390
+ /**
391
+ * Usually you can use {@link CoreCategoryType}
392
+ */
393
+ category: string;
394
+ /**
395
+ * The type of the option.
396
+ *
397
+ * When passing a type other than the ones listed below, the option is
398
+ * treated as taking any string as argument, and `--option <${type}>` will
399
+ * be displayed in --help.
400
+ */
401
+ type: Type;
402
+ /**
403
+ * Indicate that the option is deprecated.
404
+ *
405
+ * Use a string to add an extra message to --help for the option,
406
+ * for example to suggest a replacement option.
407
+ */
408
+ deprecated?: true | string | undefined;
409
+ /**
410
+ * Description to be displayed in --help. If omitted, the option won't be
411
+ * shown at all in --help.
412
+ */
413
+ description?: string | undefined;
458
414
  }
459
415
 
460
416
  export interface IntSupportOption extends BaseSupportOption<'int'> {
461
- default?: number | undefined;
462
- array?: false | undefined;
463
- range?: SupportOptionRange | undefined;
417
+ default?: number | undefined;
418
+ array?: false | undefined;
419
+ range?: SupportOptionRange | undefined;
464
420
  }
465
421
 
466
422
  export interface IntArraySupportOption extends BaseSupportOption<'int'> {
467
- default?: Array<{ value: number[] }> | undefined;
468
- array: true;
423
+ default?: Array<{ value: number[] }> | undefined;
424
+ array: true;
469
425
  }
470
426
 
471
427
  export interface BooleanSupportOption extends BaseSupportOption<'boolean'> {
472
- default?: boolean | undefined;
473
- array?: false | undefined;
474
- description: string;
475
- oppositeDescription?: string | undefined;
428
+ default?: boolean | undefined;
429
+ array?: false | undefined;
430
+ description: string;
431
+ oppositeDescription?: string | undefined;
476
432
  }
477
433
 
478
- export interface BooleanArraySupportOption
479
- extends BaseSupportOption<'boolean'> {
480
- default?: Array<{ value: boolean[] }> | undefined;
481
- array: true;
434
+ export interface BooleanArraySupportOption extends BaseSupportOption<'boolean'> {
435
+ default?: Array<{ value: boolean[] }> | undefined;
436
+ array: true;
482
437
  }
483
438
 
484
- export interface ChoiceSupportOption<Value = any>
485
- extends BaseSupportOption<'choice'> {
486
- default?: Value | Array<{ since: string; value: Value }> | undefined;
487
- description: string;
488
- choices: Array<{
489
- since?: string | undefined;
490
- value: Value;
439
+ export interface ChoiceSupportOption<Value = any> extends BaseSupportOption<'choice'> {
440
+ default?: Value | Array<{ since: string; value: Value }> | undefined;
491
441
  description: string;
492
- }>;
442
+ choices: Array<{
443
+ since?: string | undefined;
444
+ value: Value;
445
+ description: string;
446
+ }>;
493
447
  }
494
448
 
495
449
  export interface PathSupportOption extends BaseSupportOption<'path'> {
496
- default?: string | undefined;
497
- array?: false | undefined;
450
+ default?: string | undefined;
451
+ array?: false | undefined;
498
452
  }
499
453
 
500
454
  export interface PathArraySupportOption extends BaseSupportOption<'path'> {
501
- default?: Array<{ value: string[] }> | undefined;
502
- array: true;
455
+ default?: Array<{ value: string[] }> | undefined;
456
+ array: true;
503
457
  }
504
458
 
505
459
  export type SupportOption =
506
- | IntSupportOption
507
- | IntArraySupportOption
508
- | BooleanSupportOption
509
- | BooleanArraySupportOption
510
- | ChoiceSupportOption
511
- | PathSupportOption
512
- | PathArraySupportOption;
460
+ | IntSupportOption
461
+ | IntArraySupportOption
462
+ | BooleanSupportOption
463
+ | BooleanArraySupportOption
464
+ | ChoiceSupportOption
465
+ | PathSupportOption
466
+ | PathArraySupportOption;
513
467
 
514
468
  export interface SupportOptions extends Record<string, SupportOption> {}
515
469
 
516
470
  export interface SupportInfo {
517
- languages: SupportLanguage[];
518
- options: SupportOption[];
471
+ languages: SupportLanguage[];
472
+ options: SupportOption[];
519
473
  }
520
474
 
521
475
  export interface FileInfoOptions {
522
- ignorePath?: string | undefined;
523
- withNodeModules?: boolean | undefined;
524
- plugins?: string[] | undefined;
525
- resolveConfig?: boolean | undefined;
476
+ ignorePath?: string | undefined;
477
+ withNodeModules?: boolean | undefined;
478
+ plugins?: string[] | undefined;
479
+ resolveConfig?: boolean | undefined;
526
480
  }
527
481
 
528
482
  export interface FileInfoResult {
529
- ignored: boolean;
530
- inferredParser: string | null;
483
+ ignored: boolean;
484
+ inferredParser: string | null;
531
485
  }
532
486
 
533
- export function getFileInfo(
534
- filePath: string,
535
- options?: FileInfoOptions,
536
- ): Promise<FileInfoResult>;
487
+ export function getFileInfo(filePath: string, options?: FileInfoOptions): Promise<FileInfoResult>;
537
488
 
538
489
  export namespace getFileInfo {
539
- function sync(filePath: string, options?: FileInfoOptions): FileInfoResult;
490
+ function sync(filePath: string, options?: FileInfoOptions): FileInfoResult;
540
491
  }
541
492
 
542
493
  /**
@@ -551,317 +502,255 @@ export const version: string;
551
502
 
552
503
  // https://github.com/prettier/prettier/blob/main/src/common/util-shared.js
553
504
  export namespace util {
554
- interface SkipOptions {
555
- backwards?: boolean | undefined;
556
- }
557
-
558
- type Quote = "'" | '"';
559
-
560
- function addDanglingComment(node: any, comment: any, marker: any): void;
561
- function addLeadingComment(node: any, comment: any): void;
562
- function addTrailingComment(node: any, comment: any): void;
563
- function getAlignmentSize(
564
- value: string,
565
- tabWidth: number,
566
- startIndex?: number,
567
- ): number;
568
- function getIndentSize(value: string, tabWidth: number): number;
569
- function getMaxContinuousCount(str: string, target: string): number;
570
- function getNextNonSpaceNonCommentCharacterIndex<N>(
571
- text: string,
572
- node: N,
573
- locEnd: (node: N) => number,
574
- ): number | false;
575
- function getStringWidth(text: string): number;
576
- function hasNewline(text: string, index: number, opts?: SkipOptions): boolean;
577
- function hasNewlineInRange(text: string, start: number, end: number): boolean;
578
- function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean;
579
- function isNextLineEmpty<N>(
580
- text: string,
581
- node: N,
582
- locEnd: (node: N) => number,
583
- ): boolean;
584
- function isNextLineEmptyAfterIndex(text: string, index: number): boolean;
585
- function isPreviousLineEmpty<N>(
586
- text: string,
587
- node: N,
588
- locStart: (node: N) => number,
589
- ): boolean;
590
- function makeString(
591
- rawContent: string,
592
- enclosingQuote: Quote,
593
- unescapeUnnecessaryEscapes?: boolean,
594
- ): string;
595
- function skip(
596
- chars: string | RegExp,
597
- ): (
598
- text: string,
599
- index: number | false,
600
- opts?: SkipOptions,
601
- ) => number | false;
602
- function skipEverythingButNewLine(
603
- text: string,
604
- index: number | false,
605
- opts?: SkipOptions,
606
- ): number | false;
607
- function skipInlineComment(
608
- text: string,
609
- index: number | false,
610
- ): number | false;
611
- function skipNewline(
612
- text: string,
613
- index: number | false,
614
- opts?: SkipOptions,
615
- ): number | false;
616
- function skipSpaces(
617
- text: string,
618
- index: number | false,
619
- opts?: SkipOptions,
620
- ): number | false;
621
- function skipToLineEnd(
622
- text: string,
623
- index: number | false,
624
- opts?: SkipOptions,
625
- ): number | false;
626
- function skipTrailingComment(
627
- text: string,
628
- index: number | false,
629
- ): number | false;
630
- function skipWhitespace(
631
- text: string,
632
- index: number | false,
633
- opts?: SkipOptions,
634
- ): number | false;
505
+ interface SkipOptions {
506
+ backwards?: boolean | undefined;
507
+ }
508
+
509
+ type Quote = "'" | '"';
510
+
511
+ function addDanglingComment(node: any, comment: any, marker: any): void;
512
+ function addLeadingComment(node: any, comment: any): void;
513
+ function addTrailingComment(node: any, comment: any): void;
514
+ function getAlignmentSize(value: string, tabWidth: number, startIndex?: number): number;
515
+ function getIndentSize(value: string, tabWidth: number): number;
516
+ function getMaxContinuousCount(str: string, target: string): number;
517
+ function getNextNonSpaceNonCommentCharacterIndex<N>(
518
+ text: string,
519
+ node: N,
520
+ locEnd: (node: N) => number,
521
+ ): number | false;
522
+ function getStringWidth(text: string): number;
523
+ function hasNewline(text: string, index: number, opts?: SkipOptions): boolean;
524
+ function hasNewlineInRange(text: string, start: number, end: number): boolean;
525
+ function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean;
526
+ function isNextLineEmpty<N>(text: string, node: N, locEnd: (node: N) => number): boolean;
527
+ function isNextLineEmptyAfterIndex(text: string, index: number): boolean;
528
+ function isPreviousLineEmpty<N>(text: string, node: N, locStart: (node: N) => number): boolean;
529
+ function makeString(rawContent: string, enclosingQuote: Quote, unescapeUnnecessaryEscapes?: boolean): string;
530
+ function skip(chars: string | RegExp): (text: string, index: number | false, opts?: SkipOptions) => number | false;
531
+ function skipEverythingButNewLine(text: string, index: number | false, opts?: SkipOptions): number | false;
532
+ function skipInlineComment(text: string, index: number | false): number | false;
533
+ function skipNewline(text: string, index: number | false, opts?: SkipOptions): number | false;
534
+ function skipSpaces(text: string, index: number | false, opts?: SkipOptions): number | false;
535
+ function skipToLineEnd(text: string, index: number | false, opts?: SkipOptions): number | false;
536
+ function skipTrailingComment(text: string, index: number | false): number | false;
537
+ function skipWhitespace(text: string, index: number | false, opts?: SkipOptions): number | false;
635
538
  }
636
539
 
637
540
  // https://github.com/prettier/prettier/blob/main/src/document/index.js
638
541
  export namespace doc {
639
- namespace builders {
640
- type DocCommand =
641
- | Align
642
- | BreakParent
643
- | Concat
644
- | Cursor
645
- | Fill
646
- | Group
647
- | IfBreak
648
- | Indent
649
- | IndentIfBreak
650
- | Label
651
- | Line
652
- | LineSuffix
653
- | LineSuffixBoundary
654
- | Trim;
655
- type Doc = string | Doc[] | DocCommand;
656
-
657
- interface Align {
658
- type: 'align';
659
- contents: Doc;
660
- n: number | string | { type: 'root' };
661
- }
662
-
663
- interface BreakParent {
664
- type: 'break-parent';
665
- }
666
-
667
- interface Concat {
668
- type: 'concat';
669
- parts: Doc[];
670
- }
671
-
672
- interface Cursor {
673
- type: 'cursor';
674
- placeholder: symbol;
675
- }
676
-
677
- interface Fill {
678
- type: 'fill';
679
- parts: Doc[];
680
- }
681
-
682
- interface Group {
683
- type: 'group';
684
- contents: Doc;
685
- break: boolean;
686
- expandedStates: Doc[];
687
- }
688
-
689
- interface HardlineWithoutBreakParent extends Line {
690
- hard: true;
691
- }
692
-
693
- interface IfBreak {
694
- type: 'if-break';
695
- breakContents: Doc;
696
- flatContents: Doc;
697
- }
698
-
699
- interface Indent {
700
- type: 'indent';
701
- contents: Doc;
702
- }
703
-
704
- interface IndentIfBreak {
705
- type: 'indent-if-break';
706
- }
707
-
708
- interface Label {
709
- type: 'label';
710
- }
711
-
712
- interface Line {
713
- type: 'line';
714
- soft?: boolean | undefined;
715
- hard?: boolean | undefined;
716
- literal?: boolean | undefined;
542
+ namespace builders {
543
+ type DocCommand =
544
+ | Align
545
+ | BreakParent
546
+ | Concat
547
+ | Cursor
548
+ | Fill
549
+ | Group
550
+ | IfBreak
551
+ | Indent
552
+ | IndentIfBreak
553
+ | Label
554
+ | Line
555
+ | LineSuffix
556
+ | LineSuffixBoundary
557
+ | Trim;
558
+ type Doc = string | Doc[] | DocCommand;
559
+
560
+ interface Align {
561
+ type: 'align';
562
+ contents: Doc;
563
+ n: number | string | { type: 'root' };
564
+ }
565
+
566
+ interface BreakParent {
567
+ type: 'break-parent';
568
+ }
569
+
570
+ interface Concat {
571
+ type: 'concat';
572
+ parts: Doc[];
573
+ }
574
+
575
+ interface Cursor {
576
+ type: 'cursor';
577
+ placeholder: symbol;
578
+ }
579
+
580
+ interface Fill {
581
+ type: 'fill';
582
+ parts: Doc[];
583
+ }
584
+
585
+ interface Group {
586
+ type: 'group';
587
+ contents: Doc;
588
+ break: boolean;
589
+ expandedStates: Doc[];
590
+ }
591
+
592
+ interface HardlineWithoutBreakParent extends Line {
593
+ hard: true;
594
+ }
595
+
596
+ interface IfBreak {
597
+ type: 'if-break';
598
+ breakContents: Doc;
599
+ flatContents: Doc;
600
+ }
601
+
602
+ interface Indent {
603
+ type: 'indent';
604
+ contents: Doc;
605
+ }
606
+
607
+ interface IndentIfBreak {
608
+ type: 'indent-if-break';
609
+ }
610
+
611
+ interface Label {
612
+ type: 'label';
613
+ }
614
+
615
+ interface Line {
616
+ type: 'line';
617
+ soft?: boolean | undefined;
618
+ hard?: boolean | undefined;
619
+ literal?: boolean | undefined;
620
+ }
621
+
622
+ interface LineSuffix {
623
+ type: 'line-suffix';
624
+ contents: Doc;
625
+ }
626
+
627
+ interface LineSuffixBoundary {
628
+ type: 'line-suffix-boundary';
629
+ }
630
+
631
+ interface LiterallineWithoutBreakParent extends Line {
632
+ hard: true;
633
+ literal: true;
634
+ }
635
+
636
+ interface Softline extends Line {
637
+ soft: true;
638
+ }
639
+
640
+ interface Trim {
641
+ type: 'trim';
642
+ }
643
+
644
+ interface GroupOptions {
645
+ shouldBreak?: boolean | undefined;
646
+ id?: symbol | undefined;
647
+ }
648
+
649
+ function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
650
+ /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
651
+ function align(widthOrString: Align['n'], doc: Doc): Align;
652
+ /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
653
+ const breakParent: BreakParent;
654
+ /**
655
+ * @see [concat](https://github.com/prettier/prettier/blob/main/commands.md#deprecated-concat)
656
+ * @deprecated use `Doc[]` instead
657
+ */
658
+ function concat(docs: Doc[]): Concat;
659
+ /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
660
+ function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
661
+ /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
662
+ function dedent(doc: Doc): Align;
663
+ /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
664
+ function dedentToRoot(doc: Doc): Align;
665
+ /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
666
+ function fill(docs: Doc[]): Fill;
667
+ /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
668
+ function group(doc: Doc, opts?: GroupOptions): Group;
669
+ /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
670
+ const hardline: Concat;
671
+ /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
672
+ const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
673
+ /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
674
+ function ifBreak(ifBreak: Doc, noBreak?: Doc, options?: { groupId?: symbol | undefined }): IfBreak;
675
+ /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
676
+ function indent(doc: Doc): Indent;
677
+ /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
678
+ function indentIfBreak(doc: Doc, opts: { groupId: symbol; negate?: boolean | undefined }): IndentIfBreak;
679
+ /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
680
+ function join(sep: Doc, docs: Doc[]): Concat;
681
+ /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
682
+ function label(label: string, doc: Doc): Label;
683
+ /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
684
+ const line: Line;
685
+ /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
686
+ function lineSuffix(suffix: Doc): LineSuffix;
687
+ /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
688
+ const lineSuffixBoundary: LineSuffixBoundary;
689
+ /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
690
+ const literalline: Concat;
691
+ /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
692
+ const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
693
+ /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
694
+ function markAsRoot(doc: Doc): Align;
695
+ /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
696
+ const softline: Softline;
697
+ /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
698
+ const trim: Trim;
699
+ /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
700
+ const cursor: Cursor;
717
701
  }
718
-
719
- interface LineSuffix {
720
- type: 'line-suffix';
721
- contents: Doc;
722
- }
723
-
724
- interface LineSuffixBoundary {
725
- type: 'line-suffix-boundary';
702
+ namespace debug {
703
+ function printDocToDebug(doc: Doc): string;
726
704
  }
727
-
728
- interface LiterallineWithoutBreakParent extends Line {
729
- hard: true;
730
- literal: true;
705
+ namespace printer {
706
+ function printDocToString(
707
+ doc: Doc,
708
+ options: Options,
709
+ ): {
710
+ formatted: string;
711
+ cursorNodeStart?: number | undefined;
712
+ cursorNodeText?: string | undefined;
713
+ };
714
+ interface Options {
715
+ /**
716
+ * Specify the line length that the printer will wrap on.
717
+ * @default 80
718
+ */
719
+ printWidth: number;
720
+ /**
721
+ * Specify the number of spaces per indentation-level.
722
+ * @default 2
723
+ */
724
+ tabWidth: number;
725
+ /**
726
+ * Indent lines with tabs instead of spaces
727
+ * @default false
728
+ */
729
+ useTabs: boolean;
730
+ parentParser?: string | undefined;
731
+ __embeddedInHtml?: boolean | undefined;
732
+ }
731
733
  }
732
-
733
- interface Softline extends Line {
734
- soft: true;
735
- }
736
-
737
- interface Trim {
738
- type: 'trim';
739
- }
740
-
741
- interface GroupOptions {
742
- shouldBreak?: boolean | undefined;
743
- id?: symbol | undefined;
744
- }
745
-
746
- function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
747
- /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
748
- function align(widthOrString: Align['n'], doc: Doc): Align;
749
- /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
750
- const breakParent: BreakParent;
751
- /**
752
- * @see [concat](https://github.com/prettier/prettier/blob/main/commands.md#deprecated-concat)
753
- * @deprecated use `Doc[]` instead
754
- */
755
- function concat(docs: Doc[]): Concat;
756
- /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
757
- function conditionalGroup(
758
- alternatives: Doc[],
759
- options?: GroupOptions,
760
- ): Group;
761
- /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
762
- function dedent(doc: Doc): Align;
763
- /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
764
- function dedentToRoot(doc: Doc): Align;
765
- /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
766
- function fill(docs: Doc[]): Fill;
767
- /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
768
- function group(doc: Doc, opts?: GroupOptions): Group;
769
- /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
770
- const hardline: Concat;
771
- /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
772
- const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
773
- /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
774
- function ifBreak(
775
- ifBreak: Doc,
776
- noBreak?: Doc,
777
- options?: { groupId?: symbol | undefined },
778
- ): IfBreak;
779
- /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
780
- function indent(doc: Doc): Indent;
781
- /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
782
- function indentIfBreak(
783
- doc: Doc,
784
- opts: { groupId: symbol; negate?: boolean | undefined },
785
- ): IndentIfBreak;
786
- /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
787
- function join(sep: Doc, docs: Doc[]): Concat;
788
- /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
789
- function label(label: string, doc: Doc): Label;
790
- /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
791
- const line: Line;
792
- /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
793
- function lineSuffix(suffix: Doc): LineSuffix;
794
- /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
795
- const lineSuffixBoundary: LineSuffixBoundary;
796
- /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
797
- const literalline: Concat;
798
- /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
799
- const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
800
- /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
801
- function markAsRoot(doc: Doc): Align;
802
- /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
803
- const softline: Softline;
804
- /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
805
- const trim: Trim;
806
- /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
807
- const cursor: Cursor;
808
- }
809
- namespace debug {
810
- function printDocToDebug(doc: Doc): string;
811
- }
812
- namespace printer {
813
- function printDocToString(
814
- doc: Doc,
815
- options: Options,
816
- ): {
817
- formatted: string;
818
- cursorNodeStart?: number | undefined;
819
- cursorNodeText?: string | undefined;
820
- };
821
- interface Options {
822
- /**
823
- * Specify the line length that the printer will wrap on.
824
- * @default 80
825
- */
826
- printWidth: number;
827
- /**
828
- * Specify the number of spaces per indentation-level.
829
- * @default 2
830
- */
831
- tabWidth: number;
832
- /**
833
- * Indent lines with tabs instead of spaces
834
- * @default false
835
- */
836
- useTabs: boolean;
837
- parentParser?: string | undefined;
838
- __embeddedInHtml?: boolean | undefined;
734
+ namespace utils {
735
+ function cleanDoc(doc: Doc): Doc;
736
+ function findInDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T, defaultValue: T): T;
737
+ function getDocParts(doc: Doc): Doc;
738
+ function isConcat(doc: Doc): boolean;
739
+ function isEmpty(doc: Doc): boolean;
740
+ function isLineNext(doc: Doc): boolean;
741
+ function mapDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T): T;
742
+ function normalizeDoc(doc: Doc): Doc;
743
+ function normalizeParts(parts: Doc[]): Doc[];
744
+ function propagateBreaks(doc: Doc): void;
745
+ function removeLines(doc: Doc): Doc;
746
+ function replaceNewlinesWithLiterallines(doc: Doc): Doc;
747
+ function stripTrailingHardline(doc: Doc): Doc;
748
+ function traverseDoc(
749
+ doc: Doc,
750
+ onEnter?: (doc: Doc) => void | boolean,
751
+ onExit?: (doc: Doc) => void,
752
+ shouldTraverseConditionalGroups?: boolean,
753
+ ): void;
754
+ function willBreak(doc: Doc): boolean;
839
755
  }
840
- }
841
- namespace utils {
842
- function cleanDoc(doc: Doc): Doc;
843
- function findInDoc<T = Doc>(
844
- doc: Doc,
845
- callback: (doc: Doc) => T,
846
- defaultValue: T,
847
- ): T;
848
- function getDocParts(doc: Doc): Doc;
849
- function isConcat(doc: Doc): boolean;
850
- function isEmpty(doc: Doc): boolean;
851
- function isLineNext(doc: Doc): boolean;
852
- function mapDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T): T;
853
- function normalizeDoc(doc: Doc): Doc;
854
- function normalizeParts(parts: Doc[]): Doc[];
855
- function propagateBreaks(doc: Doc): void;
856
- function removeLines(doc: Doc): Doc;
857
- function replaceNewlinesWithLiterallines(doc: Doc): Doc;
858
- function stripTrailingHardline(doc: Doc): Doc;
859
- function traverseDoc(
860
- doc: Doc,
861
- onEnter?: (doc: Doc) => void | boolean,
862
- onExit?: (doc: Doc) => void,
863
- shouldTraverseConditionalGroups?: boolean,
864
- ): void;
865
- function willBreak(doc: Doc): boolean;
866
- }
867
756
  }