1
- import type { Linter } from 'eslint'
1
+ import type { Linter , RuleModule } from '@typescript-eslint/utils/ts- eslint'
2
2
import { version } from '../package.json'
3
3
import lowerCaseTitle , { RULE_NAME as lowerCaseTitleName } from './rules/prefer-lowercase-title'
4
4
import maxNestedDescribe , { RULE_NAME as maxNestedDescribeName } from './rules/max-nested-describe'
@@ -70,8 +70,8 @@ const createConfig = <R extends Linter.RulesRecord>(rules: R) => (
70
70
[ `vitest/${ ruleName } ` ] : rules [ ruleName ]
71
71
}
72
72
} , { } ) ) as {
73
- [ K in keyof R as `vitest/${Extract < K , string > } `] : R [ K ]
74
- }
73
+ [ K in keyof R as `vitest/${Extract < K , string > } `] : R [ K ]
74
+ }
75
75
76
76
const createConfigLegacy = ( rules : Record < string , string > ) => ( {
77
77
plugins : [ '@vitest' ] ,
@@ -159,7 +159,18 @@ const recommended = {
159
159
[ noImportNodeTestName ] : 'error'
160
160
} as const
161
161
162
- const plugin = {
162
+ interface VitestPLugin extends Linter . Plugin {
163
+ meta : {
164
+ name : string
165
+ version : string
166
+ }
167
+ rules : Record < string , RuleModule < any , any > >
168
+ //TODO: use classic type for config
169
+ configs ?: Record < string , any >
170
+ environments ?: Record < string , any >
171
+ }
172
+
173
+ const plugin : VitestPLugin = {
163
174
meta : {
164
175
name : 'vitest' ,
165
176
version
@@ -228,48 +239,6 @@ const plugin = {
228
239
[ paddingAroundTestBlocksName ] : paddingAroundTestBlocks ,
229
240
[ validExpectInPromiseName ] : validExpectInPromise
230
241
} ,
231
- configs : {
232
- 'legacy-recommended' : createConfigLegacy ( recommended ) ,
233
- 'legacy-all' : createConfigLegacy ( allRules ) ,
234
- 'recommended' : {
235
- plugins : {
236
- get vitest ( ) {
237
- return plugin
238
- }
239
- } ,
240
- rules : createConfig ( recommended )
241
- } ,
242
- 'all' : {
243
- plugins : {
244
- get vitest ( ) {
245
- return plugin
246
- }
247
- } ,
248
- rules : createConfig ( allRules )
249
- } ,
250
- 'env' : {
251
- languageOptions : {
252
- globals : {
253
- suite : 'writable' ,
254
- test : 'writable' ,
255
- describe : 'writable' ,
256
- it : 'writable' ,
257
- expectTypeOf : 'writable' ,
258
- assertType : 'writable' ,
259
- expect : 'writable' ,
260
- assert : 'writable' ,
261
- vitest : 'writable' ,
262
- vi : 'writable' ,
263
- beforeAll : 'writable' ,
264
- afterAll : 'writable' ,
265
- beforeEach : 'writable' ,
266
- afterEach : 'writable' ,
267
- onTestFailed : 'writable' ,
268
- onTestFinished : 'writable'
269
- }
270
- }
271
- }
272
- } ,
273
242
environments : {
274
243
env : {
275
244
globals : {
@@ -294,4 +263,44 @@ const plugin = {
294
263
}
295
264
}
296
265
266
+ plugin . configs = {
267
+ 'legacy-recommended' : createConfigLegacy ( recommended ) ,
268
+ 'legacy-all' : createConfigLegacy ( allRules ) ,
269
+ 'recommended' : {
270
+ plugins : {
271
+ [ "vitest" ] : plugin
272
+ } ,
273
+ rules : createConfig ( recommended )
274
+ } ,
275
+ 'all' : {
276
+ plugins : {
277
+ [ "vitest" ] : plugin
278
+ } ,
279
+ rules : createConfig ( allRules )
280
+ } ,
281
+ 'env' : {
282
+ languageOptions : {
283
+ globals : {
284
+ suite : 'writable' ,
285
+ test : 'writable' ,
286
+ describe : 'writable' ,
287
+ it : 'writable' ,
288
+ expectTypeOf : 'writable' ,
289
+ assertType : 'writable' ,
290
+ expect : 'writable' ,
291
+ assert : 'writable' ,
292
+ vitest : 'writable' ,
293
+ vi : 'writable' ,
294
+ beforeAll : 'writable' ,
295
+ afterAll : 'writable' ,
296
+ beforeEach : 'writable' ,
297
+ afterEach : 'writable' ,
298
+ onTestFailed : 'writable' ,
299
+ onTestFinished : 'writable'
300
+ }
301
+ }
302
+ }
303
+ }
304
+
305
+
297
306
export default plugin
0 commit comments