Skip to content

Commit

Permalink
Return reporters[0] instead of flat
Browse files Browse the repository at this point in the history
  • Loading branch information
dakro committed Jan 21, 2025
1 parent b6952fb commit 9c3a7cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/knip/fixtures/plugins/vitest7/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@fixtures/vitest7",
"devDependencies": {
"vitest": "*"
"vitest": "*",
"ReporterString": "*",
"ReporterArray": "*"
}
}
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/vitest/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ export const getExternalReporters = (reporters?: ViteConfig['test']['reporters']
reporters
? [reporters]
.flat()
.flat()
.map(reporter => (Array.isArray(reporter) ? reporter[0] : reporter))
.filter((reporter): reporter is string => typeof reporter === 'string' && !builtInReporters.includes(reporter))
: [];
6 changes: 1 addition & 5 deletions packages/knip/test/plugins/vitest7.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ import baseCounters from '../helpers/baseCounters.js';
const cwd = resolve('fixtures/plugins/vitest7');

test('Find dependencies with Vitest plugin (7)', async () => {
const { issues, counters } = await main({
const { counters } = await main({
...baseArguments,
cwd,
});

assert(issues.unlisted['vitest.config.ts']['ReporterString']);
assert(issues.unlisted['vitest.config.ts']['ReporterArray']);

assert.deepEqual(counters, {
...baseCounters,
files: 0,
processed: 3,
total: 3,
unlisted: 2,
});
});

0 comments on commit 9c3a7cb

Please sign in to comment.