knip 5.70.2 → 5.71.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 (57) hide show
  1. package/dist/DependencyDeputy.js +2 -2
  2. package/dist/ProjectPrincipal.js +1 -1
  3. package/dist/WorkspaceWorker.js +1 -1
  4. package/dist/binaries/bash-parser.js +14 -1
  5. package/dist/compilers/index.js +1 -1
  6. package/dist/constants.js +1 -0
  7. package/dist/graph/analyze.js +21 -16
  8. package/dist/graph-explorer/constants.d.ts +2 -0
  9. package/dist/graph-explorer/constants.js +2 -0
  10. package/dist/graph-explorer/explorer.d.ts +11 -0
  11. package/dist/graph-explorer/explorer.js +10 -0
  12. package/dist/graph-explorer/operations/build-trace-tree.d.ts +12 -0
  13. package/dist/graph-explorer/operations/build-trace-tree.js +51 -0
  14. package/dist/graph-explorer/operations/has-strictly-ns-references.d.ts +2 -0
  15. package/dist/graph-explorer/operations/has-strictly-ns-references.js +98 -0
  16. package/dist/graph-explorer/operations/is-referenced.d.ts +4 -0
  17. package/dist/graph-explorer/operations/is-referenced.js +89 -0
  18. package/dist/graph-explorer/utils.d.ts +4 -0
  19. package/dist/graph-explorer/utils.js +28 -0
  20. package/dist/graph-explorer/visitors.d.ts +12 -0
  21. package/dist/graph-explorer/visitors.js +30 -0
  22. package/dist/graph-explorer/walk-down.d.ts +4 -0
  23. package/dist/graph-explorer/walk-down.js +119 -0
  24. package/dist/index.js +2 -98
  25. package/dist/plugins/angular/index.js +3 -3
  26. package/dist/plugins/next/index.js +4 -3
  27. package/dist/plugins/next/resolveFromAST.d.ts +1 -0
  28. package/dist/plugins/next/resolveFromAST.js +42 -1
  29. package/dist/plugins/vite/helpers.js +1 -1
  30. package/dist/reporters/codeclimate.js +3 -7
  31. package/dist/reporters/util/util.d.ts +2 -1
  32. package/dist/reporters/util/util.js +1 -0
  33. package/dist/reporters/watch.js +1 -1
  34. package/dist/run.d.ts +25 -0
  35. package/dist/run.js +107 -0
  36. package/dist/types/issues.d.ts +4 -4
  37. package/dist/types/module-graph.d.ts +9 -10
  38. package/dist/typescript/ast-helpers.d.ts +4 -0
  39. package/dist/typescript/ast-helpers.js +48 -0
  40. package/dist/typescript/get-imports-and-exports.js +4 -1
  41. package/dist/typescript/visitors/dynamic-imports/importCall.js +5 -19
  42. package/dist/util/create-options.js +1 -1
  43. package/dist/util/file-entry-cache.js +1 -1
  44. package/dist/util/graph-sequencer.js +1 -1
  45. package/dist/util/module-graph.js +7 -7
  46. package/dist/util/trace.d.ts +3 -13
  47. package/dist/util/trace.js +10 -41
  48. package/dist/util/watch.d.ts +19 -3
  49. package/dist/util/watch.js +28 -17
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/package.json +1 -1
  53. package/vendor/bash-parser/index.d.ts +6 -1
  54. package/dist/util/has-strictly-ns-references.d.ts +0 -4
  55. package/dist/util/has-strictly-ns-references.js +0 -103
  56. package/dist/util/is-identifier-referenced.d.ts +0 -9
  57. package/dist/util/is-identifier-referenced.js +0 -145
@@ -1,145 +0,0 @@
1
- import { IMPORT_STAR, OPAQUE } from '../constants.js';
2
- import { addNodes, createNode } from './trace.js';
3
- export const getIsIdentifierReferencedHandler = (graph, entryPaths, isTrace) => {
4
- const isIdentifierReferenced = (filePath, id, isIncludeEntryExports = false, traceNode = createNode(filePath), seen = new Set()) => {
5
- let isReferenced = false;
6
- let reExportingEntryFile = entryPaths.has(filePath) ? filePath : undefined;
7
- if (reExportingEntryFile)
8
- traceNode.isEntry = true;
9
- if (!isIncludeEntryExports && reExportingEntryFile)
10
- return { isReferenced, reExportingEntryFile, traceNode };
11
- seen.add(filePath);
12
- const restIds = id.split('.');
13
- const identifier = restIds.shift();
14
- const file = graph.get(filePath)?.imported;
15
- if (!identifier || !file)
16
- return { isReferenced, reExportingEntryFile, traceNode };
17
- if (file.imported.get(OPAQUE) ||
18
- ((identifier === id || (identifier !== id && file.refs.has(id))) &&
19
- (file.imported.has(identifier) || file.importedAs.has(identifier)))) {
20
- isReferenced = true;
21
- if (!isTrace)
22
- return { isReferenced, reExportingEntryFile, traceNode };
23
- if (file.importedAs.has(identifier)) {
24
- for (const aliases of file.importedAs.values()) {
25
- for (const alias of aliases.keys())
26
- addNodes(traceNode, alias, graph, aliases.get(alias));
27
- }
28
- }
29
- else
30
- addNodes(traceNode, id, graph, file.imported.get(identifier));
31
- }
32
- for (const [exportId, aliases] of file.importedAs.entries()) {
33
- if (identifier === exportId) {
34
- for (const alias of aliases.keys()) {
35
- const aliasedRef = [alias, ...restIds].join('.');
36
- if (file.refs.has(aliasedRef)) {
37
- isReferenced = true;
38
- if (!isTrace)
39
- return { isReferenced, reExportingEntryFile, traceNode };
40
- addNodes(traceNode, aliasedRef, graph, aliases.get(alias));
41
- }
42
- }
43
- }
44
- }
45
- for (const [namespace, byFilePaths] of file.importedNs) {
46
- if (file.refs.has(`${namespace}.${id}`)) {
47
- isReferenced = true;
48
- if (!isTrace)
49
- return { isReferenced, reExportingEntryFile, traceNode };
50
- addNodes(traceNode, `${namespace}.${id}`, graph, byFilePaths);
51
- }
52
- const reExportedAs = file.reExportedAs.get(namespace);
53
- if (reExportedAs) {
54
- for (const [alias, byFilePaths] of reExportedAs) {
55
- for (const byFilePath of byFilePaths) {
56
- if (!seen.has(byFilePath)) {
57
- const child = createNode(byFilePath);
58
- traceNode.children.add(child);
59
- const result = isIdentifierReferenced(byFilePath, `${alias}.${id}`, isIncludeEntryExports, child, seen);
60
- if (result.reExportingEntryFile)
61
- reExportingEntryFile = result.reExportingEntryFile;
62
- if (result.isReferenced) {
63
- isReferenced = true;
64
- if (!isTrace)
65
- return { isReferenced, reExportingEntryFile, traceNode };
66
- }
67
- }
68
- }
69
- }
70
- }
71
- const reExportedNs = file.reExportedNs.get(namespace);
72
- if (reExportedNs) {
73
- for (const byFilePath of reExportedNs) {
74
- if (!seen.has(byFilePath)) {
75
- const child = createNode(byFilePath);
76
- traceNode.children.add(child);
77
- const result = isIdentifierReferenced(byFilePath, `${namespace}.${id}`, isIncludeEntryExports, child, seen);
78
- if (result.reExportingEntryFile)
79
- reExportingEntryFile = result.reExportingEntryFile;
80
- if (result.isReferenced) {
81
- isReferenced = true;
82
- if (!isTrace)
83
- return { isReferenced, reExportingEntryFile, traceNode };
84
- }
85
- }
86
- }
87
- }
88
- }
89
- const reExportedAs = file.reExportedAs.get(identifier);
90
- if (reExportedAs) {
91
- for (const [alias, byFilePaths] of reExportedAs) {
92
- for (const byFilePath of byFilePaths) {
93
- if (!seen.has(byFilePath)) {
94
- const child = createNode(byFilePath);
95
- traceNode.children.add(child);
96
- const ref = [alias, ...restIds].join('.');
97
- const result = isIdentifierReferenced(byFilePath, ref, isIncludeEntryExports, child, seen);
98
- if (result.reExportingEntryFile)
99
- reExportingEntryFile = result.reExportingEntryFile;
100
- if (result.isReferenced) {
101
- isReferenced = true;
102
- if (!isTrace)
103
- return { isReferenced, reExportingEntryFile, traceNode };
104
- }
105
- }
106
- }
107
- }
108
- }
109
- const reExported = file.reExported.get(identifier) ?? file.reExported.get(IMPORT_STAR);
110
- if (reExported) {
111
- for (const byFilePath of reExported) {
112
- if (!seen.has(byFilePath)) {
113
- const child = createNode(byFilePath);
114
- traceNode.children.add(child);
115
- const result = isIdentifierReferenced(byFilePath, id, isIncludeEntryExports, child, seen);
116
- if (result.reExportingEntryFile)
117
- reExportingEntryFile = result.reExportingEntryFile;
118
- if (result.isReferenced) {
119
- isReferenced = true;
120
- if (!isTrace)
121
- return { isReferenced, reExportingEntryFile, traceNode };
122
- }
123
- }
124
- }
125
- }
126
- for (const [namespace, byFilePaths] of file.reExportedNs.entries()) {
127
- for (const byFilePath of byFilePaths) {
128
- if (!seen.has(byFilePath)) {
129
- const child = createNode(byFilePath);
130
- traceNode.children.add(child);
131
- const result = isIdentifierReferenced(byFilePath, `${namespace}.${id}`, isIncludeEntryExports, child, seen);
132
- if (result.reExportingEntryFile)
133
- reExportingEntryFile = result.reExportingEntryFile;
134
- if (result.isReferenced) {
135
- isReferenced = true;
136
- if (!isTrace)
137
- return { isReferenced, reExportingEntryFile, traceNode };
138
- }
139
- }
140
- }
141
- }
142
- return { isReferenced, reExportingEntryFile, traceNode };
143
- };
144
- return isIdentifierReferenced;
145
- };