UNPKG

28.2 kBTypeScriptView Raw
1// Type definitions for prettier 2.4
2// Project: https://prettier.io
3// https://github.com/prettier/prettier
4// Definitions by: Ika <https://github.com/ikatyang>
5// Ifiok Jr. <https://github.com/ifiokjr>
6// Florian Imdahl <https://github.com/ffflorian>
7// Sosuke Suzuki <https://github.com/sosukesuzuki>
8// Christopher Quadflieg <https://github.com/Shinigami92>
9// Georgii Dolzhykov <https://github.com/thorn0>
10// JounQin <https://github.com/JounQin>
11// Chuah Chee Shian <https://github.com/shian15810>
12// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13// TypeScript Version: 3.7
14
15// This utility is here to handle the case where you have an explicit union
16// between string literals and the generic string type. It would normally
17// resolve out to just the string type, but this generic LiteralUnion maintains
18// the intellisense of the original union.
19//
20// It comes from this issue: microsoft/TypeScript#29729:
21// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227
22export type LiteralUnion<T extends U, U = string> = T | (Pick<U, never> & { _?: never | undefined });
23
24export type AST = any;
25export type Doc = doc.builders.Doc;
26
27// https://github.com/prettier/prettier/blob/main/src/common/ast-path.js
28
29export class AstPath<T = any> {
30 constructor(value: T);
31 stack: T[];
32 getName(): PropertyKey | null;
33 getValue(): T;
34 getNode(count?: number): T | null;
35 getParentNode(count?: number): T | null;
36 call<U>(callback: (path: this) => U, ...names: PropertyKey[]): U;
37 callParent<U>(callback: (path: this) => U, count?: number): U;
38 each(callback: (path: this, index: number, value: any) => void, ...names: PropertyKey[]): void;
39 map<U>(callback: (path: this, index: number, value: any) => U, ...names: PropertyKey[]): U[];
40 match(...predicates: Array<(node: any, name: string | null, number: number | null) => boolean>): boolean;
41}
42
43/** @deprecated `FastPath` was renamed to `AstPath` */
44export type FastPath<T = any> = AstPath<T>;
45
46export type BuiltInParser = (text: string, options?: any) => AST;
47export type BuiltInParserName =
48 | 'angular'
49 | 'babel-flow'
50 | 'babel-ts'
51 | 'babel'
52 | 'css'
53 | 'espree'
54 | 'flow'
55 | 'glimmer'
56 | 'graphql'
57 | 'html'
58 | 'json-stringify'
59 | 'json'
60 | 'json5'
61 | 'less'
62 | 'lwc'
63 | 'markdown'
64 | 'mdx'
65 | 'meriyah'
66 | 'scss'
67 | 'typescript'
68 | 'vue'
69 | 'yaml';
70export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
71
72export type CustomParser = (text: string, parsers: BuiltInParsers, options: Options) => AST;
73
74/**
75 * For use in `.prettierrc.js`, `.prettierrc.cjs`, `prettier.config.js` or `prettier.config.cjs`.
76 */
77export interface Config extends Options {
78 overrides?: Array<{
79 files: string | string[];
80 excludeFiles?: string | string[];
81 options?: Options;
82 }>;
83}
84
85export interface Options extends Partial<RequiredOptions> {}
86
87export interface RequiredOptions extends doc.printer.Options {
88 /**
89 * Print semicolons at the ends of statements.
90 * @default true
91 */
92 semi: boolean;
93 /**
94 * Use single quotes instead of double quotes.
95 * @default false
96 */
97 singleQuote: boolean;
98 /**
99 * Use single quotes in JSX.
100 * @default false
101 */
102 jsxSingleQuote: boolean;
103 /**
104 * Print trailing commas wherever possible.
105 * @default 'es5'
106 */
107 trailingComma: 'none' | 'es5' | 'all';
108 /**
109 * Print spaces between brackets in object literals.
110 * @default true
111 */
112 bracketSpacing: boolean;
113 /**
114 * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
115 * alone on the next line (does not apply to self closing elements).
116 * @default false
117 */
118 bracketSameLine: boolean;
119 /**
120 * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
121 * @default false
122 * @deprecated use bracketSameLine instead
123 */
124 jsxBracketSameLine: boolean;
125 /**
126 * Format only a segment of a file.
127 * @default 0
128 */
129 rangeStart: number;
130 /**
131 * Format only a segment of a file.
132 * @default Infinity
133 */
134 rangeEnd: number;
135 /**
136 * Specify which parser to use.
137 */
138 parser: LiteralUnion<BuiltInParserName> | CustomParser;
139 /**
140 * Specify the input filepath. This will be used to do parser inference.
141 */
142 filepath: string;
143 /**
144 * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
145 * This is very useful when gradually transitioning large, unformatted codebases to prettier.
146 * @default false
147 */
148 requirePragma: boolean;
149 /**
150 * Prettier can insert a special @format marker at the top of files specifying that
151 * the file has been formatted with prettier. This works well when used in tandem with
152 * the --require-pragma option. If there is already a docblock at the top of
153 * the file then this option will add a newline to it with the @format marker.
154 * @default false
155 */
156 insertPragma: boolean;
157 /**
158 * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
159 * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
160 * @default 'preserve'
161 */
162 proseWrap: 'always' | 'never' | 'preserve';
163 /**
164 * Include parentheses around a sole arrow function parameter.
165 * @default 'always'
166 */
167 arrowParens: 'avoid' | 'always';
168 /**
169 * Provide ability to support new languages to prettier.
170 */
171 plugins: Array<string | Plugin>;
172 /**
173 * Specify plugin directory paths to search for plugins if not installed in the same `node_modules` where prettier is located.
174 */
175 pluginSearchDirs: string[];
176 /**
177 * How to handle whitespaces in HTML.
178 * @default 'css'
179 */
180 htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
181 /**
182 * Which end of line characters to apply.
183 * @default 'lf'
184 */
185 endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
186 /**
187 * Change when properties in objects are quoted.
188 * @default 'as-needed'
189 */
190 quoteProps: 'as-needed' | 'consistent' | 'preserve';
191 /**
192 * Whether or not to indent the code inside <script> and <style> tags in Vue files.
193 * @default false
194 */
195 vueIndentScriptAndStyle: boolean;
196 /**
197 * Control whether Prettier formats quoted code embedded in the file.
198 * @default 'auto'
199 */
200 embeddedLanguageFormatting: 'auto' | 'off';
201}
202
203export interface ParserOptions<T = any> extends RequiredOptions {
204 locStart: (node: T) => number;
205 locEnd: (node: T) => number;
206 originalText: string;
207}
208
209export interface Plugin<T = any> {
210 languages?: SupportLanguage[] | undefined;
211 parsers?: { [parserName: string]: Parser<T> } | undefined;
212 printers?: { [astFormat: string]: Printer<T> } | undefined;
213 options?: SupportOptions | undefined;
214 defaultOptions?: Partial<RequiredOptions> | undefined;
215}
216
217export interface Parser<T = any> {
218 parse: (text: string, parsers: { [parserName: string]: Parser }, options: ParserOptions<T>) => T;
219 astFormat: string;
220 hasPragma?: ((text: string) => boolean) | undefined;
221 locStart: (node: T) => number;
222 locEnd: (node: T) => number;
223 preprocess?: ((text: string, options: ParserOptions<T>) => string) | undefined;
224}
225
226export interface Printer<T = any> {
227 print(path: AstPath<T>, options: ParserOptions<T>, print: (path: AstPath<T>) => Doc): Doc;
228 embed?:
229 | ((
230 path: AstPath<T>,
231 print: (path: AstPath<T>) => Doc,
232 textToDoc: (text: string, options: Options) => Doc,
233 options: ParserOptions<T>,
234 ) => Doc | null)
235 | undefined;
236 insertPragma?: ((text: string) => string) | undefined;
237 /**
238 * @returns `null` if you want to remove this node
239 * @returns `void` if you want to use modified newNode
240 * @returns anything if you want to replace the node with it
241 */
242 massageAstNode?: ((node: any, newNode: any, parent: any) => any) | undefined;
243 hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
244 canAttachComment?: ((node: T) => boolean) | undefined;
245 willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
246 printComment?: ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc) | undefined;
247 handleComments?:
248 | {
249 ownLine?:
250 | ((
251 commentNode: any,
252 text: string,
253 options: ParserOptions<T>,
254 ast: T,
255 isLastComment: boolean,
256 ) => boolean)
257 | undefined;
258 endOfLine?:
259 | ((
260 commentNode: any,
261 text: string,
262 options: ParserOptions<T>,
263 ast: T,
264 isLastComment: boolean,
265 ) => boolean)
266 | undefined;
267 remaining?:
268 | ((
269 commentNode: any,
270 text: string,
271 options: ParserOptions<T>,
272 ast: T,
273 isLastComment: boolean,
274 ) => boolean)
275 | undefined;
276 }
277 | undefined;
278}
279
280export interface CursorOptions extends Options {
281 /**
282 * Specify where the cursor is.
283 */
284 cursorOffset: number;
285 rangeStart?: never;
286 rangeEnd?: never;
287}
288
289export interface CursorResult {
290 formatted: string;
291 cursorOffset: number;
292}
293
294/**
295 * `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
296 */
297export function format(source: string, options?: Options): string;
298
299/**
300 * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
301 * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
302 */
303export function check(source: string, options?: Options): boolean;
304
305/**
306 * `formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code.
307 * This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
308 *
309 * The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`.
310 */
311export function formatWithCursor(source: string, options: CursorOptions): CursorResult;
312
313export interface ResolveConfigOptions {
314 /**
315 * If set to `false`, all caching will be bypassed.
316 */
317 useCache?: boolean | undefined;
318 /**
319 * Pass directly the path of the config file if you don't wish to search for it.
320 */
321 config?: string | undefined;
322 /**
323 * If set to `true` and an `.editorconfig` file is in your project,
324 * Prettier will parse it and convert its properties to the corresponding prettier configuration.
325 * This configuration will be overridden by `.prettierrc`, etc. Currently,
326 * the following EditorConfig properties are supported:
327 * - indent_style
328 * - indent_size/tab_width
329 * - max_line_length
330 */
331 editorconfig?: boolean | undefined;
332}
333
334/**
335 * `resolveConfig` can be used to resolve configuration for a given source file,
336 * passing its path as the first argument. The config search will start at the
337 * file path and continue to search up the directory.
338 * (You can use `process.cwd()` to start searching from the current directory).
339 *
340 * A promise is returned which will resolve to:
341 *
342 * - An options object, providing a [config file](https://prettier.io/docs/en/configuration.html) was found.
343 * - `null`, if no file was found.
344 *
345 * The promise will be rejected if there was an error parsing the configuration file.
346 */
347export function resolveConfig(filePath: string, options?: ResolveConfigOptions): Promise<Options | null>;
348export namespace resolveConfig {
349 function sync(filePath: string, options?: ResolveConfigOptions): Options | null;
350}
351
352/**
353 * `resolveConfigFile` can be used to find the path of the Prettier configuration file,
354 * that will be used when resolving the config (i.e. when calling `resolveConfig`).
355 *
356 * A promise is returned which will resolve to:
357 *
358 * - The path of the configuration file.
359 * - `null`, if no file was found.
360 *
361 * The promise will be rejected if there was an error parsing the configuration file.
362 */
363export function resolveConfigFile(filePath?: string): Promise<string | null>;
364export namespace resolveConfigFile {
365 function sync(filePath?: string): string | null;
366}
367
368/**
369 * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache.
370 * Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
371 */
372export function clearConfigCache(): void;
373
374export interface SupportLanguage {
375 name: string;
376 since?: string | undefined;
377 parsers: BuiltInParserName[] | string[];
378 group?: string | undefined;
379 tmScope?: string | undefined;
380 aceMode?: string | undefined;
381 codemirrorMode?: string | undefined;
382 codemirrorMimeType?: string | undefined;
383 aliases?: string[] | undefined;
384 extensions?: string[] | undefined;
385 filenames?: string[] | undefined;
386 linguistLanguageId?: number | undefined;
387 vscodeLanguageIds?: string[] | undefined;
388}
389
390export interface SupportOptionRange {
391 start: number;
392 end: number;
393 step: number;
394}
395
396export type SupportOptionType = 'int' | 'boolean' | 'choice' | 'path';
397
398export type CoreCategoryType = 'Config' | 'Editor' | 'Format' | 'Other' | 'Output' | 'Global' | 'Special';
399
400export interface BaseSupportOption<Type extends SupportOptionType> {
401 readonly name?: string | undefined;
402 since: string;
403 /**
404 * Usually you can use {@link CoreCategoryType}
405 */
406 category: string;
407 /**
408 * The type of the option.
409 *
410 * When passing a type other than the ones listed below, the option is
411 * treated as taking any string as argument, and `--option <${type}>` will
412 * be displayed in --help.
413 */
414 type: Type;
415 /**
416 * Indicate that the option is deprecated.
417 *
418 * Use a string to add an extra message to --help for the option,
419 * for example to suggest a replacement option.
420 */
421 deprecated?: true | string | undefined;
422 /**
423 * Description to be displayed in --help. If omitted, the option won't be
424 * shown at all in --help.
425 */
426 description?: string | undefined;
427}
428
429export interface IntSupportOption extends BaseSupportOption<'int'> {
430 default?: number | undefined;
431 array?: false | undefined;
432 range?: SupportOptionRange | undefined;
433}
434
435export interface IntArraySupportOption extends BaseSupportOption<'int'> {
436 default?: Array<{ value: number[] }> | undefined;
437 array: true;
438}
439
440export interface BooleanSupportOption extends BaseSupportOption<'boolean'> {
441 default?: boolean | undefined;
442 array?: false | undefined;
443 description: string;
444 oppositeDescription?: string | undefined;
445}
446
447export interface BooleanArraySupportOption extends BaseSupportOption<'boolean'> {
448 default?: Array<{ value: boolean[] }> | undefined;
449 array: true;
450}
451
452export interface ChoiceSupportOption<Value = any> extends BaseSupportOption<'choice'> {
453 default?: Value | Array<{ since: string; value: Value }> | undefined;
454 description: string;
455 choices: Array<{
456 since?: string | undefined;
457 value: Value;
458 description: string;
459 }>;
460}
461
462export interface PathSupportOption extends BaseSupportOption<'path'> {
463 default?: string | undefined;
464 array?: false | undefined;
465}
466
467export interface PathArraySupportOption extends BaseSupportOption<'path'> {
468 default?: Array<{ value: string[] }> | undefined;
469 array: true;
470}
471
472export type SupportOption =
473 | IntSupportOption
474 | IntArraySupportOption
475 | BooleanSupportOption
476 | BooleanArraySupportOption
477 | ChoiceSupportOption
478 | PathSupportOption
479 | PathArraySupportOption;
480
481export interface SupportOptions extends Record<string, SupportOption> {}
482
483export interface SupportInfo {
484 languages: SupportLanguage[];
485 options: SupportOption[];
486}
487
488export interface FileInfoOptions {
489 ignorePath?: string | undefined;
490 withNodeModules?: boolean | undefined;
491 plugins?: string[] | undefined;
492 resolveConfig?: boolean | undefined;
493}
494
495export interface FileInfoResult {
496 ignored: boolean;
497 inferredParser: string | null;
498}
499
500export function getFileInfo(filePath: string, options?: FileInfoOptions): Promise<FileInfoResult>;
501
502export namespace getFileInfo {
503 function sync(filePath: string, options?: FileInfoOptions): FileInfoResult;
504}
505
506/**
507 * Returns an object representing the parsers, languages and file types Prettier supports for the current version.
508 */
509export function getSupportInfo(): SupportInfo;
510
511/**
512 * `version` field in `package.json`
513 */
514export const version: string;
515
516// https://github.com/prettier/prettier/blob/main/src/common/util-shared.js
517export namespace util {
518 interface SkipOptions {
519 backwards?: boolean | undefined;
520 }
521
522 type Quote = "'" | '"';
523
524 function addDanglingComment(node: any, comment: any, marker: any): void;
525 function addLeadingComment(node: any, comment: any): void;
526 function addTrailingComment(node: any, comment: any): void;
527 function getAlignmentSize(value: string, tabWidth: number, startIndex?: number): number;
528 function getIndentSize(value: string, tabWidth: number): number;
529 function getMaxContinuousCount(str: string, target: string): number;
530 function getNextNonSpaceNonCommentCharacterIndex<N>(
531 text: string,
532 node: N,
533 locEnd: (node: N) => number,
534 ): number | false;
535 function getStringWidth(text: string): number;
536 function hasNewline(text: string, index: number, opts?: SkipOptions): boolean;
537 function hasNewlineInRange(text: string, start: number, end: number): boolean;
538 function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean;
539 function isNextLineEmpty<N>(text: string, node: N, locEnd: (node: N) => number): boolean;
540 function isNextLineEmptyAfterIndex(text: string, index: number): boolean;
541 function isPreviousLineEmpty<N>(text: string, node: N, locStart: (node: N) => number): boolean;
542 function makeString(rawContent: string, enclosingQuote: Quote, unescapeUnnecessaryEscapes?: boolean): string;
543 function skip(chars: string | RegExp): (text: string, index: number | false, opts?: SkipOptions) => number | false;
544 function skipEverythingButNewLine(text: string, index: number | false, opts?: SkipOptions): number | false;
545 function skipInlineComment(text: string, index: number | false): number | false;
546 function skipNewline(text: string, index: number | false, opts?: SkipOptions): number | false;
547 function skipSpaces(text: string, index: number | false, opts?: SkipOptions): number | false;
548 function skipToLineEnd(text: string, index: number | false, opts?: SkipOptions): number | false;
549 function skipTrailingComment(text: string, index: number | false): number | false;
550 function skipWhitespace(text: string, index: number | false, opts?: SkipOptions): number | false;
551}
552
553// https://github.com/prettier/prettier/blob/main/src/document/index.js
554export namespace doc {
555 namespace builders {
556 type DocCommand =
557 | Align
558 | BreakParent
559 | Concat
560 | Cursor
561 | Fill
562 | Group
563 | IfBreak
564 | Indent
565 | IndentIfBreak
566 | Label
567 | Line
568 | LineSuffix
569 | LineSuffixBoundary
570 | Trim;
571 type Doc = string | Doc[] | DocCommand;
572
573 interface Align {
574 type: 'align';
575 contents: Doc;
576 n: number | string | { type: 'root' };
577 }
578
579 interface BreakParent {
580 type: 'break-parent';
581 }
582
583 interface Concat {
584 type: 'concat';
585 parts: Doc[];
586 }
587
588 interface Cursor {
589 type: 'cursor';
590 placeholder: symbol;
591 }
592
593 interface Fill {
594 type: 'fill';
595 parts: Doc[];
596 }
597
598 interface Group {
599 type: 'group';
600 contents: Doc;
601 break: boolean;
602 expandedStates: Doc[];
603 }
604
605 interface HardlineWithoutBreakParent extends Line {
606 hard: true;
607 }
608
609 interface IfBreak {
610 type: 'if-break';
611 breakContents: Doc;
612 flatContents: Doc;
613 }
614
615 interface Indent {
616 type: 'indent';
617 contents: Doc;
618 }
619
620 interface IndentIfBreak {
621 type: 'indent-if-break';
622 }
623
624 interface Label {
625 type: 'label';
626 }
627
628 interface Line {
629 type: 'line';
630 soft?: boolean | undefined;
631 hard?: boolean | undefined;
632 literal?: boolean | undefined;
633 }
634
635 interface LineSuffix {
636 type: 'line-suffix';
637 contents: Doc;
638 }
639
640 interface LineSuffixBoundary {
641 type: 'line-suffix-boundary';
642 }
643
644 interface LiterallineWithoutBreakParent extends Line {
645 hard: true;
646 literal: true;
647 }
648
649 interface Softline extends Line {
650 soft: true;
651 }
652
653 interface Trim {
654 type: 'trim';
655 }
656
657 interface GroupOptions {
658 shouldBreak?: boolean | undefined;
659 id?: symbol | undefined;
660 }
661
662 function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
663 /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
664 function align(widthOrString: Align['n'], doc: Doc): Align;
665 /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
666 const breakParent: BreakParent;
667 /**
668 * @see [concat](https://github.com/prettier/prettier/blob/main/commands.md#deprecated-concat)
669 * @deprecated use `Doc[]` instead
670 */
671 function concat(docs: Doc[]): Concat;
672 /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
673 function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
674 /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
675 function dedent(doc: Doc): Align;
676 /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
677 function dedentToRoot(doc: Doc): Align;
678 /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
679 function fill(docs: Doc[]): Fill;
680 /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
681 function group(doc: Doc, opts?: GroupOptions): Group;
682 /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
683 const hardline: Concat;
684 /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
685 const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
686 /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
687 function ifBreak(ifBreak: Doc, noBreak?: Doc, options?: { groupId?: symbol | undefined }): IfBreak;
688 /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
689 function indent(doc: Doc): Indent;
690 /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
691 function indentIfBreak(doc: Doc, opts: { groupId: symbol; negate?: boolean | undefined }): IndentIfBreak;
692 /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
693 function join(sep: Doc, docs: Doc[]): Concat;
694 /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
695 function label(label: string, doc: Doc): Label;
696 /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
697 const line: Line;
698 /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
699 function lineSuffix(suffix: Doc): LineSuffix;
700 /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
701 const lineSuffixBoundary: LineSuffixBoundary;
702 /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
703 const literalline: Concat;
704 /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
705 const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
706 /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
707 function markAsRoot(doc: Doc): Align;
708 /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
709 const softline: Softline;
710 /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
711 const trim: Trim;
712 /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
713 const cursor: Cursor;
714 }
715 namespace debug {
716 function printDocToDebug(doc: Doc): string;
717 }
718 namespace printer {
719 function printDocToString(
720 doc: Doc,
721 options: Options,
722 ): {
723 formatted: string;
724 cursorNodeStart?: number | undefined;
725 cursorNodeText?: string | undefined;
726 };
727 interface Options {
728 /**
729 * Specify the line length that the printer will wrap on.
730 * @default 80
731 */
732 printWidth: number;
733 /**
734 * Specify the number of spaces per indentation-level.
735 * @default 2
736 */
737 tabWidth: number;
738 /**
739 * Indent lines with tabs instead of spaces
740 * @default false
741 */
742 useTabs: boolean;
743 parentParser?: string | undefined;
744 __embeddedInHtml?: boolean | undefined;
745 }
746 }
747 namespace utils {
748 function cleanDoc(doc: Doc): Doc;
749 function findInDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T, defaultValue: T): T;
750 function getDocParts(doc: Doc): Doc;
751 function isConcat(doc: Doc): boolean;
752 function isEmpty(doc: Doc): boolean;
753 function isLineNext(doc: Doc): boolean;
754 function mapDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T): T;
755 function normalizeDoc(doc: Doc): Doc;
756 function normalizeParts(parts: Doc[]): Doc[];
757 function propagateBreaks(doc: Doc): void;
758 function removeLines(doc: Doc): Doc;
759 function replaceNewlinesWithLiterallines(doc: Doc): Doc;
760 function stripTrailingHardline(doc: Doc): Doc;
761 function traverseDoc(
762 doc: Doc,
763 onEnter?: (doc: Doc) => void | boolean,
764 onExit?: (doc: Doc) => void,
765 shouldTraverseConditionalGroups?: boolean,
766 ): void;
767 function willBreak(doc: Doc): boolean;
768 }
769}
770
\No newline at end of file