Skip to content

Commit

Permalink
Add common pattern to config file patterns in vite and vitest plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 4, 2023
1 parent 1f857a4 commit 302798e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const ENABLERS = ['vite'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

export const CONFIG_FILE_PATTERNS = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
export const CONFIG_FILE_PATTERNS = ['vite*.config.{js,mjs,ts,cjs,mts,cts}'];

const findViteDependencies: GenericPluginCallback = async (configFilePath, options) => {
const localConfig: ViteConfigOrFn | undefined = await load(configFilePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/vitest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ENABLERS = ['vitest'];
export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

export const CONFIG_FILE_PATTERNS = [
'vitest.config.{js,mjs,ts,cjs,mts,cts}',
'vitest*.config.{js,mjs,ts,cjs,mts,cts}',
'vitest.{workspace,projects}.{ts,js,json}',
];

Expand Down
6 changes: 4 additions & 2 deletions packages/knip/test/plugins/vitest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ test('Find dependencies in vitest configuration', async () => {
});

assert(issues.unlisted['vitest.workspace.ts']['@edge-runtime/vm']);
assert(issues.unlisted['vitest-default-coverage.config.ts']['jsdom']);
assert(issues.unlisted['vitest-default-coverage.config.ts']['@vitest/coverage-v8']);
assert(issues.unlisted['vitest.config.ts']['happy-dom']);
assert(issues.unlisted['vitest.config.ts']['@vitest/coverage-istanbul']);
assert(issues.unlisted['vitest.config.ts']['setup.js']);

assert.deepEqual(counters, {
...baseCounters,
files: 2,
unlisted: 4,
files: 1,
unlisted: 6,
processed: 6,
total: 6,
});
Expand Down

0 comments on commit 302798e

Please sign in to comment.