knip 5.77.1 → 5.77.3

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.
package/README.md CHANGED
@@ -19,30 +19,32 @@ performance, less maintenance and easier refactorings.
19
19
 
20
20
  - Website: [knip.dev][6]
21
21
  - GitHub repo: [webpro-nl/knip][4]
22
- - npm package: [knip][1]
23
- - [Contributing Guide][7]
24
- - Follow [@webpro.nl on Bluesky][8] for updates
25
- - [Sponsor Knip!][9]
22
+ - Official npm packages: [knip][1], [@knip/create-config][7],
23
+ [@knip/language-server][8], [@knip/mcp][9]
24
+ - [Knip on the VS Code Marketplace][10], [Knip on the Open VSX Registry][11]
25
+ - [Contributing Guide][12]
26
+ - Follow [@webpro.nl on Bluesky][13] for updates
27
+ - [Sponsor Knip!][14]
26
28
 
27
29
  ## Contributors
28
30
 
29
- Special thanks to [the wonderful people who have contributed to Knip][10]!
31
+ Special thanks to [the wonderful people who have contributed to Knip][15]!
30
32
 
31
33
  ## Knip
32
34
 
33
- /'knɪp/ means "(to) cut" and is [pronounced with a hard "K"][11] 🇳🇱
35
+ /'knɪp/ means "(to) cut" and is [pronounced with a hard "K"][16] 🇳🇱
34
36
 
35
37
  ## License
36
38
 
37
- Knip is free and open-source software licensed under the [ISC License][12].
39
+ Knip is free and open-source software licensed under the [ISC License][17].
38
40
 
39
41
  Parts of Knip have been inspired by and/or partially copy code from the
40
42
  following projects:
41
43
 
42
- - [@npmcli/package-json][13] ([ISC][14])
43
- - [@pnpm/deps.graph-sequencer][15] ([MIT][16])
44
- - [file-entry-cache][17] ([MIT][18])
45
- - [json-parse-even-better-errors][19] ([MIT][20])
44
+ - [@npmcli/package-json][18] ([ISC][19])
45
+ - [@pnpm/deps.graph-sequencer][20] ([MIT][21])
46
+ - [file-entry-cache][22] ([MIT][23])
47
+ - [json-parse-even-better-errors][24] ([MIT][25])
46
48
 
47
49
  [1]: https://www.npmjs.com/package/knip
48
50
  [2]: https://img.shields.io/npm/v/knip?color=f56e0f
@@ -51,18 +53,23 @@ following projects:
51
53
  [5]:
52
54
  https://img.shields.io/github/stars/webpro-nl/knip?style=flat-square&color=f56e0f
53
55
  [6]: https://knip.dev
54
- [7]: https://github.com/webpro-nl/knip/blob/main/.github/CONTRIBUTING.md
55
- [8]: https://bsky.app/profile/webpro.nl
56
- [9]: https://knip.dev/sponsors
57
- [10]: https://knip.dev/#created-by-awesome-contributors
58
- [11]: https://www.youtube.com/watch?v=PE7h7KvQoUI&t=9s
59
- [12]: ./license
60
- [13]: https://github.com/npm/package-json
61
- [14]: https://github.com/npm/package-json/blob/main/LICENSE
62
- [15]: https://github.com/pnpm/pnpm/tree/main/deps/graph-sequencer
63
- [16]: https://github.com/pnpm/pnpm/blob/main/LICENSE
64
- [17]: https://github.com/jaredwray/cacheable/tree/main/packages/file-entry-cache
65
- [18]:
56
+ [7]: https://www.npmjs.com/package/@knip/create-config
57
+ [8]: https://www.npmjs.com/package/@knip/language-server
58
+ [9]: https://www.npmjs.com/package/@knip/mcp
59
+ [10]: https://marketplace.visualstudio.com/items?itemName=webpro.vscode-knip
60
+ [11]: https://open-vsx.org/extension/webpro/vscode-knip
61
+ [12]: https://github.com/webpro-nl/knip/blob/main/.github/CONTRIBUTING.md
62
+ [13]: https://bsky.app/profile/webpro.nl
63
+ [14]: https://knip.dev/sponsors
64
+ [15]: https://knip.dev/#created-by-awesome-contributors
65
+ [16]: https://www.youtube.com/watch?v=PE7h7KvQoUI&t=9s
66
+ [17]: ./license
67
+ [18]: https://github.com/npm/package-json
68
+ [19]: https://github.com/npm/package-json/blob/main/LICENSE
69
+ [20]: https://github.com/pnpm/pnpm/tree/main/deps/graph-sequencer
70
+ [21]: https://github.com/pnpm/pnpm/blob/main/LICENSE
71
+ [22]: https://github.com/jaredwray/cacheable/tree/main/packages/file-entry-cache
72
+ [23]:
66
73
  https://github.com/jaredwray/cacheable/blob/main/packages/file-entry-cache/LICENSE
67
- [19]: https://github.com/npm/json-parse-even-better-errors
68
- [20]: https://github.com/npm/json-parse-even-better-errors/blob/main/LICENSE.md
74
+ [24]: https://github.com/npm/json-parse-even-better-errors
75
+ [25]: https://github.com/npm/json-parse-even-better-errors/blob/main/LICENSE.md
@@ -36,7 +36,7 @@ export declare class ConfigurationChief {
36
36
  workspaceGraph: WorkspaceGraph;
37
37
  includedWorkspaces: Workspace[];
38
38
  constructor(options: MainOptions);
39
- getConfigurationHints(): Set<ConfigurationHint>;
39
+ getConfigurationHints(): ConfigurationHint[];
40
40
  private normalize;
41
41
  getWorkspaces(): Promise<Workspace[]>;
42
42
  private getListedWorkspaces;
@@ -73,18 +73,18 @@ export class ConfigurationChief {
73
73
  this.config = this.normalize(options.parsedConfig ?? {});
74
74
  }
75
75
  getConfigurationHints() {
76
- const hints = new Set();
76
+ const hints = [];
77
77
  if (this.rawConfig) {
78
78
  if (this.workspacePackages.size > 1) {
79
79
  const entry = arrayify(this.rawConfig.entry);
80
80
  if (entry.length > 0) {
81
81
  const identifier = `[${entry[0]}${entry.length > 1 ? `, ${ELLIPSIS}` : ''}]`;
82
- hints.add({ type: 'entry-top-level', identifier });
82
+ hints.push({ type: 'entry-top-level', identifier });
83
83
  }
84
84
  const project = arrayify(this.rawConfig.project);
85
85
  if (project.length > 0) {
86
86
  const identifier = `[${project[0]}${project.length > 1 ? `, ${ELLIPSIS}` : ''}]`;
87
- hints.add({ type: 'project-top-level', identifier });
87
+ hints.push({ type: 'project-top-level', identifier });
88
88
  }
89
89
  }
90
90
  }
@@ -71,7 +71,7 @@ export declare class DependencyDeputy {
71
71
  issues: Issues;
72
72
  counters: Counters;
73
73
  }): void;
74
- getConfigurationHints(): Set<ConfigurationHint>;
74
+ getConfigurationHints(): ConfigurationHint[];
75
75
  addIgnoredDependencies(workspaceName: string, identifier: string): void;
76
76
  addIgnoredBinaries(workspaceName: string, identifier: string): void;
77
77
  }
@@ -349,16 +349,16 @@ export class DependencyDeputy {
349
349
  this.handleIgnoredUnresolved(issues, counters);
350
350
  }
351
351
  getConfigurationHints() {
352
- const configurationHints = new Set();
352
+ const configurationHints = [];
353
353
  for (const [workspaceName, manifest] of this._manifests) {
354
354
  for (const identifier of manifest.unusedIgnoreDependencies) {
355
- configurationHints.add({ workspaceName, identifier, type: 'ignoreDependencies' });
355
+ configurationHints.push({ workspaceName, identifier, type: 'ignoreDependencies' });
356
356
  }
357
357
  for (const identifier of manifest.unusedIgnoreBinaries) {
358
- configurationHints.add({ workspaceName, identifier, type: 'ignoreBinaries' });
358
+ configurationHints.push({ workspaceName, identifier, type: 'ignoreBinaries' });
359
359
  }
360
360
  for (const identifier of manifest.unusedIgnoreUnresolved) {
361
- configurationHints.add({ workspaceName, identifier, type: 'ignoreUnresolved' });
361
+ configurationHints.push({ workspaceName, identifier, type: 'ignoreUnresolved' });
362
362
  }
363
363
  }
364
364
  return configurationHints;
@@ -34,7 +34,7 @@ export declare class IssueCollector {
34
34
  issues: import("./types/issues.js").Issues;
35
35
  counters: import("./types/issues.js").Counters;
36
36
  tagHints: Set<TagHint>;
37
- configurationHints: Set<ConfigurationHint>;
37
+ configurationHints: ConfigurationHint[];
38
38
  };
39
39
  private retainedIssues;
40
40
  retainIssue(issue: Issue): void;
@@ -120,7 +120,7 @@ export class IssueCollector {
120
120
  issues: this.issues,
121
121
  counters: this.counters,
122
122
  tagHints: this.tagHints,
123
- configurationHints: new Set(this.configurationHints.values()),
123
+ configurationHints: Array.from(this.configurationHints.values()),
124
124
  };
125
125
  }
126
126
  retainedIssues = [];
@@ -59,7 +59,7 @@ export declare class WorkspaceWorker {
59
59
  getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): string[];
60
60
  private getConfigurationFilePatterns;
61
61
  runPlugins(): Promise<Input[]>;
62
- getConfigurationHints(type: 'entry' | 'project', patterns: string[], filePaths: string[], includedPaths: Set<string>): Set<ConfigurationHint>;
62
+ getConfigurationHints(type: 'entry' | 'project', patterns: string[], filePaths: string[], includedPaths: Set<string>): ConfigurationHint[];
63
63
  onDispose(): void;
64
64
  }
65
65
  export {};
@@ -335,7 +335,7 @@ export class WorkspaceWorker {
335
335
  return inputs;
336
336
  }
337
337
  getConfigurationHints(type, patterns, filePaths, includedPaths) {
338
- const hints = new Set();
338
+ const hints = [];
339
339
  const entries = this.config[type].filter(pattern => !pattern.startsWith('!'));
340
340
  const workspaceName = this.name;
341
341
  const userDefinedPatterns = entries.filter(id => !isDefaultPattern(type, id));
@@ -343,7 +343,7 @@ export class WorkspaceWorker {
343
343
  return hints;
344
344
  if (filePaths.length === 0) {
345
345
  const identifier = `[${entries[0]}${entries.length > 1 ? `, ${ELLIPSIS}` : ''}]`;
346
- hints.add({ type: `${type}-empty`, identifier, workspaceName });
346
+ hints.push({ type: `${type}-empty`, identifier, workspaceName });
347
347
  return hints;
348
348
  }
349
349
  for (const pattern of patterns) {
@@ -351,12 +351,12 @@ export class WorkspaceWorker {
351
351
  continue;
352
352
  const filePathOrPattern = join(this.dir, pattern.replace(/!$/, ''));
353
353
  if (includedPaths.has(filePathOrPattern)) {
354
- hints.add({ type: `${type}-redundant`, identifier: pattern, workspaceName });
354
+ hints.push({ type: `${type}-redundant`, identifier: pattern, workspaceName });
355
355
  }
356
356
  else {
357
357
  const matcher = picomatch(filePathOrPattern);
358
358
  if (!filePaths.some(filePath => matcher(filePath))) {
359
- hints.add({ type: `${type}-empty`, identifier: pattern, workspaceName });
359
+ hints.push({ type: `${type}-empty`, identifier: pattern, workspaceName });
360
360
  }
361
361
  }
362
362
  }
package/dist/cli.js CHANGED
@@ -74,7 +74,7 @@ const run = async () => {
74
74
  logWarning('WARNING', 'Class members are not tracked when using the --isolate-workspaces flag');
75
75
  }
76
76
  if ((!args['no-exit-code'] && totalErrorCount > Number(args['max-issues'] ?? 0)) ||
77
- (!options.isDisableConfigHints && options.isTreatConfigHintsAsErrors && configurationHints.size > 0)) {
77
+ (!options.isDisableConfigHints && options.isTreatConfigHintsAsErrors && configurationHints.length > 0)) {
78
78
  process.exit(1);
79
79
  }
80
80
  }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const main: (options: MainOptions) => Promise<{
3
3
  issues: import("./types/issues.js").Issues;
4
4
  counters: import("./types/issues.js").Counters;
5
5
  tagHints: Set<import("./types/issues.js").TagHint>;
6
- configurationHints: Set<import("./types/issues.js").ConfigurationHint>;
6
+ configurationHints: import("./types/issues.js").ConfigurationHint[];
7
7
  includedWorkspaceDirs: string[];
8
8
  enabledPlugins: {
9
9
  [k: string]: string[];
@@ -54,9 +54,9 @@ export default ({ report, issues, cwd, configurationHints, isDisableConfigHints,
54
54
  }
55
55
  }
56
56
  }
57
- if (!isDisableConfigHints && configurationHints.size > 0) {
57
+ if (!isDisableConfigHints && configurationHints.length > 0) {
58
58
  const CONFIG_HINTS_TITLE = 'Configuration hints';
59
- core.info(`${CONFIG_HINTS_TITLE} (${configurationHints.size})`);
59
+ core.info(`${CONFIG_HINTS_TITLE} (${configurationHints.length})`);
60
60
  const sortedHints = [...configurationHints].sort((a, b) => (a.filePath ?? '').localeCompare(b.filePath ?? ''));
61
61
  for (const hint of sortedHints) {
62
62
  const hintPrinter = hintPrinters.get(hint.type);
@@ -28,7 +28,7 @@ export default (options) => {
28
28
  }
29
29
  if (totalIssues === 0 &&
30
30
  isShowProgress &&
31
- (!options.isTreatConfigHintsAsErrors || options.configurationHints.size === 0)) {
31
+ (!options.isTreatConfigHintsAsErrors || options.configurationHints.length === 0)) {
32
32
  console.log('✂️ Excellent, Knip found no issues.');
33
33
  }
34
34
  };
@@ -12,7 +12,7 @@ declare const hintPrinters: Map<ConfigurationHintType, {
12
12
  print: (options: PrintHintOptions) => string;
13
13
  }>;
14
14
  export { hintPrinters };
15
- export interface ProcessedHint extends ConfigurationHint {
15
+ interface ProcessedHint extends ConfigurationHint {
16
16
  message: string;
17
17
  }
18
18
  export declare const finalizeConfigurationHints: (results: Results, options: {
@@ -71,13 +71,18 @@ export const finalizeConfigurationHints = (results, options) => {
71
71
  workspace.size++;
72
72
  }
73
73
  if (workspaces.length === 1) {
74
- results.configurationHints.add({ type: 'top-level-unconfigured', identifier: '.', size: workspaces[0].size });
74
+ results.configurationHints.push({ type: 'top-level-unconfigured', identifier: '.', size: workspaces[0].size });
75
75
  }
76
76
  else {
77
77
  const topWorkspaces = workspaces.sort((a, b) => b.size - a.size).filter(ws => ws.size > 1);
78
78
  for (const { dir, size } of topWorkspaces) {
79
79
  const identifier = toRelative(dir, options.cwd) || '.';
80
- results.configurationHints.add({ type: 'workspace-unconfigured', workspaceName: identifier, identifier, size });
80
+ results.configurationHints.push({
81
+ type: 'workspace-unconfigured',
82
+ workspaceName: identifier,
83
+ identifier,
84
+ size,
85
+ });
81
86
  }
82
87
  }
83
88
  }
@@ -106,7 +111,7 @@ export const printConfigurationHints = ({ cwd, counters, issues, tagHints, confi
106
111
  const rows = finalizeConfigurationHints({ issues, counters, configurationHints, tagHints, includedWorkspaceDirs, enabledPlugins }, { cwd, configFilePath });
107
112
  if (rows.length > 0) {
108
113
  const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
109
- console.log(getTitle('Configuration hints', configurationHints.size));
114
+ console.log(getTitle('Configuration hints', configurationHints.length));
110
115
  console.warn(getTableForHints(rows).toString());
111
116
  }
112
117
  if (tagHints.size > 0) {
package/dist/run.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const run: (options: MainOptions) => Promise<{
6
6
  issues: import("./types/issues.js").Issues;
7
7
  counters: import("./types/issues.js").Counters;
8
8
  tagHints: Set<import("./types/issues.js").TagHint>;
9
- configurationHints: Set<import("./types/issues.js").ConfigurationHint>;
9
+ configurationHints: import("./types/issues.js").ConfigurationHint[];
10
10
  includedWorkspaceDirs: string[];
11
11
  enabledPlugins: {
12
12
  [k: string]: string[];
@@ -24,7 +24,7 @@ export declare const run: (options: MainOptions) => Promise<{
24
24
  issues: import("./types/issues.js").Issues;
25
25
  counters: import("./types/issues.js").Counters;
26
26
  tagHints: Set<import("./types/issues.js").TagHint>;
27
- configurationHints: Set<import("./types/issues.js").ConfigurationHint>;
27
+ configurationHints: import("./types/issues.js").ConfigurationHint[];
28
28
  };
29
29
  } | undefined;
30
30
  streamer: ConsoleStreamer;
@@ -1,5 +1,4 @@
1
1
  import type { CollectorIssues } from '../IssueCollector.js';
2
- import { type ProcessedHint } from '../reporters/util/configuration-hints.js';
3
2
  import { type Results } from '../run.js';
4
3
  import type { MainOptions } from '../util/create-options.js';
5
4
  import type { WatchChange } from '../util/watch.js';
@@ -14,7 +13,6 @@ export interface Session {
14
13
  handleFileChanges(changes: WatchChange[]): Promise<WatchUpdate>;
15
14
  getIssues(): CollectorIssues;
16
15
  getResults(): Results;
17
- getConfigurationHints(): ProcessedHint[];
18
16
  describeFile(filePath: string, options?: FileDescriptorOptions): File | undefined;
19
17
  describePackageJson(): PackageJsonFile;
20
18
  }
@@ -1,4 +1,3 @@
1
- import { finalizeConfigurationHints } from '../reporters/util/configuration-hints.js';
2
1
  import { run } from '../run.js';
3
2
  import { buildFileDescriptor } from './file-descriptor.js';
4
3
  import { buildPackageJsonDescriptor } from './package-json-descriptor.js';
@@ -13,7 +12,6 @@ const createSessionAdapter = (session, results, options) => {
13
12
  handleFileChanges: session.handleFileChanges,
14
13
  getIssues: session.getIssues,
15
14
  getResults: () => results,
16
- getConfigurationHints: () => finalizeConfigurationHints(results, options),
17
15
  describeFile: (filePath, opts) => buildFileDescriptor(filePath, options.cwd, session.getGraph(), session.getEntryPaths(), opts),
18
16
  describePackageJson: () => buildPackageJsonDescriptor(session.getGraph(), session.getEntryPaths()),
19
17
  };
@@ -54,7 +54,7 @@ export type ReporterOptions = {
54
54
  issues: Issues;
55
55
  counters: Counters;
56
56
  tagHints: TagHints;
57
- configurationHints: Set<ConfigurationHint>;
57
+ configurationHints: ConfigurationHint[];
58
58
  enabledPlugins: Record<string, string[]>;
59
59
  isDisableConfigHints: boolean;
60
60
  isTreatConfigHintsAsErrors: boolean;
@@ -41,7 +41,7 @@ export declare const getSessionHandler: (options: MainOptions, { analyzedFiles,
41
41
  issues: Issues;
42
42
  counters: import("../types/issues.js").Counters;
43
43
  tagHints: Set<import("../types/issues.js").TagHint>;
44
- configurationHints: Set<import("../types/issues.js").ConfigurationHint>;
44
+ configurationHints: import("../types/issues.js").ConfigurationHint[];
45
45
  };
46
46
  }>;
47
47
  export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.77.1";
1
+ export declare const version = "5.77.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.77.1';
1
+ export const version = '5.77.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.77.1",
3
+ "version": "5.77.3",
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": {