9cfff99e004f6b162e7bc71ba34cd5c6c51da798
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / experimental-utils / _ts3.4 / dist / ts-eslint / Linter.d.ts
1 import { TSESTree, ParserServices } from '../ts-estree';\r
2 import { ParserOptions as TSParserOptions } from './ParserOptions';\r
3 import { RuleCreateFunction, RuleFix, RuleModule } from './Rule';\r
4 import { Scope } from './Scope';\r
5 import { SourceCode } from './SourceCode';\r
6 declare class LinterBase {\r
7     /**\r
8      * Initialize the Linter.\r
9      * @param config the config object\r
10      */\r
11     constructor(config?: Linter.LinterOptions);\r
12     /**\r
13      * Define a new parser module\r
14      * @param parserId Name of the parser\r
15      * @param parserModule The parser object\r
16      */\r
17     defineParser(parserId: string, parserModule: Linter.ParserModule): void;\r
18     /**\r
19      * Defines a new linting rule.\r
20      * @param ruleId A unique rule identifier\r
21      * @param ruleModule Function from context to object mapping AST node types to event handlers\r
22      */\r
23     defineRule<TMessageIds extends string, TOptions extends readonly unknown[]>(ruleId: string, ruleModule: RuleModule<TMessageIds, TOptions> | RuleCreateFunction): void;\r
24     /**\r
25      * Defines many new linting rules.\r
26      * @param rulesToDefine map from unique rule identifier to rule\r
27      */\r
28     defineRules<TMessageIds extends string, TOptions extends readonly unknown[]>(rulesToDefine: Record<string, RuleModule<TMessageIds, TOptions> | RuleCreateFunction>): void;\r
29     /**\r
30      * Gets an object with all loaded rules.\r
31      * @returns All loaded rules\r
32      */\r
33     getRules(): Map<string, RuleModule<string, unknown[]>>;\r
34     /**\r
35      * Gets the `SourceCode` object representing the parsed source.\r
36      * @returns The `SourceCode` object.\r
37      */\r
38     getSourceCode(): SourceCode;\r
39     /**\r
40      * Verifies the text against the rules specified by the second argument.\r
41      * @param textOrSourceCode The text to parse or a SourceCode object.\r
42      * @param config An ESLintConfig instance to configure everything.\r
43      * @param filenameOrOptions The optional filename of the file being checked.\r
44      *        If this is not set, the filename will default to '<input>' in the rule context.\r
45      *        If this is an object, then it has "filename", "allowInlineConfig", and some properties.\r
46      * @returns The results as an array of messages or an empty array if no messages.\r
47      */\r
48     verify(textOrSourceCode: SourceCode | string, config: Linter.Config, filenameOrOptions?: string | Linter.VerifyOptions): Linter.LintMessage[];\r
49     /**\r
50      * Performs multiple autofix passes over the text until as many fixes as possible have been applied.\r
51      * @param text The source text to apply fixes to.\r
52      * @param config The ESLint config object to use.\r
53      * @param options The ESLint options object to use.\r
54      * @returns The result of the fix operation as returned from the SourceCodeFixer.\r
55      */\r
56     verifyAndFix(code: string, config: Linter.Config, options: Linter.FixOptions): Linter.FixReport;\r
57     /**\r
58      * The version from package.json.\r
59      */\r
60     readonly version: string;\r
61     /**\r
62      * The version from package.json.\r
63      */\r
64     static readonly version: string;\r
65 }\r
66 declare namespace Linter {\r
67     export interface LinterOptions {\r
68         /**\r
69          * path to a directory that should be considered as the current working directory.\r
70          */\r
71         cwd?: string;\r
72     }\r
73     export type Severity = 0 | 1 | 2;\r
74     export type SeverityString = 'off' | 'warn' | 'error';\r
75     export type RuleLevel = Severity | SeverityString;\r
76     export type RuleLevelAndOptions = [RuleLevel, ...unknown[]];\r
77     export type RuleEntry = RuleLevel | RuleLevelAndOptions;\r
78     export type RulesRecord = Partial<Record<string, RuleEntry>>;\r
79     interface BaseConfig {\r
80         $schema?: string;\r
81         /**\r
82          * The environment settings.\r
83          */\r
84         env?: {\r
85             [name: string]: boolean;\r
86         };\r
87         /**\r
88          * The path to other config files or the package name of shareable configs.\r
89          */\r
90         extends?: string | string[];\r
91         /**\r
92          * The global variable settings.\r
93          */\r
94         globals?: {\r
95             [name: string]: boolean;\r
96         };\r
97         /**\r
98          * The flag that disables directive comments.\r
99          */\r
100         noInlineConfig?: boolean;\r
101         /**\r
102          * The override settings per kind of files.\r
103          */\r
104         overrides?: ConfigOverride[];\r
105         /**\r
106          * The path to a parser or the package name of a parser.\r
107          */\r
108         parser?: string;\r
109         /**\r
110          * The parser options.\r
111          */\r
112         parserOptions?: ParserOptions;\r
113         /**\r
114          * The plugin specifiers.\r
115          */\r
116         plugins?: string[];\r
117         /**\r
118          * The processor specifier.\r
119          */\r
120         processor?: string;\r
121         /**\r
122          * The flag to report unused `eslint-disable` comments.\r
123          */\r
124         reportUnusedDisableDirectives?: boolean;\r
125         /**\r
126          * The rule settings.\r
127          */\r
128         rules?: RulesRecord;\r
129         /**\r
130          * The shared settings.\r
131          */\r
132         settings?: {\r
133             [name: string]: unknown;\r
134         };\r
135     }\r
136     export interface ConfigOverride extends BaseConfig {\r
137         excludedFiles?: string | string[];\r
138         files: string | string[];\r
139     }\r
140     export interface Config extends BaseConfig {\r
141         /**\r
142          * The glob patterns that ignore to lint.\r
143          */\r
144         ignorePatterns?: string | string[];\r
145         /**\r
146          * The root flag.\r
147          */\r
148         root?: boolean;\r
149     }\r
150     export type ParserOptions = TSParserOptions;\r
151     export interface VerifyOptions {\r
152         /**\r
153          * Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.\r
154          * Useful if you want to validate JS without comments overriding rules.\r
155          */\r
156         allowInlineConfig?: boolean;\r
157         /**\r
158          * if `true` then the linter doesn't make `fix` properties into the lint result.\r
159          */\r
160         disableFixes?: boolean;\r
161         /**\r
162          * the filename of the source code.\r
163          */\r
164         filename?: string;\r
165         /**\r
166          * the predicate function that selects adopt code blocks.\r
167          */\r
168         filterCodeBlock?: (filename: string, text: string) => boolean;\r
169         /**\r
170          * postprocessor for report messages.\r
171          * If provided, this should accept an array of the message lists\r
172          * for each code block returned from the preprocessor, apply a mapping to\r
173          * the messages as appropriate, and return a one-dimensional array of\r
174          * messages.\r
175          */\r
176         postprocess?: Processor['postprocess'];\r
177         /**\r
178          * preprocessor for source text.\r
179          * If provided, this should accept a string of source text, and return an array of code blocks to lint.\r
180          */\r
181         preprocess?: Processor['preprocess'];\r
182         /**\r
183          * Adds reported errors for unused `eslint-disable` directives.\r
184          */\r
185         reportUnusedDisableDirectives?: boolean | SeverityString;\r
186     }\r
187     export interface FixOptions extends VerifyOptions {\r
188         /**\r
189          * Determines whether fixes should be applied.\r
190          */\r
191         fix?: boolean;\r
192     }\r
193     export interface LintSuggestion {\r
194         desc: string;\r
195         fix: RuleFix;\r
196         messageId?: string;\r
197     }\r
198     export interface LintMessage {\r
199         /**\r
200          * The 1-based column number.\r
201          */\r
202         column: number;\r
203         /**\r
204          * The 1-based column number of the end location.\r
205          */\r
206         endColumn?: number;\r
207         /**\r
208          * The 1-based line number of the end location.\r
209          */\r
210         endLine?: number;\r
211         /**\r
212          * If `true` then this is a fatal error.\r
213          */\r
214         fatal?: true;\r
215         /**\r
216          * Information for autofix.\r
217          */\r
218         fix?: RuleFix;\r
219         /**\r
220          * The 1-based line number.\r
221          */\r
222         line: number;\r
223         /**\r
224          * The error message.\r
225          */\r
226         message: string;\r
227         messageId?: string;\r
228         nodeType: string;\r
229         /**\r
230          * The ID of the rule which makes this message.\r
231          */\r
232         ruleId: string | null;\r
233         /**\r
234          * The severity of this message.\r
235          */\r
236         severity: Severity;\r
237         source: string | null;\r
238         /**\r
239          * Information for suggestions\r
240          */\r
241         suggestions?: LintSuggestion[];\r
242     }\r
243     export interface FixReport {\r
244         /**\r
245          * True, if the code was fixed\r
246          */\r
247         fixed: boolean;\r
248         /**\r
249          * Fixed code text (might be the same as input if no fixes were applied).\r
250          */\r
251         output: string;\r
252         /**\r
253          * Collection of all messages for the given code\r
254          */\r
255         messages: LintMessage[];\r
256     }\r
257     export type ParserModule = {\r
258         parse(text: string, options?: ParserOptions): TSESTree.Program;\r
259     } | {\r
260         parseForESLint(text: string, options?: ParserOptions): ESLintParseResult;\r
261     };\r
262     export interface ESLintParseResult {\r
263         ast: TSESTree.Program;\r
264         parserServices?: ParserServices;\r
265         scopeManager?: Scope.ScopeManager;\r
266         visitorKeys?: SourceCode.VisitorKeys;\r
267     }\r
268     export interface Processor {\r
269         /**\r
270          * The function to extract code blocks.\r
271          */\r
272         preprocess?: (text: string, filename: string) => Array<string | {\r
273             text: string;\r
274             filename: string;\r
275         }>;\r
276         /**\r
277          * The function to merge messages.\r
278          */\r
279         postprocess?: (messagesList: Linter.LintMessage[][], filename: string) => Linter.LintMessage[];\r
280         /**\r
281          * If `true` then it means the processor supports autofix.\r
282          */\r
283         supportsAutofix?: boolean;\r
284     }\r
285     export interface Environment {\r
286         /**\r
287          * The definition of global variables.\r
288          */\r
289         globals?: Record<string, Linter.Config>;\r
290         /**\r
291          * The parser options that will be enabled under this environment.\r
292          */\r
293         parserOptions?: ParserOptions;\r
294     }\r
295     export interface Plugin {\r
296         /**\r
297          * The definition of plugin configs.\r
298          */\r
299         configs?: Record<string, Linter.Config>;\r
300         /**\r
301          * The definition of plugin environments.\r
302          */\r
303         environments?: Record<string, Environment>;\r
304         /**\r
305          * The definition of plugin processors.\r
306          */\r
307         processors?: Record<string, Processor>;\r
308         /**\r
309          * The definition of plugin rules.\r
310          */\r
311         rules?: Record<string, RuleCreateFunction | RuleModule<string, unknown[]>>;\r
312     }\r
313     export {};\r
314 }\r
315 declare const Linter_base: typeof LinterBase;\r
316 /**\r
317  * The Linter object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it\r
318  * simply parses and reports on the code. In particular, the Linter object does not process configuration objects\r
319  * or files.\r
320  */\r
321 declare class Linter extends Linter_base {\r
322 }\r
323 export { Linter };\r
324 //# sourceMappingURL=Linter.d.ts.map\r