Skip to content

Commit

Permalink
fix: don't create new test plugin for every run
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 10, 2024
1 parent 2263538 commit 2bc6f13
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { interopDefault } from '../utils'
import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
import { GLOB_TESTS } from '../globs'

// Hold the reference so we don't redeclare the plugin on each call
let _pluginTest: any

export async function test(
options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {},
): Promise<TypedFlatConfigItem[]> {
Expand All @@ -20,18 +23,20 @@ export async function test(
interopDefault(import('eslint-plugin-no-only-tests')),
] as const)

_pluginTest = _pluginTest || {
...pluginVitest,
rules: {
...pluginVitest.rules,
// extend `test/no-only-tests` rule
...pluginNoOnlyTests.rules,
},
}

return [
{
name: 'antfu/test/setup',
plugins: {
test: {
...pluginVitest,
rules: {
...pluginVitest.rules,
// extend `test/no-only-tests` rule
...pluginNoOnlyTests.rules,
},
},
test: _pluginTest,
},
},
{
Expand Down

0 comments on commit 2bc6f13

Please sign in to comment.