1 | import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '../ts-estree';
|
2 | import { ParserOptions } from './ParserOptions';
|
3 | import { RuleCreateFunction, RuleModule } from './Rule';
|
4 | interface ValidTestCase<TOptions extends Readonly<unknown[]>> {
|
5 | |
6 |
|
7 |
|
8 | readonly code: string;
|
9 | |
10 |
|
11 |
|
12 | readonly env?: Readonly<Record<string, boolean>>;
|
13 | |
14 |
|
15 |
|
16 | readonly filename?: string;
|
17 | |
18 |
|
19 |
|
20 | readonly globals?: Record<string, 'readonly' | 'writable' | 'off' | true>;
|
21 | |
22 |
|
23 |
|
24 | readonly options?: Readonly<TOptions>;
|
25 | |
26 |
|
27 |
|
28 | readonly parser?: string;
|
29 | |
30 |
|
31 |
|
32 | readonly parserOptions?: Readonly<ParserOptions>;
|
33 | |
34 |
|
35 |
|
36 | readonly settings?: Readonly<Record<string, unknown>>;
|
37 | }
|
38 | interface SuggestionOutput<TMessageIds extends string> {
|
39 | |
40 |
|
41 |
|
42 | readonly messageId: TMessageIds;
|
43 | |
44 |
|
45 |
|
46 | readonly data?: Readonly<Record<string, unknown>>;
|
47 | |
48 |
|
49 |
|
50 |
|
51 | readonly output: string;
|
52 | }
|
53 | interface InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> extends ValidTestCase<TOptions> {
|
54 | |
55 |
|
56 |
|
57 | readonly errors: readonly TestCaseError<TMessageIds>[];
|
58 | |
59 |
|
60 |
|
61 | readonly output?: string | null;
|
62 | }
|
63 | interface TestCaseError<TMessageIds extends string> {
|
64 | |
65 |
|
66 |
|
67 | readonly column?: number;
|
68 | |
69 |
|
70 |
|
71 | readonly data?: Readonly<Record<string, unknown>>;
|
72 | |
73 |
|
74 |
|
75 | readonly endColumn?: number;
|
76 | |
77 |
|
78 |
|
79 | readonly endLine?: number;
|
80 | |
81 |
|
82 |
|
83 | readonly line?: number;
|
84 | |
85 |
|
86 |
|
87 | readonly messageId: TMessageIds;
|
88 | |
89 |
|
90 |
|
91 | readonly suggestions?: SuggestionOutput<TMessageIds>[] | null;
|
92 | |
93 |
|
94 |
|
95 | readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;
|
96 | }
|
97 | interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
|
98 | readonly valid: readonly (ValidTestCase<TOptions> | string)[];
|
99 | readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[];
|
100 | }
|
101 | interface RuleTesterConfig {
|
102 | readonly parser: string;
|
103 | readonly parserOptions?: Readonly<ParserOptions>;
|
104 | }
|
105 | declare class RuleTesterBase {
|
106 | |
107 |
|
108 |
|
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 | * Define a rule for one particular run of tests.
|
134 | * @param name The name of the rule to define.
|
135 | * @param rule The rule definition.
|
136 | */
|
137 | defineRule<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(name: string, rule: RuleModule<TMessageIds, TOptions> | RuleCreateFunction<TMessageIds, TOptions>): void;
|
138 | }
|
139 | declare const RuleTester_base: typeof RuleTesterBase;
|
140 | declare class RuleTester extends RuleTester_base {
|
141 | }
|
142 | export { InvalidTestCase, SuggestionOutput, RuleTester, RuleTesterConfig, RunTests, TestCaseError, ValidTestCase, };
|
143 |
|
\ | No newline at end of file |