interface PrettyPrinterService

Service providing syntax based pretty printing of text for the CLI using prettier.

Methods

registerSyntax(
syntaxName: string,
syntaxDefinition: Plugin<unknown>,
): Promise<void>

Register a new syntax.

The recommended way to define a new language syntax plugin is to follow the instructions here:

https://prettier.io/docs/plugins#developing-plugins

There is a list of already defined languages available for import here:

getRegisteredSyntaxes(): Promise<ReadonlyArray<string>>

Return the names of the currently registered syntaxes.

prettify(
text: string,
syntaxName: string,
): Promise<string>

Return a pretty printed version of the provided text using the specified syntax.

Usage

import type PrettyPrinterService from ".";