import { FormatConfig } from "oxfmt"; //#region src/types.d.ts /** * Object-form editorconfig option, enabling fine-grained control. */ interface EditorconfigOption { /** * When `true`, only look for `.editorconfig` in the `cwd` directory itself * (no upward traversal). * * @default false */ onlyCwd?: boolean; /** * Override the directory from which `.editorconfig` resolution starts. * When set, editorconfig is searched from this directory instead of from * the config file's directory (or the top-level `cwd`). * * This is useful when the oxfmt config path is pre-resolved and you still * want editorconfig to be resolved relative to each file's directory. */ cwd?: string; } /** * Format option override for a single matching rule */ interface OxfmtConfigOverride { /** * Glob patterns to match files */ files: string[]; /** * Glob patterns to exclude files */ excludeFiles?: string[]; /** * Format options to apply */ options?: FormatConfig; } interface LoadOxfmtConfigOptions { /** * Path to the configuration file */ configPath?: string; /** * Current working directory */ cwd?: string; /** * Whether to use cache */ useCache?: boolean; /** * Control `.editorconfig` reading. * - `true` (default): read and merge `.editorconfig`, walking up from the config * file's directory (or `cwd` when no config path is given). * - `false`: disable `.editorconfig` reading entirely. * - `EditorconfigOption`: enable with additional settings (e.g. `onlyCwd`). * * @default true */ editorconfig?: boolean | EditorconfigOption; } /** * Final oxfmt options (including overrides) */ interface OxfmtOptions extends FormatConfig { /** * Ignore files matching these glob patterns * Patterns are based on the location of the Oxfmt configuration file */ ignorePatterns?: string[]; /** * Array of format option overrides */ overrides?: OxfmtConfigOverride[]; } /** * Result object with metadata about resolved oxfmt config. */ interface LoadOxfmtConfigResult { /** * Final merged config (oxfmt + optional editorconfig mapping) */ config: OxfmtOptions; /** * Absolute path of resolved config file */ filepath?: string; /** * Directory of resolved config file */ dirname?: string; } /** * Options for resolving whether a single file should be ignored. */ interface IsOxfmtIgnoredOptions { /** * Current working directory. * Also the base directory for default `.prettierignore` lookup. */ cwd?: string; /** * File path to test. */ filepath: string; /** * Explicit oxfmt config path. * When provided, nested config lookup is disabled (same as oxfmt CLI -c). */ configPath?: string; /** * Ignore files to use instead of default `.gitignore` hierarchy + cwd `.prettierignore`. * Can be passed multiple times in CLI style. */ ignorePath?: string | string[]; /** * Whether node_modules should be included. * @default false */ withNodeModules?: boolean; /** * Disable nested config lookup. * @default false */ disableNestedConfig?: boolean; /** * Whether to use in-memory cache. * @default true */ useCache?: boolean; /** * Whether to include ignore patterns defined in the config file. * @default true */ includeConfigIgnorePatterns?: boolean; /** * Whether to load resolved oxfmt config when evaluating config ignore patterns. * When false, only global ignore is applied and config loading is skipped. * @default true */ loadConfigForIgnorePatterns?: boolean; } /** * Ignore resolution result. */ interface IsOxfmtIgnoredResult { /** * Whether the file should be ignored. */ ignored: boolean; /** * Matched ignore source. */ reason?: 'default-dir' | 'lockfile' | 'gitignore' | 'git-info-exclude' | 'prettierignore' | 'ignore-path' | 'config-ignore-patterns'; } //#endregion //#region src/config-file.d.ts /** * Resolve the oxfmt config file path. * * - If `configPath` is provided, absolute paths are returned as-is; * relative paths are joined to `cwd`. * - Otherwise, walk upward from `cwd` to find known filenames. * * @param cwd - Starting directory for resolution. * @param configPath - Optional explicit path. * @returns Absolute path to config file, or undefined when not found. * * @example * ```ts * import { resolveOxfmtrcPath } from 'load-oxfmt-config' * * const path = await resolveOxfmtrcPath(process.cwd()) * ``` */ declare function resolveOxfmtrcPath(cwd: string, configPath?: string): Promise; //#endregion //#region src/core.d.ts /** * Resolve config + editorconfig and return merged config with metadata. * * @param options - Loader settings. * @returns Merged config and optional resolved config metadata. * * @example * ```ts * import { loadOxfmtConfig } from 'load-oxfmt-config' * * const result = await loadOxfmtConfig({ cwd: process.cwd() }) * console.log(result.config) * ``` */ declare function loadOxfmtConfig(options?: LoadOxfmtConfigOptions): Promise; //#endregion //#region src/ignore.d.ts /** * Resolve whether a file should be ignored using oxfmt-like CLI semantics. * * @param options - Ignore resolution options. * @returns Ignore status with optional reason. * * @example * ```ts * import { isOxfmtIgnored } from 'load-oxfmt-config' * * const result = await isOxfmtIgnored({ * cwd: process.cwd(), * filepath: 'src/generated/file.ts', * }) * ``` */ declare function isOxfmtIgnored(options: IsOxfmtIgnoredOptions): Promise; //#endregion export { EditorconfigOption, IsOxfmtIgnoredOptions, IsOxfmtIgnoredResult, LoadOxfmtConfigOptions, LoadOxfmtConfigResult, OxfmtConfigOverride, OxfmtOptions, isOxfmtIgnored, loadOxfmtConfig, resolveOxfmtrcPath };