prettier

  • Version 3.7.3
  • Published
  • 8.59 MB
  • No dependencies
  • MIT license

Install

npm i prettier
yarn add prettier
pnpm add prettier

Overview

Prettier is an opinionated code formatter

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable version

const version: string;
  • version field in package.json

Functions

function check

check: (source: string, options?: Options) => Promise<boolean>;
  • check checks to see if the file has been formatted with Prettier given those options and returns a Boolean. This is similar to the --list-different parameter in the CLI and is useful for running Prettier in CI scenarios.

function clearConfigCache

clearConfigCache: () => Promise<void>;
  • As you repeatedly call resolveConfig, the file system structure will be cached for performance. This function will clear the cache. Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.

function format

format: (source: string, options?: Options) => Promise<string>;
  • format is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.

function formatWithCursor

formatWithCursor: (
source: string,
options: CursorOptions
) => Promise<CursorResult>;
  • formatWithCursor both formats the code, and translates a cursor position from unformatted code to formatted code. This is useful for editor integrations, to prevent the cursor from moving when code is formatted.

    The cursorOffset option should be provided, to specify where the cursor is.

function getFileInfo

getFileInfo: (
file: string | URL,
options?: FileInfoOptions
) => Promise<FileInfoResult>;

    function getSupportInfo

    getSupportInfo: (options?: SupportInfoOptions) => Promise<SupportInfo>;
    • Returns an object representing the parsers, languages and file types Prettier supports for the current version.

    function resolveConfig

    resolveConfig: (
    fileUrlOrPath: string | URL,
    options?: ResolveConfigOptions
    ) => Promise<Options | null>;
    • resolveConfig can be used to resolve configuration for a given source file, passing its path or url as the first argument. The config search will start at the directory of the file location and continue to search up the directory.

      A promise is returned which will resolve to:

      - An options object, providing a [config file](https://prettier.io/docs/configuration) was found. - null, if no file was found.

      The promise will be rejected if there was an error parsing the configuration file.

    function resolveConfigFile

    resolveConfigFile: (fileUrlOrPath?: string | URL) => Promise<string | null>;
    • resolveConfigFile can be used to find the path of the Prettier configuration file, that will be used when resolving the config (i.e. when calling resolveConfig).

      A promise is returned which will resolve to:

      - The path of the configuration file. - null, if no file was found.

      The promise will be rejected if there was an error parsing the configuration file.

    Classes

    class AstPath

    class AstPath<T = any> {}

      constructor

      constructor(value: {});

        property ancestors

        readonly ancestors: T[];

          property grandparent

          readonly grandparent: {};

            property index

            readonly index: number;

              property isFirst

              readonly isFirst: boolean;

                property isInArray

                readonly isInArray: boolean;

                  property isLast

                  readonly isLast: boolean;

                    property isRoot

                    readonly isRoot: boolean;

                      property key

                      readonly key: string;

                        property next

                        readonly next: {};

                          property node

                          readonly node: {};

                            property parent

                            readonly parent: {};

                              property previous

                              readonly previous: {};

                                property root

                                readonly root: {};

                                  property siblings

                                  readonly siblings: T[];

                                    property stack

                                    stack: T[];

                                      method call

                                      call: {
                                      <U>(callback: CallCallback<T, U>): U;
                                      <U, P1 extends CallProperties<T>>(
                                      callback: CallCallback<IndexValue<T, P1>, U>,
                                      prop1: P1
                                      ): U;
                                      <U, P1 extends keyof T, P2 extends CallProperties<T[P1]>>(
                                      callback: CallCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
                                      prop1: P1,
                                      prop2: P2
                                      ): U;
                                      <
                                      U,
                                      P1 extends keyof T,
                                      P2 extends CallProperties<T[P1]>,
                                      P3 extends CallProperties<IndexValue<T[P1], P2>>
                                      >(
                                      callback: CallCallback<
                                      IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
                                      U
                                      >,
                                      prop1: P1,
                                      prop2: P2,
                                      prop3: P3
                                      ): U;
                                      <
                                      U,
                                      P1 extends keyof T,
                                      P2 extends CallProperties<T[P1]>,
                                      P3 extends CallProperties<IndexValue<T[P1], P2>>,
                                      P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
                                      >(
                                      callback: CallCallback<
                                      IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
                                      U
                                      >,
                                      prop1: P1,
                                      prop2: P2,
                                      prop3: P3,
                                      prop4: P4
                                      ): U;
                                      <U, P extends PropertyKey>(
                                      callback: CallCallback<any, U>,
                                      prop1: P,
                                      prop2: P,
                                      prop3: P,
                                      prop4: P,
                                      ...props: P[]
                                      ): U;
                                      };

                                        method callParent

                                        callParent: <U>(callback: (path: this) => U, count?: number) => U;

                                          method each

                                          each: {
                                          (callback: EachCallback<T>): void;
                                          <P1 extends IterProperties<T>>(
                                          callback: EachCallback<IndexValue<T, P1>>,
                                          prop1: P1
                                          ): void;
                                          <P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
                                          callback: EachCallback<IndexValue<IndexValue<T, P1>, P2>>,
                                          prop1: P1,
                                          prop2: P2
                                          ): void;
                                          <
                                          P1 extends keyof T,
                                          P2 extends IterProperties<T[P1]>,
                                          P3 extends IterProperties<IndexValue<T[P1], P2>>
                                          >(
                                          callback: EachCallback<
                                          IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>
                                          >,
                                          prop1: P1,
                                          prop2: P2,
                                          prop3: P3
                                          ): void;
                                          <
                                          P1 extends keyof T,
                                          P2 extends IterProperties<T[P1]>,
                                          P3 extends IterProperties<IndexValue<T[P1], P2>>,
                                          P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
                                          >(
                                          callback: EachCallback<
                                          IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>
                                          >,
                                          prop1: P1,
                                          prop2: P2,
                                          prop3: P3,
                                          prop4: P4
                                          ): void;
                                          (
                                          callback: EachCallback<any[]>,
                                          prop1: PropertyKey,
                                          prop2: PropertyKey,
                                          prop3: PropertyKey,
                                          prop4: PropertyKey,
                                          ...props: PropertyKey[]
                                          ): void;
                                          };

                                            method getName

                                            getName: () => PropertyKey | null;
                                            • Deprecated

                                              Please use AstPath#key or AstPath#index

                                            method getNode

                                            getNode: (count?: number) => T | null;

                                              method getParentNode

                                              getParentNode: (count?: number) => T | null;

                                                method getValue

                                                getValue: () => T;
                                                • Deprecated

                                                  Please use AstPath#node or AstPath#siblings

                                                method map

                                                map: {
                                                <U>(callback: MapCallback<T, U>): U[];
                                                <U, P1 extends IterProperties<T>>(
                                                callback: MapCallback<IndexValue<T, P1>, U>,
                                                prop1: P1
                                                ): U[];
                                                <U, P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
                                                callback: MapCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
                                                prop1: P1,
                                                prop2: P2
                                                ): U[];
                                                <
                                                U,
                                                P1 extends keyof T,
                                                P2 extends IterProperties<T[P1]>,
                                                P3 extends IterProperties<IndexValue<T[P1], P2>>
                                                >(
                                                callback: MapCallback<
                                                IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
                                                U
                                                >,
                                                prop1: P1,
                                                prop2: P2,
                                                prop3: P3
                                                ): U[];
                                                <
                                                U,
                                                P1 extends keyof T,
                                                P2 extends IterProperties<T[P1]>,
                                                P3 extends IterProperties<IndexValue<T[P1], P2>>,
                                                P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>
                                                >(
                                                callback: MapCallback<
                                                IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
                                                U
                                                >,
                                                prop1: P1,
                                                prop2: P2,
                                                prop3: P3,
                                                prop4: P4
                                                ): U[];
                                                <U>(
                                                callback: MapCallback<any[], U>,
                                                prop1: PropertyKey,
                                                prop2: PropertyKey,
                                                prop3: PropertyKey,
                                                prop4: PropertyKey,
                                                ...props: PropertyKey[]
                                                ): U[];
                                                };

                                                  method match

                                                  match: (
                                                  ...predicates: ((
                                                  node: any,
                                                  name: string | null,
                                                  number: number | null
                                                  ) => boolean)[]
                                                  ) => boolean;

                                                    Interfaces

                                                    interface BaseSupportOption

                                                    interface BaseSupportOption<Type extends SupportOptionType> {}

                                                      property category

                                                      category: string;

                                                      property deprecated

                                                      deprecated?: true | string | undefined;
                                                      • Indicate that the option is deprecated.

                                                        Use a string to add an extra message to --help for the option, for example to suggest a replacement option.

                                                      property description

                                                      description?: string | undefined;
                                                      • Description to be displayed in --help. If omitted, the option won't be shown at all in --help.

                                                      property name

                                                      readonly name?: string | undefined;

                                                        property type

                                                        type: Type;
                                                        • The type of the option.

                                                          When passing a type other than the ones listed below, the option is treated as taking any string as argument, and --option <${type}> will be displayed in --help.

                                                        interface BooleanArraySupportOption

                                                        interface BooleanArraySupportOption extends BaseSupportOption<'boolean'> {}

                                                          property array

                                                          array: true;

                                                            property default

                                                            default?: Array<{ value: boolean[] }> | undefined;

                                                              interface BooleanSupportOption

                                                              interface BooleanSupportOption extends BaseSupportOption<'boolean'> {}

                                                                property array

                                                                array?: false | undefined;

                                                                  property default

                                                                  default?: boolean | undefined;

                                                                    property description

                                                                    description: string;

                                                                      property oppositeDescription

                                                                      oppositeDescription?: string | undefined;

                                                                        interface ChoiceSupportOption

                                                                        interface ChoiceSupportOption<Value = any> extends BaseSupportOption<'choice'> {}

                                                                          property choices

                                                                          choices: Array<{
                                                                          value: Value;
                                                                          description: string;
                                                                          }>;

                                                                            property default

                                                                            default?: Value | Array<{ value: Value }> | undefined;

                                                                              property description

                                                                              description: string;

                                                                                interface Config

                                                                                interface Config extends Options {}
                                                                                • For use in .prettierrc.js, .prettierrc.ts, .prettierrc.cjs, .prettierrc.cts, prettierrc.mjs, prettierrc.mts, prettier.config.js, prettier.config.ts, prettier.config.cjs, prettier.config.cts, prettier.config.mjs, prettier.config.mts

                                                                                property overrides

                                                                                overrides?: Array<{
                                                                                files: string | string[];
                                                                                excludeFiles?: string | string[];
                                                                                options?: Options;
                                                                                }>;

                                                                                  interface CursorOptions

                                                                                  interface CursorOptions extends Options {}

                                                                                    property cursorOffset

                                                                                    cursorOffset: number;
                                                                                    • Specify where the cursor is.

                                                                                    interface CursorResult

                                                                                    interface CursorResult {}

                                                                                      property cursorOffset

                                                                                      cursorOffset: number;

                                                                                        property formatted

                                                                                        formatted: string;

                                                                                          interface FileInfoOptions

                                                                                          interface FileInfoOptions {}

                                                                                            property ignorePath

                                                                                            ignorePath?: string | URL | (string | URL)[] | undefined;

                                                                                              property plugins

                                                                                              plugins?: Array<string | URL | Plugin> | undefined;

                                                                                                property resolveConfig

                                                                                                resolveConfig?: boolean | undefined;

                                                                                                  property withNodeModules

                                                                                                  withNodeModules?: boolean | undefined;

                                                                                                    interface FileInfoResult

                                                                                                    interface FileInfoResult {}

                                                                                                      property ignored

                                                                                                      ignored: boolean;

                                                                                                        property inferredParser

                                                                                                        inferredParser: string | null;

                                                                                                          interface IntArraySupportOption

                                                                                                          interface IntArraySupportOption extends BaseSupportOption<'int'> {}

                                                                                                            property array

                                                                                                            array: true;

                                                                                                              property default

                                                                                                              default?: Array<{ value: number[] }> | undefined;

                                                                                                                interface IntSupportOption

                                                                                                                interface IntSupportOption extends BaseSupportOption<'int'> {}

                                                                                                                  property array

                                                                                                                  array?: false | undefined;

                                                                                                                    property default

                                                                                                                    default?: number | undefined;

                                                                                                                      property range

                                                                                                                      range?: SupportOptionRange | undefined;

                                                                                                                        interface Options

                                                                                                                        interface Options extends Partial<RequiredOptions> {}

                                                                                                                          interface Parser

                                                                                                                          interface Parser<T = any> {}

                                                                                                                            property astFormat

                                                                                                                            astFormat: string;

                                                                                                                              property hasIgnorePragma

                                                                                                                              hasIgnorePragma?: ((text: string) => boolean) | undefined;

                                                                                                                                property hasPragma

                                                                                                                                hasPragma?: ((text: string) => boolean) | undefined;

                                                                                                                                  property locEnd

                                                                                                                                  locEnd: (node: T) => number;

                                                                                                                                    property locStart

                                                                                                                                    locStart: (node: T) => number;

                                                                                                                                      property parse

                                                                                                                                      parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;

                                                                                                                                        property preprocess

                                                                                                                                        preprocess?:
                                                                                                                                        | ((text: string, options: ParserOptions<T>) => string | Promise<string>)
                                                                                                                                        | undefined;

                                                                                                                                          interface ParserOptions

                                                                                                                                          interface ParserOptions<T = any> extends RequiredOptions {}

                                                                                                                                            property locEnd

                                                                                                                                            locEnd: (node: T) => number;

                                                                                                                                              property locStart

                                                                                                                                              locStart: (node: T) => number;

                                                                                                                                                property originalText

                                                                                                                                                originalText: string;

                                                                                                                                                  interface PathArraySupportOption

                                                                                                                                                  interface PathArraySupportOption extends BaseSupportOption<'path'> {}

                                                                                                                                                    property array

                                                                                                                                                    array: true;

                                                                                                                                                      property default

                                                                                                                                                      default?: Array<{ value: string[] }> | undefined;

                                                                                                                                                        interface PathSupportOption

                                                                                                                                                        interface PathSupportOption extends BaseSupportOption<'path'> {}

                                                                                                                                                          property array

                                                                                                                                                          array?: false | undefined;

                                                                                                                                                            property default

                                                                                                                                                            default?: string | undefined;

                                                                                                                                                              interface Plugin

                                                                                                                                                              interface Plugin<T = any> {}

                                                                                                                                                                property defaultOptions

                                                                                                                                                                defaultOptions?: Partial<RequiredOptions> | undefined;

                                                                                                                                                                  property languages

                                                                                                                                                                  languages?: SupportLanguage[] | undefined;

                                                                                                                                                                    property options

                                                                                                                                                                    options?: SupportOptions | undefined;

                                                                                                                                                                      property parsers

                                                                                                                                                                      parsers?: { [parserName: string]: Parser<T> } | undefined;

                                                                                                                                                                        property printers

                                                                                                                                                                        printers?: { [astFormat: string]: Printer<T> } | undefined;

                                                                                                                                                                          interface Printer

                                                                                                                                                                          interface Printer<T = any> {}

                                                                                                                                                                            property canAttachComment

                                                                                                                                                                            canAttachComment?: ((node: T, ancestors: T[]) => boolean) | undefined;

                                                                                                                                                                              property embed

                                                                                                                                                                              embed?:
                                                                                                                                                                              | ((
                                                                                                                                                                              path: AstPath,
                                                                                                                                                                              options: Options
                                                                                                                                                                              ) =>
                                                                                                                                                                              | ((
                                                                                                                                                                              textToDoc: (text: string, options: Options) => Promise<Doc>,
                                                                                                                                                                              print: (
                                                                                                                                                                              selector?: string | number | Array<string | number> | AstPath
                                                                                                                                                                              ) => Doc,
                                                                                                                                                                              path: AstPath,
                                                                                                                                                                              options: Options
                                                                                                                                                                              ) => Promise<Doc | undefined> | Doc | undefined)
                                                                                                                                                                              | Doc
                                                                                                                                                                              | null)
                                                                                                                                                                              | undefined;

                                                                                                                                                                                property getCommentChildNodes

                                                                                                                                                                                getCommentChildNodes?:
                                                                                                                                                                                | ((node: T, options: ParserOptions<T>) => T[] | undefined)
                                                                                                                                                                                | undefined;
                                                                                                                                                                                • By default, Prettier searches all object properties (except for a few predefined ones) of each node recursively. This function can be provided to override that behavior.

                                                                                                                                                                                  Parameter node

                                                                                                                                                                                  The node whose children should be returned.

                                                                                                                                                                                  Parameter options

                                                                                                                                                                                  Current options.

                                                                                                                                                                                  Returns

                                                                                                                                                                                  [] if the node has no children or undefined to fall back on the default behavior.

                                                                                                                                                                                property getVisitorKeys

                                                                                                                                                                                getVisitorKeys?:
                                                                                                                                                                                | ((node: T, nonTraversableKeys: Set<string>) => string[])
                                                                                                                                                                                | undefined;

                                                                                                                                                                                  property handleComments

                                                                                                                                                                                  handleComments?:
                                                                                                                                                                                  | {
                                                                                                                                                                                  ownLine?:
                                                                                                                                                                                  | ((
                                                                                                                                                                                  commentNode: any,
                                                                                                                                                                                  text: string,
                                                                                                                                                                                  options: ParserOptions<T>,
                                                                                                                                                                                  ast: T,
                                                                                                                                                                                  isLastComment: boolean
                                                                                                                                                                                  ) => boolean)
                                                                                                                                                                                  | undefined;
                                                                                                                                                                                  endOfLine?:
                                                                                                                                                                                  | ((
                                                                                                                                                                                  commentNode: any,
                                                                                                                                                                                  text: string,
                                                                                                                                                                                  options: ParserOptions<T>,
                                                                                                                                                                                  ast: T,
                                                                                                                                                                                  isLastComment: boolean
                                                                                                                                                                                  ) => boolean)
                                                                                                                                                                                  | undefined;
                                                                                                                                                                                  remaining?:
                                                                                                                                                                                  | ((
                                                                                                                                                                                  commentNode: any,
                                                                                                                                                                                  text: string,
                                                                                                                                                                                  options: ParserOptions<T>,
                                                                                                                                                                                  ast: T,
                                                                                                                                                                                  isLastComment: boolean
                                                                                                                                                                                  ) => boolean)
                                                                                                                                                                                  | undefined;
                                                                                                                                                                                  }
                                                                                                                                                                                  | undefined;

                                                                                                                                                                                    property hasPrettierIgnore

                                                                                                                                                                                    hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;

                                                                                                                                                                                      property insertPragma

                                                                                                                                                                                      insertPragma?: (text: string) => string;

                                                                                                                                                                                        property isBlockComment

                                                                                                                                                                                        isBlockComment?: ((node: T) => boolean) | undefined;

                                                                                                                                                                                          property massageAstNode

                                                                                                                                                                                          massageAstNode?: ((original: any, cloned: any, parent: any) => any) | undefined;
                                                                                                                                                                                          • Returns

                                                                                                                                                                                            anything if you want to replace the node with it

                                                                                                                                                                                          property preprocess

                                                                                                                                                                                          preprocess?: ((ast: T, options: ParserOptions<T>) => T | Promise<T>) | undefined;

                                                                                                                                                                                            property printComment

                                                                                                                                                                                            printComment?:
                                                                                                                                                                                            | ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
                                                                                                                                                                                            | undefined;

                                                                                                                                                                                              property willPrintOwnComments

                                                                                                                                                                                              willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;

                                                                                                                                                                                                method print

                                                                                                                                                                                                print: (
                                                                                                                                                                                                path: AstPath<T>,
                                                                                                                                                                                                options: ParserOptions<T>,
                                                                                                                                                                                                print: (path: AstPath<T>) => Doc,
                                                                                                                                                                                                args?: unknown
                                                                                                                                                                                                ) => Doc;

                                                                                                                                                                                                  method printPrettierIgnored

                                                                                                                                                                                                  printPrettierIgnored: (
                                                                                                                                                                                                  path: AstPath<T>,
                                                                                                                                                                                                  options: ParserOptions<T>,
                                                                                                                                                                                                  print: (path: AstPath<T>) => Doc,
                                                                                                                                                                                                  args?: unknown
                                                                                                                                                                                                  ) => Doc;

                                                                                                                                                                                                    interface RequiredOptions

                                                                                                                                                                                                    interface RequiredOptions extends doc.printer.Options {}

                                                                                                                                                                                                      property arrowParens

                                                                                                                                                                                                      arrowParens: 'avoid' | 'always';
                                                                                                                                                                                                      • Include parentheses around a sole arrow function parameter. "always"

                                                                                                                                                                                                      property bracketSameLine

                                                                                                                                                                                                      bracketSameLine: 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). false

                                                                                                                                                                                                      property bracketSpacing

                                                                                                                                                                                                      bracketSpacing: boolean;
                                                                                                                                                                                                      • Print spaces between brackets in object literals. true

                                                                                                                                                                                                      property checkIgnorePragma

                                                                                                                                                                                                      checkIgnorePragma: boolean;
                                                                                                                                                                                                      • Prettier can allow individual files to opt out of formatting if they contain a special comment, called a pragma, at the top of the file. false

                                                                                                                                                                                                      property embeddedLanguageFormatting

                                                                                                                                                                                                      embeddedLanguageFormatting: 'auto' | 'off';
                                                                                                                                                                                                      • Control whether Prettier formats quoted code embedded in the file. "auto"

                                                                                                                                                                                                      property endOfLine

                                                                                                                                                                                                      endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
                                                                                                                                                                                                      • Which end of line characters to apply. "lf"

                                                                                                                                                                                                      property experimentalOperatorPosition

                                                                                                                                                                                                      experimentalOperatorPosition: 'start' | 'end';
                                                                                                                                                                                                      • Where to print operators when binary expressions wrap lines. "end"

                                                                                                                                                                                                      property experimentalTernaries

                                                                                                                                                                                                      experimentalTernaries: boolean;
                                                                                                                                                                                                      • Use curious ternaries, with the question mark after the condition, instead of on the same line as the consequent. false

                                                                                                                                                                                                      property filepath

                                                                                                                                                                                                      filepath: string;
                                                                                                                                                                                                      • Specify the input filepath. This will be used to do parser inference.

                                                                                                                                                                                                      property htmlWhitespaceSensitivity

                                                                                                                                                                                                      htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
                                                                                                                                                                                                      • How to handle whitespaces in HTML. "css"

                                                                                                                                                                                                      property insertPragma

                                                                                                                                                                                                      insertPragma: boolean;
                                                                                                                                                                                                      • Prettier can insert a special 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 marker. false

                                                                                                                                                                                                      property jsxBracketSameLine

                                                                                                                                                                                                      jsxBracketSameLine?: boolean;
                                                                                                                                                                                                      • Put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line. false

                                                                                                                                                                                                        Deprecated

                                                                                                                                                                                                        use bracketSameLine instead

                                                                                                                                                                                                      property jsxSingleQuote

                                                                                                                                                                                                      jsxSingleQuote: boolean;
                                                                                                                                                                                                      • Use single quotes in JSX. false

                                                                                                                                                                                                      property objectWrap

                                                                                                                                                                                                      objectWrap: 'preserve' | 'collapse';
                                                                                                                                                                                                      • How to wrap object literals. "preserve"

                                                                                                                                                                                                      property parser

                                                                                                                                                                                                      parser: LiteralUnion<BuiltInParserName>;
                                                                                                                                                                                                      • Specify which parser to use.

                                                                                                                                                                                                      property plugins

                                                                                                                                                                                                      plugins: Array<string | URL | Plugin>;
                                                                                                                                                                                                      • Provide ability to support new languages to prettier.

                                                                                                                                                                                                      property proseWrap

                                                                                                                                                                                                      proseWrap: 'always' | 'never' | 'preserve';
                                                                                                                                                                                                      • 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. "preserve"

                                                                                                                                                                                                      property quoteProps

                                                                                                                                                                                                      quoteProps: 'as-needed' | 'consistent' | 'preserve';
                                                                                                                                                                                                      • Change when properties in objects are quoted. "as-needed"

                                                                                                                                                                                                      property rangeEnd

                                                                                                                                                                                                      rangeEnd: number;
                                                                                                                                                                                                      • Format only a segment of a file. Number.POSITIVE_INFINITY

                                                                                                                                                                                                      property rangeStart

                                                                                                                                                                                                      rangeStart: number;
                                                                                                                                                                                                      • Format only a segment of a file. 0

                                                                                                                                                                                                      property requirePragma

                                                                                                                                                                                                      requirePragma: boolean;
                                                                                                                                                                                                      • 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. false

                                                                                                                                                                                                      property semi

                                                                                                                                                                                                      semi: boolean;
                                                                                                                                                                                                      • Print semicolons at the ends of statements. true

                                                                                                                                                                                                      property singleAttributePerLine

                                                                                                                                                                                                      singleAttributePerLine: boolean;
                                                                                                                                                                                                      • Enforce single attribute per line in HTML, Vue and JSX. false

                                                                                                                                                                                                      property singleQuote

                                                                                                                                                                                                      singleQuote: boolean;
                                                                                                                                                                                                      • Use single quotes instead of double quotes. false

                                                                                                                                                                                                      property trailingComma

                                                                                                                                                                                                      trailingComma: 'none' | 'es5' | 'all';
                                                                                                                                                                                                      • Print trailing commas wherever possible. "all"

                                                                                                                                                                                                      property vueIndentScriptAndStyle

                                                                                                                                                                                                      vueIndentScriptAndStyle: boolean;
                                                                                                                                                                                                      • Whether or not to indent the code inside and tags in Vue files. false

                                                                                                                                                                                                      index signature

                                                                                                                                                                                                      [_: string]: unknown;
                                                                                                                                                                                                      • Arbitrary additional values on an options object are always allowed.

                                                                                                                                                                                                      interface ResolveConfigOptions

                                                                                                                                                                                                      interface ResolveConfigOptions {}

                                                                                                                                                                                                        property config

                                                                                                                                                                                                        config?: string | URL | undefined;
                                                                                                                                                                                                        • Pass directly the path of the config file if you don't wish to search for it.

                                                                                                                                                                                                        property editorconfig

                                                                                                                                                                                                        editorconfig?: boolean | undefined;
                                                                                                                                                                                                        • If set to true and an .editorconfig file is in your project, Prettier will parse it and convert its properties to the corresponding prettier configuration. This configuration will be overridden by .prettierrc, etc. Currently, the following EditorConfig properties are supported: - indent_style - indent_size/tab_width - max_line_length

                                                                                                                                                                                                        property useCache

                                                                                                                                                                                                        useCache?: boolean | undefined;
                                                                                                                                                                                                        • If set to false, all caching will be bypassed.

                                                                                                                                                                                                        interface StringArraySupportOption

                                                                                                                                                                                                        interface StringArraySupportOption extends BaseSupportOption<'string'> {}

                                                                                                                                                                                                          property array

                                                                                                                                                                                                          array: true;

                                                                                                                                                                                                            property default

                                                                                                                                                                                                            default?: Array<{ value: string[] }> | undefined;

                                                                                                                                                                                                              interface StringSupportOption

                                                                                                                                                                                                              interface StringSupportOption extends BaseSupportOption<'string'> {}

                                                                                                                                                                                                                property array

                                                                                                                                                                                                                array?: false | undefined;

                                                                                                                                                                                                                  property default

                                                                                                                                                                                                                  default?: string | undefined;

                                                                                                                                                                                                                    interface SupportInfo

                                                                                                                                                                                                                    interface SupportInfo {}

                                                                                                                                                                                                                      property languages

                                                                                                                                                                                                                      languages: SupportLanguage[];

                                                                                                                                                                                                                        property options

                                                                                                                                                                                                                        options: SupportOption[];

                                                                                                                                                                                                                          interface SupportInfoOptions

                                                                                                                                                                                                                          interface SupportInfoOptions {}

                                                                                                                                                                                                                            property plugins

                                                                                                                                                                                                                            plugins?: Array<string | URL | Plugin> | undefined;

                                                                                                                                                                                                                              property showDeprecated

                                                                                                                                                                                                                              showDeprecated?: boolean | undefined;

                                                                                                                                                                                                                                interface SupportLanguage

                                                                                                                                                                                                                                interface SupportLanguage {}

                                                                                                                                                                                                                                  property aceMode

                                                                                                                                                                                                                                  aceMode?: string | undefined;

                                                                                                                                                                                                                                    property aliases

                                                                                                                                                                                                                                    aliases?: string[] | undefined;

                                                                                                                                                                                                                                      property codemirrorMimeType

                                                                                                                                                                                                                                      codemirrorMimeType?: string | undefined;

                                                                                                                                                                                                                                        property codemirrorMode

                                                                                                                                                                                                                                        codemirrorMode?: string | undefined;

                                                                                                                                                                                                                                          property extensions

                                                                                                                                                                                                                                          extensions?: string[] | undefined;

                                                                                                                                                                                                                                            property filenames

                                                                                                                                                                                                                                            filenames?: string[] | undefined;

                                                                                                                                                                                                                                              property group

                                                                                                                                                                                                                                              group?: string | undefined;

                                                                                                                                                                                                                                                property interpreters

                                                                                                                                                                                                                                                interpreters?: string[] | undefined;

                                                                                                                                                                                                                                                  property isSupported

                                                                                                                                                                                                                                                  isSupported?: ((options: { filepath: string }) => boolean) | undefined;

                                                                                                                                                                                                                                                    property linguistLanguageId

                                                                                                                                                                                                                                                    linguistLanguageId?: number | undefined;

                                                                                                                                                                                                                                                      property name

                                                                                                                                                                                                                                                      name: string;

                                                                                                                                                                                                                                                        property parsers

                                                                                                                                                                                                                                                        parsers: BuiltInParserName[] | string[];

                                                                                                                                                                                                                                                          property tmScope

                                                                                                                                                                                                                                                          tmScope?: string | undefined;

                                                                                                                                                                                                                                                            property vscodeLanguageIds

                                                                                                                                                                                                                                                            vscodeLanguageIds?: string[] | undefined;

                                                                                                                                                                                                                                                              interface SupportOptionRange

                                                                                                                                                                                                                                                              interface SupportOptionRange {}

                                                                                                                                                                                                                                                                property end

                                                                                                                                                                                                                                                                end: number;

                                                                                                                                                                                                                                                                  property start

                                                                                                                                                                                                                                                                  start: number;

                                                                                                                                                                                                                                                                    property step

                                                                                                                                                                                                                                                                    step: number;

                                                                                                                                                                                                                                                                      interface SupportOptions

                                                                                                                                                                                                                                                                      interface SupportOptions extends Record<string, SupportOption> {}

                                                                                                                                                                                                                                                                        Type Aliases

                                                                                                                                                                                                                                                                        type AST

                                                                                                                                                                                                                                                                        type AST = any;

                                                                                                                                                                                                                                                                          type BuiltInParser

                                                                                                                                                                                                                                                                          type BuiltInParser = (text: string, options?: any) => AST;

                                                                                                                                                                                                                                                                            type BuiltInParserName

                                                                                                                                                                                                                                                                            type BuiltInParserName =
                                                                                                                                                                                                                                                                            | 'acorn'
                                                                                                                                                                                                                                                                            | 'angular'
                                                                                                                                                                                                                                                                            | 'babel-flow'
                                                                                                                                                                                                                                                                            | 'babel-ts'
                                                                                                                                                                                                                                                                            | 'babel'
                                                                                                                                                                                                                                                                            | 'css'
                                                                                                                                                                                                                                                                            | 'espree'
                                                                                                                                                                                                                                                                            | 'flow'
                                                                                                                                                                                                                                                                            | 'glimmer'
                                                                                                                                                                                                                                                                            | 'graphql'
                                                                                                                                                                                                                                                                            | 'html'
                                                                                                                                                                                                                                                                            | 'json-stringify'
                                                                                                                                                                                                                                                                            | 'json'
                                                                                                                                                                                                                                                                            | 'json5'
                                                                                                                                                                                                                                                                            | 'jsonc'
                                                                                                                                                                                                                                                                            | 'less'
                                                                                                                                                                                                                                                                            | 'lwc'
                                                                                                                                                                                                                                                                            | 'markdown'
                                                                                                                                                                                                                                                                            | 'mdx'
                                                                                                                                                                                                                                                                            | 'meriyah'
                                                                                                                                                                                                                                                                            | 'mjml'
                                                                                                                                                                                                                                                                            | 'scss'
                                                                                                                                                                                                                                                                            | 'typescript'
                                                                                                                                                                                                                                                                            | 'vue'
                                                                                                                                                                                                                                                                            | 'yaml';

                                                                                                                                                                                                                                                                              type BuiltInParsers

                                                                                                                                                                                                                                                                              type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;

                                                                                                                                                                                                                                                                                type CoreCategoryType

                                                                                                                                                                                                                                                                                type CoreCategoryType =
                                                                                                                                                                                                                                                                                | 'Config'
                                                                                                                                                                                                                                                                                | 'Editor'
                                                                                                                                                                                                                                                                                | 'Format'
                                                                                                                                                                                                                                                                                | 'Other'
                                                                                                                                                                                                                                                                                | 'Output'
                                                                                                                                                                                                                                                                                | 'Global'
                                                                                                                                                                                                                                                                                | 'Special';

                                                                                                                                                                                                                                                                                  type Doc

                                                                                                                                                                                                                                                                                  type Doc = doc.builders.Doc;

                                                                                                                                                                                                                                                                                    type FastPath

                                                                                                                                                                                                                                                                                    type FastPath<T = any> = AstPath<T>;
                                                                                                                                                                                                                                                                                    • Deprecated

                                                                                                                                                                                                                                                                                      FastPath was renamed to AstPath

                                                                                                                                                                                                                                                                                    type LiteralUnion

                                                                                                                                                                                                                                                                                    type LiteralUnion<T extends U, U = string> =
                                                                                                                                                                                                                                                                                    | T
                                                                                                                                                                                                                                                                                    | (Pick<U, never> & { _?: never | undefined });

                                                                                                                                                                                                                                                                                      type SupportOption

                                                                                                                                                                                                                                                                                      type SupportOption =
                                                                                                                                                                                                                                                                                      | IntSupportOption
                                                                                                                                                                                                                                                                                      | IntArraySupportOption
                                                                                                                                                                                                                                                                                      | StringSupportOption
                                                                                                                                                                                                                                                                                      | StringArraySupportOption
                                                                                                                                                                                                                                                                                      | BooleanSupportOption
                                                                                                                                                                                                                                                                                      | BooleanArraySupportOption
                                                                                                                                                                                                                                                                                      | ChoiceSupportOption
                                                                                                                                                                                                                                                                                      | PathSupportOption
                                                                                                                                                                                                                                                                                      | PathArraySupportOption;

                                                                                                                                                                                                                                                                                        type SupportOptionType

                                                                                                                                                                                                                                                                                        type SupportOptionType = 'int' | 'string' | 'boolean' | 'choice' | 'path';

                                                                                                                                                                                                                                                                                          Namespaces

                                                                                                                                                                                                                                                                                          namespace doc

                                                                                                                                                                                                                                                                                          namespace doc {}

                                                                                                                                                                                                                                                                                            namespace doc.builders

                                                                                                                                                                                                                                                                                            namespace doc.builders {}

                                                                                                                                                                                                                                                                                              variable breakParent

                                                                                                                                                                                                                                                                                              const breakParent: BreakParent;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent)

                                                                                                                                                                                                                                                                                              variable cursor

                                                                                                                                                                                                                                                                                              const cursor: Cursor;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor)

                                                                                                                                                                                                                                                                                              variable hardline

                                                                                                                                                                                                                                                                                              const hardline: Hardline;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline)

                                                                                                                                                                                                                                                                                              variable hardlineWithoutBreakParent

                                                                                                                                                                                                                                                                                              const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent)

                                                                                                                                                                                                                                                                                              variable line

                                                                                                                                                                                                                                                                                              const line: Line;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [line](https://github.com/prettier/prettier/blob/main/commands.md#line)

                                                                                                                                                                                                                                                                                              variable lineSuffixBoundary

                                                                                                                                                                                                                                                                                              const lineSuffixBoundary: LineSuffixBoundary;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary)

                                                                                                                                                                                                                                                                                              variable literalline

                                                                                                                                                                                                                                                                                              const literalline: LiteralLine;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline)

                                                                                                                                                                                                                                                                                              variable literallineWithoutBreakParent

                                                                                                                                                                                                                                                                                              const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent)

                                                                                                                                                                                                                                                                                              variable softline

                                                                                                                                                                                                                                                                                              const softline: Softline;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline)

                                                                                                                                                                                                                                                                                              variable trim

                                                                                                                                                                                                                                                                                              const trim: Trim;
                                                                                                                                                                                                                                                                                              • See Also

                                                                                                                                                                                                                                                                                                • [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim)

                                                                                                                                                                                                                                                                                              function addAlignmentToDoc

                                                                                                                                                                                                                                                                                              addAlignmentToDoc: (doc: Doc, size: number, tabWidth: number) => Doc;

                                                                                                                                                                                                                                                                                                function align

                                                                                                                                                                                                                                                                                                align: (widthOrString: Align['n'], doc: Doc) => Align;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [align](https://github.com/prettier/prettier/blob/main/commands.md#align)

                                                                                                                                                                                                                                                                                                function conditionalGroup

                                                                                                                                                                                                                                                                                                conditionalGroup: (alternatives: Doc[], options?: GroupOptions) => Group;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup)

                                                                                                                                                                                                                                                                                                function dedent

                                                                                                                                                                                                                                                                                                dedent: (doc: Doc) => Align;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent)

                                                                                                                                                                                                                                                                                                function dedentToRoot

                                                                                                                                                                                                                                                                                                dedentToRoot: (doc: Doc) => Align;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot)

                                                                                                                                                                                                                                                                                                function fill

                                                                                                                                                                                                                                                                                                fill: (docs: Doc[]) => Fill;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill)

                                                                                                                                                                                                                                                                                                function group

                                                                                                                                                                                                                                                                                                group: (doc: Doc, opts?: GroupOptions) => Group;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [group](https://github.com/prettier/prettier/blob/main/commands.md#group)

                                                                                                                                                                                                                                                                                                function ifBreak

                                                                                                                                                                                                                                                                                                ifBreak: (
                                                                                                                                                                                                                                                                                                ifBreak: Doc,
                                                                                                                                                                                                                                                                                                noBreak?: Doc,
                                                                                                                                                                                                                                                                                                options?: { groupId?: symbol | undefined }
                                                                                                                                                                                                                                                                                                ) => IfBreak;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak)

                                                                                                                                                                                                                                                                                                function indent

                                                                                                                                                                                                                                                                                                indent: (doc: Doc) => Indent;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent)

                                                                                                                                                                                                                                                                                                function indentIfBreak

                                                                                                                                                                                                                                                                                                indentIfBreak: (
                                                                                                                                                                                                                                                                                                doc: Doc,
                                                                                                                                                                                                                                                                                                opts: { groupId: symbol; negate?: boolean | undefined }
                                                                                                                                                                                                                                                                                                ) => IndentIfBreak;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak)

                                                                                                                                                                                                                                                                                                function join

                                                                                                                                                                                                                                                                                                join: (sep: Doc, docs: Doc[]) => Doc[];
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [join](https://github.com/prettier/prettier/blob/main/commands.md#join)

                                                                                                                                                                                                                                                                                                function label

                                                                                                                                                                                                                                                                                                label: (label: any | undefined, contents: Doc) => Doc;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [label](https://github.com/prettier/prettier/blob/main/commands.md#label)

                                                                                                                                                                                                                                                                                                function lineSuffix

                                                                                                                                                                                                                                                                                                lineSuffix: (suffix: Doc) => LineSuffix;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix)

                                                                                                                                                                                                                                                                                                function markAsRoot

                                                                                                                                                                                                                                                                                                markAsRoot: (doc: Doc) => Align;
                                                                                                                                                                                                                                                                                                • See Also

                                                                                                                                                                                                                                                                                                  • [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot)

                                                                                                                                                                                                                                                                                                interface Align

                                                                                                                                                                                                                                                                                                interface Align {}

                                                                                                                                                                                                                                                                                                  property contents

                                                                                                                                                                                                                                                                                                  contents: Doc;

                                                                                                                                                                                                                                                                                                    property n

                                                                                                                                                                                                                                                                                                    n: number | string | { type: 'root' };

                                                                                                                                                                                                                                                                                                      property type

                                                                                                                                                                                                                                                                                                      type: 'align';

                                                                                                                                                                                                                                                                                                        interface BreakParent

                                                                                                                                                                                                                                                                                                        interface BreakParent {}

                                                                                                                                                                                                                                                                                                          property type

                                                                                                                                                                                                                                                                                                          type: 'break-parent';

                                                                                                                                                                                                                                                                                                            interface Cursor

                                                                                                                                                                                                                                                                                                            interface Cursor {}

                                                                                                                                                                                                                                                                                                              property placeholder

                                                                                                                                                                                                                                                                                                              placeholder: symbol;

                                                                                                                                                                                                                                                                                                                property type

                                                                                                                                                                                                                                                                                                                type: 'cursor';

                                                                                                                                                                                                                                                                                                                  interface Fill

                                                                                                                                                                                                                                                                                                                  interface Fill {}

                                                                                                                                                                                                                                                                                                                    property parts

                                                                                                                                                                                                                                                                                                                    parts: Doc[];

                                                                                                                                                                                                                                                                                                                      property type

                                                                                                                                                                                                                                                                                                                      type: 'fill';

                                                                                                                                                                                                                                                                                                                        interface Group

                                                                                                                                                                                                                                                                                                                        interface Group {}

                                                                                                                                                                                                                                                                                                                          property break

                                                                                                                                                                                                                                                                                                                          break: boolean;

                                                                                                                                                                                                                                                                                                                            property contents

                                                                                                                                                                                                                                                                                                                            contents: Doc;

                                                                                                                                                                                                                                                                                                                              property expandedStates

                                                                                                                                                                                                                                                                                                                              expandedStates: Doc[];

                                                                                                                                                                                                                                                                                                                                property id

                                                                                                                                                                                                                                                                                                                                id?: symbol;

                                                                                                                                                                                                                                                                                                                                  property type

                                                                                                                                                                                                                                                                                                                                  type: 'group';

                                                                                                                                                                                                                                                                                                                                    interface GroupOptions

                                                                                                                                                                                                                                                                                                                                    interface GroupOptions {}

                                                                                                                                                                                                                                                                                                                                      property id

                                                                                                                                                                                                                                                                                                                                      id?: symbol | undefined;

                                                                                                                                                                                                                                                                                                                                        property shouldBreak

                                                                                                                                                                                                                                                                                                                                        shouldBreak?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                          interface HardlineWithoutBreakParent

                                                                                                                                                                                                                                                                                                                                          interface HardlineWithoutBreakParent extends Line {}

                                                                                                                                                                                                                                                                                                                                            property hard

                                                                                                                                                                                                                                                                                                                                            hard: true;

                                                                                                                                                                                                                                                                                                                                              interface IfBreak

                                                                                                                                                                                                                                                                                                                                              interface IfBreak {}

                                                                                                                                                                                                                                                                                                                                                property breakContents

                                                                                                                                                                                                                                                                                                                                                breakContents: Doc;

                                                                                                                                                                                                                                                                                                                                                  property flatContents

                                                                                                                                                                                                                                                                                                                                                  flatContents: Doc;

                                                                                                                                                                                                                                                                                                                                                    property type

                                                                                                                                                                                                                                                                                                                                                    type: 'if-break';

                                                                                                                                                                                                                                                                                                                                                      interface Indent

                                                                                                                                                                                                                                                                                                                                                      interface Indent {}

                                                                                                                                                                                                                                                                                                                                                        property contents

                                                                                                                                                                                                                                                                                                                                                        contents: Doc;

                                                                                                                                                                                                                                                                                                                                                          property type

                                                                                                                                                                                                                                                                                                                                                          type: 'indent';

                                                                                                                                                                                                                                                                                                                                                            interface IndentIfBreak

                                                                                                                                                                                                                                                                                                                                                            interface IndentIfBreak {}

                                                                                                                                                                                                                                                                                                                                                              property type

                                                                                                                                                                                                                                                                                                                                                              type: 'indent-if-break';

                                                                                                                                                                                                                                                                                                                                                                interface Label

                                                                                                                                                                                                                                                                                                                                                                interface Label {}

                                                                                                                                                                                                                                                                                                                                                                  property contents

                                                                                                                                                                                                                                                                                                                                                                  contents: Doc;

                                                                                                                                                                                                                                                                                                                                                                    property label

                                                                                                                                                                                                                                                                                                                                                                    label: any;

                                                                                                                                                                                                                                                                                                                                                                      property type

                                                                                                                                                                                                                                                                                                                                                                      type: 'label';

                                                                                                                                                                                                                                                                                                                                                                        interface Line

                                                                                                                                                                                                                                                                                                                                                                        interface Line {}

                                                                                                                                                                                                                                                                                                                                                                          property hard

                                                                                                                                                                                                                                                                                                                                                                          hard?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                            property literal

                                                                                                                                                                                                                                                                                                                                                                            literal?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                              property soft

                                                                                                                                                                                                                                                                                                                                                                              soft?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                                property type

                                                                                                                                                                                                                                                                                                                                                                                type: 'line';

                                                                                                                                                                                                                                                                                                                                                                                  interface LineSuffix

                                                                                                                                                                                                                                                                                                                                                                                  interface LineSuffix {}

                                                                                                                                                                                                                                                                                                                                                                                    property contents

                                                                                                                                                                                                                                                                                                                                                                                    contents: Doc;

                                                                                                                                                                                                                                                                                                                                                                                      property type

                                                                                                                                                                                                                                                                                                                                                                                      type: 'line-suffix';

                                                                                                                                                                                                                                                                                                                                                                                        interface LineSuffixBoundary

                                                                                                                                                                                                                                                                                                                                                                                        interface LineSuffixBoundary {}

                                                                                                                                                                                                                                                                                                                                                                                          property type

                                                                                                                                                                                                                                                                                                                                                                                          type: 'line-suffix-boundary';

                                                                                                                                                                                                                                                                                                                                                                                            interface LiterallineWithoutBreakParent

                                                                                                                                                                                                                                                                                                                                                                                            interface LiterallineWithoutBreakParent extends Line {}

                                                                                                                                                                                                                                                                                                                                                                                              property hard

                                                                                                                                                                                                                                                                                                                                                                                              hard: true;

                                                                                                                                                                                                                                                                                                                                                                                                property literal

                                                                                                                                                                                                                                                                                                                                                                                                literal: true;

                                                                                                                                                                                                                                                                                                                                                                                                  interface Softline

                                                                                                                                                                                                                                                                                                                                                                                                  interface Softline extends Line {}

                                                                                                                                                                                                                                                                                                                                                                                                    property soft

                                                                                                                                                                                                                                                                                                                                                                                                    soft: true;

                                                                                                                                                                                                                                                                                                                                                                                                      interface Trim

                                                                                                                                                                                                                                                                                                                                                                                                      interface Trim {}

                                                                                                                                                                                                                                                                                                                                                                                                        property type

                                                                                                                                                                                                                                                                                                                                                                                                        type: 'trim';

                                                                                                                                                                                                                                                                                                                                                                                                          type Doc

                                                                                                                                                                                                                                                                                                                                                                                                          type Doc = string | Doc[] | DocCommand;

                                                                                                                                                                                                                                                                                                                                                                                                            type DocCommand

                                                                                                                                                                                                                                                                                                                                                                                                            type DocCommand =
                                                                                                                                                                                                                                                                                                                                                                                                            | Align
                                                                                                                                                                                                                                                                                                                                                                                                            | BreakParent
                                                                                                                                                                                                                                                                                                                                                                                                            | Cursor
                                                                                                                                                                                                                                                                                                                                                                                                            | Fill
                                                                                                                                                                                                                                                                                                                                                                                                            | Group
                                                                                                                                                                                                                                                                                                                                                                                                            | IfBreak
                                                                                                                                                                                                                                                                                                                                                                                                            | Indent
                                                                                                                                                                                                                                                                                                                                                                                                            | IndentIfBreak
                                                                                                                                                                                                                                                                                                                                                                                                            | Label
                                                                                                                                                                                                                                                                                                                                                                                                            | Line
                                                                                                                                                                                                                                                                                                                                                                                                            | LineSuffix
                                                                                                                                                                                                                                                                                                                                                                                                            | LineSuffixBoundary
                                                                                                                                                                                                                                                                                                                                                                                                            | Trim;

                                                                                                                                                                                                                                                                                                                                                                                                              type Hardline

                                                                                                                                                                                                                                                                                                                                                                                                              type Hardline = [HardlineWithoutBreakParent, BreakParent];

                                                                                                                                                                                                                                                                                                                                                                                                                type LiteralLine

                                                                                                                                                                                                                                                                                                                                                                                                                type LiteralLine = [LiterallineWithoutBreakParent, BreakParent];

                                                                                                                                                                                                                                                                                                                                                                                                                  namespace doc.printer

                                                                                                                                                                                                                                                                                                                                                                                                                  namespace doc.printer {}

                                                                                                                                                                                                                                                                                                                                                                                                                    function printDocToString

                                                                                                                                                                                                                                                                                                                                                                                                                    printDocToString: (
                                                                                                                                                                                                                                                                                                                                                                                                                    doc: builders.Doc,
                                                                                                                                                                                                                                                                                                                                                                                                                    options: Options
                                                                                                                                                                                                                                                                                                                                                                                                                    ) => {
                                                                                                                                                                                                                                                                                                                                                                                                                    formatted: string;
                                                                                                                                                                                                                                                                                                                                                                                                                    cursorNodeStart?: number | undefined;
                                                                                                                                                                                                                                                                                                                                                                                                                    cursorNodeText?: string | undefined;
                                                                                                                                                                                                                                                                                                                                                                                                                    };

                                                                                                                                                                                                                                                                                                                                                                                                                      interface Options

                                                                                                                                                                                                                                                                                                                                                                                                                      interface Options {}

                                                                                                                                                                                                                                                                                                                                                                                                                        property parentParser

                                                                                                                                                                                                                                                                                                                                                                                                                        parentParser?: string | undefined;

                                                                                                                                                                                                                                                                                                                                                                                                                          property printWidth

                                                                                                                                                                                                                                                                                                                                                                                                                          printWidth: number;
                                                                                                                                                                                                                                                                                                                                                                                                                          • Specify the line length that the printer will wrap on. 80

                                                                                                                                                                                                                                                                                                                                                                                                                          property tabWidth

                                                                                                                                                                                                                                                                                                                                                                                                                          tabWidth: number;
                                                                                                                                                                                                                                                                                                                                                                                                                          • Specify the number of spaces per indentation-level. 2

                                                                                                                                                                                                                                                                                                                                                                                                                          property useTabs

                                                                                                                                                                                                                                                                                                                                                                                                                          useTabs?: boolean;
                                                                                                                                                                                                                                                                                                                                                                                                                          • Indent lines with tabs instead of spaces false

                                                                                                                                                                                                                                                                                                                                                                                                                          namespace doc.utils

                                                                                                                                                                                                                                                                                                                                                                                                                          namespace doc.utils {}

                                                                                                                                                                                                                                                                                                                                                                                                                            function canBreak

                                                                                                                                                                                                                                                                                                                                                                                                                            canBreak: (doc: builders.Doc) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                              function findInDoc

                                                                                                                                                                                                                                                                                                                                                                                                                              findInDoc: <T = builders.Doc>(
                                                                                                                                                                                                                                                                                                                                                                                                                              doc: builders.Doc,
                                                                                                                                                                                                                                                                                                                                                                                                                              callback: (doc: builders.Doc) => T,
                                                                                                                                                                                                                                                                                                                                                                                                                              defaultValue: T
                                                                                                                                                                                                                                                                                                                                                                                                                              ) => T;

                                                                                                                                                                                                                                                                                                                                                                                                                                function mapDoc

                                                                                                                                                                                                                                                                                                                                                                                                                                mapDoc: <T = builders.Doc>(
                                                                                                                                                                                                                                                                                                                                                                                                                                doc: builders.Doc,
                                                                                                                                                                                                                                                                                                                                                                                                                                callback: (doc: builders.Doc) => T
                                                                                                                                                                                                                                                                                                                                                                                                                                ) => T;

                                                                                                                                                                                                                                                                                                                                                                                                                                  function removeLines

                                                                                                                                                                                                                                                                                                                                                                                                                                  removeLines: (doc: builders.Doc) => builders.Doc;

                                                                                                                                                                                                                                                                                                                                                                                                                                    function replaceEndOfLine

                                                                                                                                                                                                                                                                                                                                                                                                                                    replaceEndOfLine: (
                                                                                                                                                                                                                                                                                                                                                                                                                                    doc: builders.Doc,
                                                                                                                                                                                                                                                                                                                                                                                                                                    replacement?: builders.Doc
                                                                                                                                                                                                                                                                                                                                                                                                                                    ) => builders.Doc;

                                                                                                                                                                                                                                                                                                                                                                                                                                      function stripTrailingHardline

                                                                                                                                                                                                                                                                                                                                                                                                                                      stripTrailingHardline: (doc: builders.Doc) => builders.Doc;

                                                                                                                                                                                                                                                                                                                                                                                                                                        function traverseDoc

                                                                                                                                                                                                                                                                                                                                                                                                                                        traverseDoc: (
                                                                                                                                                                                                                                                                                                                                                                                                                                        doc: builders.Doc,
                                                                                                                                                                                                                                                                                                                                                                                                                                        onEnter?: (doc: builders.Doc) => void | boolean,
                                                                                                                                                                                                                                                                                                                                                                                                                                        onExit?: (doc: builders.Doc) => void,
                                                                                                                                                                                                                                                                                                                                                                                                                                        shouldTraverseConditionalGroups?: boolean
                                                                                                                                                                                                                                                                                                                                                                                                                                        ) => void;

                                                                                                                                                                                                                                                                                                                                                                                                                                          function willBreak

                                                                                                                                                                                                                                                                                                                                                                                                                                          willBreak: (doc: builders.Doc) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                            namespace util

                                                                                                                                                                                                                                                                                                                                                                                                                                            namespace util {}

                                                                                                                                                                                                                                                                                                                                                                                                                                              function addDanglingComment

                                                                                                                                                                                                                                                                                                                                                                                                                                              addDanglingComment: (node: any, comment: any, marker: any) => void;

                                                                                                                                                                                                                                                                                                                                                                                                                                                function addLeadingComment

                                                                                                                                                                                                                                                                                                                                                                                                                                                addLeadingComment: (node: any, comment: any) => void;

                                                                                                                                                                                                                                                                                                                                                                                                                                                  function addTrailingComment

                                                                                                                                                                                                                                                                                                                                                                                                                                                  addTrailingComment: (node: any, comment: any) => void;

                                                                                                                                                                                                                                                                                                                                                                                                                                                    function getAlignmentSize

                                                                                                                                                                                                                                                                                                                                                                                                                                                    getAlignmentSize: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                    text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                    tabWidth: number,
                                                                                                                                                                                                                                                                                                                                                                                                                                                    startIndex?: number | undefined
                                                                                                                                                                                                                                                                                                                                                                                                                                                    ) => number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                      function getIndentSize

                                                                                                                                                                                                                                                                                                                                                                                                                                                      getIndentSize: (value: string, tabWidth: number) => number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                        function getMaxContinuousCount

                                                                                                                                                                                                                                                                                                                                                                                                                                                        getMaxContinuousCount: (text: string, searchString: string) => number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                          function getNextNonSpaceNonCommentCharacter

                                                                                                                                                                                                                                                                                                                                                                                                                                                          getNextNonSpaceNonCommentCharacter: (text: string, startIndex: number) => string;

                                                                                                                                                                                                                                                                                                                                                                                                                                                            function getNextNonSpaceNonCommentCharacterIndex

                                                                                                                                                                                                                                                                                                                                                                                                                                                            getNextNonSpaceNonCommentCharacterIndex: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                            text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                            startIndex: number
                                                                                                                                                                                                                                                                                                                                                                                                                                                            ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                              function getPreferredQuote

                                                                                                                                                                                                                                                                                                                                                                                                                                                              getPreferredQuote: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                              text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                              preferredQuoteOrPreferSingleQuote: Quote | boolean
                                                                                                                                                                                                                                                                                                                                                                                                                                                              ) => Quote;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                function getStringWidth

                                                                                                                                                                                                                                                                                                                                                                                                                                                                getStringWidth: (text: string) => number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  function hasNewline

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  hasNewline: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  startIndex: number,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  options?: SkipOptions | undefined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function hasNewlineInRange

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    hasNewlineInRange: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    startIndex: number,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    endIndex: number
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      function hasSpaces

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      hasSpaces: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      startIndex: number,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options?: SkipOptions | undefined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        function isNextLineEmpty

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        isNextLineEmpty: (text: string, startIndex: number) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          function isPreviousLineEmpty

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          isPreviousLineEmpty: (text: string, startIndex: number) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                            function makeString

                                                                                                                                                                                                                                                                                                                                                                                                                                                                            makeString: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            rawText: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            enclosingQuote: Quote,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            unescapeUnnecessaryEscapes?: boolean | undefined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ) => string;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              function skip

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              skip: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              characters: string | RegExp
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ) => (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              options?: SkipOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                function skipEverythingButNewLine

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                skipEverythingButNewLine: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                options?: SkipOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  function skipInlineComment

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  skipInlineComment: (text: string, startIndex: number | false) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function skipNewline

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    skipNewline: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    options?: SkipOptions | undefined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      function skipSpaces

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      skipSpaces: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options?: SkipOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        function skipToLineEnd

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        skipToLineEnd: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        options?: SkipOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          function skipTrailingComment

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          skipTrailingComment: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (text: string, startIndex: number | false): number | false;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (text: string, startIndex: number | false): number | false;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          };

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            function skipWhitespace

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            skipWhitespace: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            text: string,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            startIndex: number | false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            options?: SkipOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ) => number | false;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              interface SkipOptions

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              interface SkipOptions {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                property backwards

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                backwards?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  type Quote

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  type Quote = "'" | '"';

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Package Files (2)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    No dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/prettier.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/prettier)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/prettier"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>