knip 5.66.0 → 5.66.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/ConfigurationChief.d.ts +6 -6
- package/dist/ConsoleStreamer.d.ts +2 -1
- package/dist/ConsoleStreamer.js +10 -5
- package/dist/IssueCollector.d.ts +4 -1
- package/dist/IssueCollector.js +8 -1
- package/dist/compilers/index.d.ts +5 -12
- package/dist/constants.d.ts +28 -3
- package/dist/constants.js +10 -0
- package/dist/graph/build.js +4 -2
- package/dist/index.js +5 -1
- package/dist/plugins/nuxt/index.js +5 -1
- package/dist/plugins/rsbuild/index.js +7 -7
- package/dist/reporters/util/util.d.ts +2 -2
- package/dist/reporters/util/util.js +2 -3
- package/dist/reporters/watch.d.ts +2 -2
- package/dist/reporters/watch.js +3 -3
- package/dist/schema/configuration.d.ts +1 -6
- package/dist/schema/configuration.js +3 -8
- package/dist/types/config.d.ts +1 -1
- package/dist/types/issues.d.ts +2 -10
- package/dist/types/issues.js +1 -11
- package/dist/typescript/ast-helpers.d.ts +3 -3
- package/dist/typescript/ast-helpers.js +11 -12
- package/dist/typescript/visitors/exports/exportDeclaration.js +4 -5
- package/dist/typescript/visitors/exports/exportKeyword.js +9 -10
- package/dist/typescript/visitors/exports/exportsAccessExpression.js +2 -3
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +5 -6
- package/dist/util/Performance.d.ts +1 -1
- package/dist/util/Performance.js +2 -2
- package/dist/util/create-options.d.ts +7 -14
- package/dist/util/create-options.js +1 -1
- package/dist/util/get-included-issue-types.js +1 -4
- package/dist/util/get-referenced-inputs.d.ts +2 -2
- package/dist/util/get-referenced-inputs.js +5 -5
- package/dist/util/has-strictly-ns-references.d.ts +1 -1
- package/dist/util/string.js +5 -1
- package/dist/util/to-source-path.d.ts +1 -1
- package/dist/util/to-source-path.js +4 -4
- package/dist/util/watch.d.ts +7 -3
- package/dist/util/watch.js +106 -67
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +3 -0
|
@@ -644,13 +644,18 @@ export declare class ConfigurationChief {
|
|
|
644
644
|
ignoreUnresolved: (string | RegExp)[];
|
|
645
645
|
};
|
|
646
646
|
getConfigForWorkspace(workspaceName: string, extensions?: string[]): {
|
|
647
|
+
bun?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
648
|
+
node?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
649
|
+
pnpm?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
650
|
+
yarn?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
651
|
+
typescript?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
652
|
+
jest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
647
653
|
angular?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
648
654
|
astro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
649
655
|
ava?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
650
656
|
babel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
651
657
|
biome?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
652
658
|
bumpp?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
653
|
-
bun?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
654
659
|
c8?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
655
660
|
capacitor?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
656
661
|
changelogen?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -679,7 +684,6 @@ export declare class ConfigurationChief {
|
|
|
679
684
|
hardhat?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
680
685
|
husky?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
681
686
|
"i18next-parser"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
682
|
-
jest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
683
687
|
karma?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
684
688
|
ladle?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
685
689
|
lefthook?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -696,7 +700,6 @@ export declare class ConfigurationChief {
|
|
|
696
700
|
nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
697
701
|
netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
698
702
|
next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
699
|
-
node?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
700
703
|
"node-modules-inspector"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
701
704
|
nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
702
705
|
"npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -709,7 +712,6 @@ export declare class ConfigurationChief {
|
|
|
709
712
|
"playwright-ct"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
710
713
|
"playwright-test"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
711
714
|
plop?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
712
|
-
pnpm?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
713
715
|
postcss?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
714
716
|
preconstruct?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
715
717
|
prettier?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -744,7 +746,6 @@ export declare class ConfigurationChief {
|
|
|
744
746
|
tsup?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
745
747
|
tsx?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
746
748
|
typedoc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
747
|
-
typescript?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
748
749
|
unbuild?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
749
750
|
unocss?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
750
751
|
"vercel-og"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -757,7 +758,6 @@ export declare class ConfigurationChief {
|
|
|
757
758
|
wireit?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
758
759
|
wrangler?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
759
760
|
xo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
760
|
-
yarn?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
761
761
|
yorkie?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
762
762
|
entry: string[];
|
|
763
763
|
project: string[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MainOptions } from './util/create-options.js';
|
|
2
2
|
export declare class ConsoleStreamer {
|
|
3
3
|
isEnabled: boolean;
|
|
4
|
+
isWatch: boolean;
|
|
4
5
|
private lines;
|
|
5
6
|
constructor(options: MainOptions);
|
|
6
7
|
private clearLines;
|
|
7
|
-
private
|
|
8
|
+
private clearScreen;
|
|
8
9
|
private update;
|
|
9
10
|
cast(message: string | string[], sub?: string): void;
|
|
10
11
|
clear(): void;
|
package/dist/ConsoleStreamer.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export class ConsoleStreamer {
|
|
2
2
|
isEnabled = false;
|
|
3
|
+
isWatch = false;
|
|
3
4
|
lines = 0;
|
|
4
5
|
constructor(options) {
|
|
5
|
-
this.isEnabled = options.isShowProgress;
|
|
6
|
+
this.isEnabled = options.isShowProgress && !options.isDebug;
|
|
7
|
+
this.isWatch = options.isWatch;
|
|
6
8
|
}
|
|
7
9
|
clearLines(count) {
|
|
8
10
|
if (count > 0) {
|
|
@@ -13,11 +15,11 @@ export class ConsoleStreamer {
|
|
|
13
15
|
}
|
|
14
16
|
process.stdout.cursorTo(0);
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
clearScreen() {
|
|
19
|
+
process.stdout.write('\x1b[2J\x1b[1;1f');
|
|
18
20
|
}
|
|
19
21
|
update(messages) {
|
|
20
|
-
this.
|
|
22
|
+
this.clear();
|
|
21
23
|
process.stdout.write(`${messages.join('\n')}\n`);
|
|
22
24
|
this.lines = messages.length;
|
|
23
25
|
}
|
|
@@ -32,6 +34,9 @@ export class ConsoleStreamer {
|
|
|
32
34
|
clear() {
|
|
33
35
|
if (!this.isEnabled)
|
|
34
36
|
return;
|
|
35
|
-
this.
|
|
37
|
+
if (this.isWatch)
|
|
38
|
+
this.clearScreen();
|
|
39
|
+
else
|
|
40
|
+
this.clearLines(this.lines);
|
|
36
41
|
}
|
|
37
42
|
}
|
package/dist/IssueCollector.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class IssueCollector {
|
|
|
25
25
|
unused: number;
|
|
26
26
|
}): void;
|
|
27
27
|
addFilesIssues(filePaths: string[]): void;
|
|
28
|
-
addIssue(issue: Issue):
|
|
28
|
+
addIssue(issue: Issue): true | undefined;
|
|
29
29
|
addConfigurationHint(issue: ConfigurationHint): void;
|
|
30
30
|
addTagHint(issue: TagHint): void;
|
|
31
31
|
purge(): import("./types/issues.js").IssueSet;
|
|
@@ -35,4 +35,7 @@ export declare class IssueCollector {
|
|
|
35
35
|
tagHints: Set<TagHint>;
|
|
36
36
|
configurationHints: Set<ConfigurationHint>;
|
|
37
37
|
};
|
|
38
|
+
private retainedIssues;
|
|
39
|
+
retainIssue(issue: Issue): void;
|
|
40
|
+
getRetainedIssues(): Issue[];
|
|
38
41
|
}
|
package/dist/IssueCollector.js
CHANGED
|
@@ -99,7 +99,7 @@ export class IssueCollector {
|
|
|
99
99
|
issues[key][symbol] = issue;
|
|
100
100
|
this.counters[issue.type]++;
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return true;
|
|
103
103
|
}
|
|
104
104
|
addConfigurationHint(issue) {
|
|
105
105
|
const key = `${issue.workspaceName}::${issue.type}::${issue.identifier}`;
|
|
@@ -123,4 +123,11 @@ export class IssueCollector {
|
|
|
123
123
|
configurationHints: new Set(this.configurationHints.values()),
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
+
retainedIssues = [];
|
|
127
|
+
retainIssue(issue) {
|
|
128
|
+
this.retainedIssues.push(issue);
|
|
129
|
+
}
|
|
130
|
+
getRetainedIssues() {
|
|
131
|
+
return this.retainedIssues;
|
|
132
|
+
}
|
|
126
133
|
}
|
|
@@ -1166,10 +1166,10 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1166
1166
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
1167
1167
|
includeEntryExports?: boolean | undefined;
|
|
1168
1168
|
}> | undefined;
|
|
1169
|
-
include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "
|
|
1170
|
-
exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "
|
|
1169
|
+
include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "nsExports" | "types" | "nsTypes" | "enumMembers" | "classMembers" | "duplicates")[] | undefined;
|
|
1170
|
+
exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "nsExports" | "types" | "nsTypes" | "enumMembers" | "classMembers" | "duplicates")[] | undefined;
|
|
1171
1171
|
$schema?: string | undefined;
|
|
1172
|
-
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "
|
|
1172
|
+
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "nsExports" | "types" | "nsTypes" | "enumMembers" | "classMembers" | "duplicates", "error" | "warn" | "off">> | undefined;
|
|
1173
1173
|
entry?: string | string[] | undefined;
|
|
1174
1174
|
project?: string | string[] | undefined;
|
|
1175
1175
|
paths?: Record<string, string[]> | undefined;
|
|
@@ -1179,15 +1179,8 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1179
1179
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
1180
1180
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
1181
1181
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
1182
|
-
ignoreExportsUsedInFile?: boolean |
|
|
1183
|
-
|
|
1184
|
-
enum?: boolean | undefined;
|
|
1185
|
-
function?: boolean | undefined;
|
|
1186
|
-
interface?: boolean | undefined;
|
|
1187
|
-
member?: boolean | undefined;
|
|
1188
|
-
type?: boolean | undefined;
|
|
1189
|
-
} | undefined;
|
|
1190
|
-
ignoreIssues?: Record<string, ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[]> | undefined;
|
|
1182
|
+
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
1183
|
+
ignoreIssues?: Record<string, ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "nsExports" | "types" | "nsTypes" | "enumMembers" | "classMembers" | "duplicates")[]> | undefined;
|
|
1191
1184
|
ignoreWorkspaces?: string[] | undefined;
|
|
1192
1185
|
includeEntryExports?: boolean | undefined;
|
|
1193
1186
|
compilers?: Record<string, true | ((filename: string, contents: string) => string) | ((filename: string, contents: string) => Promise<string>)> | undefined;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IssueType } from './types/issues.js';
|
|
2
1
|
export declare const ROOT_WORKSPACE_NAME = ".";
|
|
3
2
|
export declare const IMPORT_STAR = "*";
|
|
4
3
|
export declare const ANONYMOUS = "__anonymous";
|
|
@@ -16,8 +15,34 @@ export declare const IGNORED_DEPENDENCIES: Set<string>;
|
|
|
16
15
|
export declare const IGNORED_RUNTIME_DEPENDENCIES: Set<string>;
|
|
17
16
|
export declare const FOREIGN_FILE_EXTENSIONS: Set<string>;
|
|
18
17
|
export declare const IGNORE_DEFINITELY_TYPED: Set<string>;
|
|
19
|
-
export declare const ISSUE_TYPES:
|
|
20
|
-
export declare const ISSUE_TYPE_TITLE:
|
|
18
|
+
export declare const ISSUE_TYPES: readonly ["files", "dependencies", "devDependencies", "optionalPeerDependencies", "unlisted", "binaries", "unresolved", "exports", "nsExports", "types", "nsTypes", "enumMembers", "classMembers", "duplicates"];
|
|
19
|
+
export declare const ISSUE_TYPE_TITLE: {
|
|
20
|
+
readonly files: "Unused files";
|
|
21
|
+
readonly _files: "Unused files";
|
|
22
|
+
readonly dependencies: "Unused dependencies";
|
|
23
|
+
readonly devDependencies: "Unused devDependencies";
|
|
24
|
+
readonly optionalPeerDependencies: "Referenced optional peerDependencies";
|
|
25
|
+
readonly unlisted: "Unlisted dependencies";
|
|
26
|
+
readonly binaries: "Unlisted binaries";
|
|
27
|
+
readonly unresolved: "Unresolved imports";
|
|
28
|
+
readonly exports: "Unused exports";
|
|
29
|
+
readonly nsExports: "Exports in used namespace";
|
|
30
|
+
readonly types: "Unused exported types";
|
|
31
|
+
readonly nsTypes: "Exported types in used namespace";
|
|
32
|
+
readonly enumMembers: "Unused exported enum members";
|
|
33
|
+
readonly classMembers: "Unused exported class members";
|
|
34
|
+
readonly duplicates: "Duplicate exports";
|
|
35
|
+
};
|
|
36
|
+
export declare const SYMBOL_TYPE: {
|
|
37
|
+
readonly CLASS: "class";
|
|
38
|
+
readonly ENUM: "enum";
|
|
39
|
+
readonly FUNCTION: "function";
|
|
40
|
+
readonly INTERFACE: "interface";
|
|
41
|
+
readonly MEMBER: "member";
|
|
42
|
+
readonly TYPE: "type";
|
|
43
|
+
readonly UNKNOWN: "unknown";
|
|
44
|
+
readonly VARIABLE: "variable";
|
|
45
|
+
};
|
|
21
46
|
export declare const FIX_FLAGS: {
|
|
22
47
|
readonly NONE: 0;
|
|
23
48
|
readonly OBJECT_BINDING: number;
|
package/dist/constants.js
CHANGED
|
@@ -190,6 +190,16 @@ export const ISSUE_TYPE_TITLE = {
|
|
|
190
190
|
classMembers: 'Unused exported class members',
|
|
191
191
|
duplicates: 'Duplicate exports',
|
|
192
192
|
};
|
|
193
|
+
export const SYMBOL_TYPE = {
|
|
194
|
+
CLASS: 'class',
|
|
195
|
+
ENUM: 'enum',
|
|
196
|
+
FUNCTION: 'function',
|
|
197
|
+
INTERFACE: 'interface',
|
|
198
|
+
MEMBER: 'member',
|
|
199
|
+
TYPE: 'type',
|
|
200
|
+
UNKNOWN: 'unknown',
|
|
201
|
+
VARIABLE: 'variable',
|
|
202
|
+
};
|
|
193
203
|
export const FIX_FLAGS = {
|
|
194
204
|
NONE: 0,
|
|
195
205
|
OBJECT_BINDING: 1 << 0,
|
package/dist/graph/build.js
CHANGED
|
@@ -18,7 +18,8 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
|
|
|
18
18
|
const enabledPluginsStore = new Map();
|
|
19
19
|
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
20
20
|
const toSourceFilePaths = getToSourcePathsHandler(chief);
|
|
21
|
-
const
|
|
21
|
+
const addIssue = (issue) => collector.addIssue(issue) && options.isWatch && collector.retainIssue(issue);
|
|
22
|
+
const getReferencedInternalFilePath = getReferencedInputsHandler(deputy, chief, isGitIgnored, addIssue);
|
|
22
23
|
for (const workspace of workspaces) {
|
|
23
24
|
const { name, dir, manifestPath, manifestStr } = workspace;
|
|
24
25
|
const manifest = chief.getManifestForWorkspace(name);
|
|
@@ -77,7 +78,8 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
|
|
|
77
78
|
collector.addIgnorePatterns(config.ignore.map(p => join(options.cwd, prependDirToPattern(name, p))));
|
|
78
79
|
collector.addIgnoreFilesPatterns(config.ignoreFiles.map(p => join(options.cwd, prependDirToPattern(name, p))));
|
|
79
80
|
const entrySpecifiersFromManifest = getEntrySpecifiersFromManifest(manifest);
|
|
80
|
-
|
|
81
|
+
const label = 'entry paths from package.json';
|
|
82
|
+
for (const filePath of await toSourceFilePaths(entrySpecifiersFromManifest, dir, extensionGlobStr, label)) {
|
|
81
83
|
inputs.add(toProductionEntry(filePath));
|
|
82
84
|
}
|
|
83
85
|
for (const identifier of entrySpecifiersFromManifest) {
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { build } from './graph/build.js';
|
|
|
8
8
|
import { IssueCollector } from './IssueCollector.js';
|
|
9
9
|
import { IssueFixer } from './IssueFixer.js';
|
|
10
10
|
import { PrincipalFactory } from './PrincipalFactory.js';
|
|
11
|
+
import watchReporter from './reporters/watch.js';
|
|
11
12
|
import { debugLogArray, debugLogObject } from './util/debug.js';
|
|
12
13
|
import { getGitIgnoredHandler } from './util/glob-core.js';
|
|
13
14
|
import { getWatchHandler } from './util/watch.js';
|
|
@@ -52,6 +53,9 @@ export const main = async (options) => {
|
|
|
52
53
|
});
|
|
53
54
|
if (options.isWatch) {
|
|
54
55
|
const isIgnored = (filePath) => filePath.startsWith(options.cacheLocation) || filePath.includes('/.git/') || isGitIgnored(filePath);
|
|
56
|
+
const onUpdate = options.isWatch
|
|
57
|
+
? ({ issues, duration }) => watchReporter(options, { issues, streamer, size: analyzedFiles.size, duration })
|
|
58
|
+
: () => { };
|
|
55
59
|
const watchHandler = await getWatchHandler(options, {
|
|
56
60
|
analyzedFiles,
|
|
57
61
|
analyzeSourceFile,
|
|
@@ -61,7 +65,7 @@ export const main = async (options) => {
|
|
|
61
65
|
factory,
|
|
62
66
|
graph,
|
|
63
67
|
isIgnored,
|
|
64
|
-
|
|
68
|
+
onUpdate,
|
|
65
69
|
unreferencedFiles,
|
|
66
70
|
});
|
|
67
71
|
watch('.', { recursive: true }, watchHandler);
|
|
@@ -18,7 +18,11 @@ const production = [
|
|
|
18
18
|
];
|
|
19
19
|
const setup = async () => {
|
|
20
20
|
if (globalThis && !('defineNuxtConfig' in globalThis)) {
|
|
21
|
-
Object.defineProperty(globalThis, 'defineNuxtConfig', {
|
|
21
|
+
Object.defineProperty(globalThis, 'defineNuxtConfig', {
|
|
22
|
+
value: (id) => id,
|
|
23
|
+
writable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
});
|
|
22
26
|
}
|
|
23
27
|
};
|
|
24
28
|
const resolveConfig = async (localConfig) => {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
3
|
const title = 'Rsbuild';
|
|
4
4
|
const enablers = ['@rsbuild/core'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
7
7
|
const resolveConfig = async (config) => {
|
|
8
|
-
const
|
|
8
|
+
const entries = new Set();
|
|
9
9
|
const checkSource = (source) => {
|
|
10
10
|
if (source?.entry) {
|
|
11
11
|
for (const entry of Object.values(source.entry)) {
|
|
12
12
|
if (typeof entry === 'string')
|
|
13
|
-
|
|
13
|
+
entries.add(entry);
|
|
14
14
|
else if (Array.isArray(entry))
|
|
15
15
|
for (const e of entry)
|
|
16
|
-
|
|
16
|
+
entries.add(e);
|
|
17
17
|
else {
|
|
18
18
|
if (typeof entry.import === 'string')
|
|
19
|
-
|
|
19
|
+
entries.add(entry.import);
|
|
20
20
|
else if (Array.isArray(entry.import))
|
|
21
21
|
for (const e of entry.import)
|
|
22
|
-
|
|
22
|
+
entries.add(e);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -30,7 +30,7 @@ const resolveConfig = async (config) => {
|
|
|
30
30
|
checkSource(environment.source);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
return Array.from(
|
|
33
|
+
return Array.from(entries).map(input => toProductionEntry(input));
|
|
34
34
|
};
|
|
35
35
|
export default {
|
|
36
36
|
title,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ISSUE_TYPE_TITLE } from '../../constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { Issue, IssueSeverity, IssueSymbol } from '../../types/issues.js';
|
|
3
3
|
import { Table } from '../../util/table.js';
|
|
4
4
|
export declare const dim: import("picocolors/types.js").Formatter;
|
|
5
5
|
export declare const bright: import("picocolors/types.js").Formatter;
|
|
6
|
-
export declare const getIssueTypeTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) =>
|
|
6
|
+
export declare const getIssueTypeTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) => "Unused files" | "Unused dependencies" | "Unused devDependencies" | "Referenced optional peerDependencies" | "Unlisted dependencies" | "Unlisted binaries" | "Unresolved imports" | "Unused exports" | "Exports in used namespace" | "Unused exported types" | "Exported types in used namespace" | "Unused exported enum members" | "Unused exported class members" | "Duplicate exports";
|
|
7
7
|
export declare const getColoredTitle: (title: string, count: number) => string;
|
|
8
8
|
export declare const getDimmedTitle: (title: string, count: number) => string;
|
|
9
9
|
type LogIssueLine = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import picocolors from 'picocolors';
|
|
2
|
-
import { ISSUE_TYPE_TITLE } from '../../constants.js';
|
|
3
|
-
import { SymbolType } from '../../types/issues.js';
|
|
2
|
+
import { ISSUE_TYPE_TITLE, SYMBOL_TYPE } from '../../constants.js';
|
|
4
3
|
import { relative } from '../../util/path.js';
|
|
5
4
|
import { Table } from '../../util/table.js';
|
|
6
5
|
const plain = (text) => text;
|
|
@@ -47,7 +46,7 @@ export const getTableForType = (issues, cwd, options = { isUseColors: true }) =>
|
|
|
47
46
|
const symbol = issue.symbols ? issue.symbols.map(s => s.symbol).join(', ') : issue.symbol;
|
|
48
47
|
table.cell('symbol', print(symbol), options.isUseColors ? highlightSymbol(issue) : () => symbol);
|
|
49
48
|
table.cell('parentSymbol', issue.parentSymbol && print(issue.parentSymbol));
|
|
50
|
-
table.cell('symbolType', issue.symbolType && issue.symbolType !==
|
|
49
|
+
table.cell('symbolType', issue.symbolType && issue.symbolType !== SYMBOL_TYPE.UNKNOWN && print(issue.symbolType));
|
|
51
50
|
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
52
51
|
const cell = issue.type === 'files' ? '' : `${relative(cwd, issue.filePath)}${pos}`;
|
|
53
52
|
table.cell('filePath', print(cell));
|
|
@@ -4,8 +4,8 @@ import type { MainOptions } from '../util/create-options.js';
|
|
|
4
4
|
interface WatchReporter {
|
|
5
5
|
issues: Issues;
|
|
6
6
|
streamer: ConsoleStreamer;
|
|
7
|
-
|
|
7
|
+
duration?: number;
|
|
8
8
|
size: number;
|
|
9
9
|
}
|
|
10
|
-
declare const _default: (options: MainOptions, { issues, streamer,
|
|
10
|
+
declare const _default: (options: MainOptions, { issues, streamer, duration, size }: WatchReporter) => void;
|
|
11
11
|
export default _default;
|
package/dist/reporters/watch.js
CHANGED
|
@@ -2,7 +2,7 @@ import picocolors from 'picocolors';
|
|
|
2
2
|
import { perfObserver } from '../util/Performance.js';
|
|
3
3
|
import { prettyMilliseconds } from '../util/string.js';
|
|
4
4
|
import { getIssueTypeTitle, getTableForType } from './util/util.js';
|
|
5
|
-
export default (options, { issues, streamer,
|
|
5
|
+
export default (options, { issues, streamer, duration, size }) => {
|
|
6
6
|
const reportMultipleGroups = Object.values(options.includedIssueTypes).filter(Boolean).length > 1;
|
|
7
7
|
let totalIssues = 0;
|
|
8
8
|
const lines = [];
|
|
@@ -22,8 +22,8 @@ export default (options, { issues, streamer, startTime, size }) => {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const mem = perfObserver.getCurrentMemUsageInMb();
|
|
25
|
-
const
|
|
26
|
-
const summary = `${size} files in ${prettyMilliseconds(
|
|
25
|
+
const ms = duration ?? perfObserver.getCurrentDurationInMs();
|
|
26
|
+
const summary = `${size} files in ${prettyMilliseconds(ms)} (${mem}MB)`;
|
|
27
27
|
const messages = totalIssues === 0
|
|
28
28
|
? ['✂️ Excellent, Knip found no issues.', '', picocolors.gray(summary)]
|
|
29
29
|
: [...lines, '', picocolors.gray(summary)];
|
|
@@ -1182,12 +1182,7 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1182
1182
|
ignoreMembers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
1183
1183
|
ignoreUnresolved: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
1184
1184
|
ignoreExportsUsedInFile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniObject<{
|
|
1185
|
-
|
|
1186
|
-
enum: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1187
|
-
function: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1188
|
-
interface: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1189
|
-
member: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1190
|
-
type: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1185
|
+
[k: string]: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1191
1186
|
}, z.core.$strict>]>>;
|
|
1192
1187
|
ignoreIssues: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">]>>>>;
|
|
1193
1188
|
ignoreWorkspaces: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/mini';
|
|
2
|
+
import { SYMBOL_TYPE } from '../constants.js';
|
|
2
3
|
import { globSchema, pluginsSchema } from './plugins.js';
|
|
3
4
|
const pathsSchema = z.record(z.string(), z.array(z.string()));
|
|
4
5
|
const syncCompilerSchema = z.union([z.literal(true), z.custom()]);
|
|
@@ -23,14 +24,8 @@ const issueTypeSchema = z.union([
|
|
|
23
24
|
z.literal('classMembers'),
|
|
24
25
|
]);
|
|
25
26
|
const rulesSchema = z.partialRecord(issueTypeSchema, z.enum(['error', 'warn', 'off']));
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
enum: z.optional(z.boolean()),
|
|
29
|
-
function: z.optional(z.boolean()),
|
|
30
|
-
interface: z.optional(z.boolean()),
|
|
31
|
-
member: z.optional(z.boolean()),
|
|
32
|
-
type: z.optional(z.boolean()),
|
|
33
|
-
});
|
|
27
|
+
const ignorableSymbolTypes = Object.values(SYMBOL_TYPE).filter(type => type !== 'unknown');
|
|
28
|
+
const ignoreExportsUsedInFileObjectSchema = z.strictObject(Object.fromEntries(ignorableSymbolTypes.map(type => [type, z.optional(z.boolean())])));
|
|
34
29
|
const ignoreExportsUsedInFileSchema = z.union([z.boolean(), ignoreExportsUsedInFileObjectSchema]);
|
|
35
30
|
const ignoreIssuesSchema = z.record(z.string(), z.array(issueTypeSchema));
|
|
36
31
|
const rootConfigurationSchema = z.object({
|
package/dist/types/config.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type BinaryResolver = (binary: string, args: string[], options: BinaryRes
|
|
|
23
23
|
export type RawConfiguration = z.infer<typeof knipConfigurationSchema>;
|
|
24
24
|
export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
|
|
25
25
|
export type IgnorePatterns = (string | RegExp)[];
|
|
26
|
-
type IgnorableExport = Exclude<SymbolType,
|
|
26
|
+
type IgnorableExport = Exclude<SymbolType, 'unknown'>;
|
|
27
27
|
export type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
28
28
|
export type IgnoreIssues = Record<string, IssueType[]>;
|
|
29
29
|
export type GetImportsAndExportsOptions = {
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
TYPE = "type",
|
|
4
|
-
INTERFACE = "interface",
|
|
5
|
-
ENUM = "enum",
|
|
6
|
-
FUNCTION = "function",
|
|
7
|
-
CLASS = "class",
|
|
8
|
-
MEMBER = "member",
|
|
9
|
-
UNKNOWN = "unknown"
|
|
10
|
-
}
|
|
1
|
+
import type { SYMBOL_TYPE } from '../constants.js';
|
|
2
|
+
export type SymbolType = (typeof SYMBOL_TYPE)[keyof typeof SYMBOL_TYPE];
|
|
11
3
|
export type IssueSymbol = {
|
|
12
4
|
symbol: string;
|
|
13
5
|
pos?: number;
|
package/dist/types/issues.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
(function (SymbolType) {
|
|
3
|
-
SymbolType["VARIABLE"] = "variable";
|
|
4
|
-
SymbolType["TYPE"] = "type";
|
|
5
|
-
SymbolType["INTERFACE"] = "interface";
|
|
6
|
-
SymbolType["ENUM"] = "enum";
|
|
7
|
-
SymbolType["FUNCTION"] = "function";
|
|
8
|
-
SymbolType["CLASS"] = "class";
|
|
9
|
-
SymbolType["MEMBER"] = "member";
|
|
10
|
-
SymbolType["UNKNOWN"] = "unknown";
|
|
11
|
-
})(SymbolType || (SymbolType = {}));
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { Fix } from '../types/exports.js';
|
|
3
|
-
import { SymbolType } from '../types/issues.js';
|
|
3
|
+
import type { SymbolType } from '../types/issues.js';
|
|
4
4
|
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): boolean;
|
|
5
5
|
export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpression;
|
|
6
6
|
export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
@@ -12,14 +12,14 @@ export declare const getClassMember: (member: ts.MethodDeclaration | ts.Property
|
|
|
12
12
|
node: ts.MethodDeclaration | ts.PropertyDeclaration;
|
|
13
13
|
identifier: string;
|
|
14
14
|
pos: number;
|
|
15
|
-
type:
|
|
15
|
+
type: "member";
|
|
16
16
|
fix: Fix;
|
|
17
17
|
};
|
|
18
18
|
export declare const getEnumMember: (member: ts.EnumMember, isFixTypes: boolean) => {
|
|
19
19
|
node: ts.EnumMember;
|
|
20
20
|
identifier: string;
|
|
21
21
|
pos: number;
|
|
22
|
-
type:
|
|
22
|
+
type: "member";
|
|
23
23
|
fix: Fix;
|
|
24
24
|
};
|
|
25
25
|
export declare function stripQuotes(name: string): string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS } from '../constants.js';
|
|
3
|
-
import { SymbolType } from '../types/issues.js';
|
|
2
|
+
import { FIX_FLAGS, SYMBOL_TYPE } from '../constants.js';
|
|
4
3
|
function isGetOrSetAccessorDeclaration(node) {
|
|
5
4
|
return node.kind === ts.SyntaxKind.SetAccessor || node.kind === ts.SyntaxKind.GetAccessor;
|
|
6
5
|
}
|
|
@@ -34,20 +33,20 @@ export function isPropertyAccessCall(node, identifier) {
|
|
|
34
33
|
}
|
|
35
34
|
export const getNodeType = (node) => {
|
|
36
35
|
if (!node)
|
|
37
|
-
return
|
|
36
|
+
return SYMBOL_TYPE.UNKNOWN;
|
|
38
37
|
if (ts.isFunctionDeclaration(node))
|
|
39
|
-
return
|
|
38
|
+
return SYMBOL_TYPE.FUNCTION;
|
|
40
39
|
if (ts.isClassDeclaration(node))
|
|
41
|
-
return
|
|
40
|
+
return SYMBOL_TYPE.CLASS;
|
|
42
41
|
if (ts.isInterfaceDeclaration(node))
|
|
43
|
-
return
|
|
42
|
+
return SYMBOL_TYPE.INTERFACE;
|
|
44
43
|
if (ts.isTypeAliasDeclaration(node))
|
|
45
|
-
return
|
|
44
|
+
return SYMBOL_TYPE.TYPE;
|
|
46
45
|
if (ts.isEnumDeclaration(node))
|
|
47
|
-
return
|
|
46
|
+
return SYMBOL_TYPE.ENUM;
|
|
48
47
|
if (ts.isVariableDeclaration(node))
|
|
49
|
-
return
|
|
50
|
-
return
|
|
48
|
+
return SYMBOL_TYPE.VARIABLE;
|
|
49
|
+
return SYMBOL_TYPE.UNKNOWN;
|
|
51
50
|
};
|
|
52
51
|
export const isNonPrivatePropertyOrMethodDeclaration = (member) => (ts.isPropertyDeclaration(member) || ts.isMethodDeclaration(member) || isGetOrSetAccessorDeclaration(member)) &&
|
|
53
52
|
!isPrivateMember(member);
|
|
@@ -55,14 +54,14 @@ export const getClassMember = (member, isFixTypes) => ({
|
|
|
55
54
|
node: member,
|
|
56
55
|
identifier: member.name.getText(),
|
|
57
56
|
pos: member.name.getStart() + (ts.isComputedPropertyName(member.name) ? 1 : 0),
|
|
58
|
-
type:
|
|
57
|
+
type: SYMBOL_TYPE.MEMBER,
|
|
59
58
|
fix: isFixTypes ? [member.getStart(), member.getEnd(), FIX_FLAGS.NONE] : undefined,
|
|
60
59
|
});
|
|
61
60
|
export const getEnumMember = (member, isFixTypes) => ({
|
|
62
61
|
node: member,
|
|
63
62
|
identifier: stripQuotes(member.name.getText()),
|
|
64
63
|
pos: member.name.getStart(),
|
|
65
|
-
type:
|
|
64
|
+
type: SYMBOL_TYPE.MEMBER,
|
|
66
65
|
fix: isFixTypes
|
|
67
66
|
? [member.getStart(), member.getEnd(), FIX_FLAGS.OBJECT_BINDING | FIX_FLAGS.WITH_NEWLINE]
|
|
68
67
|
: undefined,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS } from '../../../constants.js';
|
|
3
|
-
import { SymbolType } from '../../../types/issues.js';
|
|
2
|
+
import { FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
4
3
|
import { isModule } from '../helpers.js';
|
|
5
4
|
import { exportVisitor as visit } from '../index.js';
|
|
6
5
|
export default visit(isModule, (node, { isFixExports, isFixTypes }) => {
|
|
7
6
|
if (ts.isExportDeclaration(node)) {
|
|
8
7
|
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
9
|
-
const nodeType = node.isTypeOnly ?
|
|
8
|
+
const nodeType = node.isTypeOnly ? SYMBOL_TYPE.TYPE : SYMBOL_TYPE.UNKNOWN;
|
|
10
9
|
const sourceFile = node.getSourceFile();
|
|
11
10
|
const declarations = sourceFile.getNamedDeclarations?.();
|
|
12
11
|
return node.exportClause.elements.map(element => {
|
|
@@ -14,8 +13,8 @@ export default visit(isModule, (node, { isFixExports, isFixTypes }) => {
|
|
|
14
13
|
const propName = element.propertyName?.text;
|
|
15
14
|
const symbol = declarations?.get(propName ?? identifier)?.[0]?.symbol;
|
|
16
15
|
const pos = element.name.pos;
|
|
17
|
-
const type = element.isTypeOnly ?
|
|
18
|
-
const fix = (isFixExports && type !==
|
|
16
|
+
const type = element.isTypeOnly ? SYMBOL_TYPE.TYPE : nodeType;
|
|
17
|
+
const fix = (isFixExports && type !== SYMBOL_TYPE.TYPE) || (isFixTypes && type === SYMBOL_TYPE.TYPE)
|
|
19
18
|
? [element.getStart(), element.getEnd(), FIX_FLAGS.OBJECT_BINDING | FIX_FLAGS.EMPTY_DECLARATION]
|
|
20
19
|
: undefined;
|
|
21
20
|
return { node: element, symbol, identifier, type, pos, fix };
|