1import { TSESTree, ParserServices } from '@typescript-eslint/typescript-estree'; 2import { ParserOptions as TSParserOptions } from './ParserOptions'; 3import { RuleModule, RuleFix } from './Rule'; 4import { Scope } from './Scope'; 5import { SourceCode } from './SourceCode'; 6interface Linter { 7 version: string; 8 verify(code: SourceCode | string, config: Linter.Config, filename?: string): Linter.LintMessage[]; 9 verify(code: SourceCode | string, config: Linter.Config, options: Linter.LintOptions): Linter.LintMessage[]; 10 verifyAndFix(code: string, config: Linter.Config, filename?: string): Linter.FixReport; 11 verifyAndFix(code: string, config: Linter.Config, options: Linter.FixOptions): Linter.FixReport; 12 getSourceCode(): SourceCode; 13 defineRule<TMessageIds extends string, TOptions extends readonly unknown[]>(name: string, rule: { 14 meta?: RuleModule<TMessageIds, TOptions>['meta']; 15 create: RuleModule<TMessageIds, TOptions>['create']; 16 }): void; 17 defineRules<TMessageIds extends string, TOptions extends readonly unknown[]>(rules: Record<string, RuleModule<TMessageIds, TOptions>>): void; 18 getRules<TMessageIds extends string, TOptions extends readonly unknown[]>(): Map<string, RuleModule<TMessageIds, TOptions>>; 19 defineParser(name: string, parser: Linter.ParserModule): void; 20} 21declare namespace Linter { 22 type Severity = 0 | 1 | 2; 23 type RuleLevel = Severity | 'off' | 'warn' | 'error'; 24 type RuleLevelAndOptions = [RuleLevel, ...unknown[]]; 25 interface Config { 26 rules?: { 27 [name: string]: RuleLevel | RuleLevelAndOptions; 28 }; 29 parser?: string; 30 parserOptions?: ParserOptions; 31 settings?: { 32 [name: string]: unknown; 33 }; 34 env?: { 35 [name: string]: boolean; 36 }; 37 globals?: { 38 [name: string]: boolean; 39 }; 40 } 41 type ParserOptions = TSParserOptions; 42 interface LintOptions { 43 filename?: string; 44 preprocess?: (code: string) => string[]; 45 postprocess?: (problemLists: LintMessage[][]) => LintMessage[]; 46 allowInlineConfig?: boolean; 47 reportUnusedDisableDirectives?: boolean; 48 } 49 interface LintMessage { 50 column: number; 51 line: number; 52 endColumn?: number; 53 endLine?: number; 54 ruleId: string | null; 55 message: string; 56 nodeType: string; 57 fatal?: true; 58 severity: Severity; 59 fix?: RuleFix; 60 source: string | null; 61 } 62 interface FixOptions extends LintOptions { 63 fix?: boolean; 64 } 65 interface FixReport { 66 fixed: boolean; 67 output: string; 68 messages: LintMessage[]; 69 } 70 type ParserModule = { 71 parse(text: string, options?: unknown): TSESTree.Program; 72 } | { 73 parseForESLint(text: string, options?: unknown): ESLintParseResult; 74 }; 75 interface ESLintParseResult { 76 ast: TSESTree.Program; 77 parserServices?: ParserServices; 78 scopeManager?: Scope.ScopeManager; 79 visitorKeys?: SourceCode.VisitorKeys; 80 } 81} 82declare const Linter: new () => Linter; 83export { Linter }; 84//# sourceMappingURL=Linter.d.ts.map