-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
232 lines (199 loc) · 4.57 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/**
* A test case.
*/
export type TestCase = {
/**
* Code of the test case.
*/
code: string;
/**
* A filename for this `code` property.
*/
codeFilename?: string;
/**
* Description of the test case.
*/
description?: string | undefined;
/**
* Whether to run only the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#only-tests
*/
only?: boolean | undefined;
/**
* Whether to skip the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#skipping-tests
*/
skip?: boolean | undefined;
};
/**
* An accept test case.
*/
export type AcceptTestCase = TestCase;
/**
* A warning.
*/
export type Warning = {
/**
* Expected message from the test case. Usually exported from the plugin.
* Optional if `warnings` is used.
*/
message?: string | undefined;
/**
* Expected line number of the warning.
*/
line?: number | undefined;
/**
* Expected column number of the warning.
*/
column?: number | undefined;
/**
* Expected end line number of the warning.
*/
endLine?: number | undefined;
/**
* Expected end column number of the warning.
*/
endColumn?: number | undefined;
/**
* Expected `EditInfo` of the warning.
*
* @experimental
*/
fix?: { range: [number, number]; text: string };
};
/**
* Use the `warnings` property, rather than `message`, `line`, and `column`,
* if the test case is expected to produce more than one warning.
*/
export type RejectTestCase = TestCase &
Warning & {
/**
* Expected fixed code of the test case. Optional if `fix` isn't `true`.
*/
fixed?: string | undefined;
/**
* Don't check the `fixed` code. Default: `false`.
*/
unfixable?: boolean | undefined;
/**
* Warning objects containing expected `message`, `line` and `column` etc.
* Optional if `message` is used.
*/
warnings?: Warning[] | undefined;
};
/**
* A test schema.
*/
export type TestSchema = {
/**
* Name of the rule being tested. Usually exported from the plugin.
*/
ruleName: string;
/**
* Config to pass to the rule.
*/
config: unknown;
/**
* Accept test cases.
*/
accept?: AcceptTestCase[] | undefined;
/**
* Reject test cases.
*/
reject?: RejectTestCase[] | undefined;
/**
* Turn on autofix. Default: `false`.
*/
fix?: boolean | undefined;
/**
* Turn on computing `EditInfo`. Default: `false`.
*
* @experimental
*/
computeEditInfo?: boolean;
/**
* Maps to Stylelint's `plugins` configuration property.
*
* Path to the file that exports the plugin object, relative to the root.
* Usually it's the same path as a `main` property in plugin's `package.json`.
*
* If you're testing a plugin pack, it's the path to the file that exports the array of plugin objects.
*
* Optional, if `plugins` option was passed to advanced configuration with `getTestRule()`.
*
* @see https://stylelint.io/user-guide/configure#plugins
*/
plugins?: import('stylelint').Config['plugins'] | undefined;
/**
* Maps to Stylelint's `customSyntax` option.
*
* @see https://stylelint.io/user-guide/usage/options#customsyntax
*/
customSyntax?: string | undefined;
/**
* Maps to Stylelint's `codeFilename` option.
*
* @see https://stylelint.io/user-guide/usage/options#codefilename
*/
codeFilename?: string | undefined;
/**
* Whether to run only the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#only-tests
*/
only?: boolean | undefined;
/**
* Whether to skip the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#skipping-tests
*/
skip?: boolean | undefined;
};
/**
* Test a rule with the specified schema.
*/
export function testRule(schema: TestSchema): void;
/**
* A test case for a rule configuration.
*/
export type RuleConfigTestCase = {
/**
* Config of the test case.
*/
config: unknown;
/**
* Description of the test case.
*/
description?: string | undefined;
/**
* Whether to run only the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#only-tests
*/
only?: boolean | undefined;
/**
* Whether to skip the test case. Default: `false`.
*
* @see https://nodejs.org/api/test.html#skipping-tests
*/
skip?: boolean | undefined;
};
/**
* A test schema for a rule configuration.
*/
export type RuleConfigTestSchema = Pick<TestSchema, 'ruleName' | 'plugins' | 'only' | 'skip'> & {
/**
* Accept test cases.
*/
accept?: RuleConfigTestCase[];
/**
* Reject test cases.
*/
reject?: RuleConfigTestCase[];
};
/**
* Test configurations for a rule.
*/
export function testRuleConfigs(schema: RuleConfigTestSchema): void;