API Reference / @gtkx/testing / prettyFormat / PrettyFormatOptions
Interface: PrettyFormatOptions
Properties
callToJSON?
optionalcallToJSON?:boolean
Call toJSON on objects before formatting them. Ignored after the formatter has already called toJSON once for a value.
Default
truecompareKeys?
optionalcompareKeys?:CompareKeys
Compare function used when sorting object keys. Set to null to disable sorting.
escapeRegex?
optionalescapeRegex?:boolean
Whether to escape special characters in regular expressions.
Default
falseescapeString?
optionalescapeString?:boolean
Whether to escape special characters in strings.
Default
truehighlight?
optionalhighlight?:boolean
Whether to highlight syntax using terminal colors.
Default
falseindent?
optionalindent?:number
Number of spaces to use for each level of indentation.
Default
2maxDepth?
optionalmaxDepth?:number
Maximum depth to recurse into nested values.
Default
InfinitymaxOutputLength?
optionalmaxOutputLength?:number
Approximate per-depth-level budget for output length. When the accumulated output at any single depth level exceeds this value, further nesting is collapsed. This is a heuristic safety valve, not a hard limit — total output can reach up to roughly maxDepth × maxOutputLength.
Default
1_000_000maxWidth?
optionalmaxWidth?:number
Maximum number of items to print in arrays, sets, maps, and similar collections.
Default
Infinitymin?
optionalmin?:boolean
Whether to minimize added whitespace, including indentation and line breaks.
When true, pretty-format defaults spacingInner to ' ', spacingOuter to '', and ignores indentation. It also changes the default for printBasicPrototype from true to false, although an explicit printBasicPrototype still wins. Explicit spacingInner / spacingOuter overrides still apply.
Default
falseplugins?
optionalplugins?:Plugins
Plugins used to serialize application-specific data types.
Default
[]printBasicPrototype?
optionalprintBasicPrototype?:boolean
Whether to print Object / Array prefixes for plain objects and arrays.
Defaults to true, unless min is true, in which case it defaults to false. An explicit printBasicPrototype value always overrides the min default.
printFunctionName?
optionalprintFunctionName?:boolean
Whether to include the function name when formatting functions.
Default
trueprintShadowRoot?
optionalprintShadowRoot?:boolean
Whether to include shadow-root contents when formatting DOM nodes.
Default
truequoteKeys?
optionalquoteKeys?:boolean
Whether to always quote object property keys.
For example: {"a": 1} when true{a: 1} when false and the key is a valid identifier {"my-key": 1} still stays quoted because it is not a valid identifier
Default
truesingleQuote?
optionalsingleQuote?:boolean
Whether to print strings using single quotes instead of double quotes.
For example: "hello" when false'hello' when true
Default
falsespacingInner?
optionalspacingInner?:string
Whitespace inserted after commas between items or entries.
For example, in {a: 1, b: 2} or [1, 2], this controls the gap after each comma: {a: 1,${spacingInner}b: 2}[1,${spacingInner}2]
Defaults to '\n' in regular mode and ' ' when min is true. Can be overridden independently of min.
spacingOuter?
optionalspacingOuter?:string
Whitespace inserted immediately inside collection/object delimiters.
For example, this controls the space or newline right after the opening delimiter and right before the closing delimiter: {${spacingOuter}a: 1${spacingOuter}}[${spacingOuter}1${spacingOuter}]
Defaults to '\n' in regular mode and '' when min is true. Can be overridden independently of min.