knip 5.60.1 → 5.60.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,8 +6,13 @@ const packageJsonPath = (id) => id;
6
6
  const resolveConfig = localConfig => {
7
7
  const scripts = localConfig.scripts;
8
8
  const entries = [toProductionEntry('server.js')];
9
- if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
10
- const patterns = ['**/*{.,-,_}test.?(c|m)js', '**/test-*.?(c|m)js', '**/test.?(c|m)js', '**/test/**/*.?(c|m)js'];
9
+ if (scripts && Object.values(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(script))) {
10
+ const patterns = [
11
+ '**/*{.,-,_}test.{cjs,mjs,js,cts,mts,ts}',
12
+ '**/test-*.{cjs,mjs,js,cts,mts,ts}',
13
+ '**/test.{cjs,mjs,js,cts,mts,ts}',
14
+ '**/test/**/*.{cjs,mjs,js,cts,mts,ts}',
15
+ ];
11
16
  entries.push(...patterns.map(id => toEntry(id)));
12
17
  }
13
18
  return entries;
@@ -8,7 +8,7 @@ const packageJsonPath = (id) => id;
8
8
  const resolveConfig = localConfig => {
9
9
  const scripts = localConfig.scripts;
10
10
  const entries = [];
11
- if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)tsx\s(.*)--test/.test(scripts[script]))) {
11
+ if (scripts && Object.values(scripts).some(script => /(?<=^|\s)tsx\s(.*)--test/.test(script))) {
12
12
  const patterns = [
13
13
  '**/*{.,-,_}test.?(c|m)(j|t)s',
14
14
  '**/test-*.?(c|m)(j|t)s',
@@ -10,11 +10,7 @@ const config = ['vitest.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,proj
10
10
  const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
11
11
  const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)', ...mocks];
12
12
  const isVitestCoverageCommand = /vitest(.+)--coverage(?:\.enabled(?:=true)?)?/;
13
- const hasScriptWithCoverage = (scripts) => scripts
14
- ? Object.values(scripts).some(script => {
15
- return isVitestCoverageCommand.test(script);
16
- })
17
- : false;
13
+ const hasScriptWithCoverage = (scripts) => scripts ? Object.values(scripts).some(script => isVitestCoverageCommand.test(script)) : false;
18
14
  const findConfigDependencies = (localConfig, options) => {
19
15
  const { manifest, cwd: dir } = options;
20
16
  const testConfig = localConfig.test;
@@ -8,7 +8,7 @@ const unused = (options) => `Remove from ${type(options.type)}${options.workspac
8
8
  const empty = (options) => `Refine ${type(options.type)}${workspace(options)}: ${id(options.identifier)} (no files found)`;
9
9
  const remove = (options) => `Remove ${type(options.type)}${workspace(options)}: ${id(options.identifier)}`;
10
10
  const add = (options) => `Add to or refine in ${yellow('workspaces')}: ${id(options.identifier)} (${options.size} unused files)`;
11
- const topLevel = (options) => `Remove or move unused top-level ${type(options.type)} to ${yellow('"."')}: ${id(options.identifier)}`;
11
+ const topLevel = (options) => `Remove or move unused top-level ${type(options.type)} to ${yellow('"."')} workspace: ${id(options.identifier)}`;
12
12
  const hintPrinters = new Map([
13
13
  ['ignoreBinaries', { print: unused }],
14
14
  ['ignoreDependencies', { print: unused }],
@@ -41,11 +41,13 @@ export const printConfigurationHints = ({ counters, issues, tagHints, configurat
41
41
  }
42
42
  }
43
43
  if (configurationHints.size > 0) {
44
+ const isTopLevel = (type) => type.includes('top-level');
45
+ const hintOrderer = (a, b) => isTopLevel(a.type) && !isTopLevel(b.type) ? -1 : !isTopLevel(a.type) && isTopLevel(b.type) ? 1 : 0;
44
46
  const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
45
47
  const style = isTreatConfigHintsAsErrors ? plain : dim;
46
48
  console.log(getTitle('Configuration hints', configurationHints.size));
47
49
  const isRootOnly = includedWorkspaces.length === 1 && includedWorkspaces[0].name === '.';
48
- for (const hint of configurationHints) {
50
+ for (const hint of Array.from(configurationHints).sort(hintOrderer)) {
49
51
  const hintPrinter = hintPrinters.get(hint.type);
50
52
  if (hintPrinter)
51
53
  console.warn(style(hintPrinter.print({ ...hint, isRootOnly })));
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.60.1";
1
+ export declare const version = "5.60.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.60.1';
1
+ export const version = '5.60.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.60.1",
3
+ "version": "5.60.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": {