knip 6.41.0 → 6.42.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.
- package/README.md +1 -1
- package/dist/ConfigurationChief.d.ts +18 -0
- package/dist/WorkspaceWorker.js +1 -0
- package/dist/binaries/bash-parser.js +16 -39
- package/dist/binaries/resolvers/bun.js +1 -0
- package/dist/graph-explorer/operations/is-referenced.js +8 -2
- package/dist/manifest/index.js +2 -3
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.d.ts +2 -0
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.js +40 -0
- package/dist/plugins/angular/index.js +7 -1
- package/dist/plugins/biome/index.js +2 -2
- package/dist/plugins/commitlint/index.js +2 -2
- package/dist/plugins/eslint/helpers.js +1 -1
- package/dist/plugins/filesystem-routing/index.d.ts +3 -0
- package/dist/plugins/filesystem-routing/index.js +57 -0
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/jest/index.js +5 -0
- package/dist/plugins/jest/visitors/mock.d.ts +2 -0
- package/dist/plugins/jest/visitors/mock.js +91 -0
- package/dist/plugins/mise/scripts.js +55 -97
- package/dist/plugins/next/index.js +33 -1
- package/dist/plugins/nx/index.js +46 -8
- package/dist/plugins/nx/types.d.ts +8 -0
- package/dist/plugins/oxlint/index.js +1 -1
- package/dist/plugins/react-router/index.d.ts +3 -0
- package/dist/plugins/react-router/index.js +3 -0
- package/dist/plugins/rstest/index.js +1 -1
- package/dist/plugins/solidjs-vite-plugin/index.d.ts +6 -0
- package/dist/plugins/solidjs-vite-plugin/index.js +17 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.d.ts +3 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +76 -0
- package/dist/plugins/sst/resolveFromAST.js +1 -1
- package/dist/plugins/stencil/index.js +2 -39
- package/dist/plugins/storybook/index.js +2 -4
- package/dist/plugins/sveltejs-package/helpers.js +2 -2
- package/dist/plugins/taskfile/index.js +3 -6
- package/dist/plugins/tsrs/index.d.ts +3 -0
- package/dist/plugins/tsrs/index.js +15 -0
- package/dist/plugins/typescript/index.d.ts +12 -1
- package/dist/plugins/typescript/index.js +5 -7
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +15 -1
- package/dist/plugins/vitest/index.js +2 -2
- package/dist/schema/configuration.d.ts +45 -0
- package/dist/schema/plugins.d.ts +15 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/visitors/imports.js +11 -0
- package/dist/typescript/visitors/jsdoc.js +27 -22
- package/dist/util/create-options.d.ts +30 -0
- package/dist/util/create-options.js +2 -3
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/scripts.d.ts +3 -2
- package/dist/util/scripts.js +32 -72
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/schema.json +12 -0
package/dist/util/scripts.js
CHANGED
|
@@ -1,86 +1,46 @@
|
|
|
1
|
-
import { parse } from 'unbash';
|
|
1
|
+
import { forEachChild, parse, } from 'unbash';
|
|
2
2
|
import { extractBinary } from './modules.js';
|
|
3
3
|
const spawningBinaries = new Set(['c8', 'cross-env', 'retry-cli']);
|
|
4
4
|
export const toShellCommand = (argv) => argv.map(arg => `'${arg.replaceAll("'", `'\\''`)}'`).join(' ');
|
|
5
5
|
export const getCommandWords = (node) => node.args.filter((arg) => arg.type === 'Word');
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
yield* walkCommands(statement.command);
|
|
19
|
-
for (const statement of node.then.commands)
|
|
20
|
-
yield* walkCommands(statement.command);
|
|
21
|
-
if (node.else)
|
|
22
|
-
yield* walkCommands(node.else);
|
|
23
|
-
break;
|
|
24
|
-
case 'While':
|
|
25
|
-
for (const statement of node.clause.commands)
|
|
26
|
-
yield* walkCommands(statement.command);
|
|
27
|
-
for (const statement of node.body.commands)
|
|
28
|
-
yield* walkCommands(statement.command);
|
|
29
|
-
break;
|
|
30
|
-
case 'For':
|
|
31
|
-
case 'Select':
|
|
32
|
-
case 'Subshell':
|
|
33
|
-
case 'BraceGroup':
|
|
34
|
-
for (const statement of node.body.commands)
|
|
35
|
-
yield* walkCommands(statement.command);
|
|
36
|
-
break;
|
|
37
|
-
case 'CompoundList':
|
|
38
|
-
for (const statement of node.commands)
|
|
39
|
-
yield* walkCommands(statement.command);
|
|
40
|
-
break;
|
|
41
|
-
case 'Function':
|
|
42
|
-
case 'Coproc':
|
|
43
|
-
yield* walkCommands(node.body);
|
|
44
|
-
break;
|
|
45
|
-
case 'Statement':
|
|
46
|
-
case 'Redirected':
|
|
47
|
-
case 'Time':
|
|
48
|
-
case 'Negation':
|
|
49
|
-
if (node.command)
|
|
50
|
-
yield* walkCommands(node.command);
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
6
|
+
export const collectCommands = (root) => {
|
|
7
|
+
const commands = [];
|
|
8
|
+
const visit = (node) => {
|
|
9
|
+
if (node.type === 'Command')
|
|
10
|
+
commands.push(node);
|
|
11
|
+
if (!isScriptExpansion(node))
|
|
12
|
+
forEachChild(node, visit);
|
|
13
|
+
};
|
|
14
|
+
visit(root);
|
|
15
|
+
return commands;
|
|
16
|
+
};
|
|
17
|
+
export const isScriptExpansion = (node) => node.type === 'CommandExpansion' || node.type === 'ProcessSubstitution' || node.type === 'ArithmeticCommandExpansion';
|
|
54
18
|
export const getScriptCommands = (script) => {
|
|
55
19
|
if (!script)
|
|
56
20
|
return [];
|
|
57
|
-
|
|
21
|
+
const out = [];
|
|
58
22
|
try {
|
|
59
|
-
|
|
23
|
+
for (const statement of parse(script).commands) {
|
|
24
|
+
for (const node of collectCommands(statement.command)) {
|
|
25
|
+
const text = node.name?.value;
|
|
26
|
+
if (!text)
|
|
27
|
+
continue;
|
|
28
|
+
const binary = extractBinary(text);
|
|
29
|
+
const words = getCommandWords(node);
|
|
30
|
+
if (spawningBinaries.has(binary)) {
|
|
31
|
+
const rest = words
|
|
32
|
+
.filter(word => word.text !== '--')
|
|
33
|
+
.map(word => word.text)
|
|
34
|
+
.join(' ');
|
|
35
|
+
out.push(...getScriptCommands(rest));
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
out.push({ binary, args: words.map(word => word.value) });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
60
41
|
}
|
|
61
42
|
catch {
|
|
62
43
|
return [];
|
|
63
44
|
}
|
|
64
|
-
if (!parsed.commands)
|
|
65
|
-
return [];
|
|
66
|
-
const out = [];
|
|
67
|
-
for (const statement of parsed.commands) {
|
|
68
|
-
for (const node of walkCommands(statement.command)) {
|
|
69
|
-
const text = node.name?.value;
|
|
70
|
-
if (!text)
|
|
71
|
-
continue;
|
|
72
|
-
const binary = extractBinary(text);
|
|
73
|
-
const words = getCommandWords(node);
|
|
74
|
-
if (spawningBinaries.has(binary)) {
|
|
75
|
-
const rest = words
|
|
76
|
-
.filter(word => word.text !== '--')
|
|
77
|
-
.map(word => word.text)
|
|
78
|
-
.join(' ');
|
|
79
|
-
out.push(...getScriptCommands(rest));
|
|
80
|
-
}
|
|
81
|
-
else
|
|
82
|
-
out.push({ binary, args: words.map(word => word.value) });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
45
|
return out;
|
|
86
46
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.42.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.42.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.42.0",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -84,22 +84,22 @@
|
|
|
84
84
|
"formatly": "^0.11.4",
|
|
85
85
|
"get-tsconfig": "4.14.3",
|
|
86
86
|
"jiti": "^2.7.0",
|
|
87
|
-
"oxc-parser": "^0.
|
|
87
|
+
"oxc-parser": "^0.154.0",
|
|
88
88
|
"oxc-resolver": "11.24.2",
|
|
89
89
|
"picomatch": "^4.0.7",
|
|
90
90
|
"smol-toml": "^1.9.0",
|
|
91
91
|
"strip-json-comments": "5.0.3",
|
|
92
92
|
"tinyglobby": "^0.2.17",
|
|
93
|
-
"unbash": "^
|
|
93
|
+
"unbash": "^6.0.0",
|
|
94
94
|
"yaml": "^2.9.1",
|
|
95
95
|
"zod": "^4.6.5"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@jest/types": "^30.5.1",
|
|
99
|
-
"@types/bun": "^1.4.
|
|
99
|
+
"@types/bun": "^1.4.3",
|
|
100
100
|
"@types/picomatch": "^4.0.3",
|
|
101
101
|
"codeclimate-types": "^0.3.1",
|
|
102
|
-
"prettier": "^3.9.
|
|
102
|
+
"prettier": "^3.9.10",
|
|
103
103
|
"tsx": "^4.23.15",
|
|
104
104
|
"typescript": "7.0.2",
|
|
105
105
|
"webpack": "^5.111.1"
|
package/schema.json
CHANGED
|
@@ -574,6 +574,10 @@
|
|
|
574
574
|
"title": "fast plugin configuration (https://knip.dev/reference/plugins/fast)",
|
|
575
575
|
"$ref": "#/definitions/plugin"
|
|
576
576
|
},
|
|
577
|
+
"filesystem-routing": {
|
|
578
|
+
"title": "filesystem-routing plugin configuration (https://knip.dev/reference/plugins/filesystem-routing)",
|
|
579
|
+
"$ref": "#/definitions/plugin"
|
|
580
|
+
},
|
|
577
581
|
"flue": {
|
|
578
582
|
"title": "flue plugin configuration (https://knip.dev/reference/plugins/flue)",
|
|
579
583
|
"$ref": "#/definitions/plugin"
|
|
@@ -938,6 +942,10 @@
|
|
|
938
942
|
"title": "size-limit plugin configuration (https://knip.dev/reference/plugins/size-limit)",
|
|
939
943
|
"$ref": "#/definitions/plugin"
|
|
940
944
|
},
|
|
945
|
+
"solidjs-vite-plugin": {
|
|
946
|
+
"title": "solidjs-vite-plugin plugin configuration (https://knip.dev/reference/plugins/solidjs-vite-plugin)",
|
|
947
|
+
"$ref": "#/definitions/plugin"
|
|
948
|
+
},
|
|
941
949
|
"sst": {
|
|
942
950
|
"title": "sst plugin configuration (https://knip.dev/reference/plugins/sst)",
|
|
943
951
|
"$ref": "#/definitions/plugin"
|
|
@@ -1030,6 +1038,10 @@
|
|
|
1030
1038
|
"title": "tsdown plugin configuration (https://knip.dev/reference/plugins/tsdown)",
|
|
1031
1039
|
"$ref": "#/definitions/plugin"
|
|
1032
1040
|
},
|
|
1041
|
+
"tsrs": {
|
|
1042
|
+
"title": "tsrs plugin configuration (https://knip.dev/reference/plugins/tsrs)",
|
|
1043
|
+
"$ref": "#/definitions/plugin"
|
|
1044
|
+
},
|
|
1033
1045
|
"tsup": {
|
|
1034
1046
|
"title": "tsup plugin configuration (https://knip.dev/reference/plugins/tsup)",
|
|
1035
1047
|
"$ref": "#/definitions/plugin"
|