knip 6.0.0-2 → 6.0.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/cli.js +1 -4
- package/dist/graph/analyze.js +10 -2
- package/dist/plugins/nuxt/helpers.js +13 -12
- package/dist/plugins/nuxt/types.d.ts +1 -0
- package/dist/typescript/visitors/walk.js +3 -5
- package/dist/util/cli-arguments.d.ts +0 -1
- package/dist/util/cli-arguments.js +0 -1
- package/dist/util/create-options.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { run } from "./run.js";
|
|
|
3
3
|
import parseArgs, { helpText } from "./util/cli-arguments.js";
|
|
4
4
|
import { createOptions } from "./util/create-options.js";
|
|
5
5
|
import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError, isLoaderError, isModuleNotFoundError, } from "./util/errors.js";
|
|
6
|
-
import { logError
|
|
6
|
+
import { logError } from "./util/log.js";
|
|
7
7
|
import { perfObserver } from "./util/Performance.js";
|
|
8
8
|
import { runPreprocessors, runReporters } from "./util/reporter.js";
|
|
9
9
|
import { prettyMilliseconds } from "./util/string.js";
|
|
@@ -72,9 +72,6 @@ const main = async () => {
|
|
|
72
72
|
console.log('\nTotal running time:', prettyMilliseconds(duration));
|
|
73
73
|
perfObserver.reset();
|
|
74
74
|
}
|
|
75
|
-
if (args['experimental-tags'] && args['experimental-tags'].length > 0) {
|
|
76
|
-
logWarning('DEPRECATION WARNING', '--experimental-tags is deprecated, please start using --tags instead');
|
|
77
|
-
}
|
|
78
75
|
if ((!args['no-exit-code'] && totalErrorCount > Number(args['max-issues'] ?? 0)) ||
|
|
79
76
|
(!options.isDisableConfigHints && options.isTreatConfigHintsAsErrors && configurationHints.length > 0)) {
|
|
80
77
|
process.exit(1);
|
package/dist/graph/analyze.js
CHANGED
|
@@ -9,7 +9,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
9
9
|
const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
|
|
10
10
|
const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
|
|
11
11
|
const explorer = createGraphExplorer(graph, entryPaths);
|
|
12
|
-
const isReferencedInUsedExport = (exportedItem, filePath, includeEntryExports) => {
|
|
12
|
+
const isReferencedInUsedExport = (exportedItem, filePath, includeEntryExports, visited) => {
|
|
13
13
|
if (!exportedItem.referencedIn)
|
|
14
14
|
return false;
|
|
15
15
|
const file = graph.get(filePath);
|
|
@@ -20,9 +20,17 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
20
20
|
return true;
|
|
21
21
|
const inExport = file.exports.get(containingExport);
|
|
22
22
|
if (!inExport)
|
|
23
|
-
|
|
23
|
+
continue;
|
|
24
24
|
if (inExport.hasRefsInFile && (inExport.type === 'type' || inExport.type === 'interface'))
|
|
25
25
|
return true;
|
|
26
|
+
if (inExport.referencedIn) {
|
|
27
|
+
const v = visited ?? new Set();
|
|
28
|
+
if (!v.has(containingExport)) {
|
|
29
|
+
v.add(containingExport);
|
|
30
|
+
if (isReferencedInUsedExport(inExport, filePath, includeEntryExports, v))
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
return false;
|
|
28
36
|
};
|
|
@@ -114,19 +114,20 @@ export function buildAutoImportMap(filePath, result) {
|
|
|
114
114
|
importMap.set(name, absSpecifier);
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (!entry.moduleRequest)
|
|
122
|
-
continue;
|
|
123
|
-
const specifier = entry.moduleRequest.value;
|
|
117
|
+
ExportNamedDeclaration(node) {
|
|
118
|
+
if (!node.source)
|
|
119
|
+
return;
|
|
120
|
+
const specifier = node.source.value;
|
|
124
121
|
if (!isLocalSpecifier(specifier))
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
return;
|
|
123
|
+
const absSpecifier = join(dir, specifier);
|
|
124
|
+
for (const s of node.specifiers) {
|
|
125
|
+
const name = s.exported.type === 'Identifier' ? s.exported.name : s.exported.value;
|
|
126
|
+
if (name)
|
|
127
|
+
importMap.set(name, absSpecifier);
|
|
128
128
|
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
matchVisitor.visit(result.program);
|
|
131
132
|
return { importMap, componentMap };
|
|
132
133
|
}
|
|
@@ -61,11 +61,9 @@ const _collectRefsInType = (node, exportName, signatureOnly) => {
|
|
|
61
61
|
}
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
if (signatureOnly)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
else if (node.type === 'TSTypeReference' && node.typeName.type === 'Identifier') {
|
|
64
|
+
if (signatureOnly && (node.type === 'FunctionBody' || node.type === 'BlockStatement'))
|
|
65
|
+
return;
|
|
66
|
+
if (node.type === 'TSTypeReference' && node.typeName.type === 'Identifier') {
|
|
69
67
|
const name = node.typeName.name;
|
|
70
68
|
const refs = state.referencedInExport.get(name);
|
|
71
69
|
if (refs)
|
|
@@ -10,7 +10,6 @@ export default function parseCLIArgs(): {
|
|
|
10
10
|
exclude?: string[] | undefined;
|
|
11
11
|
exports?: boolean | undefined;
|
|
12
12
|
tags?: string[] | undefined;
|
|
13
|
-
'experimental-tags'?: string[] | undefined;
|
|
14
13
|
files?: boolean | undefined;
|
|
15
14
|
fix?: boolean | undefined;
|
|
16
15
|
'fix-type'?: string[] | undefined;
|
|
@@ -87,7 +87,6 @@ export default function parseCLIArgs() {
|
|
|
87
87
|
exclude: { type: 'string', multiple: true },
|
|
88
88
|
exports: { type: 'boolean' },
|
|
89
89
|
tags: { type: 'string', multiple: true },
|
|
90
|
-
'experimental-tags': { type: 'string', multiple: true },
|
|
91
90
|
files: { type: 'boolean' },
|
|
92
91
|
fix: { type: 'boolean' },
|
|
93
92
|
'fix-type': { type: 'string', multiple: true },
|
|
@@ -90,7 +90,7 @@ export const createOptions = async (options) => {
|
|
|
90
90
|
}
|
|
91
91
|
const fixTypes = options.fixTypes ?? args['fix-type'] ?? [];
|
|
92
92
|
const isFixFiles = args['allow-remove-files'] && (fixTypes.length === 0 || fixTypes.includes('files'));
|
|
93
|
-
const tags = splitTags(args.tags ?? options.tags ?? parsedConfig.tags ??
|
|
93
|
+
const tags = splitTags(args.tags ?? options.tags ?? parsedConfig.tags ?? []);
|
|
94
94
|
const workspace = options.workspace ?? args.workspace;
|
|
95
95
|
return {
|
|
96
96
|
cacheLocation: args['cache-location'] ?? join(cwd, 'node_modules', '.cache', 'knip'),
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.0
|
|
1
|
+
export declare const version = "6.0.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.0.0
|
|
1
|
+
export const version = '6.0.0';
|