1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export {};
|
10 |
|
11 | import { builders, printer, utils } from "./doc.js";
|
12 |
|
13 | export namespace doc {
|
14 | export { builders, printer, utils };
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export type LiteralUnion<T extends U, U = string> =
|
25 | | T
|
26 | | (Pick<U, never> & { _?: never | undefined });
|
27 |
|
28 | export type AST = any;
|
29 | export type Doc = doc.builders.Doc;
|
30 |
|
31 |
|
32 | type ArrayElement<T> = T extends Array<infer E> ? E : never;
|
33 |
|
34 |
|
35 | type ArrayProperties<T> = {
|
36 | [K in keyof T]: NonNullable<T[K]> extends any[] ? K : never;
|
37 | }[keyof T];
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | type IndexProperties<T extends { length: number }> = IsTuple<T> extends true
|
43 | ? Exclude<Partial<T>["length"], T["length"]>
|
44 | : number;
|
45 |
|
46 |
|
47 |
|
48 | type IndexValue<T, P> = T extends any[]
|
49 | ? P extends number
|
50 | ? T[P]
|
51 | : never
|
52 | : P extends keyof T
|
53 | ? T[P]
|
54 | : never;
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | type IsTuple<T> = T extends []
|
61 | ? true
|
62 | : T extends [infer First, ...infer Remain]
|
63 | ? IsTuple<Remain>
|
64 | : false;
|
65 |
|
66 | type CallProperties<T> = T extends any[] ? IndexProperties<T> : keyof T;
|
67 | type IterProperties<T> = T extends any[]
|
68 | ? IndexProperties<T>
|
69 | : ArrayProperties<T>;
|
70 |
|
71 | type CallCallback<T, U> = (path: AstPath<T>, index: number, value: any) => U;
|
72 | type EachCallback<T> = (
|
73 | path: AstPath<ArrayElement<T>>,
|
74 | index: number,
|
75 | value: any
|
76 | ) => void;
|
77 | type MapCallback<T, U> = (
|
78 | path: AstPath<ArrayElement<T>>,
|
79 | index: number,
|
80 | value: any
|
81 | ) => U;
|
82 |
|
83 |
|
84 | export class AstPath<T = any> {
|
85 | constructor(value: T);
|
86 |
|
87 | get key(): string | null;
|
88 | get index(): number | null;
|
89 | get node(): T;
|
90 | get parent(): T | null;
|
91 | get grandparent(): T | null;
|
92 | get isInArray(): boolean;
|
93 | get siblings(): T[] | null;
|
94 | get next(): T | null;
|
95 | get previous(): T | null;
|
96 | get isFirst(): boolean;
|
97 | get isLast(): boolean;
|
98 | get isRoot(): boolean;
|
99 | get root(): T;
|
100 | get ancestors(): T[];
|
101 |
|
102 | stack: T[];
|
103 |
|
104 | callParent<U>(callback: (path: this) => U, count?: number): U;
|
105 |
|
106 | /**
|
107 | * @deprecated Please use `AstPath#key` or `AstPath#index`
|
108 | */
|
109 | getName(): PropertyKey | null;
|
110 |
|
111 | /**
|
112 | * @deprecated Please use `AstPath#node` or `AstPath#siblings`
|
113 | */
|
114 | getValue(): T;
|
115 |
|
116 | getNode(count?: number): T | null;
|
117 |
|
118 | getParentNode(count?: number): T | null;
|
119 |
|
120 | match(
|
121 | ...predicates: Array<
|
122 | (node: any, name: string | null, number: number | null) => boolean
|
123 | >
|
124 | ): boolean;
|
125 |
|
126 | // For each of the tree walk functions (call, each, and map) this provides 5
|
127 | // strict type signatures, along with a fallback at the end if you end up
|
128 | // calling more than 5 properties deep. This helps a lot with typing because
|
129 | // for the majority of cases you're calling fewer than 5 properties, so the
|
130 | // tree walk functions have a clearer understanding of what you're doing.
|
131 | //
|
132 | // Note that resolving these types is somewhat complicated, and it wasn't
|
133 | // even supported until TypeScript 4.2 (before it would just say that the
|
134 |
|
135 |
|
136 | call<U>(callback: CallCallback<T, U>): U;
|
137 | call<U, P1 extends CallProperties<T>>(
|
138 | callback: CallCallback<IndexValue<T, P1>, U>,
|
139 | prop1: P1
|
140 | ): U;
|
141 | call<U, P1 extends keyof T, P2 extends CallProperties<T[P1]>>(
|
142 | callback: CallCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
143 | prop1: P1,
|
144 | prop2: P2
|
145 | ): U;
|
146 | call<
|
147 | U,
|
148 | P1 extends keyof T,
|
149 | P2 extends CallProperties<T[P1]>,
|
150 | P3 extends CallProperties<IndexValue<T[P1], P2>>
|
151 | >(
|
152 | callback: CallCallback<
|
153 | IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
|
154 | U
|
155 | >,
|
156 | prop1: P1,
|
157 | prop2: P2,
|
158 | prop3: P3
|
159 | ): U;
|
160 | call<
|
161 | U,
|
162 | P1 extends keyof T,
|
163 | P2 extends CallProperties<T[P1]>,
|
164 | P3 extends CallProperties<IndexValue<T[P1], P2>>,
|
165 | P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
|
166 | >(
|
167 | callback: CallCallback<
|
168 | IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
169 | U
|
170 | >,
|
171 | prop1: P1,
|
172 | prop2: P2,
|
173 | prop3: P3,
|
174 | prop4: P4
|
175 | ): U;
|
176 | call<U, P extends PropertyKey>(
|
177 | callback: CallCallback<any, U>,
|
178 | prop1: P,
|
179 | prop2: P,
|
180 | prop3: P,
|
181 | prop4: P,
|
182 | ...props: P[]
|
183 | ): U;
|
184 |
|
185 | each(callback: EachCallback<T>): void;
|
186 | each<P1 extends IterProperties<T>>(
|
187 | callback: EachCallback<IndexValue<T, P1>>,
|
188 | prop1: P1
|
189 | ): void;
|
190 | each<P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
191 | callback: EachCallback<IndexValue<IndexValue<T, P1>, P2>>,
|
192 | prop1: P1,
|
193 | prop2: P2
|
194 | ): void;
|
195 | each<
|
196 | P1 extends keyof T,
|
197 | P2 extends IterProperties<T[P1]>,
|
198 | P3 extends IterProperties<IndexValue<T[P1], P2>>
|
199 | >(
|
200 | callback: EachCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>>,
|
201 | prop1: P1,
|
202 | prop2: P2,
|
203 | prop3: P3
|
204 | ): void;
|
205 | each<
|
206 | P1 extends keyof T,
|
207 | P2 extends IterProperties<T[P1]>,
|
208 | P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
209 | P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
|
210 | >(
|
211 | callback: EachCallback<
|
212 | IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>
|
213 | >,
|
214 | prop1: P1,
|
215 | prop2: P2,
|
216 | prop3: P3,
|
217 | prop4: P4
|
218 | ): void;
|
219 | each(
|
220 | callback: EachCallback<any[]>,
|
221 | prop1: PropertyKey,
|
222 | prop2: PropertyKey,
|
223 | prop3: PropertyKey,
|
224 | prop4: PropertyKey,
|
225 | ...props: PropertyKey[]
|
226 | ): void;
|
227 |
|
228 | map<U>(callback: MapCallback<T, U>): U[];
|
229 | map<U, P1 extends IterProperties<T>>(
|
230 | callback: MapCallback<IndexValue<T, P1>, U>,
|
231 | prop1: P1
|
232 | ): U[];
|
233 | map<U, P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
234 | callback: MapCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
235 | prop1: P1,
|
236 | prop2: P2
|
237 | ): U[];
|
238 | map<
|
239 | U,
|
240 | P1 extends keyof T,
|
241 | P2 extends IterProperties<T[P1]>,
|
242 | P3 extends IterProperties<IndexValue<T[P1], P2>>
|
243 | >(
|
244 | callback: MapCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, U>,
|
245 | prop1: P1,
|
246 | prop2: P2,
|
247 | prop3: P3
|
248 | ): U[];
|
249 | map<
|
250 | U,
|
251 | P1 extends keyof T,
|
252 | P2 extends IterProperties<T[P1]>,
|
253 | P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
254 | P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
|
255 | >(
|
256 | callback: MapCallback<
|
257 | IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
258 | U
|
259 | >,
|
260 | prop1: P1,
|
261 | prop2: P2,
|
262 | prop3: P3,
|
263 | prop4: P4
|
264 | ): U[];
|
265 | map<U>(
|
266 | callback: MapCallback<any[], U>,
|
267 | prop1: PropertyKey,
|
268 | prop2: PropertyKey,
|
269 | prop3: PropertyKey,
|
270 | prop4: PropertyKey,
|
271 | ...props: PropertyKey[]
|
272 | ): U[];
|
273 | }
|
274 |
|
275 |
|
276 | export type FastPath<T = any> = AstPath<T>;
|
277 |
|
278 | export type BuiltInParser = (text: string, options?: any) => AST;
|
279 | export type BuiltInParserName =
|
280 | | "acorn"
|
281 | | "angular"
|
282 | | "babel-flow"
|
283 | | "babel-ts"
|
284 | | "babel"
|
285 | | "css"
|
286 | | "espree"
|
287 | | "flow"
|
288 | | "glimmer"
|
289 | | "graphql"
|
290 | | "html"
|
291 | | "json-stringify"
|
292 | | "json"
|
293 | | "json5"
|
294 | | "less"
|
295 | | "lwc"
|
296 | | "markdown"
|
297 | | "mdx"
|
298 | | "meriyah"
|
299 | | "scss"
|
300 | | "typescript"
|
301 | | "vue"
|
302 | | "yaml";
|
303 | export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
|
304 |
|
305 | export type CustomParser = (
|
306 | text: string,
|
307 | options: Options
|
308 | ) => AST | Promise<AST>;
|
309 |
|
310 |
|
311 |
|
312 |
|
313 | export interface Config extends Options {
|
314 | overrides?: Array<{
|
315 | files: string | string[];
|
316 | excludeFiles?: string | string[];
|
317 | options?: Options;
|
318 | }>;
|
319 | }
|
320 |
|
321 | export interface Options extends Partial<RequiredOptions> {}
|
322 |
|
323 | export interface RequiredOptions extends doc.printer.Options {
|
324 | |
325 |
|
326 |
|
327 |
|
328 | semi: boolean;
|
329 | |
330 |
|
331 |
|
332 |
|
333 | singleQuote: boolean;
|
334 | |
335 |
|
336 |
|
337 |
|
338 | jsxSingleQuote: boolean;
|
339 | |
340 |
|
341 |
|
342 |
|
343 | trailingComma: "none" | "es5" | "all";
|
344 | |
345 |
|
346 |
|
347 |
|
348 | bracketSpacing: boolean;
|
349 | |
350 |
|
351 |
|
352 |
|
353 |
|
354 | bracketSameLine: boolean;
|
355 | |
356 |
|
357 |
|
358 |
|
359 |
|
360 | jsxBracketSameLine: boolean;
|
361 | |
362 |
|
363 |
|
364 |
|
365 | rangeStart: number;
|
366 | |
367 |
|
368 |
|
369 |
|
370 | rangeEnd: number;
|
371 | |
372 |
|
373 |
|
374 | parser: LiteralUnion<BuiltInParserName> | CustomParser;
|
375 | |
376 |
|
377 |
|
378 | filepath: string;
|
379 | |
380 |
|
381 |
|
382 |
|
383 |
|
384 | requirePragma: boolean;
|
385 | |
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | insertPragma: boolean;
|
393 | |
394 |
|
395 |
|
396 |
|
397 |
|
398 | proseWrap: "always" | "never" | "preserve";
|
399 | |
400 |
|
401 |
|
402 |
|
403 | arrowParens: "avoid" | "always";
|
404 | |
405 |
|
406 |
|
407 | plugins: Array<string | Plugin>;
|
408 | |
409 |
|
410 |
|
411 |
|
412 | htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
|
413 | |
414 |
|
415 |
|
416 |
|
417 | endOfLine: "auto" | "lf" | "crlf" | "cr";
|
418 | |
419 |
|
420 |
|
421 |
|
422 | quoteProps: "as-needed" | "consistent" | "preserve";
|
423 | |
424 |
|
425 |
|
426 |
|
427 | vueIndentScriptAndStyle: boolean;
|
428 | |
429 |
|
430 |
|
431 |
|
432 | embeddedLanguageFormatting: "auto" | "off";
|
433 | |
434 |
|
435 |
|
436 |
|
437 | singleAttributePerLine: boolean;
|
438 | }
|
439 |
|
440 | export interface ParserOptions<T = any> extends RequiredOptions {
|
441 | locStart: (node: T) => number;
|
442 | locEnd: (node: T) => number;
|
443 | originalText: string;
|
444 | }
|
445 |
|
446 | export interface Plugin<T = any> {
|
447 | languages?: SupportLanguage[] | undefined;
|
448 | parsers?: { [parserName: string]: Parser<T> } | undefined;
|
449 | printers?: { [astFormat: string]: Printer<T> } | undefined;
|
450 | options?: SupportOptions | undefined;
|
451 | defaultOptions?: Partial<RequiredOptions> | undefined;
|
452 | }
|
453 |
|
454 | export interface Parser<T = any> {
|
455 | parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;
|
456 | astFormat: string;
|
457 | hasPragma?: ((text: string) => boolean) | undefined;
|
458 | locStart: (node: T) => number;
|
459 | locEnd: (node: T) => number;
|
460 | preprocess?:
|
461 | | ((text: string, options: ParserOptions<T>) => string)
|
462 | | undefined;
|
463 | }
|
464 |
|
465 | export interface Printer<T = any> {
|
466 | print(
|
467 | path: AstPath<T>,
|
468 | options: ParserOptions<T>,
|
469 | print: (path: AstPath<T>) => Doc,
|
470 | args?: unknown
|
471 | ): Doc;
|
472 | embed?:
|
473 | | ((
|
474 | path: AstPath,
|
475 | options: Options
|
476 | ) =>
|
477 | | ((
|
478 | textToDoc: (text: string, options: Options) => Promise<Doc>,
|
479 | print: (
|
480 | selector?: string | number | Array<string | number> | AstPath
|
481 | ) => Doc,
|
482 | path: AstPath,
|
483 | options: Options
|
484 | ) => Promise<Doc | undefined> | Doc | undefined)
|
485 | | Doc
|
486 | | null)
|
487 | | undefined;
|
488 | insertPragma?: (text: string) => string;
|
489 | |
490 |
|
491 |
|
492 |
|
493 |
|
494 | massageAstNode?: ((node: any, newNode: any, parent: any) => any) | undefined;
|
495 | hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
|
496 | canAttachComment?: ((node: T) => boolean) | undefined;
|
497 | isBlockComment?: ((node: T) => boolean) | undefined;
|
498 | willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
|
499 | printComment?:
|
500 | | ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
|
501 | | undefined;
|
502 | |
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 | getCommentChildNodes?:
|
510 | | ((node: T, options: ParserOptions<T>) => T[] | undefined)
|
511 | | undefined;
|
512 | handleComments?:
|
513 | | {
|
514 | ownLine?:
|
515 | | ((
|
516 | commentNode: any,
|
517 | text: string,
|
518 | options: ParserOptions<T>,
|
519 | ast: T,
|
520 | isLastComment: boolean
|
521 | ) => boolean)
|
522 | | undefined;
|
523 | endOfLine?:
|
524 | | ((
|
525 | commentNode: any,
|
526 | text: string,
|
527 | options: ParserOptions<T>,
|
528 | ast: T,
|
529 | isLastComment: boolean
|
530 | ) => boolean)
|
531 | | undefined;
|
532 | remaining?:
|
533 | | ((
|
534 | commentNode: any,
|
535 | text: string,
|
536 | options: ParserOptions<T>,
|
537 | ast: T,
|
538 | isLastComment: boolean
|
539 | ) => boolean)
|
540 | | undefined;
|
541 | }
|
542 | | undefined;
|
543 | }
|
544 |
|
545 | export interface CursorOptions extends Options {
|
546 | |
547 |
|
548 |
|
549 | cursorOffset: number;
|
550 | rangeStart?: never;
|
551 | rangeEnd?: never;
|
552 | }
|
553 |
|
554 | export interface CursorResult {
|
555 | formatted: string;
|
556 | cursorOffset: number;
|
557 | }
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | export function format(source: string, options?: Options): Promise<string>;
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 | export function check(source: string, options?: Options): Promise<boolean>;
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 | export function formatWithCursor(
|
577 | source: string,
|
578 | options: CursorOptions
|
579 | ): Promise<CursorResult>;
|
580 |
|
581 | export function formatAST(ast: any, options?: Options): Promise<string>;
|
582 |
|
583 | export interface ResolveConfigOptions {
|
584 | |
585 |
|
586 |
|
587 | useCache?: boolean | undefined;
|
588 | |
589 |
|
590 |
|
591 | config?: string | undefined;
|
592 | |
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | editorconfig?: boolean | undefined;
|
602 | }
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 | export function resolveConfig(
|
618 | filePath: string,
|
619 | options?: ResolveConfigOptions
|
620 | ): Promise<Options | null>;
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 | export function resolveConfigFile(filePath?: string): Promise<string | null>;
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 | export function clearConfigCache(): Promise<void>;
|
640 |
|
641 | export interface SupportLanguage {
|
642 | name: string;
|
643 | since?: string | undefined;
|
644 | parsers: BuiltInParserName[] | string[];
|
645 | group?: string | undefined;
|
646 | tmScope?: string | undefined;
|
647 | aceMode?: string | undefined;
|
648 | codemirrorMode?: string | undefined;
|
649 | codemirrorMimeType?: string | undefined;
|
650 | aliases?: string[] | undefined;
|
651 | extensions?: string[] | undefined;
|
652 | filenames?: string[] | undefined;
|
653 | linguistLanguageId?: number | undefined;
|
654 | vscodeLanguageIds?: string[] | undefined;
|
655 | interpreters?: string[] | undefined;
|
656 | }
|
657 |
|
658 | export interface SupportOptionRange {
|
659 | start: number;
|
660 | end: number;
|
661 | step: number;
|
662 | }
|
663 |
|
664 | export type SupportOptionType =
|
665 | | "int"
|
666 | | "string"
|
667 | | "boolean"
|
668 | | "choice"
|
669 | | "path";
|
670 |
|
671 | export type CoreCategoryType =
|
672 | | "Config"
|
673 | | "Editor"
|
674 | | "Format"
|
675 | | "Other"
|
676 | | "Output"
|
677 | | "Global"
|
678 | | "Special";
|
679 |
|
680 | export interface BaseSupportOption<Type extends SupportOptionType> {
|
681 | readonly name?: string | undefined;
|
682 | |
683 |
|
684 |
|
685 | category: string;
|
686 | |
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | type: Type;
|
694 | |
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 | deprecated?: true | string | undefined;
|
701 | |
702 |
|
703 |
|
704 |
|
705 | description?: string | undefined;
|
706 | }
|
707 |
|
708 | export interface IntSupportOption extends BaseSupportOption<"int"> {
|
709 | default?: number | undefined;
|
710 | array?: false | undefined;
|
711 | range?: SupportOptionRange | undefined;
|
712 | }
|
713 |
|
714 | export interface IntArraySupportOption extends BaseSupportOption<"int"> {
|
715 | default?: Array<{ value: number[] }> | undefined;
|
716 | array: true;
|
717 | }
|
718 |
|
719 | export interface StringSupportOption extends BaseSupportOption<"string"> {
|
720 | default?: string | undefined;
|
721 | array?: false | undefined;
|
722 | }
|
723 |
|
724 | export interface StringArraySupportOption extends BaseSupportOption<"string"> {
|
725 | default?: Array<{ value: string[] }> | undefined;
|
726 | array: true;
|
727 | }
|
728 |
|
729 | export interface BooleanSupportOption extends BaseSupportOption<"boolean"> {
|
730 | default?: boolean | undefined;
|
731 | array?: false | undefined;
|
732 | description: string;
|
733 | oppositeDescription?: string | undefined;
|
734 | }
|
735 |
|
736 | export interface BooleanArraySupportOption
|
737 | extends BaseSupportOption<"boolean"> {
|
738 | default?: Array<{ value: boolean[] }> | undefined;
|
739 | array: true;
|
740 | }
|
741 |
|
742 | export interface ChoiceSupportOption<Value = any>
|
743 | extends BaseSupportOption<"choice"> {
|
744 | default?: Value | Array<{ value: Value }> | undefined;
|
745 | description: string;
|
746 | choices: Array<{
|
747 | since?: string | undefined;
|
748 | value: Value;
|
749 | description: string;
|
750 | }>;
|
751 | }
|
752 |
|
753 | export interface PathSupportOption extends BaseSupportOption<"path"> {
|
754 | default?: string | undefined;
|
755 | array?: false | undefined;
|
756 | }
|
757 |
|
758 | export interface PathArraySupportOption extends BaseSupportOption<"path"> {
|
759 | default?: Array<{ value: string[] }> | undefined;
|
760 | array: true;
|
761 | }
|
762 |
|
763 | export type SupportOption =
|
764 | | IntSupportOption
|
765 | | IntArraySupportOption
|
766 | | StringSupportOption
|
767 | | StringArraySupportOption
|
768 | | BooleanSupportOption
|
769 | | BooleanArraySupportOption
|
770 | | ChoiceSupportOption
|
771 | | PathSupportOption
|
772 | | PathArraySupportOption;
|
773 |
|
774 | export interface SupportOptions extends Record<string, SupportOption> {}
|
775 |
|
776 | export interface SupportInfo {
|
777 | languages: SupportLanguage[];
|
778 | options: SupportOption[];
|
779 | }
|
780 |
|
781 | export interface FileInfoOptions {
|
782 | ignorePath?: string | string[] | undefined;
|
783 | withNodeModules?: boolean | undefined;
|
784 | plugins?: string[] | undefined;
|
785 | resolveConfig?: boolean | undefined;
|
786 | }
|
787 |
|
788 | export interface FileInfoResult {
|
789 | ignored: boolean;
|
790 | inferredParser: string | null;
|
791 | }
|
792 |
|
793 | export function getFileInfo(
|
794 | filePath: string,
|
795 | options?: FileInfoOptions
|
796 | ): Promise<FileInfoResult>;
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | export function getSupportInfo(): Promise<SupportInfo>;
|
802 |
|
803 |
|
804 |
|
805 |
|
806 | export const version: string;
|
807 |
|
808 |
|
809 | export namespace util {
|
810 | interface SkipOptions {
|
811 | backwards?: boolean | undefined;
|
812 | }
|
813 |
|
814 | type Quote = "'" | '"';
|
815 |
|
816 | function getMaxContinuousCount(text: string, searchString: string): number;
|
817 |
|
818 | function getStringWidth(text: string): number;
|
819 |
|
820 | function getAlignmentSize(
|
821 | text: string,
|
822 | tabWidth: number,
|
823 | startIndex?: number | undefined
|
824 | ): number;
|
825 |
|
826 | function getIndentSize(value: string, tabWidth: number): number;
|
827 |
|
828 | function skipNewline(
|
829 | text: string,
|
830 | startIndex: number | false,
|
831 | options?: SkipOptions | undefined
|
832 | ): number | false;
|
833 |
|
834 | function skipInlineComment(
|
835 | text: string,
|
836 | startIndex: number | false
|
837 | ): number | false;
|
838 |
|
839 | function skipTrailingComment(
|
840 | text: string,
|
841 | startIndex: number | false
|
842 | ): number | false;
|
843 |
|
844 | function skipTrailingComment(
|
845 | text: string,
|
846 | startIndex: number | false
|
847 | ): number | false;
|
848 |
|
849 | function hasNewline(
|
850 | text: string,
|
851 | startIndex: number,
|
852 | options?: SkipOptions | undefined
|
853 | ): boolean;
|
854 |
|
855 | function hasNewlineInRange(
|
856 | text: string,
|
857 | startIndex: number,
|
858 | endIndex: number
|
859 | ): boolean;
|
860 |
|
861 | function hasSpaces(
|
862 | text: string,
|
863 | startIndex: number,
|
864 | options?: SkipOptions | undefined
|
865 | ): boolean;
|
866 |
|
867 | function getNextNonSpaceNonCommentCharacter(
|
868 | text: string,
|
869 | startIndex: number
|
870 | ): string;
|
871 |
|
872 | function makeString(
|
873 | rawText: string,
|
874 | enclosingQuote: Quote,
|
875 | unescapeUnnecessaryEscapes?: boolean | undefined
|
876 | ): string;
|
877 |
|
878 | function skip(
|
879 | characters: string | RegExp
|
880 | ): (
|
881 | text: string,
|
882 | startIndex: number | false,
|
883 | options?: SkipOptions
|
884 | ) => number | false;
|
885 |
|
886 | const skipWhitespace: (
|
887 | text: string,
|
888 | startIndex: number | false,
|
889 | options?: SkipOptions
|
890 | ) => number | false;
|
891 |
|
892 | const skipSpaces: (
|
893 | text: string,
|
894 | startIndex: number | false,
|
895 | options?: SkipOptions
|
896 | ) => number | false;
|
897 |
|
898 | const skipToLineEnd: (
|
899 | text: string,
|
900 | startIndex: number | false,
|
901 | options?: SkipOptions
|
902 | ) => number | false;
|
903 |
|
904 | const skipEverythingButNewLine: (
|
905 | text: string,
|
906 | startIndex: number | false,
|
907 | options?: SkipOptions
|
908 | ) => number | false;
|
909 |
|
910 | function addLeadingComment(node: any, comment: any): void;
|
911 |
|
912 | function addDanglingComment(node: any, comment: any, marker: any): void;
|
913 |
|
914 | function addTrailingComment(node: any, comment: any): void;
|
915 | }
|
916 |
|
\ | No newline at end of file |