knip 5.55.0 → 5.56.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/CacheConsultant.d.ts +1 -0
- package/dist/CacheConsultant.js +1 -1
- package/dist/ConfigurationChief.d.ts +1 -0
- package/dist/ConsoleStreamer.d.ts +1 -1
- package/dist/ConsoleStreamer.js +2 -2
- package/dist/DependencyDeputy.d.ts +2 -0
- package/dist/DependencyDeputy.js +6 -0
- package/dist/PrincipalFactory.d.ts +2 -9
- package/dist/PrincipalFactory.js +10 -6
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/ProjectPrincipal.js +3 -3
- package/dist/WorkspaceWorker.js +1 -1
- package/dist/cli.js +6 -5
- package/dist/compilers/index.d.ts +10 -0
- package/dist/constants.js +1 -0
- package/dist/graph/analyze.js +1 -1
- package/dist/graph/build.js +14 -5
- package/dist/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.d.ts +5 -0
- package/dist/plugins/docusaurus/helpers.js +89 -0
- package/dist/plugins/docusaurus/index.d.ts +12 -0
- package/dist/plugins/docusaurus/index.js +36 -0
- package/dist/plugins/docusaurus/types.d.ts +40 -0
- package/dist/plugins/docusaurus/types.js +1 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/webpack/index.js +9 -9
- package/dist/reporters/codeclimate.js +3 -3
- package/dist/reporters/codeowners.js +15 -30
- package/dist/reporters/compact.js +10 -4
- package/dist/reporters/disclosure.js +5 -24
- package/dist/reporters/markdown.js +2 -2
- package/dist/reporters/symbols.d.ts +1 -1
- package/dist/reporters/symbols.js +10 -45
- package/dist/reporters/util.d.ts +11 -7
- package/dist/reporters/util.js +45 -14
- package/dist/reporters/watch.js +7 -21
- package/dist/schema/configuration.d.ts +56 -0
- package/dist/schema/plugins.d.ts +23 -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/project.d.ts +1 -0
- package/dist/typescript/resolve-module-names.js +2 -2
- package/dist/util/Performance.d.ts +7 -7
- package/dist/util/Performance.js +20 -16
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/util/input.d.ts +8 -1
- package/dist/util/input.js +6 -0
- package/dist/util/resolve.d.ts +3 -1
- package/dist/util/resolve.js +7 -9
- package/dist/util/table.d.ts +4 -2
- package/dist/util/table.js +20 -24
- package/dist/util/watch.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/schema.json +4 -0
|
@@ -11,8 +11,8 @@ interface MemoryEntry extends PerformanceEntry {
|
|
|
11
11
|
}
|
|
12
12
|
declare class Performance {
|
|
13
13
|
isEnabled: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isTimerifyFunctions: boolean;
|
|
15
|
+
isMemoryUsageEnabled: boolean;
|
|
16
16
|
startTime: number;
|
|
17
17
|
endTime: number;
|
|
18
18
|
perfEntries: PerformanceEntry[];
|
|
@@ -23,17 +23,17 @@ declare class Performance {
|
|
|
23
23
|
memObserver?: PerformanceObserver;
|
|
24
24
|
memoryUsageStart?: ReturnType<typeof memoryUsage>;
|
|
25
25
|
freeMemoryStart?: number;
|
|
26
|
-
constructor({
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
constructor({ isTimerifyFunctions, isMemoryUsageEnabled }: {
|
|
27
|
+
isTimerifyFunctions?: boolean | undefined;
|
|
28
|
+
isMemoryUsageEnabled?: boolean | undefined;
|
|
29
29
|
});
|
|
30
30
|
private setMark;
|
|
31
31
|
private clearMark;
|
|
32
32
|
private flush;
|
|
33
33
|
private getPerfEntriesByName;
|
|
34
|
-
|
|
34
|
+
getTimerifiedFunctionsTable(): string;
|
|
35
35
|
addMemoryMark(index: number): void;
|
|
36
|
-
|
|
36
|
+
getMemoryUsageTable(): string;
|
|
37
37
|
getCurrentDurationInMs(startTime?: number): number;
|
|
38
38
|
getMemHeapUsage(): number;
|
|
39
39
|
getCurrentMemUsageInMb(): any;
|
package/dist/util/Performance.js
CHANGED
|
@@ -4,9 +4,13 @@ import { memoryUsage } from 'node:process';
|
|
|
4
4
|
import parsedArgValues from './cli-arguments.js';
|
|
5
5
|
import { getStats } from './math.js';
|
|
6
6
|
import { Table } from './table.js';
|
|
7
|
-
const { performance:
|
|
7
|
+
const { performance: enableTimerify = false, 'performance-fn': timerifyOnlyFnName, memory: enableMemoryUsage = false, 'memory-realtime': memoryRealtime = false, } = parsedArgValues;
|
|
8
|
+
const isTimerifyFunctions = enableTimerify || !!timerifyOnlyFnName;
|
|
9
|
+
const isMemoryUsageEnabled = enableMemoryUsage || memoryRealtime;
|
|
8
10
|
export const timerify = (fn, name = fn.name) => {
|
|
9
|
-
if (!
|
|
11
|
+
if (!isTimerifyFunctions)
|
|
12
|
+
return fn;
|
|
13
|
+
if (timerifyOnlyFnName && name !== timerifyOnlyFnName)
|
|
10
14
|
return fn;
|
|
11
15
|
return performance.timerify(Object.defineProperty(fn, 'name', { get: () => name }));
|
|
12
16
|
};
|
|
@@ -18,8 +22,8 @@ const logHead = () => console.log(keys.map(key => key.padStart(10)).join(' '));
|
|
|
18
22
|
const log = (memInfo) => console.log(keys.map(key => twoFixed(inMB(memInfo[key])).padStart(10)).join(' '));
|
|
19
23
|
class Performance {
|
|
20
24
|
isEnabled;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isTimerifyFunctions;
|
|
26
|
+
isMemoryUsageEnabled;
|
|
23
27
|
startTime = 0;
|
|
24
28
|
endTime = 0;
|
|
25
29
|
perfEntries = [];
|
|
@@ -30,15 +34,15 @@ class Performance {
|
|
|
30
34
|
memObserver;
|
|
31
35
|
memoryUsageStart;
|
|
32
36
|
freeMemoryStart;
|
|
33
|
-
constructor({
|
|
34
|
-
this.isEnabled =
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
+
constructor({ isTimerifyFunctions = false, isMemoryUsageEnabled = false }) {
|
|
38
|
+
this.isEnabled = isTimerifyFunctions || isMemoryUsageEnabled;
|
|
39
|
+
this.isTimerifyFunctions = isTimerifyFunctions;
|
|
40
|
+
this.isMemoryUsageEnabled = isMemoryUsageEnabled;
|
|
37
41
|
this.startTime = performance.now();
|
|
38
42
|
const instanceId = Math.floor(performance.now() * 100);
|
|
39
43
|
this.perfId = `perf-${instanceId}`;
|
|
40
44
|
this.memId = `mem-${instanceId}`;
|
|
41
|
-
if (
|
|
45
|
+
if (isTimerifyFunctions) {
|
|
42
46
|
this.fnObserver = new PerformanceObserver(items => {
|
|
43
47
|
for (const entry of items.getEntries()) {
|
|
44
48
|
this.perfEntries.push(entry);
|
|
@@ -46,7 +50,7 @@ class Performance {
|
|
|
46
50
|
});
|
|
47
51
|
this.fnObserver.observe({ type: 'function' });
|
|
48
52
|
}
|
|
49
|
-
if (
|
|
53
|
+
if (isMemoryUsageEnabled) {
|
|
50
54
|
this.memObserver = new PerformanceObserver(items => {
|
|
51
55
|
for (const entry of items.getEntries()) {
|
|
52
56
|
this.memEntries.push(entry);
|
|
@@ -82,12 +86,12 @@ class Performance {
|
|
|
82
86
|
return entries;
|
|
83
87
|
}, {});
|
|
84
88
|
}
|
|
85
|
-
|
|
89
|
+
getTimerifiedFunctionsTable() {
|
|
86
90
|
const entriesByName = this.getPerfEntriesByName();
|
|
87
91
|
const table = new Table({ header: true });
|
|
88
92
|
for (const [name, values] of Object.entries(entriesByName)) {
|
|
89
93
|
const stats = getStats(values);
|
|
90
|
-
table.
|
|
94
|
+
table.row();
|
|
91
95
|
table.cell('Name', name);
|
|
92
96
|
table.cell('size', values.length);
|
|
93
97
|
table.cell('min', stats.min, twoFixed);
|
|
@@ -99,7 +103,7 @@ class Performance {
|
|
|
99
103
|
return table.toString();
|
|
100
104
|
}
|
|
101
105
|
addMemoryMark(index) {
|
|
102
|
-
if (!this.
|
|
106
|
+
if (!this.isMemoryUsageEnabled)
|
|
103
107
|
return;
|
|
104
108
|
const id = `${this.memId}:${index}`;
|
|
105
109
|
const detail = getMemInfo();
|
|
@@ -107,12 +111,12 @@ class Performance {
|
|
|
107
111
|
if (memoryRealtime && detail)
|
|
108
112
|
log(detail);
|
|
109
113
|
}
|
|
110
|
-
|
|
114
|
+
getMemoryUsageTable() {
|
|
111
115
|
const table = new Table({ header: true });
|
|
112
116
|
for (const entry of this.memEntries) {
|
|
113
117
|
if (!entry.detail)
|
|
114
118
|
continue;
|
|
115
|
-
table.
|
|
119
|
+
table.row();
|
|
116
120
|
table.cell('heapUsed', inMB(entry.detail.heapUsed), twoFixed);
|
|
117
121
|
table.cell('heapTotal', inMB(entry.detail.heapTotal), twoFixed);
|
|
118
122
|
table.cell('freemem', inMB(entry.detail.freemem), twoFixed);
|
|
@@ -139,4 +143,4 @@ class Performance {
|
|
|
139
143
|
this.memObserver?.disconnect();
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
|
-
export const perfObserver = new Performance({
|
|
146
|
+
export const perfObserver = new Performance({ isTimerifyFunctions, isMemoryUsageEnabled });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files 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 --format Format modified files after --fix using the local formatter\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 key functions and display stats table\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\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 dependencies, exports and files 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 --format Format modified files after --fix using the local formatter\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 key functions and display stats table\n --performance-fn [name] Measure only function [name]\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\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;
|
|
@@ -29,6 +29,7 @@ declare const _default: {
|
|
|
29
29
|
'no-gitignore'?: boolean | undefined;
|
|
30
30
|
'no-progress'?: boolean | undefined;
|
|
31
31
|
performance?: boolean | undefined;
|
|
32
|
+
'performance-fn'?: string | undefined;
|
|
32
33
|
production?: boolean | undefined;
|
|
33
34
|
preprocessor?: string[] | undefined;
|
|
34
35
|
'preprocessor-options'?: string | undefined;
|
|
@@ -41,6 +41,7 @@ Options:
|
|
|
41
41
|
--trace-export [name] Show trace output for named export(s)
|
|
42
42
|
--trace-file [file] Show trace output for exports in file
|
|
43
43
|
--performance Measure count and running time of key functions and display stats table
|
|
44
|
+
--performance-fn [name] Measure only function [name]
|
|
44
45
|
--memory Measure memory usage and display data table
|
|
45
46
|
--memory-realtime Log memory usage in realtime
|
|
46
47
|
-h, --help Print this help text
|
|
@@ -92,6 +93,7 @@ try {
|
|
|
92
93
|
'no-gitignore': { type: 'boolean' },
|
|
93
94
|
'no-progress': { type: 'boolean', short: 'n' },
|
|
94
95
|
performance: { type: 'boolean' },
|
|
96
|
+
'performance-fn': { type: 'string' },
|
|
95
97
|
production: { type: 'boolean' },
|
|
96
98
|
preprocessor: { type: 'string', multiple: true },
|
|
97
99
|
'preprocessor-options': { type: 'string' },
|
package/dist/util/input.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PluginName } from '../types/PluginNames.js';
|
|
2
|
-
type
|
|
2
|
+
import type { IssueType } from '../types/issues.js';
|
|
3
|
+
type InputType = 'binary' | 'entry' | 'project' | 'config' | 'dependency' | 'deferResolve' | 'deferResolveEntry' | 'alias' | 'ignore';
|
|
3
4
|
export interface Input {
|
|
4
5
|
type: InputType;
|
|
5
6
|
specifier: string;
|
|
@@ -19,6 +20,10 @@ interface AliasInput extends Input {
|
|
|
19
20
|
type: 'alias';
|
|
20
21
|
prefixes: string[];
|
|
21
22
|
}
|
|
23
|
+
interface IgnoreInput extends Input {
|
|
24
|
+
type: 'ignore';
|
|
25
|
+
issueType: IssueType;
|
|
26
|
+
}
|
|
22
27
|
type Options = {
|
|
23
28
|
optional?: boolean;
|
|
24
29
|
dir?: string;
|
|
@@ -47,5 +52,7 @@ export declare const toDeferResolveEntry: (specifier: string, options?: Options)
|
|
|
47
52
|
export declare const isDeferResolveEntry: (input: Input) => boolean;
|
|
48
53
|
export declare const toAlias: (specifier: string, prefix: string | string[], options?: Options) => AliasInput;
|
|
49
54
|
export declare const isAlias: (input: Input) => input is AliasInput;
|
|
55
|
+
export declare const toIgnore: (specifier: string, issueType: IssueType) => IgnoreInput;
|
|
56
|
+
export declare const isIgnore: (input: Input) => input is IgnoreInput;
|
|
50
57
|
export declare const toDebugString: (input: Input) => string;
|
|
51
58
|
export {};
|
package/dist/util/input.js
CHANGED
|
@@ -57,4 +57,10 @@ export const toAlias = (specifier, prefix, options = {}) => ({
|
|
|
57
57
|
...options,
|
|
58
58
|
});
|
|
59
59
|
export const isAlias = (input) => input.type === 'alias';
|
|
60
|
+
export const toIgnore = (specifier, issueType) => ({
|
|
61
|
+
type: 'ignore',
|
|
62
|
+
specifier,
|
|
63
|
+
issueType,
|
|
64
|
+
});
|
|
65
|
+
export const isIgnore = (input) => input.type === 'ignore';
|
|
60
66
|
export const toDebugString = (input) => `${input.type}:${isAbsolute(input.specifier) ? toRelative(input.specifier) : input.specifier}${input.containingFilePath ? ` (${toRelative(input.containingFilePath)})` : ''}`;
|
package/dist/util/resolve.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare const createSyncResolver: (extensions: string[]) => (specifier: string, baseDir: string) => string | undefined;
|
|
2
2
|
export declare const _resolveSync: (specifier: string, baseDir: string) => string | undefined;
|
|
3
|
+
export declare const _createSyncResolver: typeof createSyncResolver;
|
|
4
|
+
export {};
|
package/dist/util/resolve.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ER from 'enhanced-resolve';
|
|
1
|
+
import { ResolverFactory } from 'oxc-resolver';
|
|
3
2
|
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
4
3
|
import { timerify } from './Performance.js';
|
|
5
4
|
import { toPosix } from './path.js';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const resolver = ER.create.sync({
|
|
9
|
-
fileSystem,
|
|
5
|
+
const createSyncResolver = (extensions) => {
|
|
6
|
+
const resolver = new ResolverFactory({
|
|
10
7
|
extensions,
|
|
11
8
|
conditionNames: ['require', 'import', 'node', 'default'],
|
|
12
9
|
});
|
|
13
10
|
return function resolveSync(specifier, baseDir) {
|
|
14
11
|
try {
|
|
15
|
-
const resolved = resolver(
|
|
16
|
-
if (resolved)
|
|
17
|
-
return toPosix(resolved);
|
|
12
|
+
const resolved = resolver.sync(baseDir, specifier);
|
|
13
|
+
if (resolved?.path)
|
|
14
|
+
return toPosix(resolved.path);
|
|
18
15
|
}
|
|
19
16
|
catch (_error) { }
|
|
20
17
|
};
|
|
21
18
|
};
|
|
22
19
|
const resolveSync = createSyncResolver([...DEFAULT_EXTENSIONS, '.json']);
|
|
23
20
|
export const _resolveSync = timerify(resolveSync);
|
|
21
|
+
export const _createSyncResolver = extensions => timerify(createSyncResolver(extensions));
|
package/dist/util/table.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ export declare class Table {
|
|
|
12
12
|
truncateStart?: string[];
|
|
13
13
|
noTruncate?: string[];
|
|
14
14
|
});
|
|
15
|
+
row(): this;
|
|
15
16
|
cell(column: string, value: Value, formatter?: (value: Value) => string): this;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
sort(column: string): this;
|
|
18
|
+
toCells(): string[][];
|
|
19
|
+
toRows(): string[];
|
|
18
20
|
toString(): string;
|
|
19
21
|
}
|
|
20
22
|
export {};
|
package/dist/util/table.js
CHANGED
|
@@ -16,30 +16,24 @@ export class Table {
|
|
|
16
16
|
this.truncateStart = options?.truncateStart || [];
|
|
17
17
|
this.noTruncate = options?.noTruncate || [];
|
|
18
18
|
}
|
|
19
|
+
row() {
|
|
20
|
+
this.rows.push({});
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
19
23
|
cell(column, value, formatter) {
|
|
20
24
|
if (!this.columns.includes(column))
|
|
21
25
|
this.columns.push(column);
|
|
22
26
|
const row = this.rows[this.rows.length - 1];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
align: typeof value === 'number' ? 'right' : 'left',
|
|
27
|
-
};
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
newRow() {
|
|
31
|
-
this.rows.push({});
|
|
27
|
+
const align = typeof value === 'number' ? 'right' : 'left';
|
|
28
|
+
const formatted = formatter ? formatter(value) : undefined;
|
|
29
|
+
row[column] = { value, formatted, align };
|
|
32
30
|
return this;
|
|
33
31
|
}
|
|
34
|
-
sort(
|
|
35
|
-
if (typeof compareFn === 'function') {
|
|
36
|
-
this.rows.sort(compareFn);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
32
|
+
sort(column) {
|
|
39
33
|
this.rows.sort((a, b) => {
|
|
40
|
-
const [
|
|
41
|
-
const vA = a[
|
|
42
|
-
const vB = b[
|
|
34
|
+
const [columnName, order] = column.split('|');
|
|
35
|
+
const vA = a[columnName].value;
|
|
36
|
+
const vB = b[columnName].value;
|
|
43
37
|
if (typeof vA === 'string' && typeof vB === 'string')
|
|
44
38
|
return (order === 'desc' ? -1 : 1) * vA.localeCompare(vB);
|
|
45
39
|
if (typeof vA === 'number' && typeof vB === 'number')
|
|
@@ -48,7 +42,7 @@ export class Table {
|
|
|
48
42
|
});
|
|
49
43
|
return this;
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
toCells() {
|
|
52
46
|
const columns = this.columns.filter(col => this.rows.some(row => typeof row[col].value === 'string' || typeof row[col].value === 'number'));
|
|
53
47
|
if (this.header) {
|
|
54
48
|
const headerRow = {};
|
|
@@ -87,17 +81,19 @@ export class Table {
|
|
|
87
81
|
columnWidths[truncatableColumns.length > 0 ? truncatableColumns[0] : columns[0]] += roundingDiff;
|
|
88
82
|
}
|
|
89
83
|
}
|
|
90
|
-
return this.rows
|
|
91
|
-
.map(row => columns
|
|
92
|
-
.map((col, index) => {
|
|
84
|
+
return this.rows.map(row => columns.map((col, index) => {
|
|
93
85
|
const cell = row[col];
|
|
94
86
|
const width = columnWidths[col];
|
|
95
87
|
const fill = cell.fill || ' ';
|
|
96
88
|
const padded = pad(String(cell.formatted || cell.value || ''), width, fill, cell.align);
|
|
97
89
|
const truncated = this.truncateStart.includes(col) ? truncateStart(padded, width) : truncate(padded, width);
|
|
98
90
|
return index === 0 ? truncated : COLUMN_SEPARATOR + truncated;
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
toRows() {
|
|
94
|
+
return this.toCells().map(row => row.join(''));
|
|
95
|
+
}
|
|
96
|
+
toString() {
|
|
97
|
+
return this.toRows().join('\n');
|
|
102
98
|
}
|
|
103
99
|
}
|
package/dist/util/watch.js
CHANGED
|
@@ -42,7 +42,7 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
|
|
|
42
42
|
debugLog(workspace.name, `Watcher: ± ${filename}`);
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
|
-
const filePaths =
|
|
45
|
+
const filePaths = factory.getPrincipals().flatMap(p => p.getUsedResolvedFiles());
|
|
46
46
|
if (event === 'added' || event === 'deleted') {
|
|
47
47
|
graph.clear();
|
|
48
48
|
for (const filePath of filePaths)
|
|
@@ -56,7 +56,7 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
|
|
|
56
56
|
else {
|
|
57
57
|
graph.delete(filePath);
|
|
58
58
|
analyzedFiles.delete(filePath);
|
|
59
|
-
if (
|
|
59
|
+
if (principal.projectPaths.has(filePath))
|
|
60
60
|
cachedUnusedFiles.add(filePath);
|
|
61
61
|
}
|
|
62
62
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.56.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.56.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.56.0",
|
|
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": {
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@nodelib/fs.walk": "^1.2.3",
|
|
65
|
-
"enhanced-resolve": "^5.18.1",
|
|
66
65
|
"fast-glob": "^3.3.3",
|
|
67
66
|
"formatly": "^0.2.3",
|
|
68
67
|
"jiti": "^2.4.2",
|
|
69
68
|
"js-yaml": "^4.1.0",
|
|
70
69
|
"minimist": "^1.2.8",
|
|
70
|
+
"oxc-resolver": "^9.0.2",
|
|
71
71
|
"picocolors": "^1.1.0",
|
|
72
72
|
"picomatch": "^4.0.1",
|
|
73
73
|
"smol-toml": "^1.3.1",
|
package/schema.json
CHANGED
|
@@ -359,6 +359,10 @@
|
|
|
359
359
|
"title": "dependency-cruiser plugin configuration (https://knip.dev/reference/plugins/dependency-cruiser)",
|
|
360
360
|
"$ref": "#/definitions/plugin"
|
|
361
361
|
},
|
|
362
|
+
"docusaurus": {
|
|
363
|
+
"title": "Docusaurus plugin configuration (https://knip.dev/reference/plugins/docusaurus)",
|
|
364
|
+
"$ref": "#/definitions/plugin"
|
|
365
|
+
},
|
|
362
366
|
"dotenv": {
|
|
363
367
|
"title": "dotenv plugin configuration (https://knip.dev/reference/plugins/dotenv)",
|
|
364
368
|
"$ref": "#/definitions/plugin"
|