diff --git a/packages/format-json/README.md b/packages/format-json/README.md index fe12e98c6..a32c2aabd 100644 --- a/packages/format-json/README.md +++ b/packages/format-json/README.md @@ -52,6 +52,13 @@ export type JsonFormatterOptions = { * @default "lingui" */ style?: "lingui" | "minimal" + + /** + * Indentation of output JSON + * + * @default 2 + */ + indentation?: number } ``` diff --git a/packages/format-json/src/json.ts b/packages/format-json/src/json.ts index 305ab72ce..b9684c45b 100644 --- a/packages/format-json/src/json.ts +++ b/packages/format-json/src/json.ts @@ -28,6 +28,13 @@ export type JsonFormatterOptions = { * @default "lingui" */ style?: "lingui" | "minimal" + + /** + * Indentation of output JSON + * + * @default 2 + */ + indentation?: number } type NoOriginsCatalogType = { @@ -87,7 +94,10 @@ export function formatter( outputCatalog = serializeMinimal(outputCatalog) } - return JSON.stringify(outputCatalog, null, 2) + trailingNewLine + return ( + JSON.stringify(outputCatalog, null, options.indentation ?? 2) + + trailingNewLine + ) }, parse(content) {