format_file.ts

view source

Declarations
#

3 declarations

format_file
#

format_file.ts view source

(content: string, options?: FormatFileOptions): string import {format_file} from '@fuzdev/gro/format_file.js';

Formats a string of source code in-process. Passes the input through unchanged when the language is unsupported (an expected no-op), but throws when the formatter rejects the source — e.g. a syntax error — so callers can decide whether to log, skip, or fail rather than silently treating broken input as already-formatted.

content

the source to format

type string

options

a filepath to infer the language, or an explicit lang

default {}

returns

string

FormatFileOptions
#

format_file.ts view source

FormatFileOptions import type {FormatFileOptions} from '@fuzdev/gro/format_file.js';

filepath?

The file path, used to infer the language from its extension.

type string

lang?

The language to format as, overriding any inference from filepath.

type FormatLang

FormatLang
#

format_file.ts view source

FormatLang

type "typescript" | "svelte" | "css" | "json"

import type {FormatLang} from '@fuzdev/gro/format_file.js';

The source languages Gro can format in-process, backed by @fuzdev/tsv (typescript/svelte/css) plus a builtin json formatter. Anything else passes through unchanged.

Imported by
#