knip 4.3.0 → 4.4.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/dist/IssueFixer.d.ts +2 -2
- package/dist/IssueFixer.js +8 -8
- package/dist/binaries/resolvers/pnpm.js +4 -1
- package/dist/plugins/nx/index.js +24 -1
- package/dist/plugins/nx/types.d.ts +7 -0
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
package/dist/IssueFixer.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare class IssueFixer {
|
|
|
13
13
|
cwd: string;
|
|
14
14
|
fixTypes: string[];
|
|
15
15
|
});
|
|
16
|
-
addUnusedTypeNode(filePath: string,
|
|
17
|
-
addUnusedExportNode(filePath: string,
|
|
16
|
+
addUnusedTypeNode(filePath: string, fixes: Fixes | undefined): void;
|
|
17
|
+
addUnusedExportNode(filePath: string, fixes: Fixes | undefined): void;
|
|
18
18
|
fixIssues(issues: Issues): Promise<void>;
|
|
19
19
|
private removeUnusedExportKeywords;
|
|
20
20
|
private removeUnusedDependencies;
|
package/dist/IssueFixer.js
CHANGED
|
@@ -16,21 +16,21 @@ export class IssueFixer {
|
|
|
16
16
|
this.isFixUnusedTypes = fixTypes.length === 0 || fixTypes.includes('types');
|
|
17
17
|
this.isFixUnusedExports = fixTypes.length === 0 || fixTypes.includes('exports');
|
|
18
18
|
}
|
|
19
|
-
addUnusedTypeNode(filePath,
|
|
20
|
-
if (
|
|
19
|
+
addUnusedTypeNode(filePath, fixes) {
|
|
20
|
+
if (!fixes || fixes.length === 0)
|
|
21
21
|
return;
|
|
22
22
|
if (this.unusedTypeNodes.has(filePath))
|
|
23
|
-
|
|
23
|
+
fixes.forEach(fix => this.unusedTypeNodes.get(filePath).add(fix));
|
|
24
24
|
else
|
|
25
|
-
this.unusedTypeNodes.set(filePath, new Set(
|
|
25
|
+
this.unusedTypeNodes.set(filePath, new Set(fixes));
|
|
26
26
|
}
|
|
27
|
-
addUnusedExportNode(filePath,
|
|
28
|
-
if (
|
|
27
|
+
addUnusedExportNode(filePath, fixes) {
|
|
28
|
+
if (!fixes || fixes.length === 0)
|
|
29
29
|
return;
|
|
30
30
|
if (this.unusedExportNodes.has(filePath))
|
|
31
|
-
|
|
31
|
+
fixes.forEach(fix => this.unusedExportNodes.get(filePath).add(fix));
|
|
32
32
|
else
|
|
33
|
-
this.unusedExportNodes.set(filePath, new Set(
|
|
33
|
+
this.unusedExportNodes.set(filePath, new Set(fixes));
|
|
34
34
|
}
|
|
35
35
|
async fixIssues(issues) {
|
|
36
36
|
await this.removeUnusedExportKeywords();
|
|
@@ -52,7 +52,10 @@ const commands = [
|
|
|
52
52
|
'why',
|
|
53
53
|
];
|
|
54
54
|
export const resolve = (_binary, args, { manifestScriptNames }) => {
|
|
55
|
-
const parsed = parseArgs(args, {
|
|
55
|
+
const parsed = parseArgs(args, {
|
|
56
|
+
boolean: ['recursive', 'silent', 'shell-mode'],
|
|
57
|
+
alias: { recursive: 'r', silent: 's', 'shell-mode': 'c' },
|
|
58
|
+
});
|
|
56
59
|
const [command, binary] = parsed._;
|
|
57
60
|
if (manifestScriptNames.has(command) || commands.includes(command))
|
|
58
61
|
return [];
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
+
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
2
3
|
import { timerify } from '../../util/Performance.js';
|
|
3
4
|
import { getDependenciesFromScripts, hasDependency, load } from '../../util/plugin.js';
|
|
4
5
|
const NAME = 'Nx';
|
|
5
6
|
const ENABLERS = ['nx', /^@nrwl\//, /^@nx\//];
|
|
6
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
const CONFIG_FILE_PATTERNS = ['project.json', '{apps,libs}/**/project.json'];
|
|
8
|
+
const CONFIG_FILE_PATTERNS = ['nx.json', 'project.json', '{apps,libs}/**/project.json'];
|
|
9
|
+
const findNxDependenciesInNxJson = async (configFilePath) => {
|
|
10
|
+
const localConfig = await load(configFilePath);
|
|
11
|
+
if (!localConfig)
|
|
12
|
+
return [];
|
|
13
|
+
const targetsDefault = localConfig.targetDefaults
|
|
14
|
+
? Object.keys(localConfig.targetDefaults)
|
|
15
|
+
.filter(it => it.includes(':') && it.startsWith('@'))
|
|
16
|
+
.map(it => it.split(':')[0])
|
|
17
|
+
: [];
|
|
18
|
+
const plugins = localConfig.plugins && Array.isArray(localConfig.plugins)
|
|
19
|
+
? localConfig.plugins.map(it => getPackageNameFromModuleSpecifier(it.plugin)).filter(value => value !== undefined)
|
|
20
|
+
: [];
|
|
21
|
+
const generators = localConfig.generators
|
|
22
|
+
? Object.keys(localConfig.generators)
|
|
23
|
+
.map(it => getPackageNameFromModuleSpecifier(it))
|
|
24
|
+
.filter(value => value !== undefined)
|
|
25
|
+
: [];
|
|
26
|
+
return compact([...targetsDefault, ...plugins, ...generators]);
|
|
27
|
+
};
|
|
8
28
|
const findNxDependencies = async (configFilePath, options) => {
|
|
9
29
|
const { isProduction } = options;
|
|
10
30
|
if (isProduction)
|
|
11
31
|
return [];
|
|
32
|
+
if (configFilePath.endsWith('nx.json')) {
|
|
33
|
+
return findNxDependenciesInNxJson(configFilePath, options);
|
|
34
|
+
}
|
|
12
35
|
const localConfig = await load(configFilePath);
|
|
13
36
|
if (!localConfig)
|
|
14
37
|
return [];
|
|
@@ -53,7 +53,7 @@ export const findVitestDependencies = async (configFilePath, localConfig, option
|
|
|
53
53
|
const dependencies = (typeof entry === 'string' ? [entry] : Object.values(entry)).map(specifier => resolveEntry(configFilePath, specifier));
|
|
54
54
|
if (!options.enabledPlugins.includes('vitest'))
|
|
55
55
|
return dependencies;
|
|
56
|
-
return [...dependencies, ...findConfigDependencies(configFilePath, localConfig, options)];
|
|
56
|
+
return compact([...dependencies, ...findConfigDependencies(configFilePath, localConfig, options)]);
|
|
57
57
|
};
|
|
58
58
|
const findVitestWorkspaceDependencies = async (configFilePath, options) => {
|
|
59
59
|
const localConfig = await load(configFilePath);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.
|
|
1
|
+
export declare const version = "4.4.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.
|
|
1
|
+
export const version = '4.4.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@knip/eslint-config": "0.0.0",
|
|
86
86
|
"@release-it/bumper": "^6.0.1",
|
|
87
87
|
"@swc/cli": "^0.1.65",
|
|
88
|
-
"@swc/core": "^1.
|
|
88
|
+
"@swc/core": "^1.4.0",
|
|
89
89
|
"@types/js-yaml": "^4.0.9",
|
|
90
90
|
"@types/micromatch": "^4.0.6",
|
|
91
91
|
"@types/minimist": "^1.2.5",
|
|
@@ -94,11 +94,11 @@
|
|
|
94
94
|
"@types/webpack": "^5.28.5",
|
|
95
95
|
"c8": "9.1.0",
|
|
96
96
|
"eslint": "^8.56.0",
|
|
97
|
-
"playwright": "^1.41.
|
|
98
|
-
"prettier": "^3.2.
|
|
97
|
+
"playwright": "^1.41.2",
|
|
98
|
+
"prettier": "^3.2.5",
|
|
99
99
|
"release-it": "^17.0.3",
|
|
100
100
|
"tsx": "^4.7.0",
|
|
101
|
-
"type-fest": "^4.10.
|
|
101
|
+
"type-fest": "^4.10.2",
|
|
102
102
|
"typescript": "5.3.3"
|
|
103
103
|
},
|
|
104
104
|
"engines": {
|