1 import { Linter } from './Linter';
2 import { RuleListener, RuleMetaData, RuleModule } from './Rule';
3 declare class CLIEngineBase {
5 * Creates a new instance of the core CLI engine.
6 * @param providedOptions The options for this instance.
8 constructor(options: CLIEngine.Options);
10 * Add a plugin by passing its configuration
11 * @param name Name of the plugin.
12 * @param pluginObject Plugin configuration object.
14 addPlugin(name: string, pluginObject: Linter.Plugin): void;
16 * Executes the current configuration on an array of file and directory names.
17 * @param patterns An array of file and directory names.
18 * @returns The results for all files that were linted.
20 executeOnFiles(patterns: string[]): CLIEngine.LintReport;
22 * Executes the current configuration on text.
23 * @param text A string of JavaScript code to lint.
24 * @param filename An optional string representing the texts filename.
25 * @param warnIgnored Always warn when a file is ignored
26 * @returns The results for the linting.
28 executeOnText(text: string, filename?: string, warnIgnored?: boolean): CLIEngine.LintReport;
30 * Returns a configuration object for the given file based on the CLI options.
31 * This is the same logic used by the ESLint CLI executable to determine configuration for each file it processes.
32 * @param filePath The path of the file to retrieve a config object for.
33 * @returns A configuration object for the file.
35 getConfigForFile(filePath: string): Linter.Config;
37 * Returns the formatter representing the given format.
38 * @param format The name of the format to load or the path to a custom formatter.
39 * @returns The formatter function.
41 getFormatter(format?: string): CLIEngine.Formatter;
43 * Checks if a given path is ignored by ESLint.
44 * @param filePath The path of the file to check.
45 * @returns Whether or not the given path is ignored.
47 isPathIgnored(filePath: string): boolean;
49 * Resolves the patterns passed into `executeOnFiles()` into glob-based patterns for easier handling.
50 * @param patterns The file patterns passed on the command line.
51 * @returns The equivalent glob patterns.
53 resolveFileGlobPatterns(patterns: string[]): string[];
54 getRules<TMessageIds extends string = string, TOptions extends readonly unknown[] = unknown[], TRuleListener extends RuleListener = RuleListener>(): Map<string, RuleModule<TMessageIds, TOptions, TRuleListener>>;
56 * Returns results that only contains errors.
57 * @param results The results to filter.
58 * @returns The filtered results.
60 static getErrorResults(results: CLIEngine.LintResult[]): CLIEngine.LintResult[];
62 * Returns the formatter representing the given format or null if the `format` is not a string.
63 * @param format The name of the format to load or the path to a custom formatter.
64 * @returns The formatter function.
66 static getFormatter(format?: string): CLIEngine.Formatter;
68 * Outputs fixes from the given results to files.
69 * @param report The report object created by CLIEngine.
71 static outputFixes(report: CLIEngine.LintReport): void;
72 static version: string;
74 declare namespace CLIEngine {
76 allowInlineConfig?: boolean;
77 baseConfig?: false | {
78 [name: string]: unknown;
82 cacheLocation?: string;
86 errorOnUnmatchedPattern?: boolean;
87 extensions?: string[];
92 ignorePattern?: string | string[];
93 useEslintrc?: boolean;
95 parserOptions?: Linter.ParserOptions;
97 resolvePluginsRelativeTo?: string;
99 [name: string]: Linter.RuleLevel | Linter.RuleLevelAndOptions;
101 rulePaths?: string[];
102 reportUnusedDisableDirectives?: boolean;
104 interface LintResult {
106 messages: Linter.LintMessage[];
108 warningCount: number;
109 fixableErrorCount: number;
110 fixableWarningCount: number;
114 interface LintReport {
115 results: LintResult[];
117 warningCount: number;
118 fixableErrorCount: number;
119 fixableWarningCount: number;
120 usedDeprecatedRules: DeprecatedRuleUse[];
122 interface DeprecatedRuleUse {
124 replacedBy: string[];
126 interface LintResultData<TMessageIds extends string> {
128 [ruleId: string]: RuleMetaData<TMessageIds>;
131 type Formatter = <TMessageIds extends string>(results: LintResult[], data?: LintResultData<TMessageIds>) => string;
133 declare const CLIEngine_base: typeof CLIEngineBase;
135 * The underlying utility that runs the ESLint command line interface. This object will read the filesystem for
136 * configuration and file information but will not output any results. Instead, it allows you direct access to the
137 * important information so you can deal with the output yourself.
138 * @deprecated use the ESLint class instead
140 declare class CLIEngine extends CLIEngine_base {
142 export { CLIEngine };
143 //# sourceMappingURL=CLIEngine.d.ts.map