eslint-doc-generator
Version:
Automatic documentation generator for ESLint plugins and rules.
35 lines (34 loc) • 1.49 kB
TypeScript
type EndOfLine = '\n' | '\r\n';
export type EndOfLineResolver = {
/** EditorConfig `end_of_line` for the file path, if set. */
getExplicitEndOfLine: (filePath: string) => Promise<EndOfLine | undefined>;
/**
* Write-time precedence: EditorConfig → detect(contents) → `os.EOL`.
* New/empty docs pass `contents` as undefined (skip detection).
*/
resolve: (filePath: string, contents: string | undefined) => Promise<EndOfLine>;
};
/**
* Create a memoized end-of-line resolver scoped to one `generate()` run.
* Cache keys are absolute file paths so sibling `.md`/`.mdx` files can differ.
*
* Write-time precedence for `resolve()`:
* 1. Explicit EditorConfig `end_of_line`
* 2. Predominant end of line in existing contents (skip when `contents` is undefined)
* 3. `os.EOL`
*
* Prettier config is not read — run Prettier via `postprocess` if needed.
*/
export declare function createEndOfLineResolver(): EndOfLineResolver;
/**
* Detect the predominant end of line in the given file contents.
* Returns undefined if the contents have no line breaks.
*/
export declare function detectEndOfLine(contents: string): EndOfLine | undefined;
/**
* Convert all line endings in the given contents to the given end of line.
*/
export declare function normalizeEndOfLine(contents: string, endOfLine: string): string;
/** Fallback when there is no config and no detectable end of line. */
export declare function getFallbackEndOfLine(): EndOfLine;
export {};