-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
CLIEngine.ts
90 lines (72 loc) · 2.31 KB
/
CLIEngine.ts
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
/* eslint-disable @typescript-eslint/no-namespace, no-redeclare */
import { CLIEngine as ESLintCLIEngine } from 'eslint';
import { Linter } from './Linter';
import { RuleModule, RuleListener } from './Rule';
interface CLIEngine {
version: string;
executeOnFiles(patterns: string[]): CLIEngine.LintReport;
resolveFileGlobPatterns(patterns: string[]): string[];
getConfigForFile(filePath: string): Linter.Config;
executeOnText(text: string, filename?: string): CLIEngine.LintReport;
addPlugin(name: string, pluginObject: any): void;
isPathIgnored(filePath: string): boolean;
getFormatter(format?: string): CLIEngine.Formatter;
getRules<
TMessageIds extends string = any,
TOptions extends readonly any[] = any[],
// for extending base rules
TRuleListener extends RuleListener = RuleListener
>(): Map<string, RuleModule<TMessageIds, TOptions, TRuleListener>>;
}
namespace CLIEngine {
export interface Options {
allowInlineConfig?: boolean;
baseConfig?: false | { [name: string]: any };
cache?: boolean;
cacheFile?: string;
cacheLocation?: string;
configFile?: string;
cwd?: string;
envs?: string[];
extensions?: string[];
fix?: boolean;
globals?: string[];
ignore?: boolean;
ignorePath?: string;
ignorePattern?: string | string[];
useEslintrc?: boolean;
parser?: string;
parserOptions?: Linter.ParserOptions;
plugins?: string[];
rules?: {
[name: string]: Linter.RuleLevel | Linter.RuleLevelAndOptions;
};
rulePaths?: string[];
reportUnusedDisableDirectives?: boolean;
}
export interface LintResult {
filePath: string;
messages: Linter.LintMessage[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
output?: string;
source?: string;
}
export interface LintReport {
results: LintResult[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
}
export type Formatter = (results: LintResult[]) => string;
}
const CLIEngine = ESLintCLIEngine as {
new (options: CLIEngine.Options): CLIEngine;
// static methods
getErrorResults(results: CLIEngine.LintResult[]): CLIEngine.LintResult[];
outputFixes(report: CLIEngine.LintReport): void;
};
export { CLIEngine };