@@ -5,6 +5,7 @@ import tseslint from 'typescript-eslint';
55import unicorn from 'eslint-plugin-unicorn' ;
66import importX , { createNodeResolver } from 'eslint-plugin-import-x' ;
77import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript' ;
8+ import vitest from '@vitest/eslint-plugin' ;
89import globals from 'globals' ;
910
1011export default defineConfig (
@@ -128,5 +129,45 @@ export default defineConfig(
128129 } ,
129130 } ,
130131
132+ // Test rules.
133+ {
134+ files : [ '**/*.@(test|spec).[tj]s?(x)' ] ,
135+ ...vitest . configs . recommended ,
136+ rules : {
137+ ...vitest . configs . recommended . rules ,
138+ 'vitest/prefer-vi-mocked' : 'error' ,
139+ 'vitest/prefer-hooks-on-top' : 'error' ,
140+ 'vitest/no-duplicate-hooks' : 'error' ,
141+ 'vitest/hoisted-apis-on-top' : 'error' ,
142+
143+ 'vitest/consistent-each-for' : [
144+ 'error' ,
145+ {
146+ test : 'each' ,
147+ it : 'each' ,
148+ describe : 'each' ,
149+ suite : 'each' ,
150+ } ,
151+ ] ,
152+
153+ 'vitest/consistent-test-filename' : [
154+ 'error' ,
155+ {
156+ pattern : '\\.test\\.[tj]sx?$' ,
157+ } ,
158+ ] ,
159+
160+ 'vitest/consistent-test-it' : [
161+ 'error' ,
162+ {
163+ fn : 'it' ,
164+ withinDescribe : 'it' ,
165+ } ,
166+ ] ,
167+
168+ 'vitest/prefer-hooks-in-order' : 'error' ,
169+ } ,
170+ } ,
171+
131172 globalIgnores ( [ '**/dist' , '**/.turbo' ] ) ,
132173) ;
0 commit comments