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 }> = 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 |
|
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 |
|
355 | jsxBracketSameLine: boolean;
|
356 | |
357 |
|
358 |
|
359 |
|
360 | rangeStart: number;
|
361 | |
362 |
|
363 |
|
364 |
|
365 | rangeEnd: number;
|
366 | |
367 |
|
368 |
|
369 | parser: LiteralUnion<BuiltInParserName>;
|
370 | |
371 |
|
372 |
|
373 | filepath: string;
|
374 | |
375 |
|
376 |
|
377 |
|
378 |
|
379 | requirePragma: boolean;
|
380 | |
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 | insertPragma: boolean;
|
388 | |
389 |
|
390 |
|
391 |
|
392 |
|
393 | proseWrap: "always" | "never" | "preserve";
|
394 | |
395 |
|
396 |
|
397 |
|
398 | arrowParens: "avoid" | "always";
|
399 | |
400 |
|
401 |
|
402 | plugins: Array<string | Plugin>;
|
403 | |
404 |
|
405 |
|
406 |
|
407 | htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
|
408 | |
409 |
|
410 |
|
411 |
|
412 | endOfLine: "auto" | "lf" | "crlf" | "cr";
|
413 | |
414 |
|
415 |
|
416 |
|
417 | quoteProps: "as-needed" | "consistent" | "preserve";
|
418 | |
419 |
|
420 |
|
421 |
|
422 | vueIndentScriptAndStyle: boolean;
|
423 | |
424 |
|
425 |
|
426 |
|
427 | embeddedLanguageFormatting: "auto" | "off";
|
428 | |
429 |
|
430 |
|
431 |
|
432 | singleAttributePerLine: boolean;
|
433 | }
|
434 |
|
435 | export interface ParserOptions<T = any> extends RequiredOptions {
|
436 | locStart: (node: T) => number;
|
437 | locEnd: (node: T) => number;
|
438 | originalText: string;
|
439 | }
|
440 |
|
441 | export interface Plugin<T = any> {
|
442 | languages?: SupportLanguage[] | undefined;
|
443 | parsers?: { [parserName: string]: Parser<T> } | undefined;
|
444 | printers?: { [astFormat: string]: Printer<T> } | undefined;
|
445 | options?: SupportOptions | undefined;
|
446 | defaultOptions?: Partial<RequiredOptions> | undefined;
|
447 | }
|
448 |
|
449 | export interface Parser<T = any> {
|
450 | parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;
|
451 | astFormat: string;
|
452 | hasPragma?: ((text: string) => boolean) | undefined;
|
453 | locStart: (node: T) => number;
|
454 | locEnd: (node: T) => number;
|
455 | preprocess?:
|
456 | | ((text: string, options: ParserOptions<T>) => string)
|
457 | | undefined;
|
458 | }
|
459 |
|
460 | export interface Printer<T = any> {
|
461 | print(
|
462 | path: AstPath<T>,
|
463 | options: ParserOptions<T>,
|
464 | print: (path: AstPath<T>) => Doc,
|
465 | args?: unknown,
|
466 | ): Doc;
|
467 | embed?:
|
468 | | ((
|
469 | path: AstPath,
|
470 | options: Options,
|
471 | ) =>
|
472 | | ((
|
473 | textToDoc: (text: string, options: Options) => Promise<Doc>,
|
474 | print: (
|
475 | selector?: string | number | Array<string | number> | AstPath,
|
476 | ) => Doc,
|
477 | path: AstPath,
|
478 | options: Options,
|
479 | ) => Promise<Doc | undefined> | Doc | undefined)
|
480 | | Doc
|
481 | | null)
|
482 | | undefined;
|
483 | preprocess?:
|
484 | | ((ast: T, options: ParserOptions<T>) => T | Promise<T>)
|
485 | | undefined;
|
486 | insertPragma?: (text: string) => string;
|
487 | |
488 |
|
489 |
|
490 |
|
491 |
|
492 | massageAstNode?: ((node: any, newNode: any, parent: any) => any) | undefined;
|
493 | hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
|
494 | canAttachComment?: ((node: T) => boolean) | undefined;
|
495 | isBlockComment?: ((node: T) => boolean) | undefined;
|
496 | willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
|
497 | printComment?:
|
498 | | ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
|
499 | | undefined;
|
500 | |
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | getCommentChildNodes?:
|
508 | | ((node: T, options: ParserOptions<T>) => T[] | undefined)
|
509 | | undefined;
|
510 | handleComments?:
|
511 | | {
|
512 | ownLine?:
|
513 | | ((
|
514 | commentNode: any,
|
515 | text: string,
|
516 | options: ParserOptions<T>,
|
517 | ast: T,
|
518 | isLastComment: boolean,
|
519 | ) => boolean)
|
520 | | undefined;
|
521 | endOfLine?:
|
522 | | ((
|
523 | commentNode: any,
|
524 | text: string,
|
525 | options: ParserOptions<T>,
|
526 | ast: T,
|
527 | isLastComment: boolean,
|
528 | ) => boolean)
|
529 | | undefined;
|
530 | remaining?:
|
531 | | ((
|
532 | commentNode: any,
|
533 | text: string,
|
534 | options: ParserOptions<T>,
|
535 | ast: T,
|
536 | isLastComment: boolean,
|
537 | ) => boolean)
|
538 | | undefined;
|
539 | }
|
540 | | undefined;
|
541 | getVisitorKeys?:
|
542 | | ((node: T, nonTraversableKeys: Set<string>) => string[])
|
543 | | undefined;
|
544 | }
|
545 |
|
546 | export interface CursorOptions extends Options {
|
547 | |
548 |
|
549 |
|
550 | cursorOffset: number;
|
551 | rangeStart?: never;
|
552 | rangeEnd?: never;
|
553 | }
|
554 |
|
555 | export interface CursorResult {
|
556 | formatted: string;
|
557 | cursorOffset: number;
|
558 | }
|
559 |
|
560 |
|
561 |
|
562 |
|
563 | export function format(source: string, options?: Options): Promise<string>;
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 | export function check(source: string, options?: Options): Promise<boolean>;
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 | export function formatWithCursor(
|
578 | source: string,
|
579 | options: CursorOptions,
|
580 | ): Promise<CursorResult>;
|
581 |
|
582 | export interface ResolveConfigOptions {
|
583 | |
584 |
|
585 |
|
586 | useCache?: boolean | undefined;
|
587 | |
588 |
|
589 |
|
590 | config?: string | undefined;
|
591 | |
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | editorconfig?: boolean | undefined;
|
601 | }
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 | export function resolveConfig(
|
617 | fileUrlOrPath: string | URL,
|
618 | options?: ResolveConfigOptions,
|
619 | ): Promise<Options | null>;
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 | export function resolveConfigFile(
|
633 | fileUrlOrPath?: string | URL,
|
634 | ): Promise<string | null>;
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 | export function clearConfigCache(): Promise<void>;
|
641 |
|
642 | export interface SupportLanguage {
|
643 | name: string;
|
644 | since?: string | undefined;
|
645 | parsers: BuiltInParserName[] | string[];
|
646 | group?: string | undefined;
|
647 | tmScope?: string | undefined;
|
648 | aceMode?: string | undefined;
|
649 | codemirrorMode?: string | undefined;
|
650 | codemirrorMimeType?: string | undefined;
|
651 | aliases?: string[] | undefined;
|
652 | extensions?: string[] | undefined;
|
653 | filenames?: string[] | undefined;
|
654 | linguistLanguageId?: number | undefined;
|
655 | vscodeLanguageIds?: string[] | undefined;
|
656 | interpreters?: string[] | undefined;
|
657 | }
|
658 |
|
659 | export interface SupportOptionRange {
|
660 | start: number;
|
661 | end: number;
|
662 | step: number;
|
663 | }
|
664 |
|
665 | export type SupportOptionType =
|
666 | | "int"
|
667 | | "string"
|
668 | | "boolean"
|
669 | | "choice"
|
670 | | "path";
|
671 |
|
672 | export type CoreCategoryType =
|
673 | | "Config"
|
674 | | "Editor"
|
675 | | "Format"
|
676 | | "Other"
|
677 | | "Output"
|
678 | | "Global"
|
679 | | "Special";
|
680 |
|
681 | export interface BaseSupportOption<Type extends SupportOptionType> {
|
682 | readonly name?: string | undefined;
|
683 | |
684 |
|
685 |
|
686 | category: string;
|
687 | |
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 | type: Type;
|
695 | |
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 | deprecated?: true | string | undefined;
|
702 | |
703 |
|
704 |
|
705 |
|
706 | description?: string | undefined;
|
707 | }
|
708 |
|
709 | export interface IntSupportOption extends BaseSupportOption<"int"> {
|
710 | default?: number | undefined;
|
711 | array?: false | undefined;
|
712 | range?: SupportOptionRange | undefined;
|
713 | }
|
714 |
|
715 | export interface IntArraySupportOption extends BaseSupportOption<"int"> {
|
716 | default?: Array<{ value: number[] }> | undefined;
|
717 | array: true;
|
718 | }
|
719 |
|
720 | export interface StringSupportOption extends BaseSupportOption<"string"> {
|
721 | default?: string | undefined;
|
722 | array?: false | undefined;
|
723 | }
|
724 |
|
725 | export interface StringArraySupportOption extends BaseSupportOption<"string"> {
|
726 | default?: Array<{ value: string[] }> | undefined;
|
727 | array: true;
|
728 | }
|
729 |
|
730 | export interface BooleanSupportOption extends BaseSupportOption<"boolean"> {
|
731 | default?: boolean | undefined;
|
732 | array?: false | undefined;
|
733 | description: string;
|
734 | oppositeDescription?: string | undefined;
|
735 | }
|
736 |
|
737 | export interface BooleanArraySupportOption
|
738 | extends BaseSupportOption<"boolean"> {
|
739 | default?: Array<{ value: boolean[] }> | undefined;
|
740 | array: true;
|
741 | }
|
742 |
|
743 | export interface ChoiceSupportOption<Value = any>
|
744 | extends BaseSupportOption<"choice"> {
|
745 | default?: Value | Array<{ value: Value }> | undefined;
|
746 | description: string;
|
747 | choices: Array<{
|
748 | since?: string | undefined;
|
749 | value: Value;
|
750 | description: string;
|
751 | }>;
|
752 | }
|
753 |
|
754 | export interface PathSupportOption extends BaseSupportOption<"path"> {
|
755 | default?: string | undefined;
|
756 | array?: false | undefined;
|
757 | }
|
758 |
|
759 | export interface PathArraySupportOption extends BaseSupportOption<"path"> {
|
760 | default?: Array<{ value: string[] }> | undefined;
|
761 | array: true;
|
762 | }
|
763 |
|
764 | export type SupportOption =
|
765 | | IntSupportOption
|
766 | | IntArraySupportOption
|
767 | | StringSupportOption
|
768 | | StringArraySupportOption
|
769 | | BooleanSupportOption
|
770 | | BooleanArraySupportOption
|
771 | | ChoiceSupportOption
|
772 | | PathSupportOption
|
773 | | PathArraySupportOption;
|
774 |
|
775 | export interface SupportOptions extends Record<string, SupportOption> {}
|
776 |
|
777 | export interface SupportInfo {
|
778 | languages: SupportLanguage[];
|
779 | options: SupportOption[];
|
780 | }
|
781 |
|
782 | export interface FileInfoOptions {
|
783 | ignorePath?: string | URL | (string | URL)[] | undefined;
|
784 | withNodeModules?: boolean | undefined;
|
785 | plugins?: string[] | undefined;
|
786 | resolveConfig?: boolean | undefined;
|
787 | }
|
788 |
|
789 | export interface FileInfoResult {
|
790 | ignored: boolean;
|
791 | inferredParser: string | null;
|
792 | }
|
793 |
|
794 | export function getFileInfo(
|
795 | file: string | URL,
|
796 | options?: FileInfoOptions,
|
797 | ): Promise<FileInfoResult>;
|
798 |
|
799 |
|
800 |
|
801 |
|
802 | export function getSupportInfo(): Promise<SupportInfo>;
|
803 |
|
804 |
|
805 |
|
806 |
|
807 | export const version: string;
|
808 |
|
809 |
|
810 | export namespace util {
|
811 | interface SkipOptions {
|
812 | backwards?: boolean | undefined;
|
813 | }
|
814 |
|
815 | type Quote = "'" | '"';
|
816 |
|
817 | function getMaxContinuousCount(text: string, searchString: string): number;
|
818 |
|
819 | function getStringWidth(text: string): number;
|
820 |
|
821 | function getAlignmentSize(
|
822 | text: string,
|
823 | tabWidth: number,
|
824 | startIndex?: number | undefined,
|
825 | ): number;
|
826 |
|
827 | function getIndentSize(value: string, tabWidth: number): number;
|
828 |
|
829 | function skipNewline(
|
830 | text: string,
|
831 | startIndex: number | false,
|
832 | options?: SkipOptions | undefined,
|
833 | ): number | false;
|
834 |
|
835 | function skipInlineComment(
|
836 | text: string,
|
837 | startIndex: number | false,
|
838 | ): number | false;
|
839 |
|
840 | function skipTrailingComment(
|
841 | text: string,
|
842 | startIndex: number | false,
|
843 | ): number | false;
|
844 |
|
845 | function skipTrailingComment(
|
846 | text: string,
|
847 | startIndex: number | false,
|
848 | ): number | false;
|
849 |
|
850 | function hasNewline(
|
851 | text: string,
|
852 | startIndex: number,
|
853 | options?: SkipOptions | undefined,
|
854 | ): boolean;
|
855 |
|
856 | function hasNewlineInRange(
|
857 | text: string,
|
858 | startIndex: number,
|
859 | endIndex: number,
|
860 | ): boolean;
|
861 |
|
862 | function hasSpaces(
|
863 | text: string,
|
864 | startIndex: number,
|
865 | options?: SkipOptions | undefined,
|
866 | ): boolean;
|
867 |
|
868 | function getNextNonSpaceNonCommentCharacterIndex(
|
869 | text: string,
|
870 | startIndex: number,
|
871 | ): number | false;
|
872 |
|
873 | function getNextNonSpaceNonCommentCharacter(
|
874 | text: string,
|
875 | startIndex: number,
|
876 | ): string;
|
877 |
|
878 | function isNextLineEmpty(text: string, startIndex: number): boolean;
|
879 |
|
880 | function isPreviousLineEmpty(text: string, startIndex: number): boolean;
|
881 |
|
882 | function makeString(
|
883 | rawText: string,
|
884 | enclosingQuote: Quote,
|
885 | unescapeUnnecessaryEscapes?: boolean | undefined,
|
886 | ): string;
|
887 |
|
888 | function skip(
|
889 | characters: string | RegExp,
|
890 | ): (
|
891 | text: string,
|
892 | startIndex: number | false,
|
893 | options?: SkipOptions,
|
894 | ) => number | false;
|
895 |
|
896 | const skipWhitespace: (
|
897 | text: string,
|
898 | startIndex: number | false,
|
899 | options?: SkipOptions,
|
900 | ) => number | false;
|
901 |
|
902 | const skipSpaces: (
|
903 | text: string,
|
904 | startIndex: number | false,
|
905 | options?: SkipOptions,
|
906 | ) => number | false;
|
907 |
|
908 | const skipToLineEnd: (
|
909 | text: string,
|
910 | startIndex: number | false,
|
911 | options?: SkipOptions,
|
912 | ) => number | false;
|
913 |
|
914 | const skipEverythingButNewLine: (
|
915 | text: string,
|
916 | startIndex: number | false,
|
917 | options?: SkipOptions,
|
918 | ) => number | false;
|
919 |
|
920 | function addLeadingComment(node: any, comment: any): void;
|
921 |
|
922 | function addDanglingComment(node: any, comment: any, marker: any): void;
|
923 |
|
924 | function addTrailingComment(node: any, comment: any): void;
|
925 | }
|
926 |
|
\ | No newline at end of file |