knip 6.35.0 → 6.35.1
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/IssueCollector.d.ts +3 -0
- package/dist/IssueCollector.js +5 -0
- package/dist/WorkspaceWorker.d.ts +3 -1
- package/dist/WorkspaceWorker.js +4 -1
- package/dist/cli.js +4 -0
- package/dist/graph/build.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +1 -1
- package/dist/reporters/util/configuration-hints.js +11 -2
- package/dist/run.d.ts +2 -0
- package/dist/run.js +2 -1
- package/dist/types/issues.d.ts +1 -0
- package/dist/typescript/resolve-module-names.js +7 -27
- package/dist/util/watch.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/IssueCollector.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class IssueCollector {
|
|
|
12
12
|
private referencedFiles;
|
|
13
13
|
private configurationHints;
|
|
14
14
|
private tagHints;
|
|
15
|
+
private hasConfigLoadErrors;
|
|
15
16
|
private ignorePatterns;
|
|
16
17
|
private ignoreFilesPatterns;
|
|
17
18
|
private isMatch;
|
|
@@ -46,12 +47,14 @@ export declare class IssueCollector {
|
|
|
46
47
|
addIssue(issue: Issue): true | undefined;
|
|
47
48
|
addConfigurationHint(issue: ConfigurationHint): void;
|
|
48
49
|
addTagHint(issue: TagHint): void;
|
|
50
|
+
addConfigLoadError(): void;
|
|
49
51
|
purge(): Set<string>;
|
|
50
52
|
getIssues(): {
|
|
51
53
|
issues: import("./types/issues.ts").Issues;
|
|
52
54
|
counters: import("./types/issues.ts").Counters;
|
|
53
55
|
tagHints: Set<TagHint>;
|
|
54
56
|
configurationHints: ConfigurationHint[];
|
|
57
|
+
hasConfigLoadErrors: boolean;
|
|
55
58
|
};
|
|
56
59
|
getUnusedIgnorePatternHints(options: MainOptions): ConfigurationHint[];
|
|
57
60
|
private retainedIssues;
|
package/dist/IssueCollector.js
CHANGED
|
@@ -22,6 +22,7 @@ export class IssueCollector {
|
|
|
22
22
|
referencedFiles = new Set();
|
|
23
23
|
configurationHints = new Map();
|
|
24
24
|
tagHints = new Set();
|
|
25
|
+
hasConfigLoadErrors = false;
|
|
25
26
|
ignorePatterns = new Set();
|
|
26
27
|
ignoreFilesPatterns = new Set();
|
|
27
28
|
isMatch;
|
|
@@ -162,6 +163,9 @@ export class IssueCollector {
|
|
|
162
163
|
addTagHint(issue) {
|
|
163
164
|
this.tagHints.add(issue);
|
|
164
165
|
}
|
|
166
|
+
addConfigLoadError() {
|
|
167
|
+
this.hasConfigLoadErrors = true;
|
|
168
|
+
}
|
|
165
169
|
purge() {
|
|
166
170
|
const unusedFiles = new Set();
|
|
167
171
|
for (const issues of Object.values(this.issues.files)) {
|
|
@@ -178,6 +182,7 @@ export class IssueCollector {
|
|
|
178
182
|
counters: this.counters,
|
|
179
183
|
tagHints: this.tagHints,
|
|
180
184
|
configurationHints: Array.from(this.configurationHints.values()),
|
|
185
|
+
hasConfigLoadErrors: this.hasConfigLoadErrors,
|
|
181
186
|
};
|
|
182
187
|
}
|
|
183
188
|
getUnusedIgnorePatternHints(options) {
|
|
@@ -16,6 +16,7 @@ type WorkspaceManagerOptions = {
|
|
|
16
16
|
dependencies: DependencySet;
|
|
17
17
|
rootManifest: Manifest | undefined;
|
|
18
18
|
handleInput: HandleInput;
|
|
19
|
+
handleConfigLoadError: () => void;
|
|
19
20
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
20
21
|
getManifest: (dir: string) => Manifest | undefined;
|
|
21
22
|
readRawFile: (filePath: string) => string;
|
|
@@ -38,6 +39,7 @@ export declare class WorkspaceWorker {
|
|
|
38
39
|
rootManifest: Manifest | undefined;
|
|
39
40
|
dependencies: DependencySet;
|
|
40
41
|
handleInput: HandleInput;
|
|
42
|
+
handleConfigLoadError: () => void;
|
|
41
43
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
42
44
|
getManifest: (dir: string) => Manifest | undefined;
|
|
43
45
|
readRawFile: (filePath: string) => string;
|
|
@@ -49,7 +51,7 @@ export declare class WorkspaceWorker {
|
|
|
49
51
|
enabledPluginsInAncestors: string[];
|
|
50
52
|
cache: CacheConsultant<CacheItem>;
|
|
51
53
|
configFilesMap: Map<string, Map<PluginName, Set<string>>>;
|
|
52
|
-
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
54
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
53
55
|
init(): Promise<void>;
|
|
54
56
|
private determineEnabledPlugins;
|
|
55
57
|
private getConfigForPlugin;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -29,6 +29,7 @@ export class WorkspaceWorker {
|
|
|
29
29
|
rootManifest;
|
|
30
30
|
dependencies;
|
|
31
31
|
handleInput;
|
|
32
|
+
handleConfigLoadError;
|
|
32
33
|
findWorkspaceByFilePath;
|
|
33
34
|
getManifest;
|
|
34
35
|
readRawFile;
|
|
@@ -40,7 +41,7 @@ export class WorkspaceWorker {
|
|
|
40
41
|
enabledPluginsInAncestors;
|
|
41
42
|
cache;
|
|
42
43
|
configFilesMap;
|
|
43
|
-
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }) {
|
|
44
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }) {
|
|
44
45
|
this.name = name;
|
|
45
46
|
this.dir = dir;
|
|
46
47
|
this.config = config;
|
|
@@ -52,6 +53,7 @@ export class WorkspaceWorker {
|
|
|
52
53
|
this.enabledPluginsInAncestors = enabledPluginsInAncestors;
|
|
53
54
|
this.configFilesMap = configFilesMap;
|
|
54
55
|
this.handleInput = handleInput;
|
|
56
|
+
this.handleConfigLoadError = handleConfigLoadError;
|
|
55
57
|
this.findWorkspaceByFilePath = findWorkspaceByFilePath;
|
|
56
58
|
this.getManifest = getManifest;
|
|
57
59
|
this.readRawFile = readRawFile;
|
|
@@ -378,6 +380,7 @@ export class WorkspaceWorker {
|
|
|
378
380
|
if (!(error instanceof Error))
|
|
379
381
|
throw error;
|
|
380
382
|
hasLoadConfigError = true;
|
|
383
|
+
this.handleConfigLoadError();
|
|
381
384
|
const relPath = toRelative(configFilePath, this.options.cwd);
|
|
382
385
|
const cause = formatCauseMessage(error, this.options.cwd);
|
|
383
386
|
logError(`Error loading ${relPath} (${cause})`);
|
package/dist/cli.js
CHANGED
|
@@ -54,6 +54,10 @@ const main = async () => {
|
|
|
54
54
|
console.log('\nTotal running time:', prettyMilliseconds(duration));
|
|
55
55
|
perfObserver.reset();
|
|
56
56
|
}
|
|
57
|
+
if (results.hasConfigLoadErrors) {
|
|
58
|
+
process.exitCode = 2;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
57
61
|
if (!args['no-exit-code'] &&
|
|
58
62
|
(totalErrorCount > options.maxIssues ||
|
|
59
63
|
(!options.isDisableConfigHints &&
|
package/dist/graph/build.js
CHANGED
|
@@ -88,6 +88,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
88
88
|
dependencies,
|
|
89
89
|
rootManifest,
|
|
90
90
|
handleInput: (input) => handleInput(input, workspace),
|
|
91
|
+
handleConfigLoadError: () => collector.addConfigLoadError(),
|
|
91
92
|
findWorkspaceByFilePath: chief.findWorkspaceByFilePath.bind(chief),
|
|
92
93
|
getManifest,
|
|
93
94
|
negatedWorkspacePatterns: chief.getNegatedWorkspacePatterns(name),
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const main: (options: MainOptions) => Promise<{
|
|
|
4
4
|
counters: import("./types/issues.ts").Counters;
|
|
5
5
|
tagHints: Set<import("./types/issues.ts").TagHint>;
|
|
6
6
|
configurationHints: import("./types/issues.ts").ConfigurationHint[];
|
|
7
|
+
hasConfigLoadErrors: boolean;
|
|
7
8
|
selectedWorkspaces: string[] | undefined;
|
|
8
9
|
includedWorkspaceDirs: string[];
|
|
9
10
|
enabledPlugins: {
|
|
@@ -18,6 +18,6 @@ export declare const finalizeConfigurationHints: (results: Results, options: {
|
|
|
18
18
|
cwd: string;
|
|
19
19
|
configFilePath?: string;
|
|
20
20
|
}) => ProcessedHint[];
|
|
21
|
-
export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
|
|
21
|
+
export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
|
|
22
22
|
export declare const printTagHints: ({ cwd, tagHints, isTreatTagHintsAsErrors }: ReporterOptions) => void;
|
|
23
23
|
export {};
|
|
@@ -128,8 +128,17 @@ export const finalizeConfigurationHints = (results, options) => {
|
|
|
128
128
|
return row;
|
|
129
129
|
}));
|
|
130
130
|
};
|
|
131
|
-
export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
|
|
132
|
-
const rows = finalizeConfigurationHints({
|
|
131
|
+
export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
|
|
132
|
+
const rows = finalizeConfigurationHints({
|
|
133
|
+
issues,
|
|
134
|
+
counters,
|
|
135
|
+
configurationHints,
|
|
136
|
+
hasConfigLoadErrors,
|
|
137
|
+
tagHints,
|
|
138
|
+
includedWorkspaceDirs,
|
|
139
|
+
selectedWorkspaces,
|
|
140
|
+
enabledPlugins,
|
|
141
|
+
}, { cwd, configFilePath });
|
|
133
142
|
if (rows.length > 0) {
|
|
134
143
|
const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
|
|
135
144
|
console.warn(getTitle('Configuration hints', configurationHints.length));
|
package/dist/run.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const run: (options: MainOptions) => Promise<{
|
|
|
7
7
|
counters: import("./types/issues.ts").Counters;
|
|
8
8
|
tagHints: Set<import("./types/issues.ts").TagHint>;
|
|
9
9
|
configurationHints: import("./types/issues.ts").ConfigurationHint[];
|
|
10
|
+
hasConfigLoadErrors: boolean;
|
|
10
11
|
selectedWorkspaces: string[] | undefined;
|
|
11
12
|
includedWorkspaceDirs: string[];
|
|
12
13
|
enabledPlugins: {
|
|
@@ -26,6 +27,7 @@ export declare const run: (options: MainOptions) => Promise<{
|
|
|
26
27
|
counters: import("./types/issues.ts").Counters;
|
|
27
28
|
tagHints: Set<import("./types/issues.ts").TagHint>;
|
|
28
29
|
configurationHints: import("./types/issues.ts").ConfigurationHint[];
|
|
30
|
+
hasConfigLoadErrors: boolean;
|
|
29
31
|
};
|
|
30
32
|
} | undefined;
|
|
31
33
|
streamer: ConsoleStreamer;
|
package/dist/run.js
CHANGED
|
@@ -114,7 +114,7 @@ export const run = async (options) => {
|
|
|
114
114
|
if (options.isWatch)
|
|
115
115
|
watch('.', { recursive: true }, session.listener);
|
|
116
116
|
}
|
|
117
|
-
const { issues, counters, tagHints, configurationHints } = collector.getIssues();
|
|
117
|
+
const { issues, counters, tagHints, configurationHints, hasConfigLoadErrors } = collector.getIssues();
|
|
118
118
|
if (!options.isWatch)
|
|
119
119
|
streamer.clear();
|
|
120
120
|
if (options.isCache) {
|
|
@@ -127,6 +127,7 @@ export const run = async (options) => {
|
|
|
127
127
|
counters,
|
|
128
128
|
tagHints,
|
|
129
129
|
configurationHints,
|
|
130
|
+
hasConfigLoadErrors,
|
|
130
131
|
selectedWorkspaces: chief.selectedWorkspaces ? Array.from(chief.selectedWorkspaces) : undefined,
|
|
131
132
|
includedWorkspaceDirs: Array.from(chief.workspacesByDir.keys()),
|
|
132
133
|
enabledPlugins: Object.fromEntries(enabledPluginsStore),
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export type ReporterOptions = {
|
|
|
56
56
|
counters: Counters;
|
|
57
57
|
tagHints: TagHints;
|
|
58
58
|
configurationHints: ConfigurationHint[];
|
|
59
|
+
hasConfigLoadErrors: boolean;
|
|
59
60
|
enabledPlugins: Record<string, string[]>;
|
|
60
61
|
isDisableConfigHints: boolean;
|
|
61
62
|
isDisableTagHints: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
2
|
import { isBuiltin } from 'node:module';
|
|
3
3
|
import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS, IS_DTS } from '../constants.js';
|
|
4
4
|
import { isFile } from '../util/fs.js';
|
|
5
5
|
import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, sanitizeSpecifier } from '../util/modules.js';
|
|
6
6
|
import { timerify } from '../util/Performance.js';
|
|
7
7
|
import { dirname, extname, isAbsolute, isInNodeModules, join, toPosix } from '../util/path.js';
|
|
8
|
-
import { _createSyncModuleResolver, _resolveModuleSync } from '../util/resolve.js';
|
|
8
|
+
import { _createSyncModuleResolver, _resolveModuleSync, resolvePackageManifestPath } from '../util/resolve.js';
|
|
9
9
|
function pickStringTarget(value) {
|
|
10
10
|
if (typeof value === 'string')
|
|
11
11
|
return value;
|
|
@@ -64,40 +64,20 @@ function pickExistingPackageTarget(value, dir, patternMatch, moduleExtensions) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
const moduleResolutionCaches = [];
|
|
67
|
-
const installedPackageRootCache = new Map();
|
|
68
67
|
export function clearModuleResolutionCaches() {
|
|
69
68
|
for (const cache of moduleResolutionCaches)
|
|
70
69
|
cache.clear();
|
|
71
|
-
installedPackageRootCache.clear();
|
|
72
|
-
}
|
|
73
|
-
function getInstalledPackageRoot(candidate) {
|
|
74
|
-
if (installedPackageRootCache.has(candidate))
|
|
75
|
-
return installedPackageRootCache.get(candidate);
|
|
76
|
-
let packageRoot;
|
|
77
|
-
try {
|
|
78
|
-
packageRoot = toPosix(realpathSync(candidate));
|
|
79
|
-
}
|
|
80
|
-
catch { }
|
|
81
|
-
installedPackageRootCache.set(candidate, packageRoot);
|
|
82
|
-
return packageRoot;
|
|
83
70
|
}
|
|
84
71
|
function getAttributedPackageName(specifier, containingFile, resolvedFileName) {
|
|
85
72
|
const packageName = getPackageNameFromFilePath(resolvedFileName);
|
|
86
73
|
const specifierPackageName = getPackageNameFromModuleSpecifier(specifier);
|
|
87
74
|
if (!specifierPackageName || specifierPackageName === packageName)
|
|
88
75
|
return packageName;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return isResolvedInstall ? specifierPackageName : packageName;
|
|
95
|
-
}
|
|
96
|
-
const parent = dirname(dir);
|
|
97
|
-
if (parent === dir)
|
|
98
|
-
return packageName;
|
|
99
|
-
dir = parent;
|
|
100
|
-
}
|
|
76
|
+
const manifestPath = resolvePackageManifestPath(specifierPackageName, dirname(containingFile));
|
|
77
|
+
if (!manifestPath)
|
|
78
|
+
return packageName;
|
|
79
|
+
const packageRoot = dirname(manifestPath);
|
|
80
|
+
return resolvedFileName.startsWith(`${packageRoot}/`) ? specifierPackageName : packageName;
|
|
101
81
|
}
|
|
102
82
|
function compilePathMappings(scopedPaths) {
|
|
103
83
|
if (!scopedPaths)
|
package/dist/util/watch.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare const getSessionHandler: (options: MainOptions, { analyzedFiles,
|
|
|
41
41
|
counters: import("../types/issues.ts").Counters;
|
|
42
42
|
tagHints: Set<import("../types/issues.ts").TagHint>;
|
|
43
43
|
configurationHints: import("../types/issues.ts").ConfigurationHint[];
|
|
44
|
+
hasConfigLoadErrors: boolean;
|
|
44
45
|
};
|
|
45
46
|
}>;
|
|
46
47
|
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.35.
|
|
1
|
+
export declare const version = "6.35.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.35.
|
|
1
|
+
export const version = '6.35.1';
|