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