@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.
- package/compiled/axios/index.d.ts +29 -14
- package/compiled/axios/index.js +1 -1
- package/compiled/chalk/LICENSE +1 -1
- package/compiled/chalk/index.js +1 -1
- package/compiled/chalk/package.json +1 -1
- package/compiled/chalk/source/index.d.ts +318 -0
- package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/compiled/color/color-convert/conversions.d.ts +87 -87
- package/compiled/color/color-convert/index.d.ts +75 -60
- package/compiled/color/color-convert/route.d.ts +271 -271
- package/compiled/color/index.d.ts +118 -121
- package/compiled/color/index.js +1 -1
- package/compiled/color/package.json +1 -4
- package/compiled/debug/LICENSE +10 -9
- package/compiled/debug/index.js +1 -1
- package/compiled/debug/package.json +1 -1
- package/compiled/execa/index.d.ts +467 -445
- package/compiled/execa/index.js +1 -1
- package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/globby/LICENSE +9 -0
- package/compiled/globby/fast-glob/out/index.d.ts +27 -0
- package/compiled/globby/fast-glob/out/managers/tasks.d.ts +22 -0
- package/compiled/globby/fast-glob/out/settings.d.ts +164 -0
- package/compiled/globby/fast-glob/out/types/index.d.ts +31 -0
- package/compiled/globby/index.d.ts +206 -0
- package/compiled/globby/index.js +37 -0
- package/compiled/globby/package.json +1 -0
- package/compiled/pirates/LICENSE +21 -0
- package/compiled/pirates/index.d.ts +82 -0
- package/compiled/pirates/index.js +1 -0
- package/compiled/pirates/package.json +1 -0
- package/compiled/pkg-up/LICENSE +1 -1
- package/compiled/pkg-up/index.d.ts +55 -44
- package/compiled/pkg-up/index.js +1 -1
- package/compiled/pkg-up/package.json +1 -1
- package/compiled/prettier/index.d.ts +568 -679
- package/compiled/prettier/index.js +62 -274
- package/compiled/prettier/package.json +1 -5
- package/compiled/resolve/index.js +1 -1
- package/compiled/strip-ansi/LICENSE +1 -1
- package/compiled/strip-ansi/index.d.ts +2 -4
- package/compiled/strip-ansi/index.js +1 -1
- package/compiled/strip-ansi/package.json +1 -1
- package/compiled/yargs-parser/index.js +1 -1
- package/dist/getCorejsVersion.d.ts +1 -0
- package/dist/getCorejsVersion.js +11 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6 -5
- package/dist/installDeps.js +20 -4
- package/dist/isStyleFile.d.ts +5 -0
- package/dist/isStyleFile.js +16 -0
- package/dist/logger.d.ts +8 -6
- package/dist/logger.js +8 -1
- package/dist/register.js +22 -22
- package/dist/tryPaths.d.ts +1 -0
- package/dist/tryPaths.js +11 -0
- 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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
callback: (path: this, index: number, value: any) =>
|
|
41
|
-
...
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
306
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
-
|
|
468
|
-
|
|
423
|
+
default?: Array<{ value: number[] }> | undefined;
|
|
424
|
+
array: true;
|
|
469
425
|
}
|
|
470
426
|
|
|
471
427
|
export interface BooleanSupportOption extends BaseSupportOption<'boolean'> {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
428
|
+
default?: boolean | undefined;
|
|
429
|
+
array?: false | undefined;
|
|
430
|
+
description: string;
|
|
431
|
+
oppositeDescription?: string | undefined;
|
|
476
432
|
}
|
|
477
433
|
|
|
478
|
-
export interface BooleanArraySupportOption
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
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
|
-
|
|
497
|
-
|
|
450
|
+
default?: string | undefined;
|
|
451
|
+
array?: false | undefined;
|
|
498
452
|
}
|
|
499
453
|
|
|
500
454
|
export interface PathArraySupportOption extends BaseSupportOption<'path'> {
|
|
501
|
-
|
|
502
|
-
|
|
455
|
+
default?: Array<{ value: string[] }> | undefined;
|
|
456
|
+
array: true;
|
|
503
457
|
}
|
|
504
458
|
|
|
505
459
|
export type SupportOption =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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
|
-
|
|
518
|
-
|
|
471
|
+
languages: SupportLanguage[];
|
|
472
|
+
options: SupportOption[];
|
|
519
473
|
}
|
|
520
474
|
|
|
521
475
|
export interface FileInfoOptions {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
|
|
530
|
-
|
|
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
|
-
|
|
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
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
value: string,
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
text: string
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
text: string,
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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
|
-
|
|
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
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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
|
}
|