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