knip 5.57.1 → 5.57.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,8 @@ const title = 'Jest';
6
6
  const enablers = ['jest'];
7
7
  const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) || Boolean(manifest.name?.startsWith('jest-presets'));
8
8
  const config = ['jest.config.{js,ts,mjs,cjs,json}', 'package.json'];
9
- const entry = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)', '**/__mocks__/**/*.[jt]s'];
9
+ const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
10
+ const entry = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)', ...mocks];
10
11
  const resolveDependencies = async (config, options) => {
11
12
  const { configFileDir } = options;
12
13
  if (config?.preset) {
@@ -84,6 +85,8 @@ const resolveConfig = async (localConfig, options) => {
84
85
  const entries = localConfig.testMatch
85
86
  ? localConfig.testMatch.map(replaceRootDir).map(id => toEntry(id))
86
87
  : entry.map(id => toEntry(id));
88
+ if (localConfig.testMatch && !options.config.entry)
89
+ entries.push(...mocks.map(id => toEntry(id)));
87
90
  const result = inputs.map(dependency => {
88
91
  dependency.specifier = replaceRootDir(dependency.specifier);
89
92
  return dependency;
@@ -6,7 +6,8 @@ const title = 'Vitest';
6
6
  const enablers = ['vitest'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['vitest.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{js,mjs,ts,cjs,mts,cts,json}'];
9
- const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)', '**/__mocks__/**/*.[jt]s?(x)'];
9
+ const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
10
+ const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)', ...mocks];
10
11
  const isVitestCoverageCommand = /vitest(.+)--coverage(?:\.enabled(?:=true)?)?/;
11
12
  const hasScriptWithCoverage = (scripts) => scripts
12
13
  ? Object.values(scripts).some(script => {
@@ -84,6 +85,9 @@ export const resolveConfig = async (localConfig, options) => {
84
85
  if (cfg.test?.include) {
85
86
  for (const dependency of cfg.test.include)
86
87
  dependency[0] !== '!' && inputs.add(toEntry(join(dir, dependency)));
88
+ if (!options.config.entry)
89
+ for (const dependency of mocks)
90
+ inputs.add(toEntry(join(dir, dependency)));
87
91
  }
88
92
  else {
89
93
  for (const dependency of options.config.entry ?? entry)
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.57.1";
1
+ export declare const version = "5.57.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.57.1';
1
+ export const version = '5.57.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.57.1",
3
+ "version": "5.57.2",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {