@adguard/aglint
Version:
Universal adblock filter list linter.
41 lines (40 loc) • 1.32 kB
TypeScript
import { type ParsedPath } from 'node:path';
import { type Ignore } from 'ignore';
/**
* Represents the result of a scan.
*/
export interface ScannedDirectory {
/**
* Data about the current directory.
*/
dir: ParsedPath;
/**
* Only one config file is allowed in a directory, it may be null if no config file is found in
* the directory.
*/
configFile: ParsedPath | null;
/**
* Lintable files in the directory (if any).
*/
lintableFiles: ParsedPath[];
/**
* Subdirectories in the directory (if any).
*/
subdirectories: ScannedDirectory[];
}
/**
* Searches for lintable files in a directory recursively. Practically it means files with the
* supported extensions. It will also search for config files.
*
* It will ignore files and directories that are ignored by the ignore file at any level.
* `.aglintignore` works exactly like `.gitignore`.
*
* @param dir Directory to search in.
* @param ignores File ignores.
* @param useIgnoreFiles Use ignore files or not (default: true).
*
* @returns The result of the scan (`ScannedDirectory` object).
*
* @throws If multiple config files are found in the given directory.
*/
export declare function scan(dir: string, ignores?: Ignore[], useIgnoreFiles?: boolean): Promise<ScannedDirectory>;