knip 5.69.1 → 5.70.1

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 (54) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/binaries/package-manager/yarn.js +1 -0
  3. package/dist/binaries/plugins.js +4 -4
  4. package/dist/compilers/index.d.ts +10 -0
  5. package/dist/compilers/index.js +2 -0
  6. package/dist/compilers/prisma.d.ts +6 -0
  7. package/dist/compilers/prisma.js +13 -0
  8. package/dist/constants.d.ts +4 -0
  9. package/dist/constants.js +4 -0
  10. package/dist/graph/build.js +3 -3
  11. package/dist/plugins/index.d.ts +1 -0
  12. package/dist/plugins/index.js +2 -0
  13. package/dist/plugins/prisma/index.js +27 -5
  14. package/dist/plugins/prisma/types.d.ts +1 -0
  15. package/dist/plugins/taskfile/index.d.ts +3 -0
  16. package/dist/plugins/taskfile/index.js +111 -0
  17. package/dist/plugins/taskfile/types.d.ts +25 -0
  18. package/dist/plugins/taskfile/types.js +1 -0
  19. package/dist/plugins/vitest/helpers.d.ts +1 -1
  20. package/dist/plugins/vitest/helpers.js +1 -1
  21. package/dist/plugins/vitest/index.js +11 -4
  22. package/dist/reporters/util/configuration-hints.js +1 -1
  23. package/dist/schema/configuration.d.ts +10 -0
  24. package/dist/schema/plugins.d.ts +5 -0
  25. package/dist/schema/plugins.js +1 -0
  26. package/dist/types/PluginNames.d.ts +2 -2
  27. package/dist/types/PluginNames.js +1 -0
  28. package/dist/types/args.d.ts +4 -1
  29. package/dist/types/module-graph.d.ts +6 -6
  30. package/dist/typescript/ast-helpers.d.ts +9 -0
  31. package/dist/typescript/ast-helpers.js +33 -4
  32. package/dist/typescript/get-imports-and-exports.js +46 -38
  33. package/dist/typescript/pragmas/custom.d.ts +3 -0
  34. package/dist/typescript/pragmas/custom.js +25 -0
  35. package/dist/typescript/pragmas/index.d.ts +3 -0
  36. package/dist/typescript/pragmas/index.js +3 -0
  37. package/dist/typescript/pragmas/typescript.d.ts +3 -0
  38. package/dist/typescript/pragmas/typescript.js +29 -0
  39. package/dist/typescript/visitors/dynamic-imports/importCall.js +21 -9
  40. package/dist/typescript/visitors/dynamic-imports/jsDocType.js +23 -9
  41. package/dist/typescript/visitors/dynamic-imports/requireCall.js +7 -4
  42. package/dist/typescript/visitors/helpers.d.ts +0 -2
  43. package/dist/typescript/visitors/helpers.js +0 -38
  44. package/dist/typescript/visitors/imports/importDeclaration.js +1 -1
  45. package/dist/typescript/visitors/imports/reExportDeclaration.js +4 -4
  46. package/dist/util/create-options.d.ts +10 -0
  47. package/dist/util/has-strictly-ns-references.d.ts +3 -3
  48. package/dist/util/is-identifier-referenced.js +10 -10
  49. package/dist/util/module-graph.d.ts +2 -2
  50. package/dist/util/module-graph.js +22 -22
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +5 -5
  54. package/schema.json +4 -0
@@ -1,4 +1,4 @@
1
- import { IMPORT_STAR } from '../constants.js';
1
+ import { IMPORT_STAR, OPAQUE } from '../constants.js';
2
2
  import { addNodes, createNode } from './trace.js';
3
3
  export const getIsIdentifierReferencedHandler = (graph, entryPaths, isTrace) => {
4
4
  const isIdentifierReferenced = (filePath, id, isIncludeEntryExports = false, traceNode = createNode(filePath), seen = new Set()) => {
@@ -9,13 +9,14 @@ export const getIsIdentifierReferencedHandler = (graph, entryPaths, isTrace) =>
9
9
  if (!isIncludeEntryExports && reExportingEntryFile)
10
10
  return { isReferenced, reExportingEntryFile, traceNode };
11
11
  seen.add(filePath);
12
- const ids = id.split('.');
13
- const [identifier, ...rest] = ids;
12
+ const restIds = id.split('.');
13
+ const identifier = restIds.shift();
14
14
  const file = graph.get(filePath)?.imported;
15
- if (!file)
15
+ if (!identifier || !file)
16
16
  return { isReferenced, reExportingEntryFile, traceNode };
17
- if (((identifier !== id && file.refs.has(id)) || identifier === id) &&
18
- (file.imported.has(identifier) || file.importedAs.has(identifier))) {
17
+ if (file.imported.get(OPAQUE) ||
18
+ ((identifier === id || (identifier !== id && file.refs.has(id))) &&
19
+ (file.imported.has(identifier) || file.importedAs.has(identifier)))) {
19
20
  isReferenced = true;
20
21
  if (!isTrace)
21
22
  return { isReferenced, reExportingEntryFile, traceNode };
@@ -31,12 +32,11 @@ export const getIsIdentifierReferencedHandler = (graph, entryPaths, isTrace) =>
31
32
  for (const [exportId, aliases] of file.importedAs.entries()) {
32
33
  if (identifier === exportId) {
33
34
  for (const alias of aliases.keys()) {
34
- const aliasedRef = [alias, ...rest].join('.');
35
+ const aliasedRef = [alias, ...restIds].join('.');
35
36
  if (file.refs.has(aliasedRef)) {
36
37
  isReferenced = true;
37
- if (!isTrace) {
38
+ if (!isTrace)
38
39
  return { isReferenced, reExportingEntryFile, traceNode };
39
- }
40
40
  addNodes(traceNode, aliasedRef, graph, aliases.get(alias));
41
41
  }
42
42
  }
@@ -93,7 +93,7 @@ export const getIsIdentifierReferencedHandler = (graph, entryPaths, isTrace) =>
93
93
  if (!seen.has(byFilePath)) {
94
94
  const child = createNode(byFilePath);
95
95
  traceNode.children.add(child);
96
- const ref = [alias, ...rest].join('.');
96
+ const ref = [alias, ...restIds].join('.');
97
97
  const result = isIdentifierReferenced(byFilePath, ref, isIncludeEntryExports, child, seen);
98
98
  if (result.reExportingEntryFile)
99
99
  reExportingEntryFile = result.reExportingEntryFile;
@@ -1,6 +1,6 @@
1
- import type { FileNode, IdToFileMap, IdToNsToFileMap, ImportDetails, ImportMap, ModuleGraph } from '../types/module-graph.js';
1
+ import type { FileNode, IdToFileMap, IdToNsToFileMap, ImportMap, ImportMaps, ModuleGraph } from '../types/module-graph.js';
2
2
  export declare const getOrCreateFileNode: (graph: ModuleGraph, filePath: string) => FileNode;
3
3
  export declare const updateImportMap: (file: FileNode, importMap: ImportMap, graph: ModuleGraph) => void;
4
- export declare const createImports: () => ImportDetails;
4
+ export declare const createImports: () => ImportMaps;
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,31 +1,31 @@
1
1
  export const getOrCreateFileNode = (graph, filePath) => graph.get(filePath) ?? createFileNode();
2
- const updateImportDetails = (importedModule, importItems) => {
3
- for (const id of importItems.refs)
4
- importedModule.refs.add(id);
5
- for (const [id, v] of importItems.imported.entries())
6
- addValues(importedModule.imported, id, v);
7
- for (const [id, v] of importItems.importedAs.entries())
8
- addNsValues(importedModule.importedAs, id, v);
9
- for (const [id, v] of importItems.importedNs.entries())
10
- addValues(importedModule.importedNs, id, v);
11
- for (const [id, v] of importItems.reExported.entries())
12
- addValues(importedModule.reExported, id, v);
13
- for (const [id, v] of importItems.reExportedAs.entries())
14
- addNsValues(importedModule.reExportedAs, id, v);
15
- for (const [id, v] of importItems.reExportedNs.entries())
16
- addValues(importedModule.reExportedNs, id, v);
2
+ const updateImportMaps = (fromImportMaps, toImportMaps) => {
3
+ for (const id of fromImportMaps.refs)
4
+ toImportMaps.refs.add(id);
5
+ for (const [id, v] of fromImportMaps.imported.entries())
6
+ addValues(toImportMaps.imported, id, v);
7
+ for (const [id, v] of fromImportMaps.importedAs.entries())
8
+ addNsValues(toImportMaps.importedAs, id, v);
9
+ for (const [id, v] of fromImportMaps.importedNs.entries())
10
+ addValues(toImportMaps.importedNs, id, v);
11
+ for (const [id, v] of fromImportMaps.reExported.entries())
12
+ addValues(toImportMaps.reExported, id, v);
13
+ for (const [id, v] of fromImportMaps.reExportedAs.entries())
14
+ addNsValues(toImportMaps.reExportedAs, id, v);
15
+ for (const [id, v] of fromImportMaps.reExportedNs.entries())
16
+ addValues(toImportMaps.reExportedNs, id, v);
17
17
  };
18
18
  export const updateImportMap = (file, importMap, graph) => {
19
- for (const [importedFilePath, importDetails] of importMap.entries()) {
20
- const importedFileImports = file.imports.internal.get(importedFilePath);
21
- if (!importedFileImports)
22
- file.imports.internal.set(importedFilePath, importDetails);
19
+ for (const [importedFilePath, fileImportMaps] of importMap.entries()) {
20
+ const importMaps = file.imports.internal.get(importedFilePath);
21
+ if (!importMaps)
22
+ file.imports.internal.set(importedFilePath, fileImportMaps);
23
23
  else
24
- updateImportDetails(importedFileImports, importDetails);
24
+ updateImportMaps(fileImportMaps, importMaps);
25
25
  const importedFile = getOrCreateFileNode(graph, importedFilePath);
26
26
  if (!importedFile.imported)
27
27
  importedFile.imported = createImports();
28
- updateImportDetails(importedFile.imported, importDetails);
28
+ updateImportMaps(fileImportMaps, importedFile.imported);
29
29
  graph.set(importedFilePath, importedFile);
30
30
  }
31
31
  };
@@ -35,7 +35,7 @@ const createFileNode = () => ({
35
35
  external: new Set(),
36
36
  unresolved: new Set(),
37
37
  resolved: new Set(),
38
- specifiers: new Set(),
38
+ imports: new Set(),
39
39
  },
40
40
  exports: new Map(),
41
41
  duplicates: new Set(),
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.69.1";
1
+ export declare const version = "5.70.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.69.1';
1
+ export const version = '5.70.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.69.1",
3
+ "version": "5.70.1",
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": {
@@ -61,13 +61,13 @@
61
61
  "fast-glob": "^3.3.3",
62
62
  "formatly": "^0.3.0",
63
63
  "jiti": "^2.6.0",
64
- "js-yaml": "^4.1.0",
64
+ "js-yaml": "^4.1.1",
65
65
  "minimist": "^1.2.8",
66
- "oxc-resolver": "^11.12.0",
66
+ "oxc-resolver": "^11.13.2",
67
67
  "picocolors": "^1.1.1",
68
68
  "picomatch": "^4.0.1",
69
- "smol-toml": "^1.4.1",
70
- "strip-json-comments": "5.0.2",
69
+ "smol-toml": "^1.5.2",
70
+ "strip-json-comments": "5.0.3",
71
71
  "zod": "^4.1.11"
72
72
  },
73
73
  "peerDependencies": {
package/schema.json CHANGED
@@ -722,6 +722,10 @@
722
722
  "title": "tailwind plugin configuration (https://knip.dev/reference/plugins/tailwind)",
723
723
  "$ref": "#/definitions/plugin"
724
724
  },
725
+ "taskfile": {
726
+ "title": "taskfile plugin configuration (https://knip.dev/reference/plugins/taskfile)",
727
+ "$ref": "#/definitions/plugin"
728
+ },
725
729
  "travis": {
726
730
  "title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
727
731
  "$ref": "#/definitions/plugin"