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
coderwyd committed Apr 16, 2024
1 parent cbb706f commit f2609d6
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 @@ -7,6 +7,9 @@ import type {
TypedFlatConfigItem,
} from '../types'

// 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 @@ -18,18 +21,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: 'coderwyd/test/setup',
plugins: {
test: {
...pluginVitest,
rules: {
...pluginVitest.rules,
// extend `test/no-only-tests` rule
...pluginNoOnlyTests.rules,
},
},
test: _pluginTest,
},
},
{
Expand Down

0 comments on commit f2609d6

Please sign in to comment.