UNPKG

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