import type { NormalizedRule } from '../types/index.js'; import type { ScopeRuleContext } from '../rules/types.js'; export declare function discoverMarkdownFiles(inputPath: string): Promise; /** * Load list of changed files from either a file path or stdin */ export declare function loadChangedFiles(changedListPath?: string): Promise; /** * Runs `fn` over `items` with at most `limit` calls in flight at once, * returning results in the same order as `items` regardless of completion * order. Used to bound concurrency for disk I/O (e.g. lintFiles' reads) * without pulling in a workspace dependency — recheck is published * independently, so it can't depend on @redocly/shared's promiseMapLimit. */ export declare function mapLimit(items: T[], limit: number, fn: (item: T, index: number) => Promise): Promise; /** * Whether any of the given rules use the max-image-size assertion, which * requires loading image metadata (file size, existence) from disk. */ export declare function needsImageMetadata(rules: NormalizedRule[]): boolean; /** * Cap on unique image refs processed per file by `loadImageMetadata`. Each * ref costs an `fs.stat`, so without a bound a pathological file (hundreds * of thousands of image refs) turns one lint into an unbounded stat storm. * 1,000 is far above any real document's image count. Refs beyond the cap * are OMITTED from the metadata map entirely — see the doc comment below * for why omission (not a fabricated `exists: false`) is the honest shape. */ export declare const MAX_IMAGE_REFS_PER_FILE = 1000; /** * Loads on-disk metadata (size, existence) for images referenced in a markdown * file's content, keyed by the image path as written in the source. * * Refs are confined to `root` (default: `process.cwd()`): a ref whose * resolved path escapes the root — `../` traversal above it, or an absolute * path like `/etc/passwd` — is recorded as `exists: false` WITHOUT being * stat'ed, so a hostile document can't use the linter to probe existence or * size of arbitrary files (both would otherwise leak into lint output). * Site-absolute doc refs like `/images/foo.png` land in the same bucket, * which matches the previous behavior for them observably: they used to be * stat'ed against the FILESYSTEM root, fail, and come back `exists: false` * anyway. Callers linting files outside their cwd should pass the lint root * explicitly (`lintFiles` threads its `root` option here). * * Confinement is physical, not just lexical: after the string-level check, * each surviving ref is `fs.realpath`'d and its REAL path must sit inside * the REAL root (the root's own realpath, resolved once per call). Without * this, a symlink planted INSIDE the root (`root/docs/evil.png -> * /etc/passwd`, or a symlinked directory escaping the root) passes the * lexical check and `fs.stat` follows it, leaking the target's existence * and size. Symlinks that RESOLVE inside the root keep working — legit repo * layouts symlink shared asset dirs around within the checkout. When * `realpath` throws (ENOENT for a missing file or dangling link — the * common case — or any other resolution failure), the ref falls through to * the same `fs.stat` try/catch as before: `stat` performs the identical * full path resolution, so it fails the same way and the ref reads * `exists: false` exactly as missing files always have. Cost: one extra * realpath per stat'ed image, only on the max-image-size code path. * * At most `MAX_IMAGE_REFS_PER_FILE` unique refs are processed; overflow refs * are omitted from the map rather than recorded. An absent key means "no * metadata loaded" to consumers — `max-image-size` skips refs it finds no * entry for, exactly as it skips `exists: false` entries — so omission never * fabricates a "this image is missing" fact for a ref that was simply never * checked. Duplicate refs share one entry (and one stat) and don't consume * extra cap slots. */ export declare function loadImageMetadata(file: string, content: string, root?: string): Promise; //# sourceMappingURL=files.d.ts.map