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.
- package/dist/ConfigurationChief.d.ts +6 -0
- package/dist/binaries/package-manager/yarn.js +1 -0
- package/dist/binaries/plugins.js +4 -4
- package/dist/compilers/index.d.ts +10 -0
- package/dist/compilers/index.js +2 -0
- package/dist/compilers/prisma.d.ts +6 -0
- package/dist/compilers/prisma.js +13 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/dist/graph/build.js +3 -3
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/prisma/index.js +27 -5
- package/dist/plugins/prisma/types.d.ts +1 -0
- package/dist/plugins/taskfile/index.d.ts +3 -0
- package/dist/plugins/taskfile/index.js +111 -0
- package/dist/plugins/taskfile/types.d.ts +25 -0
- package/dist/plugins/taskfile/types.js +1 -0
- package/dist/plugins/vitest/helpers.d.ts +1 -1
- package/dist/plugins/vitest/helpers.js +1 -1
- package/dist/plugins/vitest/index.js +11 -4
- package/dist/reporters/util/configuration-hints.js +1 -1
- package/dist/schema/configuration.d.ts +10 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/args.d.ts +4 -1
- package/dist/types/module-graph.d.ts +6 -6
- package/dist/typescript/ast-helpers.d.ts +9 -0
- package/dist/typescript/ast-helpers.js +33 -4
- package/dist/typescript/get-imports-and-exports.js +46 -38
- package/dist/typescript/pragmas/custom.d.ts +3 -0
- package/dist/typescript/pragmas/custom.js +25 -0
- package/dist/typescript/pragmas/index.d.ts +3 -0
- package/dist/typescript/pragmas/index.js +3 -0
- package/dist/typescript/pragmas/typescript.d.ts +3 -0
- package/dist/typescript/pragmas/typescript.js +29 -0
- package/dist/typescript/visitors/dynamic-imports/importCall.js +21 -9
- package/dist/typescript/visitors/dynamic-imports/jsDocType.js +23 -9
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +7 -4
- package/dist/typescript/visitors/helpers.d.ts +0 -2
- package/dist/typescript/visitors/helpers.js +0 -38
- package/dist/typescript/visitors/imports/importDeclaration.js +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.js +4 -4
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/has-strictly-ns-references.d.ts +3 -3
- package/dist/util/is-identifier-referenced.js +10 -10
- package/dist/util/module-graph.d.ts +2 -2
- package/dist/util/module-graph.js +22 -22
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- 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
|
|
13
|
-
const
|
|
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 (
|
|
18
|
-
(
|
|
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, ...
|
|
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, ...
|
|
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,
|
|
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: () =>
|
|
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
|
|
3
|
-
for (const id of
|
|
4
|
-
|
|
5
|
-
for (const [id, v] of
|
|
6
|
-
addValues(
|
|
7
|
-
for (const [id, v] of
|
|
8
|
-
addNsValues(
|
|
9
|
-
for (const [id, v] of
|
|
10
|
-
addValues(
|
|
11
|
-
for (const [id, v] of
|
|
12
|
-
addValues(
|
|
13
|
-
for (const [id, v] of
|
|
14
|
-
addNsValues(
|
|
15
|
-
for (const [id, v] of
|
|
16
|
-
addValues(
|
|
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,
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
file.imports.internal.set(importedFilePath,
|
|
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
|
-
|
|
24
|
+
updateImportMaps(fileImportMaps, importMaps);
|
|
25
25
|
const importedFile = getOrCreateFileNode(graph, importedFilePath);
|
|
26
26
|
if (!importedFile.imported)
|
|
27
27
|
importedFile.imported = createImports();
|
|
28
|
-
|
|
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
|
-
|
|
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.
|
|
1
|
+
export declare const version = "5.70.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.70.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
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.
|
|
64
|
+
"js-yaml": "^4.1.1",
|
|
65
65
|
"minimist": "^1.2.8",
|
|
66
|
-
"oxc-resolver": "^11.
|
|
66
|
+
"oxc-resolver": "^11.13.2",
|
|
67
67
|
"picocolors": "^1.1.1",
|
|
68
68
|
"picomatch": "^4.0.1",
|
|
69
|
-
"smol-toml": "^1.
|
|
70
|
-
"strip-json-comments": "5.0.
|
|
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"
|