Skip to content

Commit f2609d6

Browse files
committed
fix: don't create new test plugin for every run
1 parent cbb706f commit f2609d6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/configs/test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import type {
77
TypedFlatConfigItem,
88
} from '../types'
99

10+
// Hold the reference so we don't redeclare the plugin on each call
11+
let _pluginTest: any
12+
1013
export async function test(
1114
options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {},
1215
): Promise<TypedFlatConfigItem[]> {
@@ -18,18 +21,20 @@ export async function test(
1821
interopDefault(import('eslint-plugin-no-only-tests')),
1922
] as const)
2023

24+
_pluginTest = _pluginTest || {
25+
...pluginVitest,
26+
rules: {
27+
...pluginVitest.rules,
28+
// extend `test/no-only-tests` rule
29+
...pluginNoOnlyTests.rules,
30+
},
31+
}
32+
2133
return [
2234
{
2335
name: 'coderwyd/test/setup',
2436
plugins: {
25-
test: {
26-
...pluginVitest,
27-
rules: {
28-
...pluginVitest.rules,
29-
// extend `test/no-only-tests` rule
30-
...pluginNoOnlyTests.rules,
31-
},
32-
},
37+
test: _pluginTest,
3338
},
3439
},
3540
{

0 commit comments

Comments
 (0)