.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / experimental-utils / _ts3.4 / dist / ts-eslint / RuleTester.d.ts
1 import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '../ts-estree';\r
2 import { ParserOptions } from './ParserOptions';\r
3 import { RuleModule } from './Rule';\r
4 interface ValidTestCase<TOptions extends Readonly<unknown[]>> {\r
5     /**\r
6      * Code for the test case.\r
7      */\r
8     readonly code: string;\r
9     /**\r
10      * Environments for the test case.\r
11      */\r
12     readonly env?: Readonly<Record<string, boolean>>;\r
13     /**\r
14      * The fake filename for the test case. Useful for rules that make assertion about filenames.\r
15      */\r
16     readonly filename?: string;\r
17     /**\r
18      * The additional global variables.\r
19      */\r
20     readonly globals?: Record<string, 'readonly' | 'writable' | 'off'>;\r
21     /**\r
22      * Options for the test case.\r
23      */\r
24     readonly options?: Readonly<TOptions>;\r
25     /**\r
26      * The absolute path for the parser.\r
27      */\r
28     readonly parser?: string;\r
29     /**\r
30      * Options for the parser.\r
31      */\r
32     readonly parserOptions?: Readonly<ParserOptions>;\r
33     /**\r
34      * Settings for the test case.\r
35      */\r
36     readonly settings?: Readonly<Record<string, unknown>>;\r
37 }\r
38 interface SuggestionOutput<TMessageIds extends string> {\r
39     /**\r
40      * Reported message ID.\r
41      */\r
42     readonly messageId: TMessageIds;\r
43     /**\r
44      * The data used to fill the message template.\r
45      */\r
46     readonly data?: Readonly<Record<string, unknown>>;\r
47     /**\r
48      * NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes.\r
49      * Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion.\r
50      */\r
51     readonly output: string;\r
52 }\r
53 interface InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> extends ValidTestCase<TOptions> {\r
54     /**\r
55      * Expected errors.\r
56      */\r
57     readonly errors: TestCaseError<TMessageIds>[];\r
58     /**\r
59      * The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested.\r
60      */\r
61     readonly output?: string | null;\r
62 }\r
63 interface TestCaseError<TMessageIds extends string> {\r
64     /**\r
65      * The 1-based column number of the reported start location.\r
66      */\r
67     readonly column?: number;\r
68     /**\r
69      * The data used to fill the message template.\r
70      */\r
71     readonly data?: Readonly<Record<string, unknown>>;\r
72     /**\r
73      * The 1-based column number of the reported end location.\r
74      */\r
75     readonly endColumn?: number;\r
76     /**\r
77      * The 1-based line number of the reported end location.\r
78      */\r
79     readonly endLine?: number;\r
80     /**\r
81      * The 1-based line number of the reported start location.\r
82      */\r
83     readonly line?: number;\r
84     /**\r
85      * Reported message ID.\r
86      */\r
87     readonly messageId: TMessageIds;\r
88     /**\r
89      * Reported suggestions.\r
90      */\r
91     readonly suggestions?: SuggestionOutput<TMessageIds>[] | null;\r
92     /**\r
93      * The type of the reported AST node.\r
94      */\r
95     readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;\r
96 }\r
97 interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {\r
98     readonly valid: (ValidTestCase<TOptions> | string)[];\r
99     readonly invalid: InvalidTestCase<TMessageIds, TOptions>[];\r
100 }\r
101 interface RuleTesterConfig {\r
102     readonly parser: string;\r
103     readonly parserOptions?: Readonly<ParserOptions>;\r
104 }\r
105 declare class RuleTesterBase {\r
106     /**\r
107      * Creates a new instance of RuleTester.\r
108      * @param testerConfig extra configuration for the tester\r
109      */\r
110     constructor(testerConfig?: RuleTesterConfig);\r
111     /**\r
112      * Adds a new rule test to execute.\r
113      * @param ruleName The name of the rule to run.\r
114      * @param rule The rule to test.\r
115      * @param test The collection of tests to run.\r
116      */\r
117     run<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(ruleName: string, rule: RuleModule<TMessageIds, TOptions>, tests: RunTests<TMessageIds, TOptions>): void;\r
118     /**\r
119      * If you supply a value to this property, the rule tester will call this instead of using the version defined on\r
120      * the global namespace.\r
121      * @param text a string describing the rule\r
122      * @param callback the test callback\r
123      */\r
124     static describe?: (text: string, callback: () => void) => void;\r
125     /**\r
126      * If you supply a value to this property, the rule tester will call this instead of using the version defined on\r
127      * the global namespace.\r
128      * @param text a string describing the test case\r
129      * @param callback the test callback\r
130      */\r
131     static it?: (text: string, callback: () => void) => void;\r
132 }\r
133 declare const RuleTester_base: typeof RuleTesterBase;\r
134 declare class RuleTester extends RuleTester_base {\r
135 }\r
136 export { InvalidTestCase, SuggestionOutput, RuleTester, RuleTesterConfig, RunTests, TestCaseError, ValidTestCase, };\r
137 //# sourceMappingURL=RuleTester.d.ts.map\r