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