1- import type { Linter } from 'eslint'
1+ import type { Linter , RuleModule } from '@typescript-eslint/utils/ts- eslint'
22import { version } from '../package.json'
33import lowerCaseTitle , { RULE_NAME as lowerCaseTitleName } from './rules/prefer-lowercase-title'
44import maxNestedDescribe , { RULE_NAME as maxNestedDescribeName } from './rules/max-nested-describe'
@@ -70,8 +70,8 @@ const createConfig = <R extends Linter.RulesRecord>(rules: R) => (
7070 [ `vitest/${ ruleName } ` ] : rules [ ruleName ]
7171 }
7272 } , { } ) ) 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+ }
7575
7676const createConfigLegacy = ( rules : Record < string , string > ) => ( {
7777 plugins : [ '@vitest' ] ,
@@ -159,7 +159,18 @@ const recommended = {
159159 [ noImportNodeTestName ] : 'error'
160160} as const
161161
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 = {
163174 meta : {
164175 name : 'vitest' ,
165176 version
@@ -228,48 +239,6 @@ const plugin = {
228239 [ paddingAroundTestBlocksName ] : paddingAroundTestBlocks ,
229240 [ validExpectInPromiseName ] : validExpectInPromise
230241 } ,
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- } ,
273242 environments : {
274243 env : {
275244 globals : {
@@ -294,4 +263,44 @@ const plugin = {
294263 }
295264}
296265
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+
297306export default plugin
0 commit comments