@envsa/prettier-config
Version:
Prettier configuration for @envsa/shared-config.
54 lines (53 loc) • 2.3 kB
TypeScript
import { Config } from "prettier";
import { Options } from "prettier-plugin-jsdoc";
//#region src/config.d.ts
type PrettierConfig = Config & Options;
declare const sharedPrettierConfig: PrettierConfig;
/**
* **@Envsa's Shared Prettier Configuration**
*
* @example
* export default prettierConfig({
* printWidth: 120,
* });
*
* @see [@envsa/prettier-config](https://github.com/envsa/shared-config/tree/main/packages/prettier-config)
* @see [@envsa/shared-config](https://github.com/envsa/shared-config)
*/
declare function prettierConfig(config?: PrettierConfig): PrettierConfig;
//#endregion
//#region src/api.d.ts
/**
* File extension or filepath hint for parser inference and config override
* matching. Accepts a bare extension (e.g. `'md'`), a virtual filename (e.g.
* `'file.md'`), or a full path. Known extensions supported by the default
* shared config are offered as autocomplete suggestions.
*/
type FileType = 'bash' | 'css' | 'fish' | 'html' | 'js' | 'json' | 'md' | 'php' | 'sh' | 'svelte' | 'ts' | 'twig' | 'xml' | 'yml' | 'zsh' | (string & {});
/**
* Format a source string using the shared Prettier configuration.
*
* @param source - The source code to format.
* @param fileTypeOrConfig - A file extension (e.g. `'md'`), virtual filepath
* (e.g. `'file.md'`), or a `PrettierConfig` object for overrides. Defaults to
* `'ts'` (TypeScript parser).
* @param config - Optional `PrettierConfig` overrides when a file type is
* provided as the second argument.
*
* @returns The formatted source string.
*/
declare function fix(source: string, fileTypeOrConfig?: FileType | PrettierConfig, config?: PrettierConfig): Promise<string>;
/**
* Format a file in place using the shared Prettier configuration.
*
* @param filePath - Path to the file to format.
* @param config - Optional `PrettierConfig` overrides.
*/
declare function fixFile(filePath: string, config?: PrettierConfig): Promise<void>;
/**
* Clear the cached Prettier module and resolved plugin paths. Subsequent calls
* to `fix` or `fixFile` will re-import Prettier and re-resolve plugins.
*/
declare function clearCache(): void;
//#endregion
export { type FileType, type PrettierConfig, clearCache, sharedPrettierConfig as default, sharedPrettierConfig, fix, fixFile, prettierConfig };