Skip to content

Commit 2bc6f13

Browse files
committedApr 10, 2024
fix: don't create new test plugin for every run
fix nuxt/eslint#389
1 parent 2263538 commit 2bc6f13

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
 

Diff for: ‎src/configs/test.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { interopDefault } from '../utils'
22
import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
33
import { GLOB_TESTS } from '../globs'
44

5+
// Hold the reference so we don't redeclare the plugin on each call
6+
let _pluginTest: any
7+
58
export async function test(
69
options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {},
710
): Promise<TypedFlatConfigItem[]> {
@@ -20,18 +23,20 @@ export async function test(
2023
interopDefault(import('eslint-plugin-no-only-tests')),
2124
] as const)
2225

26+
_pluginTest = _pluginTest || {
27+
...pluginVitest,
28+
rules: {
29+
...pluginVitest.rules,
30+
// extend `test/no-only-tests` rule
31+
...pluginNoOnlyTests.rules,
32+
},
33+
}
34+
2335
return [
2436
{
2537
name: 'antfu/test/setup',
2638
plugins: {
27-
test: {
28-
...pluginVitest,
29-
rules: {
30-
...pluginVitest.rules,
31-
// extend `test/no-only-tests` rule
32-
...pluginNoOnlyTests.rules,
33-
},
34-
},
39+
test: _pluginTest,
3540
},
3641
},
3742
{

0 commit comments

Comments
 (0)
Please sign in to comment.