Giant blob of minor changes
[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 = [\r
77         RuleLevel,\r
78         ...unknown[]\r
79     ];\r
80     export type RuleEntry = RuleLevel | RuleLevelAndOptions;\r
81     export type RulesRecord = Partial<Record<string, RuleEntry>>;\r
82     interface BaseConfig {\r
83         $schema?: string;\r
84         /**\r
85          * The environment settings.\r
86          */\r
87         env?: {\r
88             [name: string]: boolean;\r
89         };\r
90         /**\r
91          * The path to other config files or the package name of shareable configs.\r
92          */\r
93         extends?: string | string[];\r
94         /**\r
95          * The global variable settings.\r
96          */\r
97         globals?: {\r
98             [name: string]: boolean;\r
99         };\r
100         /**\r
101          * The flag that disables directive comments.\r
102          */\r
103         noInlineConfig?: boolean;\r
104         /**\r
105          * The override settings per kind of files.\r
106          */\r
107         overrides?: ConfigOverride[];\r
108         /**\r
109          * The path to a parser or the package name of a parser.\r
110          */\r
111         parser?: string;\r
112         /**\r
113          * The parser options.\r
114          */\r
115         parserOptions?: ParserOptions;\r
116         /**\r
117          * The plugin specifiers.\r
118          */\r
119         plugins?: string[];\r
120         /**\r
121          * The processor specifier.\r
122          */\r
123         processor?: string;\r
124         /**\r
125          * The flag to report unused `eslint-disable` comments.\r
126          */\r
127         reportUnusedDisableDirectives?: boolean;\r
128         /**\r
129          * The rule settings.\r
130          */\r
131         rules?: RulesRecord;\r
132         /**\r
133          * The shared settings.\r
134          */\r
135         settings?: {\r
136             [name: string]: unknown;\r
137         };\r
138     }\r
139     export interface ConfigOverride extends BaseConfig {\r
140         excludedFiles?: string | string[];\r
141         files: string | string[];\r
142     }\r
143     export interface Config extends BaseConfig {\r
144         /**\r
145          * The glob patterns that ignore to lint.\r
146          */\r
147         ignorePatterns?: string | string[];\r
148         /**\r
149          * The root flag.\r
150          */\r
151         root?: boolean;\r
152     }\r
153     export type ParserOptions = TSParserOptions;\r
154     export interface VerifyOptions {\r
155         /**\r
156          * Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.\r
157          * Useful if you want to validate JS without comments overriding rules.\r
158          */\r
159         allowInlineConfig?: boolean;\r
160         /**\r
161          * if `true` then the linter doesn't make `fix` properties into the lint result.\r
162          */\r
163         disableFixes?: boolean;\r
164         /**\r
165          * the filename of the source code.\r
166          */\r
167         filename?: string;\r
168         /**\r
169          * the predicate function that selects adopt code blocks.\r
170          */\r
171         filterCodeBlock?: (filename: string, text: string) => boolean;\r
172         /**\r
173          * postprocessor for report messages.\r
174          * If provided, this should accept an array of the message lists\r
175          * for each code block returned from the preprocessor, apply a mapping to\r
176          * the messages as appropriate, and return a one-dimensional array of\r
177          * messages.\r
178          */\r
179         postprocess?: Processor['postprocess'];\r
180         /**\r
181          * preprocessor for source text.\r
182          * If provided, this should accept a string of source text, and return an array of code blocks to lint.\r
183          */\r
184         preprocess?: Processor['preprocess'];\r
185         /**\r
186          * Adds reported errors for unused `eslint-disable` directives.\r
187          */\r
188         reportUnusedDisableDirectives?: boolean | SeverityString;\r
189     }\r
190     export interface FixOptions extends VerifyOptions {\r
191         /**\r
192          * Determines whether fixes should be applied.\r
193          */\r
194         fix?: boolean;\r
195     }\r
196     export interface LintSuggestion {\r
197         desc: string;\r
198         fix: RuleFix;\r
199         messageId?: string;\r
200     }\r
201     export interface LintMessage {\r
202         /**\r
203          * The 1-based column number.\r
204          */\r
205         column: number;\r
206         /**\r
207          * The 1-based column number of the end location.\r
208          */\r
209         endColumn?: number;\r
210         /**\r
211          * The 1-based line number of the end location.\r
212          */\r
213         endLine?: number;\r
214         /**\r
215          * If `true` then this is a fatal error.\r
216          */\r
217         fatal?: true;\r
218         /**\r
219          * Information for autofix.\r
220          */\r
221         fix?: RuleFix;\r
222         /**\r
223          * The 1-based line number.\r
224          */\r
225         line: number;\r
226         /**\r
227          * The error message.\r
228          */\r
229         message: string;\r
230         messageId?: string;\r
231         nodeType: string;\r
232         /**\r
233          * The ID of the rule which makes this message.\r
234          */\r
235         ruleId: string | null;\r
236         /**\r
237          * The severity of this message.\r
238          */\r
239         severity: Severity;\r
240         source: string | null;\r
241         /**\r
242          * Information for suggestions\r
243          */\r
244         suggestions?: LintSuggestion[];\r
245     }\r
246     export interface FixReport {\r
247         /**\r
248          * True, if the code was fixed\r
249          */\r
250         fixed: boolean;\r
251         /**\r
252          * Fixed code text (might be the same as input if no fixes were applied).\r
253          */\r
254         output: string;\r
255         /**\r
256          * Collection of all messages for the given code\r
257          */\r
258         messages: LintMessage[];\r
259     }\r
260     export type ParserModule = {\r
261         parse(text: string, options?: ParserOptions): TSESTree.Program;\r
262     } | {\r
263         parseForESLint(text: string, options?: ParserOptions): ESLintParseResult;\r
264     };\r
265     export interface ESLintParseResult {\r
266         ast: TSESTree.Program;\r
267         parserServices?: ParserServices;\r
268         scopeManager?: Scope.ScopeManager;\r
269         visitorKeys?: SourceCode.VisitorKeys;\r
270     }\r
271     export interface Processor {\r
272         /**\r
273          * The function to extract code blocks.\r
274          */\r
275         preprocess?: (text: string, filename: string) => Array<string | {\r
276             text: string;\r
277             filename: string;\r
278         }>;\r
279         /**\r
280          * The function to merge messages.\r
281          */\r
282         postprocess?: (messagesList: Linter.LintMessage[][], filename: string) => Linter.LintMessage[];\r
283         /**\r
284          * If `true` then it means the processor supports autofix.\r
285          */\r
286         supportsAutofix?: boolean;\r
287     }\r
288     export interface Environment {\r
289         /**\r
290          * The definition of global variables.\r
291          */\r
292         globals?: Record<string, Linter.Config>;\r
293         /**\r
294          * The parser options that will be enabled under this environment.\r
295          */\r
296         parserOptions?: ParserOptions;\r
297     }\r
298     export interface Plugin {\r
299         /**\r
300          * The definition of plugin configs.\r
301          */\r
302         configs?: Record<string, Linter.Config>;\r
303         /**\r
304          * The definition of plugin environments.\r
305          */\r
306         environments?: Record<string, Environment>;\r
307         /**\r
308          * The definition of plugin processors.\r
309          */\r
310         processors?: Record<string, Processor>;\r
311         /**\r
312          * The definition of plugin rules.\r
313          */\r
314         rules?: Record<string, RuleCreateFunction | RuleModule<string, unknown[]>>;\r
315     }\r
316     export {};\r
317 }\r
318 declare const Linter_base: typeof LinterBase;\r
319 /**\r
320  * The Linter object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it\r
321  * simply parses and reports on the code. In particular, the Linter object does not process configuration objects\r
322  * or files.\r
323  */\r
324 declare class Linter extends Linter_base {\r
325 }\r
326 export { Linter };\r
327 //# sourceMappingURL=Linter.d.ts.map\r