// Type definitions for prettier 2.4 // Project: https://github.com/prettier/prettier, https://prettier.io // Definitions by: Ika , // Ifiok Jr. , // Florian Imdahl , // Sosuke Suzuki , // Christopher Quadflieg // Kevin Deisz // Georgii Dolzhykov // JounQin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 // This utility is here to handle the case where you have an explicit union // between string literals and the generic string type. It would normally // resolve out to just the string type, but this generic LiteralUnion maintains // the intellisense of the original union. // // It comes from this issue: microsoft/TypeScript#29729: // https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227 export type LiteralUnion = T | (Pick & { _?: never | undefined }); export type AST = any; export type Doc = doc.builders.Doc; // https://github.com/prettier/prettier/blob/main/src/common/ast-path.js export class AstPath { constructor(value: T); stack: T[]; getName(): PropertyKey | null; getValue(): T; getNode(count?: number): T | null; getParentNode(count?: number): T | null; call(callback: (path: this) => U, ...names: PropertyKey[]): U; callParent(callback: (path: this) => U, count?: number): U; each(callback: (path: this, index: number, value: any) => void, ...names: PropertyKey[]): void; map(callback: (path: this, index: number, value: any) => U, ...names: PropertyKey[]): U[]; match(...predicates: Array<(node: any, name: string | null, number: number | null) => boolean>): boolean; } /** @deprecated `FastPath` was renamed to `AstPath` */ export type FastPath = AstPath; export type BuiltInParser = (text: string, options?: any) => AST; export type BuiltInParserName = | 'angular' | 'babel-flow' | 'babel-ts' | 'babel' | 'css' | 'espree' | 'flow' | 'glimmer' | 'graphql' | 'html' | 'json-stringify' | 'json' | 'json5' | 'less' | 'lwc' | 'markdown' | 'mdx' | 'meriyah' | 'scss' | 'typescript' | 'vue' | 'yaml'; export type BuiltInParsers = Record; export type CustomParser = (text: string, parsers: BuiltInParsers, options: Options) => AST; export interface Options extends Partial {} export interface RequiredOptions extends doc.printer.Options { /** * Print semicolons at the ends of statements. * @default true */ semi: boolean; /** * Use single quotes instead of double quotes. * @default false */ singleQuote: boolean; /** * Use single quotes in JSX. * @default false */ jsxSingleQuote: boolean; /** * Print trailing commas wherever possible. * @default 'es5' */ trailingComma: 'none' | 'es5' | 'all'; /** * Print spaces between brackets in object literals. * @default true */ bracketSpacing: boolean; /** * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being * alone on the next line (does not apply to self closing elements). * @default false */ bracketSameLine: boolean; /** * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line. * @default false * @deprecated use bracketSameLine instead */ jsxBracketSameLine: boolean; /** * Format only a segment of a file. * @default 0 */ rangeStart: number; /** * Format only a segment of a file. * @default Infinity */ rangeEnd: number; /** * Specify which parser to use. */ parser: LiteralUnion | CustomParser; /** * Specify the input filepath. This will be used to do parser inference. */ filepath: string; /** * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. * This is very useful when gradually transitioning large, unformatted codebases to prettier. * @default false */ requirePragma: boolean; /** * Prettier can insert a special @format marker at the top of files specifying that * the file has been formatted with prettier. This works well when used in tandem with * the --require-pragma option. If there is already a docblock at the top of * the file then this option will add a newline to it with the @format marker. * @default false */ insertPragma: boolean; /** * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer. * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out. * @default 'preserve' */ proseWrap: 'always' | 'never' | 'preserve'; /** * Include parentheses around a sole arrow function parameter. * @default 'always' */ arrowParens: 'avoid' | 'always'; /** * Provide ability to support new languages to prettier. */ plugins: Array; /** * Specify plugin directory paths to search for plugins if not installed in the same `node_modules` where prettier is located. */ pluginSearchDirs: string[]; /** * How to handle whitespaces in HTML. * @default 'css' */ htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore'; /** * Which end of line characters to apply. * @default 'lf' */ endOfLine: 'auto' | 'lf' | 'crlf' | 'cr'; /** * Change when properties in objects are quoted. * @default 'as-needed' */ quoteProps: 'as-needed' | 'consistent' | 'preserve'; /** * Whether or not to indent the code inside