knip 5.44.0 → 5.44.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.
Files changed (34) hide show
  1. package/dist/ConfigurationChief.js +3 -3
  2. package/dist/DependencyDeputy.d.ts +1 -1
  3. package/dist/DependencyDeputy.js +4 -4
  4. package/dist/IssueCollector.js +1 -1
  5. package/dist/ProjectPrincipal.d.ts +2 -2
  6. package/dist/WorkspaceWorker.js +5 -1
  7. package/dist/graph/analyze.d.ts +30 -0
  8. package/dist/graph/analyze.js +232 -0
  9. package/dist/graph/build.d.ts +40 -0
  10. package/dist/graph/build.js +268 -0
  11. package/dist/index.js +46 -484
  12. package/dist/plugins/react-router/index.js +1 -1
  13. package/dist/plugins/stylelint/index.js +1 -1
  14. package/dist/plugins/stylelint/types.d.ts +1 -1
  15. package/dist/{ConfigurationValidator.d.ts → schema/configuration.d.ts} +1 -1
  16. package/dist/{ConfigurationValidator.js → schema/configuration.js} +2 -2
  17. package/dist/types/config.d.ts +2 -2
  18. package/dist/types/{dependency-graph.d.ts → module-graph.d.ts} +1 -1
  19. package/dist/typescript/find-internal-references.d.ts +1 -1
  20. package/dist/typescript/get-imports-and-exports.d.ts +1 -1
  21. package/dist/typescript/get-imports-and-exports.js +1 -1
  22. package/dist/util/has-strictly-ns-references.d.ts +2 -2
  23. package/dist/util/is-identifier-referenced.d.ts +2 -2
  24. package/dist/util/{dependency-graph.d.ts → module-graph.d.ts} +3 -3
  25. package/dist/util/trace.d.ts +2 -2
  26. package/dist/util/watch.d.ts +4 -4
  27. package/dist/util/watch.js +3 -4
  28. package/dist/version.d.ts +1 -1
  29. package/dist/version.js +1 -1
  30. package/package.json +1 -1
  31. /package/dist/types/{dependency-graph.js → module-graph.js} +0 -0
  32. /package/dist/{issues/initializers.d.ts → util/issue-initializers.d.ts} +0 -0
  33. /package/dist/{issues/initializers.js → util/issue-initializers.js} +0 -0
  34. /package/dist/util/{dependency-graph.js → module-graph.js} +0 -0
@@ -2,7 +2,7 @@ import { isBuiltin } from 'node:module';
2
2
  import ts from 'typescript';
3
3
  import { ALIAS_TAG, ANONYMOUS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
4
4
  import { timerify } from '../util/Performance.js';
5
- import { addNsValue, addValue, createImports } from '../util/dependency-graph.js';
5
+ import { addNsValue, addValue, createImports } from '../util/module-graph.js';
6
6
  import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
7
7
  import { isInNodeModules } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
@@ -1,4 +1,4 @@
1
- import type { DependencyGraph, ImportDetails } from '../types/dependency-graph.js';
1
+ import type { ImportDetails, ModuleGraph } from '../types/module-graph.js';
2
2
  export declare const hasStrictlyEnumReferences: (importsForExport: ImportDetails | undefined, id: string) => boolean;
3
- export declare const hasStrictlyNsReferences: (graph: DependencyGraph, importsForExport: ImportDetails | undefined, id: string) => [boolean, string?];
3
+ export declare const hasStrictlyNsReferences: (graph: ModuleGraph, importsForExport: ImportDetails | undefined, id: string) => [boolean, string?];
4
4
  export declare const getType: (hasOnlyNsReference: boolean, isType: boolean) => "exports" | "types" | "nsExports" | "nsTypes";
@@ -1,9 +1,9 @@
1
- import type { DependencyGraph } from '../types/dependency-graph.js';
1
+ import type { ModuleGraph } from '../types/module-graph.js';
2
2
  import { type TraceNode } from './trace.js';
3
3
  type Result = {
4
4
  isReferenced: boolean;
5
5
  reExportingEntryFile: undefined | string;
6
6
  traceNode: TraceNode;
7
7
  };
8
- export declare const getIsIdentifierReferencedHandler: (graph: DependencyGraph, entryPaths: Set<string>) => (filePath: string, id: string, isIncludeEntryExports?: boolean, traceNode?: TraceNode, seen?: Set<string>) => Result;
8
+ export declare const getIsIdentifierReferencedHandler: (graph: ModuleGraph, entryPaths: Set<string>) => (filePath: string, id: string, isIncludeEntryExports?: boolean, traceNode?: TraceNode, seen?: Set<string>) => Result;
9
9
  export {};
@@ -1,6 +1,6 @@
1
- import type { DependencyGraph, FileNode, IdToFileMap, IdToNsToFileMap, ImportDetails, ImportMap } from '../types/dependency-graph.js';
2
- export declare const getOrCreateFileNode: (graph: DependencyGraph, filePath: string) => FileNode;
3
- export declare const updateImportMap: (file: FileNode, importMap: ImportMap, graph: DependencyGraph) => void;
1
+ import type { FileNode, IdToFileMap, IdToNsToFileMap, ImportDetails, ImportMap, ModuleGraph } from '../types/module-graph.js';
2
+ export declare const getOrCreateFileNode: (graph: ModuleGraph, filePath: string) => FileNode;
3
+ export declare const updateImportMap: (file: FileNode, importMap: ImportMap, graph: ModuleGraph) => void;
4
4
  export declare const createImports: () => ImportDetails;
5
5
  export declare const addValue: (map: IdToFileMap, id: string, value: string) => void;
6
6
  export declare const addNsValue: (map: IdToNsToFileMap, id: string, ns: string, value: string) => void;
@@ -1,4 +1,4 @@
1
- import type { DependencyGraph } from '../types/dependency-graph.js';
1
+ import type { ModuleGraph } from '../types/module-graph.js';
2
2
  declare const isTrace: boolean;
3
3
  type CreateNode = {
4
4
  identifier?: string;
@@ -16,5 +16,5 @@ export type TraceNode = {
16
16
  export { isTrace };
17
17
  export declare const printTrace: (node: TraceNode, filePath: string, identifier?: string) => void;
18
18
  export declare const createNode: Create;
19
- export declare const addNodes: (node: TraceNode, id: string, importedSymbols: DependencyGraph, filePaths?: Set<string>) => void;
19
+ export declare const addNodes: (node: TraceNode, id: string, importedSymbols: ModuleGraph, filePaths?: Set<string>) => void;
20
20
  export declare const createAndPrintTrace: (filePath: string, options?: CreateNode) => void;
@@ -4,22 +4,22 @@ import type { ConsoleStreamer } from '../ConsoleStreamer.js';
4
4
  import type { IssueCollector } from '../IssueCollector.js';
5
5
  import type { PrincipalFactory } from '../PrincipalFactory.js';
6
6
  import type { ProjectPrincipal } from '../ProjectPrincipal.js';
7
- import type { DependencyGraph } from '../types/dependency-graph.js';
8
7
  import type { Report } from '../types/issues.js';
8
+ import type { ModuleGraph } from '../types/module-graph.js';
9
9
  type Watch = {
10
10
  analyzedFiles: Set<string>;
11
11
  analyzeSourceFile: (filePath: string, principal: ProjectPrincipal) => void;
12
12
  chief: ConfigurationChief;
13
13
  collector: IssueCollector;
14
- collectUnusedExports: () => Promise<void>;
14
+ analyze: () => Promise<void>;
15
15
  cwd: string;
16
16
  factory: PrincipalFactory;
17
- graph: DependencyGraph;
17
+ graph: ModuleGraph;
18
18
  isDebug: boolean;
19
19
  isIgnored: (path: string) => boolean;
20
20
  report: Report;
21
21
  streamer: ConsoleStreamer;
22
22
  unreferencedFiles: Set<string>;
23
23
  };
24
- export declare const getWatchHandler: ({ analyzedFiles, analyzeSourceFile, chief, collector, collectUnusedExports, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }: Watch) => Promise<WatchListener<string | Buffer>>;
24
+ export declare const getWatchHandler: ({ analyzedFiles, analyzeSourceFile, chief, collector, analyze, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }: Watch) => Promise<WatchListener<string | Buffer>>;
25
25
  export {};
@@ -1,9 +1,9 @@
1
1
  import watchReporter from '../reporters/watch.js';
2
2
  import { debugLog } from './debug.js';
3
- import { updateImportMap } from './dependency-graph.js';
4
3
  import { isFile } from './fs.js';
4
+ import { updateImportMap } from './module-graph.js';
5
5
  import { join, toPosix } from './path.js';
6
- export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief, collector, collectUnusedExports, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }) => {
6
+ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief, collector, analyze, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }) => {
7
7
  const reportIssues = async (startTime) => {
8
8
  const { issues } = collector.getIssues();
9
9
  watchReporter({ report, issues, streamer, startTime, size: analyzedFiles.size, isDebug });
@@ -71,7 +71,7 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
71
71
  updateImportMap(file, file.internalImportCache, graph);
72
72
  }
73
73
  }
74
- await collectUnusedExports();
74
+ await analyze();
75
75
  const unusedFiles = [...cachedUnusedFiles].filter(filePath => !analyzedFiles.has(filePath));
76
76
  collector.addFilesIssues(unusedFiles);
77
77
  collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
@@ -80,7 +80,6 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
80
80
  }
81
81
  }
82
82
  };
83
- await collectUnusedExports();
84
83
  await reportIssues();
85
84
  return listener;
86
85
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.44.0";
1
+ export declare const version = "5.44.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.44.0';
1
+ export const version = '5.44.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.44.0",
3
+ "version": "5.44.2",
4
4
  "description": "Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {