/** * Deterministic, tested helper for the contribution polish pass: detect the * formatter a target repository already uses from its OWN config and declared * dependencies, so the polish pass can tidy only the lines this run added with * the repo's native tool (never installing or imposing one). * * Pure over inputs the caller has already read (parsed package.json, the list * of root config-file basenames, the pyproject.toml text) — no I/O — so it is * unit-testable, the same house style as `commit-convention.ts`. The bash copy * in `ralph-run.sh` (`detect_formatter`) gathers those inputs from disk and * mirrors this logic. */ /** The formatters the polish pass knows how to invoke, or `'none'`. */ export type FormatterId = 'prettier' | 'eslint' | 'black' | 'gofmt' | 'none'; /** A detected formatter and the command that formats specific files in place. */ export interface DetectedFormatter { formatter: FormatterId; /** * Argv string the caller appends file paths to (e.g. `prettier --write`). * `null` when `formatter === 'none'` — nothing to run. */ command: string | null; } /** A minimal view of the fields of package.json this detector reads. */ export interface PackageJsonLike { dependencies?: Record; devDependencies?: Record; } /** Inputs the caller reads from the repo root; every field is optional. */ export interface FormatterDetectionInput { /** Parsed package.json, or undefined when the repo has none. */ packageJson?: PackageJsonLike; /** Basenames of files present at the repo root (e.g. `['.prettierrc', 'go.mod']`). */ configFiles?: string[]; /** Contents of `pyproject.toml`, when present, for the `[tool.black]` check. */ pyprojectText?: string; } /** * Detect the repo's own formatter. Priority — JS first (most explicit config), * then Python, then Go — matching how a repo that declares several would expect * its primary formatter to win: * * 1. `prettier` — a `prettier` dependency or a prettier config file. * 2. `eslint` — an `eslint` dependency or an eslint config file (`--fix`). * 3. `black` — a `pyproject.toml` whose text declares `[tool.black]`. * 4. `gofmt` — a `go.mod` at the repo root (gofmt ships with the Go toolchain). * 5. `none` — nothing detected; the polish pass applies no formatting. */ export declare function detectFormatter(input: FormatterDetectionInput): DetectedFormatter; //# sourceMappingURL=formatter-detection.d.ts.map