Skip to content

FormatLoader

Format loader — parses file content into a config object.

Register custom config formats by providing file extensions and a parser. Parsers may return any parsed value; discoverConfig validates that the result is a plain object before feeding it into the resolution chain.

Implementations should throw on syntax or shape errors; the caller wraps those failures as CLIError with code CONFIG_PARSE_ERROR.

Signatures

ts
interface FormatLoader {}

Members

Properties

extensions

File extensions this loader handles (without leading dot, e.g. 'toml').

ts
extensions: readonly string[];

parse

Parse file content into a config value.

Arrays, primitives, and null are allowed at this boundary so generic parsers like Bun.YAML.parse can be passed directly. Those values are still rejected by discoverConfig, which requires a plain object.

ts
parse: { (content: string): unknown; };

See Also

Released under the MIT License.