@umijs/utils 3.5.17 → 4.0.0-beta.1

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 (208) hide show
  1. package/README.md +2 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/axios/LICENSE +19 -0
  6. package/compiled/axios/index.d.ts +206 -0
  7. package/compiled/axios/index.js +1 -0
  8. package/compiled/axios/package.json +1 -0
  9. package/compiled/chalk/LICENSE +9 -0
  10. package/compiled/chalk/index.d.ts +415 -0
  11. package/compiled/chalk/index.js +1 -0
  12. package/compiled/chalk/package.json +1 -0
  13. package/compiled/cheerio/LICENSE +21 -0
  14. package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
  15. package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
  16. package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
  17. package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
  18. package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
  19. package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
  20. package/compiled/cheerio/index.js +16 -0
  21. package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
  22. package/compiled/cheerio/lib/api/css.d.ts +41 -0
  23. package/compiled/cheerio/lib/api/forms.d.ts +31 -0
  24. package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
  25. package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
  26. package/compiled/cheerio/lib/cheerio.d.ts +53 -0
  27. package/compiled/cheerio/lib/index.d.ts +91 -0
  28. package/compiled/cheerio/lib/load.d.ts +73 -0
  29. package/compiled/cheerio/lib/options.d.ts +31 -0
  30. package/compiled/cheerio/lib/static.d.ts +88 -0
  31. package/compiled/cheerio/lib/types.d.ts +20 -0
  32. package/compiled/cheerio/package.json +1 -0
  33. package/compiled/color/LICENSE +21 -0
  34. package/compiled/color/color-convert/conversions.d.ts +149 -0
  35. package/compiled/color/color-convert/index.d.ts +113 -0
  36. package/compiled/color/color-convert/route.d.ts +294 -0
  37. package/compiled/color/color-name/index.d.ts +161 -0
  38. package/compiled/color/index.d.ts +142 -0
  39. package/compiled/color/index.js +1 -0
  40. package/compiled/color/package.json +4 -0
  41. package/compiled/cross-spawn/LICENSE +21 -0
  42. package/compiled/cross-spawn/index.d.ts +36 -0
  43. package/compiled/cross-spawn/index.js +1 -0
  44. package/compiled/cross-spawn/package.json +1 -0
  45. package/compiled/debug/LICENSE +19 -0
  46. package/compiled/debug/index.d.ts +54 -0
  47. package/compiled/debug/index.js +1 -0
  48. package/compiled/debug/ms/index.d.ts +25 -0
  49. package/compiled/debug/package.json +1 -0
  50. package/compiled/fs-extra/LICENSE +15 -0
  51. package/compiled/fs-extra/index.d.ts +332 -0
  52. package/compiled/fs-extra/index.js +1 -0
  53. package/compiled/fs-extra/package.json +1 -0
  54. package/compiled/glob/LICENSE +21 -0
  55. package/compiled/glob/index.d.ts +89 -0
  56. package/compiled/glob/index.js +1 -0
  57. package/compiled/glob/minimatch/index.d.ts +204 -0
  58. package/compiled/glob/package.json +1 -0
  59. package/compiled/import-lazy/LICENSE +9 -0
  60. package/compiled/import-lazy/index.d.ts +26 -0
  61. package/compiled/import-lazy/index.js +1 -0
  62. package/compiled/import-lazy/package.json +1 -0
  63. package/compiled/lodash/LICENSE +47 -0
  64. package/compiled/lodash/common/array.d.ts +2126 -0
  65. package/compiled/lodash/common/collection.d.ts +1930 -0
  66. package/compiled/lodash/common/common.d.ts +280 -0
  67. package/compiled/lodash/common/date.d.ts +23 -0
  68. package/compiled/lodash/common/function.d.ts +1430 -0
  69. package/compiled/lodash/common/lang.d.ts +1692 -0
  70. package/compiled/lodash/common/math.d.ts +405 -0
  71. package/compiled/lodash/common/number.d.ts +131 -0
  72. package/compiled/lodash/common/object.d.ts +2519 -0
  73. package/compiled/lodash/common/seq.d.ts +210 -0
  74. package/compiled/lodash/common/string.d.ts +788 -0
  75. package/compiled/lodash/common/util.d.ts +1219 -0
  76. package/compiled/lodash/index.d.ts +46 -0
  77. package/compiled/lodash/index.js +9 -0
  78. package/compiled/lodash/package.json +1 -0
  79. package/compiled/mustache/LICENSE +11 -0
  80. package/compiled/mustache/index.d.ts +437 -0
  81. package/compiled/mustache/index.js +5 -0
  82. package/compiled/mustache/package.json +1 -0
  83. package/compiled/pkg-up/LICENSE +9 -0
  84. package/compiled/pkg-up/index.d.ts +48 -0
  85. package/compiled/pkg-up/index.js +1 -0
  86. package/compiled/pkg-up/package.json +1 -0
  87. package/compiled/portfinder/LICENSE +22 -0
  88. package/compiled/portfinder/index.js +1 -0
  89. package/compiled/portfinder/lib/portfinder.d.ts +47 -0
  90. package/compiled/portfinder/package.json +1 -0
  91. package/compiled/prettier/LICENSE +7 -0
  92. package/compiled/prettier/index.d.ts +867 -0
  93. package/compiled/prettier/index.js +475 -0
  94. package/compiled/prettier/package.json +5 -0
  95. package/compiled/prompts/LICENSE +21 -0
  96. package/compiled/prompts/index.d.ts +120 -0
  97. package/compiled/prompts/index.js +1 -0
  98. package/compiled/prompts/package.json +1 -0
  99. package/compiled/resolve/LICENSE +21 -0
  100. package/compiled/resolve/index.d.ts +166 -0
  101. package/compiled/resolve/index.js +1 -0
  102. package/compiled/resolve/package.json +1 -0
  103. package/compiled/rimraf/LICENSE +15 -0
  104. package/compiled/rimraf/glob/index.d.ts +89 -0
  105. package/compiled/rimraf/index.d.ts +49 -0
  106. package/compiled/rimraf/index.js +1 -0
  107. package/compiled/rimraf/minimatch/index.d.ts +204 -0
  108. package/compiled/rimraf/package.json +1 -0
  109. package/compiled/semver/LICENSE +15 -0
  110. package/compiled/semver/classes/comparator.d.ts +17 -0
  111. package/compiled/semver/classes/range.d.ts +21 -0
  112. package/compiled/semver/classes/semver.d.ts +62 -0
  113. package/compiled/semver/functions/clean.d.ts +8 -0
  114. package/compiled/semver/functions/cmp.d.ts +16 -0
  115. package/compiled/semver/functions/coerce.d.ts +12 -0
  116. package/compiled/semver/functions/compare-build.d.ts +16 -0
  117. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  118. package/compiled/semver/functions/compare.d.ts +20 -0
  119. package/compiled/semver/functions/diff.d.ts +13 -0
  120. package/compiled/semver/functions/eq.d.ts +9 -0
  121. package/compiled/semver/functions/gt.d.ts +9 -0
  122. package/compiled/semver/functions/gte.d.ts +9 -0
  123. package/compiled/semver/functions/inc.d.ts +15 -0
  124. package/compiled/semver/functions/lt.d.ts +9 -0
  125. package/compiled/semver/functions/lte.d.ts +8 -0
  126. package/compiled/semver/functions/major.d.ts +9 -0
  127. package/compiled/semver/functions/minor.d.ts +9 -0
  128. package/compiled/semver/functions/neq.d.ts +9 -0
  129. package/compiled/semver/functions/parse.d.ts +12 -0
  130. package/compiled/semver/functions/patch.d.ts +9 -0
  131. package/compiled/semver/functions/prerelease.d.ts +12 -0
  132. package/compiled/semver/functions/rcompare.d.ts +15 -0
  133. package/compiled/semver/functions/rsort.d.ts +9 -0
  134. package/compiled/semver/functions/satisfies.d.ts +14 -0
  135. package/compiled/semver/functions/sort.d.ts +9 -0
  136. package/compiled/semver/functions/valid.d.ts +11 -0
  137. package/compiled/semver/index.d.ts +133 -0
  138. package/compiled/semver/index.js +1 -0
  139. package/compiled/semver/internals/identifiers.d.ts +13 -0
  140. package/compiled/semver/package.json +1 -0
  141. package/compiled/semver/ranges/gtr.d.ts +14 -0
  142. package/compiled/semver/ranges/intersects.d.ts +13 -0
  143. package/compiled/semver/ranges/ltr.d.ts +14 -0
  144. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  145. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  146. package/compiled/semver/ranges/min-version.d.ts +10 -0
  147. package/compiled/semver/ranges/outside.d.ts +15 -0
  148. package/compiled/semver/ranges/simplify.d.ts +14 -0
  149. package/compiled/semver/ranges/subset.d.ts +13 -0
  150. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  151. package/compiled/semver/ranges/valid.d.ts +12 -0
  152. package/compiled/strip-ansi/LICENSE +9 -0
  153. package/compiled/strip-ansi/index.d.ts +17 -0
  154. package/compiled/strip-ansi/index.js +1 -0
  155. package/compiled/strip-ansi/package.json +1 -0
  156. package/compiled/yargs-parser/index.d.ts +112 -0
  157. package/compiled/yargs-parser/index.js +1 -0
  158. package/compiled/yargs-parser/package.json +1 -0
  159. package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
  160. package/dist/BaseGenerator/BaseGenerator.js +58 -0
  161. package/{lib → dist}/Generator/Generator.d.ts +3 -3
  162. package/dist/Generator/Generator.js +74 -0
  163. package/dist/importLazy.d.ts +6 -0
  164. package/dist/importLazy.js +17 -0
  165. package/dist/index.d.ts +28 -0
  166. package/dist/index.js +79 -0
  167. package/dist/logger.d.ts +14 -0
  168. package/dist/logger.js +39 -0
  169. package/dist/randomColor/randomColor.d.ts +6 -0
  170. package/dist/randomColor/randomColor.js +19 -0
  171. package/dist/register.d.ts +6 -0
  172. package/dist/register.js +47 -0
  173. package/dist/winPath.d.ts +1 -0
  174. package/dist/winPath.js +11 -0
  175. package/package.json +92 -12
  176. package/lib/BabelRegister/BabelRegister.d.ts +0 -9
  177. package/lib/BabelRegister/BabelRegister.js +0 -66
  178. package/lib/Generator/Generator.js +0 -120
  179. package/lib/cheerio/cheerio.d.ts +0 -2
  180. package/lib/cheerio/cheerio.js +0 -37
  181. package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
  182. package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
  183. package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
  184. package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
  185. package/lib/delay/delay.d.ts +0 -1
  186. package/lib/delay/delay.js +0 -22
  187. package/lib/getFile/getFile.d.ts +0 -22
  188. package/lib/getFile/getFile.js +0 -85
  189. package/lib/index.d.ts +0 -66
  190. package/lib/index.js +0 -619
  191. package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
  192. package/lib/isLernaPackage/isLernaPackage.js +0 -42
  193. package/lib/mergeConfig/mergeConfig.d.ts +0 -8
  194. package/lib/mergeConfig/mergeConfig.js +0 -42
  195. package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
  196. package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
  197. package/lib/randomColor/randomColor.d.ts +0 -6
  198. package/lib/randomColor/randomColor.js +0 -42
  199. package/lib/routes.d.ts +0 -11
  200. package/lib/routes.js +0 -53
  201. package/lib/ssr.d.ts +0 -12
  202. package/lib/ssr.js +0 -41
  203. package/lib/types.d.ts +0 -7
  204. package/lib/types.js +0 -17
  205. package/lib/winEOL/winEOL.d.ts +0 -7
  206. package/lib/winEOL/winEOL.js +0 -39
  207. package/lib/winPath/winPath.d.ts +0 -1
  208. package/lib/winPath/winPath.js +0 -28
@@ -0,0 +1,867 @@
1
+ // Type definitions for prettier 2.4
2
+ // Project: https://github.com/prettier/prettier, https://prettier.io
3
+ // Definitions by: Ika <https://github.com/ikatyang>,
4
+ // Ifiok Jr. <https://github.com/ifiokjr>,
5
+ // Florian Imdahl <https://github.com/ffflorian>,
6
+ // Sosuke Suzuki <https://github.com/sosukesuzuki>,
7
+ // Christopher Quadflieg <https://github.com/Shinigami92>
8
+ // Kevin Deisz <https://github.com/kddeisz>
9
+ // Georgii Dolzhykov <https://github.com/thorn0>
10
+ // JounQin <https://github.com/JounQin>
11
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12
+ // TypeScript Version: 3.7
13
+
14
+ // This utility is here to handle the case where you have an explicit union
15
+ // between string literals and the generic string type. It would normally
16
+ // resolve out to just the string type, but this generic LiteralUnion maintains
17
+ // the intellisense of the original union.
18
+ //
19
+ // It comes from this issue: microsoft/TypeScript#29729:
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 });
24
+
25
+ export type AST = any;
26
+ export type Doc = doc.builders.Doc;
27
+
28
+ // https://github.com/prettier/prettier/blob/main/src/common/ast-path.js
29
+
30
+ 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;
52
+ }
53
+
54
+ /** @deprecated `FastPath` was renamed to `AstPath` */
55
+ export type FastPath<T = any> = AstPath<T>;
56
+
57
+ export type BuiltInParser = (text: string, options?: any) => AST;
58
+ 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';
81
+ export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
82
+
83
+ export type CustomParser = (
84
+ text: string,
85
+ parsers: BuiltInParsers,
86
+ options: Options,
87
+ ) => AST;
88
+
89
+ export interface Options extends Partial<RequiredOptions> {}
90
+ 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';
204
+ }
205
+
206
+ export interface ParserOptions<T = any> extends RequiredOptions {
207
+ locStart: (node: T) => number;
208
+ locEnd: (node: T) => number;
209
+ originalText: string;
210
+ }
211
+
212
+ 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;
218
+ }
219
+
220
+ 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;
233
+ }
234
+
235
+ 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,
286
+ options: ParserOptions<T>,
287
+ ast: T,
288
+ isLastComment: boolean,
289
+ ) => boolean)
290
+ | undefined;
291
+ }
292
+ | undefined;
293
+ }
294
+
295
+ export interface CursorOptions extends Options {
296
+ /**
297
+ * Specify where the cursor is.
298
+ */
299
+ cursorOffset: number;
300
+ rangeStart?: never;
301
+ rangeEnd?: never;
302
+ }
303
+
304
+ export interface CursorResult {
305
+ formatted: string;
306
+ cursorOffset: number;
307
+ }
308
+
309
+ /**
310
+ * `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
311
+ */
312
+ export function format(source: string, options?: Options): string;
313
+
314
+ /**
315
+ * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
316
+ * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
317
+ */
318
+ export function check(source: string, options?: Options): boolean;
319
+
320
+ /**
321
+ * `formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code.
322
+ * This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
323
+ *
324
+ * The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`.
325
+ */
326
+ export function formatWithCursor(
327
+ source: string,
328
+ options: CursorOptions,
329
+ ): CursorResult;
330
+
331
+ 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;
350
+ }
351
+
352
+ /**
353
+ * `resolveConfig` can be used to resolve configuration for a given source file,
354
+ * passing its path as the first argument. The config search will start at the
355
+ * file path and continue to search up the directory.
356
+ * (You can use `process.cwd()` to start searching from the current directory).
357
+ *
358
+ * A promise is returned which will resolve to:
359
+ *
360
+ * - An options object, providing a [config file](https://prettier.io/docs/en/configuration.html) was found.
361
+ * - `null`, if no file was found.
362
+ *
363
+ * The promise will be rejected if there was an error parsing the configuration file.
364
+ */
365
+ export function resolveConfig(
366
+ filePath: string,
367
+ options?: ResolveConfigOptions,
368
+ ): Promise<Options | null>;
369
+ export namespace resolveConfig {
370
+ function sync(
371
+ filePath: string,
372
+ options?: ResolveConfigOptions,
373
+ ): Options | null;
374
+ }
375
+
376
+ /**
377
+ * `resolveConfigFile` can be used to find the path of the Prettier configuration file,
378
+ * that will be used when resolving the config (i.e. when calling `resolveConfig`).
379
+ *
380
+ * A promise is returned which will resolve to:
381
+ *
382
+ * - The path of the configuration file.
383
+ * - `null`, if no file was found.
384
+ *
385
+ * The promise will be rejected if there was an error parsing the configuration file.
386
+ */
387
+ export function resolveConfigFile(filePath?: string): Promise<string | null>;
388
+ export namespace resolveConfigFile {
389
+ function sync(filePath?: string): string | null;
390
+ }
391
+
392
+ /**
393
+ * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache.
394
+ * Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
395
+ */
396
+ export function clearConfigCache(): void;
397
+
398
+ 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;
412
+ }
413
+
414
+ export interface SupportOptionRange {
415
+ start: number;
416
+ end: number;
417
+ step: number;
418
+ }
419
+
420
+ export type SupportOptionType = 'int' | 'boolean' | 'choice' | 'path';
421
+
422
+ export type CoreCategoryType =
423
+ | 'Config'
424
+ | 'Editor'
425
+ | 'Format'
426
+ | 'Other'
427
+ | 'Output'
428
+ | 'Global'
429
+ | 'Special';
430
+
431
+ 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;
458
+ }
459
+
460
+ export interface IntSupportOption extends BaseSupportOption<'int'> {
461
+ default?: number | undefined;
462
+ array?: false | undefined;
463
+ range?: SupportOptionRange | undefined;
464
+ }
465
+
466
+ export interface IntArraySupportOption extends BaseSupportOption<'int'> {
467
+ default?: Array<{ value: number[] }> | undefined;
468
+ array: true;
469
+ }
470
+
471
+ export interface BooleanSupportOption extends BaseSupportOption<'boolean'> {
472
+ default?: boolean | undefined;
473
+ array?: false | undefined;
474
+ description: string;
475
+ oppositeDescription?: string | undefined;
476
+ }
477
+
478
+ export interface BooleanArraySupportOption
479
+ extends BaseSupportOption<'boolean'> {
480
+ default?: Array<{ value: boolean[] }> | undefined;
481
+ array: true;
482
+ }
483
+
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;
491
+ description: string;
492
+ }>;
493
+ }
494
+
495
+ export interface PathSupportOption extends BaseSupportOption<'path'> {
496
+ default?: string | undefined;
497
+ array?: false | undefined;
498
+ }
499
+
500
+ export interface PathArraySupportOption extends BaseSupportOption<'path'> {
501
+ default?: Array<{ value: string[] }> | undefined;
502
+ array: true;
503
+ }
504
+
505
+ export type SupportOption =
506
+ | IntSupportOption
507
+ | IntArraySupportOption
508
+ | BooleanSupportOption
509
+ | BooleanArraySupportOption
510
+ | ChoiceSupportOption
511
+ | PathSupportOption
512
+ | PathArraySupportOption;
513
+
514
+ export interface SupportOptions extends Record<string, SupportOption> {}
515
+
516
+ export interface SupportInfo {
517
+ languages: SupportLanguage[];
518
+ options: SupportOption[];
519
+ }
520
+
521
+ export interface FileInfoOptions {
522
+ ignorePath?: string | undefined;
523
+ withNodeModules?: boolean | undefined;
524
+ plugins?: string[] | undefined;
525
+ resolveConfig?: boolean | undefined;
526
+ }
527
+
528
+ export interface FileInfoResult {
529
+ ignored: boolean;
530
+ inferredParser: string | null;
531
+ }
532
+
533
+ export function getFileInfo(
534
+ filePath: string,
535
+ options?: FileInfoOptions,
536
+ ): Promise<FileInfoResult>;
537
+
538
+ export namespace getFileInfo {
539
+ function sync(filePath: string, options?: FileInfoOptions): FileInfoResult;
540
+ }
541
+
542
+ /**
543
+ * Returns an object representing the parsers, languages and file types Prettier supports for the current version.
544
+ */
545
+ export function getSupportInfo(): SupportInfo;
546
+
547
+ /**
548
+ * `version` field in `package.json`
549
+ */
550
+ export const version: string;
551
+
552
+ // https://github.com/prettier/prettier/blob/main/src/common/util-shared.js
553
+ 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;
635
+ }
636
+
637
+ // https://github.com/prettier/prettier/blob/main/src/document/index.js
638
+ 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;
717
+ }
718
+
719
+ interface LineSuffix {
720
+ type: 'line-suffix';
721
+ contents: Doc;
722
+ }
723
+
724
+ interface LineSuffixBoundary {
725
+ type: 'line-suffix-boundary';
726
+ }
727
+
728
+ interface LiterallineWithoutBreakParent extends Line {
729
+ hard: true;
730
+ literal: true;
731
+ }
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;
839
+ }
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
+ }