knip 5.46.0 → 5.46.2
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/binaries/plugins.js +1 -1
- package/dist/constants.js +1 -0
- package/dist/graph/build.js +2 -1
- package/dist/plugins/node/index.js +5 -4
- package/dist/plugins/nuxt/index.js +8 -8
- package/dist/plugins/stylelint/index.js +1 -1
- package/dist/plugins/stylelint/types.d.ts +1 -1
- package/dist/plugins/webpack/index.js +5 -4
- package/dist/reporters/codeclimate.js +17 -10
- package/dist/reporters/symbols.d.ts +1 -1
- package/dist/reporters/symbols.js +2 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/issues.d.ts +1 -0
- package/dist/types/issues.js +1 -0
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +18 -0
- package/dist/typescript/visitors/exports/exportAssignment.js +3 -2
- package/dist/typescript/visitors/imports/importDeclaration.js +7 -1
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/glob.d.ts +1 -1
- package/dist/util/input.d.ts +2 -2
- package/dist/util/input.js +7 -2
- package/dist/util/require.d.ts +1 -1
- package/dist/util/watch.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -4
package/dist/binaries/plugins.js
CHANGED
|
@@ -39,7 +39,7 @@ export const resolve = (binary, _args, options) => {
|
|
|
39
39
|
if (id.includes('node_modules/.bin/'))
|
|
40
40
|
positionals.push(toBinary(extractBinary(id)));
|
|
41
41
|
else
|
|
42
|
-
positionals.push(toDeferResolveEntry(id));
|
|
42
|
+
positionals.push(toDeferResolveEntry(id, { optional: true }));
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
const mapToParsedKey = (id) => parsed[id];
|
package/dist/constants.js
CHANGED
package/dist/graph/build.js
CHANGED
|
@@ -109,7 +109,8 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
109
109
|
productionEntryFilePatterns.add(resolvedFilePath);
|
|
110
110
|
}
|
|
111
111
|
else if (isDeferResolveEntry(input)) {
|
|
112
|
-
|
|
112
|
+
if (!isProduction || !input.optional)
|
|
113
|
+
entryFilePatterns.add(resolvedFilePath);
|
|
113
114
|
}
|
|
114
115
|
else {
|
|
115
116
|
principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: true });
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { toEntry } from '../../util/input.js';
|
|
1
|
+
import { toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
const title = 'Node.js';
|
|
3
3
|
const isEnabled = () => true;
|
|
4
4
|
const config = ['package.json'];
|
|
5
5
|
const packageJsonPath = (id) => id;
|
|
6
6
|
const resolveEntryPaths = localConfig => {
|
|
7
7
|
const scripts = localConfig.scripts;
|
|
8
|
-
const
|
|
8
|
+
const entries = [toProductionEntry('server.js')];
|
|
9
9
|
if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
|
|
10
|
-
|
|
10
|
+
const patterns = ['**/*{.,-,_}test.?(c|m)js', '**/test-*.?(c|m)js', '**/test.?(c|m)js', '**/test/**/*.?(c|m)js'];
|
|
11
|
+
entries.push(...patterns.map(toEntry));
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return entries;
|
|
13
14
|
};
|
|
14
15
|
const args = {
|
|
15
16
|
positional: true,
|
|
@@ -11,10 +11,10 @@ const isEnabled = ({ dependencies }) => {
|
|
|
11
11
|
};
|
|
12
12
|
const entry = ['nuxt.config.{js,mjs,ts}'];
|
|
13
13
|
const production = [
|
|
14
|
-
'app.vue',
|
|
15
|
-
'error.vue',
|
|
16
|
-
'pages/**/*.vue',
|
|
17
|
-
'layouts/default.vue',
|
|
14
|
+
'app.{vue,jsx,tsx}',
|
|
15
|
+
'error.{vue,jsx,tsx}',
|
|
16
|
+
'pages/**/*.{vue,jsx,tsx}',
|
|
17
|
+
'layouts/default.{vue,jsx,tsx}',
|
|
18
18
|
'middleware/**/*.ts',
|
|
19
19
|
'server/api/**/*.ts',
|
|
20
20
|
'server/routes/**/*.ts',
|
|
@@ -24,10 +24,10 @@ const production = [
|
|
|
24
24
|
const resolveEntryPaths = async (localConfig) => {
|
|
25
25
|
const srcDir = localConfig.srcDir ?? '.';
|
|
26
26
|
const patterns = [
|
|
27
|
-
'app.vue',
|
|
28
|
-
'error.vue',
|
|
29
|
-
join(typeof localConfig.dir?.pages === 'string' ? localConfig.dir.pages : 'pages', '**/*.vue'),
|
|
30
|
-
join(typeof localConfig.dir?.layouts === 'string' ? localConfig.dir.layouts : 'layouts', '**/*.vue'),
|
|
27
|
+
'app.{vue,jsx,tsx}',
|
|
28
|
+
'error.{vue,jsx,tsx}',
|
|
29
|
+
join(typeof localConfig.dir?.pages === 'string' ? localConfig.dir.pages : 'pages', '**/*.{vue,jsx,tsx}'),
|
|
30
|
+
join(typeof localConfig.dir?.layouts === 'string' ? localConfig.dir.layouts : 'layouts', '**/*.{vue,jsx,tsx}'),
|
|
31
31
|
join(typeof localConfig.dir?.middleware === 'string' ? localConfig.dir.middleware : 'middleware', '**/*.ts'),
|
|
32
32
|
'server/api/**/*.ts',
|
|
33
33
|
'server/routes/**/*.ts',
|
|
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
7
7
|
const config = ['package.json', ...toCosmiconfig('stylelint')];
|
|
8
8
|
const resolve = (config) => {
|
|
9
9
|
const extend = config.extends ?? [];
|
|
10
|
-
const plugins = config.plugins ?? [];
|
|
10
|
+
const plugins = config.plugins?.flatMap(plugin => (typeof plugin === 'string' ? [plugin] : [])) ?? [];
|
|
11
11
|
const customSyntax = typeof config.customSyntax === 'string' ? [config.customSyntax] : [];
|
|
12
12
|
const overrideConfigs = 'overrides' in config ? config.overrides.flatMap(resolve) : [];
|
|
13
13
|
return [...[extend, plugins, customSyntax].flat().map(toDeferResolve), ...overrideConfigs];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
2
|
import { toDeferResolve, toDeferResolveEntry, toDeferResolveProductionEntry, toDependency, toDevDependency, } from '../../util/input.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isInternal } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
5
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
6
6
|
const title = 'webpack';
|
|
@@ -81,9 +81,10 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
81
81
|
inputs.add(toDependency(entry));
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
84
|
+
const dir = options.context ? options.context : cwd;
|
|
85
|
+
const input = options.mode === 'development'
|
|
86
|
+
? toDeferResolveEntry(entry, { dir })
|
|
87
|
+
: toDeferResolveProductionEntry(entry, { dir });
|
|
87
88
|
inputs.add(input);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
2
3
|
import { toRelative } from '../util/path.js';
|
|
3
4
|
import { getTitle } from './util.js';
|
|
4
5
|
export default async ({ report, issues }) => {
|
|
@@ -14,11 +15,11 @@ export default async ({ report, issues }) => {
|
|
|
14
15
|
entries.push(...issue.symbols.map(symbol => ({
|
|
15
16
|
type: 'issue',
|
|
16
17
|
check_name: getTitle(fixedType),
|
|
17
|
-
description: getSymbolDescription({ symbol, parentSymbol: issue.parentSymbol }),
|
|
18
|
+
description: getSymbolDescription({ type: issue.type, symbol, parentSymbol: issue.parentSymbol }),
|
|
18
19
|
categories: ['Duplication'],
|
|
19
20
|
location: createLocation(filePath, symbol.line, symbol.col),
|
|
20
21
|
severity: convertSeverity(issue.severity),
|
|
21
|
-
fingerprint: createFingerprint(filePath, symbol.symbol
|
|
22
|
+
fingerprint: createFingerprint(filePath, symbol.symbol),
|
|
22
23
|
})));
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
@@ -29,7 +30,7 @@ export default async ({ report, issues }) => {
|
|
|
29
30
|
categories: ['Bug Risk'],
|
|
30
31
|
location: createLocation(filePath, issue.line, issue.col),
|
|
31
32
|
severity: convertSeverity(issue.severity),
|
|
32
|
-
fingerprint: createFingerprint(filePath, issue.symbol
|
|
33
|
+
fingerprint: createFingerprint(filePath, issue.symbol),
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -51,12 +52,15 @@ function convertSeverity(severity) {
|
|
|
51
52
|
return 'info';
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function getPrefix(type) {
|
|
56
|
+
return ISSUE_TYPE_TITLE[type].replace(/ies$/, 'y').replace(/s$/, '');
|
|
57
|
+
}
|
|
58
|
+
function getIssueDescription({ type, symbol, symbols, parentSymbol }) {
|
|
55
59
|
const symbolDescription = symbols ? `${symbols.map(s => s.symbol).join(', ')}` : symbol;
|
|
56
|
-
return `${symbolDescription}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
60
|
+
return `${getPrefix(type)}: ${symbolDescription}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
57
61
|
}
|
|
58
|
-
function getSymbolDescription({ symbol, parentSymbol }) {
|
|
59
|
-
return `${symbol.symbol}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
62
|
+
function getSymbolDescription({ type, symbol, parentSymbol, }) {
|
|
63
|
+
return `${getPrefix(type)}: ${symbol.symbol}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
60
64
|
}
|
|
61
65
|
function createLocation(filePath, line, col) {
|
|
62
66
|
if (col !== undefined) {
|
|
@@ -67,6 +71,10 @@ function createLocation(filePath, line, col) {
|
|
|
67
71
|
line: line ?? 0,
|
|
68
72
|
column: col,
|
|
69
73
|
},
|
|
74
|
+
end: {
|
|
75
|
+
line: line ?? 0,
|
|
76
|
+
column: col,
|
|
77
|
+
},
|
|
70
78
|
},
|
|
71
79
|
};
|
|
72
80
|
}
|
|
@@ -78,10 +86,9 @@ function createLocation(filePath, line, col) {
|
|
|
78
86
|
},
|
|
79
87
|
};
|
|
80
88
|
}
|
|
81
|
-
function createFingerprint(filePath, message
|
|
89
|
+
function createFingerprint(filePath, message) {
|
|
82
90
|
const md5 = createHash('md5');
|
|
83
|
-
md5.update(filePath);
|
|
91
|
+
md5.update(toRelative(filePath));
|
|
84
92
|
md5.update(message);
|
|
85
|
-
md5.update(pos?.toString() ?? '');
|
|
86
93
|
return md5.digest('hex');
|
|
87
94
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReporterOptions } from '../types/issues.js';
|
|
2
2
|
declare const _default: ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }: ReporterOptions) => void;
|
|
3
3
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasyTable from 'easy-table';
|
|
2
2
|
import picocolors from 'picocolors';
|
|
3
3
|
import { ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
4
|
+
import { SymbolType } from '../types/issues.js';
|
|
4
5
|
import { relative, toRelative } from '../util/path.js';
|
|
5
6
|
import { truncate } from '../util/string.js';
|
|
6
7
|
import { getTitle, identity, logTitle, logTitleDimmed } from './util.js';
|
|
@@ -31,7 +32,7 @@ const logIssueRecord = (issues) => {
|
|
|
31
32
|
const symbols = issue.symbols;
|
|
32
33
|
table.cell('symbol', print(symbols ? truncate(symbols.map(s => s.symbol).join(', '), TRUNCATE_WIDTH) : hl(issue)));
|
|
33
34
|
issue.parentSymbol && table.cell('parentSymbol', print(issue.parentSymbol));
|
|
34
|
-
issue.symbolType && table.cell('symbolType', print(issue.symbolType));
|
|
35
|
+
issue.symbolType && issue.symbolType !== SymbolType.UNKNOWN && table.cell('symbolType', print(issue.symbolType));
|
|
35
36
|
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
36
37
|
const cell = issue.type === 'files' ? '' : `${relative(issue.filePath)}${pos}`;
|
|
37
38
|
table.cell('filePath', print(cell));
|
package/dist/types/config.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Input } from '../util/input.js';
|
|
|
6
6
|
import type { PluginName } from './PluginNames.js';
|
|
7
7
|
import type { Args } from './args.js';
|
|
8
8
|
import type { Tags } from './cli.js';
|
|
9
|
-
import type { IssueType, Rules } from './issues.js';
|
|
9
|
+
import type { IssueType, Rules, SymbolType } from './issues.js';
|
|
10
10
|
import type { PackageJson } from './package-json.js';
|
|
11
11
|
export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
12
12
|
knownBinsOnly?: boolean;
|
|
@@ -22,7 +22,7 @@ export type BinaryResolver = (binary: string, args: string[], options: BinaryRes
|
|
|
22
22
|
export type RawConfiguration = z.infer<typeof knipConfigurationSchema>;
|
|
23
23
|
export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
|
|
24
24
|
export type IgnorePatterns = (string | RegExp)[];
|
|
25
|
-
type IgnorableExport =
|
|
25
|
+
type IgnorableExport = Exclude<SymbolType, SymbolType.UNKNOWN>;
|
|
26
26
|
type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
27
27
|
export type GetImportsAndExportsOptions = {
|
|
28
28
|
skipTypeOnly: boolean;
|
package/dist/types/issues.d.ts
CHANGED
package/dist/types/issues.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import { SymbolType } from '../types/issues.js';
|
|
2
3
|
export declare function isGetOrSetAccessorDeclaration(node: ts.Node): node is ts.AccessorDeclaration;
|
|
3
4
|
export declare function isPrivateMember(node: ts.MethodDeclaration | ts.PropertyDeclaration | ts.SetAccessorDeclaration | ts.GetAccessorDeclaration): boolean;
|
|
4
5
|
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): boolean;
|
|
@@ -6,6 +7,7 @@ export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpr
|
|
|
6
7
|
export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
7
8
|
export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
|
|
8
9
|
export declare function isPropertyAccessCall(node: ts.Node, identifier: string): node is ts.CallExpression;
|
|
10
|
+
export declare const getNodeType: (node: ts.Node) => SymbolType;
|
|
9
11
|
export declare function stripQuotes(name: string): string;
|
|
10
12
|
export declare function findAncestor<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T | undefined;
|
|
11
13
|
export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import { SymbolType } from '../types/issues.js';
|
|
2
3
|
export function isGetOrSetAccessorDeclaration(node) {
|
|
3
4
|
return node.kind === ts.SyntaxKind.SetAccessor || node.kind === ts.SyntaxKind.GetAccessor;
|
|
4
5
|
}
|
|
@@ -30,6 +31,23 @@ export function isPropertyAccessCall(node, identifier) {
|
|
|
30
31
|
ts.isPropertyAccessExpression(node.expression) &&
|
|
31
32
|
node.expression.getText() === identifier);
|
|
32
33
|
}
|
|
34
|
+
export const getNodeType = (node) => {
|
|
35
|
+
if (!node)
|
|
36
|
+
return SymbolType.UNKNOWN;
|
|
37
|
+
if (ts.isFunctionDeclaration(node))
|
|
38
|
+
return SymbolType.FUNCTION;
|
|
39
|
+
if (ts.isClassDeclaration(node))
|
|
40
|
+
return SymbolType.CLASS;
|
|
41
|
+
if (ts.isInterfaceDeclaration(node))
|
|
42
|
+
return SymbolType.INTERFACE;
|
|
43
|
+
if (ts.isTypeAliasDeclaration(node))
|
|
44
|
+
return SymbolType.TYPE;
|
|
45
|
+
if (ts.isEnumDeclaration(node))
|
|
46
|
+
return SymbolType.ENUM;
|
|
47
|
+
if (ts.isVariableDeclaration(node))
|
|
48
|
+
return SymbolType.VARIABLE;
|
|
49
|
+
return SymbolType.UNKNOWN;
|
|
50
|
+
};
|
|
33
51
|
export function stripQuotes(name) {
|
|
34
52
|
const length = name.length;
|
|
35
53
|
if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { FIX_FLAGS } from '../../../constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getNodeType } from '../../ast-helpers.js';
|
|
4
4
|
import { isModule } from '../helpers.js';
|
|
5
5
|
import { exportVisitor as visit } from '../index.js';
|
|
6
6
|
export default visit(isModule, (node, { isFixExports }) => {
|
|
@@ -8,6 +8,7 @@ export default visit(isModule, (node, { isFixExports }) => {
|
|
|
8
8
|
const pos = node.getChildAt(1).getStart();
|
|
9
9
|
const fix = isFixExports ? [node.getStart(), node.getEnd() + 1, FIX_FLAGS.NONE] : undefined;
|
|
10
10
|
const symbol = node.getSourceFile().locals?.get(node.expression.escapedText);
|
|
11
|
-
|
|
11
|
+
const type = getNodeType(symbol?.valueDeclaration);
|
|
12
|
+
return { node, symbol, identifier: 'default', type, pos, fix };
|
|
12
13
|
}
|
|
13
14
|
});
|
|
@@ -21,7 +21,13 @@ export default visit(() => true, node => {
|
|
|
21
21
|
if (node.importClause?.namedBindings) {
|
|
22
22
|
if (ts.isNamespaceImport(node.importClause.namedBindings)) {
|
|
23
23
|
const symbol = node.importClause.namedBindings.symbol;
|
|
24
|
-
imports.push({
|
|
24
|
+
imports.push({
|
|
25
|
+
symbol,
|
|
26
|
+
specifier,
|
|
27
|
+
identifier: IMPORT_STAR,
|
|
28
|
+
isTypeOnly: node.importClause?.isTypeOnly,
|
|
29
|
+
pos: symbol?.declarations[0]?.pos ?? node.pos,
|
|
30
|
+
});
|
|
25
31
|
}
|
|
26
32
|
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
27
33
|
for (const element of node.importClause.namedBindings.elements) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no test files, devDependencies)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --directory [dir] Run process from a different directory (default: cwd)\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --watch Watch mode\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --files Shortcut for --include files\n --fix Fix issues\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n --include-libs Include type definitions from external dependencies (default: false)\n --include-entry-exports Include entry files when reporting unused exports\n --isolate-workspaces Isolate workspaces into separate programs\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter: symbols, compact, codeowners, json, codeclimate, markdown, disclosure, can be repeated (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --tags Include or exclude tagged exports\n --no-config-hints Suppress configuration hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --trace Show trace output\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n --performance Measure count and running time of expensive functions and display stats table\n -h, --help Print this help text\n -V, --version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n(2) Fixable issue types: dependencies, exports, types\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
|
|
1
|
+
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no test files, devDependencies)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --directory [dir] Run process from a different directory (default: cwd)\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --watch Watch mode\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --files Shortcut for --include files\n --fix Fix issues\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n --include-libs Include type definitions from external dependencies (default: false)\n --include-entry-exports Include entry files when reporting unused exports\n --isolate-workspaces Isolate workspaces into separate programs\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter: symbols, compact, codeowners, json, codeclimate, markdown, disclosure, can be repeated (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --tags Include or exclude tagged exports\n --no-config-hints Suppress configuration hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --trace Show trace output\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n --performance Measure count and running time of expensive functions and display stats table\n -h, --help Print this help text\n -V, --version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n(2) Fixable issue types: dependencies, exports, types\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
cache?: boolean | undefined;
|
|
4
4
|
'cache-location'?: string | undefined;
|
|
@@ -4,7 +4,7 @@ export const helpText = `✂️ Find unused files, dependencies and exports in
|
|
|
4
4
|
Usage: knip [options]
|
|
5
5
|
|
|
6
6
|
Options:
|
|
7
|
-
-c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)
|
|
7
|
+
-c, --config [file] Configuration file path (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)
|
|
8
8
|
-t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)
|
|
9
9
|
--production Analyze only production source files (e.g. no test files, devDependencies)
|
|
10
10
|
--strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)
|
package/dist/util/glob.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare const negate: (pattern: string) => string;
|
|
|
11
11
|
export declare const hasProductionSuffix: (pattern: string) => boolean;
|
|
12
12
|
export declare const hasNoProductionSuffix: (pattern: string) => boolean;
|
|
13
13
|
export declare const _glob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
|
|
14
|
-
export declare const _firstGlob: ({ cwd, patterns }: GlobOptions) => Promise<string | Buffer | undefined>;
|
|
14
|
+
export declare const _firstGlob: ({ cwd, patterns }: GlobOptions) => Promise<string | Buffer<ArrayBufferLike> | undefined>;
|
|
15
15
|
export declare const _dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
|
|
16
16
|
export {};
|
package/dist/util/input.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ export declare const toProductionDependency: (specifier: string) => Input;
|
|
|
33
33
|
export declare const toDevDependency: (specifier: string) => Input;
|
|
34
34
|
export declare const toDeferResolve: (specifier: string) => Input;
|
|
35
35
|
export declare const isDeferResolve: (input: Input) => boolean;
|
|
36
|
-
export declare const toDeferResolveProductionEntry: (specifier: string) => Input;
|
|
36
|
+
export declare const toDeferResolveProductionEntry: (specifier: string, options?: Options) => Input;
|
|
37
37
|
export declare const isDeferResolveProductionEntry: (input: Input) => boolean;
|
|
38
|
-
export declare const toDeferResolveEntry: (specifier: string) => Input;
|
|
38
|
+
export declare const toDeferResolveEntry: (specifier: string, options?: Options) => Input;
|
|
39
39
|
export declare const isDeferResolveEntry: (input: Input) => boolean;
|
|
40
40
|
export declare const toDebugString: (input: Input) => string;
|
|
41
41
|
export {};
|
package/dist/util/input.js
CHANGED
|
@@ -36,12 +36,17 @@ export const toProductionDependency = (specifier) => ({
|
|
|
36
36
|
export const toDevDependency = (specifier) => ({ type: 'dependency', specifier });
|
|
37
37
|
export const toDeferResolve = (specifier) => ({ type: 'deferResolve', specifier });
|
|
38
38
|
export const isDeferResolve = (input) => input.type === 'deferResolve';
|
|
39
|
-
export const toDeferResolveProductionEntry = (specifier) => ({
|
|
39
|
+
export const toDeferResolveProductionEntry = (specifier, options = {}) => ({
|
|
40
40
|
type: 'deferResolveEntry',
|
|
41
41
|
specifier,
|
|
42
42
|
production: true,
|
|
43
|
+
...options,
|
|
43
44
|
});
|
|
44
45
|
export const isDeferResolveProductionEntry = (input) => input.type === 'deferResolveEntry' && input.production === true;
|
|
45
|
-
export const toDeferResolveEntry = (specifier) => ({
|
|
46
|
+
export const toDeferResolveEntry = (specifier, options = {}) => ({
|
|
47
|
+
type: 'deferResolveEntry',
|
|
48
|
+
specifier,
|
|
49
|
+
...options,
|
|
50
|
+
});
|
|
46
51
|
export const isDeferResolveEntry = (input) => input.type === 'deferResolveEntry';
|
|
47
52
|
export const toDebugString = (input) => `${input.type}:${isAbsolute(input.specifier) ? toRelative(input.specifier) : input.specifier}${input.containingFilePath ? ` (${toRelative(input.containingFilePath)})` : ''}`;
|
package/dist/util/require.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const _require:
|
|
1
|
+
export declare const _require: NodeJS.Require;
|
package/dist/util/watch.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ type Watch = {
|
|
|
21
21
|
streamer: ConsoleStreamer;
|
|
22
22
|
unreferencedFiles: Set<string>;
|
|
23
23
|
};
|
|
24
|
-
export declare const getWatchHandler: ({ analyzedFiles, analyzeSourceFile, chief, collector, analyze, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }: Watch) => Promise<WatchListener<string | Buffer
|
|
24
|
+
export declare const getWatchHandler: ({ analyzedFiles, analyzeSourceFile, chief, collector, analyze, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }: Watch) => Promise<WatchListener<string | Buffer<ArrayBufferLike>>>;
|
|
25
25
|
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.46.
|
|
1
|
+
export declare const version = "5.46.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.46.
|
|
1
|
+
export const version = '5.46.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.46.
|
|
3
|
+
"version": "5.46.2",
|
|
4
4
|
"description": "Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -82,15 +82,16 @@
|
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@jest/types": "^29.6.3",
|
|
85
|
-
"@release-it/bumper": "^7.0.
|
|
86
|
-
"@types/bun": "
|
|
85
|
+
"@release-it/bumper": "^7.0.2",
|
|
86
|
+
"@types/bun": "1.2.4",
|
|
87
87
|
"@types/js-yaml": "^4.0.9",
|
|
88
88
|
"@types/minimist": "^1.2.5",
|
|
89
89
|
"@types/picomatch": "3.0.1",
|
|
90
90
|
"@types/webpack": "^5.28.5",
|
|
91
91
|
"@wdio/types": "^9.5.0",
|
|
92
|
+
"codeclimate-types": "^0.3.1",
|
|
92
93
|
"glob": "^10.4.2",
|
|
93
|
-
"release-it": "^19.0.0-next.
|
|
94
|
+
"release-it": "^19.0.0-next.2",
|
|
94
95
|
"type-fest": "^4.31.0",
|
|
95
96
|
"typescript": "^5.5.2"
|
|
96
97
|
},
|