import { type Options } from 'prettier'; import { type Logger } from '../../utils/logging.js'; /** * Infers a parser for the specified filepath. * * This is a cut-down version of Prettier's built-in function of the same name; * ours operates purely on the `filepath` string and does not perform file I/O. * Prettier's internal `getInterpreter` function can open a file to read the * shebang, and its file descriptor usage can throw warnings on worker threads: * * ```console * Warning: File descriptor 123 closed but not opened in unmanaged mode * at Object.closeSync (node:fs:530:11) * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20) * ... * ``` * * References: * * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167 * - seek-oss/skuba#659 */ export declare const inferParser: (filepath: string) => Promise; interface File { data: string; options: Options; filepath: string; } interface Result { count: number; errored: Array<{ err?: unknown; filepath: string; }>; touched: string[]; unparsed: string[]; } export declare const formatOrLintFile: ({ data, filepath, options }: File, mode: "format" | "lint", result: Result | null) => Promise; export interface PrettierOutput { ok: boolean; result: Result; } /** * Formats/lints files with Prettier. * * Prettier doesn't provide a higher-level Node.js API that replicates the * behaviour of its CLI, so we have to plumb together its lower-level functions. * On the other hand, this affords more flexibility in how we track and report * on progress and results. */ export declare const runPrettier: (mode: "format" | "lint", logger: Logger, cwd?: string) => Promise; export {};