knip 5.55.1 → 5.57.0

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.
Files changed (71) hide show
  1. package/README.md +44 -20
  2. package/dist/CacheConsultant.d.ts +1 -0
  3. package/dist/CacheConsultant.js +1 -1
  4. package/dist/ConfigurationChief.d.ts +5 -0
  5. package/dist/DependencyDeputy.d.ts +2 -0
  6. package/dist/DependencyDeputy.js +6 -0
  7. package/dist/PrincipalFactory.d.ts +2 -9
  8. package/dist/PrincipalFactory.js +10 -6
  9. package/dist/ProjectPrincipal.d.ts +1 -1
  10. package/dist/ProjectPrincipal.js +3 -3
  11. package/dist/WorkspaceWorker.js +1 -1
  12. package/dist/cli.js +6 -5
  13. package/dist/compilers/index.d.ts +50 -0
  14. package/dist/graph/build.js +11 -2
  15. package/dist/plugins/changelogen/index.d.ts +9 -0
  16. package/dist/plugins/changelogen/index.js +14 -0
  17. package/dist/plugins/changelogithub/index.d.ts +9 -0
  18. package/dist/plugins/changelogithub/index.js +14 -0
  19. package/dist/plugins/convex/index.d.ts +8 -0
  20. package/dist/plugins/convex/index.js +11 -0
  21. package/dist/plugins/docusaurus/helpers.d.ts +5 -0
  22. package/dist/plugins/docusaurus/helpers.js +89 -0
  23. package/dist/plugins/docusaurus/index.d.ts +12 -0
  24. package/dist/plugins/docusaurus/index.js +36 -0
  25. package/dist/plugins/docusaurus/types.d.ts +40 -0
  26. package/dist/plugins/docusaurus/types.js +1 -0
  27. package/dist/plugins/hardhat/index.d.ts +9 -0
  28. package/dist/plugins/hardhat/index.js +16 -0
  29. package/dist/plugins/index.d.ts +40 -0
  30. package/dist/plugins/index.js +10 -0
  31. package/dist/plugins/mocha/index.js +5 -2
  32. package/dist/plugins/nx/index.js +1 -1
  33. package/dist/plugins/nx/types.d.ts +3 -1
  34. package/dist/plugins/tsx/index.d.ts +6 -0
  35. package/dist/plugins/tsx/index.js +24 -0
  36. package/dist/reporters/codeclimate.js +3 -3
  37. package/dist/reporters/codeowners.js +15 -30
  38. package/dist/reporters/compact.js +10 -4
  39. package/dist/reporters/disclosure.js +5 -24
  40. package/dist/reporters/markdown.js +2 -2
  41. package/dist/reporters/symbols.d.ts +1 -1
  42. package/dist/reporters/symbols.js +10 -45
  43. package/dist/reporters/util.d.ts +11 -7
  44. package/dist/reporters/util.js +45 -14
  45. package/dist/reporters/watch.js +7 -21
  46. package/dist/schema/configuration.d.ts +280 -0
  47. package/dist/schema/plugins.d.ts +115 -0
  48. package/dist/schema/plugins.js +5 -0
  49. package/dist/types/PluginNames.d.ts +2 -2
  50. package/dist/types/PluginNames.js +5 -0
  51. package/dist/types/project.d.ts +1 -0
  52. package/dist/typescript/resolve-module-names.js +2 -2
  53. package/dist/util/Performance.d.ts +7 -7
  54. package/dist/util/Performance.js +20 -16
  55. package/dist/util/cli-arguments.d.ts +2 -1
  56. package/dist/util/cli-arguments.js +2 -0
  57. package/dist/util/input.d.ts +8 -1
  58. package/dist/util/input.js +6 -0
  59. package/dist/util/math.js +1 -1
  60. package/dist/util/plugin-config.d.ts +8 -0
  61. package/dist/util/plugin-config.js +1 -0
  62. package/dist/util/resolve.d.ts +3 -1
  63. package/dist/util/resolve.js +7 -9
  64. package/dist/util/table.d.ts +4 -2
  65. package/dist/util/table.js +20 -24
  66. package/dist/util/watch.js +2 -2
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/package.json +2 -2
  70. package/schema.json +20 -0
  71. package/license +0 -12
@@ -16,30 +16,24 @@ export class Table {
16
16
  this.truncateStart = options?.truncateStart || [];
17
17
  this.noTruncate = options?.noTruncate || [];
18
18
  }
19
+ row() {
20
+ this.rows.push({});
21
+ return this;
22
+ }
19
23
  cell(column, value, formatter) {
20
24
  if (!this.columns.includes(column))
21
25
  this.columns.push(column);
22
26
  const row = this.rows[this.rows.length - 1];
23
- row[column] = {
24
- value,
25
- formatted: formatter ? formatter(value) : undefined,
26
- align: typeof value === 'number' ? 'right' : 'left',
27
- };
28
- return this;
29
- }
30
- newRow() {
31
- this.rows.push({});
27
+ const align = typeof value === 'number' ? 'right' : 'left';
28
+ const formatted = formatter ? formatter(value) : undefined;
29
+ row[column] = { value, formatted, align };
32
30
  return this;
33
31
  }
34
- sort(compareFn) {
35
- if (typeof compareFn === 'function') {
36
- this.rows.sort(compareFn);
37
- return this;
38
- }
32
+ sort(column) {
39
33
  this.rows.sort((a, b) => {
40
- const [col, order] = compareFn.split('|');
41
- const vA = a[col].value;
42
- const vB = b[col].value;
34
+ const [columnName, order] = column.split('|');
35
+ const vA = a[columnName].value;
36
+ const vB = b[columnName].value;
43
37
  if (typeof vA === 'string' && typeof vB === 'string')
44
38
  return (order === 'desc' ? -1 : 1) * vA.localeCompare(vB);
45
39
  if (typeof vA === 'number' && typeof vB === 'number')
@@ -48,7 +42,7 @@ export class Table {
48
42
  });
49
43
  return this;
50
44
  }
51
- toString() {
45
+ toCells() {
52
46
  const columns = this.columns.filter(col => this.rows.some(row => typeof row[col].value === 'string' || typeof row[col].value === 'number'));
53
47
  if (this.header) {
54
48
  const headerRow = {};
@@ -87,17 +81,19 @@ export class Table {
87
81
  columnWidths[truncatableColumns.length > 0 ? truncatableColumns[0] : columns[0]] += roundingDiff;
88
82
  }
89
83
  }
90
- return this.rows
91
- .map(row => columns
92
- .map((col, index) => {
84
+ return this.rows.map(row => columns.map((col, index) => {
93
85
  const cell = row[col];
94
86
  const width = columnWidths[col];
95
87
  const fill = cell.fill || ' ';
96
88
  const padded = pad(String(cell.formatted || cell.value || ''), width, fill, cell.align);
97
89
  const truncated = this.truncateStart.includes(col) ? truncateStart(padded, width) : truncate(padded, width);
98
90
  return index === 0 ? truncated : COLUMN_SEPARATOR + truncated;
99
- })
100
- .join(''))
101
- .join('\n');
91
+ }));
92
+ }
93
+ toRows() {
94
+ return this.toCells().map(row => row.join(''));
95
+ }
96
+ toString() {
97
+ return this.toRows().join('\n');
102
98
  }
103
99
  }
@@ -42,7 +42,7 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
42
42
  debugLog(workspace.name, `Watcher: ± ${filename}`);
43
43
  break;
44
44
  }
45
- const filePaths = principal.getUsedResolvedFiles();
45
+ const filePaths = factory.getPrincipals().flatMap(p => p.getUsedResolvedFiles());
46
46
  if (event === 'added' || event === 'deleted') {
47
47
  graph.clear();
48
48
  for (const filePath of filePaths)
@@ -56,7 +56,7 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
56
56
  else {
57
57
  graph.delete(filePath);
58
58
  analyzedFiles.delete(filePath);
59
- if (filePath.startsWith(cwd))
59
+ if (principal.projectPaths.has(filePath))
60
60
  cachedUnusedFiles.add(filePath);
61
61
  }
62
62
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.55.1";
1
+ export declare const version = "5.57.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.55.1';
1
+ export const version = '5.57.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.55.1",
3
+ "version": "5.57.0",
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": {
@@ -62,12 +62,12 @@
62
62
  ],
63
63
  "dependencies": {
64
64
  "@nodelib/fs.walk": "^1.2.3",
65
- "enhanced-resolve": "^5.18.1",
66
65
  "fast-glob": "^3.3.3",
67
66
  "formatly": "^0.2.3",
68
67
  "jiti": "^2.4.2",
69
68
  "js-yaml": "^4.1.0",
70
69
  "minimist": "^1.2.8",
70
+ "oxc-resolver": "^9.0.2",
71
71
  "picocolors": "^1.1.0",
72
72
  "picomatch": "^4.0.1",
73
73
  "smol-toml": "^1.3.1",
package/schema.json CHANGED
@@ -327,6 +327,14 @@
327
327
  "title": "Capacitor plugin configuration (https://knip.dev/reference/plugins/capacitor)",
328
328
  "$ref": "#/definitions/plugin"
329
329
  },
330
+ "changelogen": {
331
+ "title": "changelogen plugin configuration (https://knip.dev/reference/plugins/changelogen)",
332
+ "$ref": "#/definitions/plugin"
333
+ },
334
+ "changelogithub": {
335
+ "title": "changelogithub plugin configuration (https://knip.dev/reference/plugins/changelogithub)",
336
+ "$ref": "#/definitions/plugin"
337
+ },
330
338
  "changesets": {
331
339
  "title": "Changesets plugin configuration (https://knip.dev/reference/plugins/changesets)",
332
340
  "$ref": "#/definitions/plugin"
@@ -339,6 +347,10 @@
339
347
  "title": "commitlint plugin configuration (https://knip.dev/reference/plugins/commitlint)",
340
348
  "$ref": "#/definitions/plugin"
341
349
  },
350
+ "convex": {
351
+ "title": "convex plugin configuration (https://knip.dev/reference/plugins/convex)",
352
+ "$ref": "#/definitions/plugin"
353
+ },
342
354
  "create-typescript-app": {
343
355
  "title": "create-typescript-app plugin configuration (https://knip.dev/reference/plugins/create-typescript-app)",
344
356
  "$ref": "#/definitions/plugin"
@@ -359,6 +371,10 @@
359
371
  "title": "dependency-cruiser plugin configuration (https://knip.dev/reference/plugins/dependency-cruiser)",
360
372
  "$ref": "#/definitions/plugin"
361
373
  },
374
+ "docusaurus": {
375
+ "title": "Docusaurus plugin configuration (https://knip.dev/reference/plugins/docusaurus)",
376
+ "$ref": "#/definitions/plugin"
377
+ },
362
378
  "dotenv": {
363
379
  "title": "dotenv plugin configuration (https://knip.dev/reference/plugins/dotenv)",
364
380
  "$ref": "#/definitions/plugin"
@@ -395,6 +411,10 @@
395
411
  "title": "graphql-codegen plugin configuration (https://knip.dev/reference/plugins/graphql-codegen)",
396
412
  "$ref": "#/definitions/plugin"
397
413
  },
414
+ "hardhat": {
415
+ "title": "hardhat plugin configuration (https://knip.dev/reference/plugins/hardhat)",
416
+ "$ref": "#/definitions/plugin"
417
+ },
398
418
  "husky": {
399
419
  "title": "husky plugin configuration (https://knip.dev/reference/plugins/husky)",
400
420
  "$ref": "#/definitions/plugin"
package/license DELETED
@@ -1,12 +0,0 @@
1
- ISC License (ISC)
2
-
3
- Copyright 2022-2024 Lars Kappert
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
6
- provided that the above copyright notice and this permission notice appear in all copies.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
9
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
11
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
12
- THIS SOFTWARE.