knip 6.43.0 → 6.44.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/README.md +2 -4
- package/dist/CacheConsultant.d.ts +1 -0
- package/dist/CacheConsultant.js +2 -0
- package/dist/CatalogCounselor.d.ts +1 -3
- package/dist/CatalogCounselor.js +18 -15
- package/dist/ConfigurationChief.d.ts +24 -0
- package/dist/DependencyDeputy.d.ts +2 -1
- package/dist/DependencyDeputy.js +11 -6
- package/dist/IssueCollector.js +1 -0
- package/dist/ProjectPrincipal.d.ts +4 -2
- package/dist/ProjectPrincipal.js +32 -10
- package/dist/WorkspaceWorker.d.ts +5 -2
- package/dist/WorkspaceWorker.js +20 -7
- package/dist/binaries/resolvers/bun.js +7 -2
- package/dist/binaries/util.js +2 -1
- package/dist/cli.js +6 -1
- package/dist/compilers/index.d.ts +5 -0
- package/dist/compilers/index.js +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/graph/analyze.js +3 -2
- package/dist/graph/build.d.ts +2 -0
- package/dist/graph/build.js +37 -22
- package/dist/graph-explorer/cache.d.ts +2 -1
- package/dist/graph-explorer/cache.js +5 -1
- package/dist/graph-explorer/explorer.d.ts +3 -5
- package/dist/graph-explorer/explorer.js +24 -3
- package/dist/plugins/babel/index.js +6 -1
- package/dist/plugins/biome/index.js +1 -1
- package/dist/plugins/cspell/index.js +10 -2
- package/dist/plugins/dependency-cruiser/index.js +2 -2
- package/dist/plugins/docusaurus/helpers.js +4 -4
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +2 -2
- package/dist/plugins/expressive-code/index.d.ts +1 -1
- package/dist/plugins/expressive-code/index.js +2 -2
- package/dist/plugins/gatsby/index.js +6 -6
- package/dist/plugins/gatsby/types.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/i18next-parser/index.js +2 -2
- package/dist/plugins/index.d.ts +5 -1
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/jasmine/index.js +2 -2
- package/dist/plugins/karma/index.js +4 -4
- package/dist/plugins/kysely-codegen/index.d.ts +3 -0
- package/dist/plugins/kysely-codegen/index.js +20 -0
- package/dist/plugins/lefthook/index.js +2 -2
- package/dist/plugins/lingui/index.d.ts +3 -0
- package/dist/plugins/lingui/index.js +16 -0
- package/dist/plugins/lockfile-lint/index.js +2 -2
- package/dist/plugins/lost-pixel/index.js +2 -2
- package/dist/plugins/lunaria/index.js +2 -2
- package/dist/plugins/marko/index.js +5 -6
- package/dist/plugins/mastra/index.d.ts +3 -0
- package/dist/plugins/mastra/index.js +57 -0
- package/dist/plugins/mcp/index.js +1 -1
- package/dist/plugins/mise/index.js +0 -3
- package/dist/plugins/mocha/index.js +43 -4
- package/dist/plugins/mocha/types.d.ts +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +1 -1
- package/dist/plugins/npm-package-json-lint/types.d.ts +1 -1
- package/dist/plugins/nx/index.js +3 -8
- package/dist/plugins/nyc/index.js +1 -1
- package/dist/plugins/openapi-ts/index.js +2 -2
- package/dist/plugins/oxfmt/index.js +2 -2
- package/dist/plugins/playwright/index.js +6 -11
- package/dist/plugins/pnpm/index.js +2 -4
- package/dist/plugins/purgecss/index.d.ts +3 -0
- package/dist/plugins/purgecss/index.js +16 -0
- package/dist/plugins/railway/index.js +1 -4
- package/dist/plugins/relay/index.js +1 -1
- package/dist/plugins/release-it/index.js +1 -1
- package/dist/plugins/remix/index.js +1 -1
- package/dist/plugins/rsbuild/index.js +29 -1
- package/dist/plugins/rsbuild/types.d.ts +8 -0
- package/dist/plugins/rstest/index.js +2 -2
- package/dist/plugins/serverless-framework/index.js +1 -1
- package/dist/plugins/storybook/index.js +5 -5
- package/dist/plugins/sveltekit/resolveFromAST.js +1 -1
- package/dist/plugins/svgr/index.js +2 -1
- package/dist/plugins/swc/index.js +8 -3
- package/dist/plugins/syncpack/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +3 -2
- package/dist/plugins/taskfile/index.js +4 -7
- package/dist/plugins/textlint/helpers.js +2 -2
- package/dist/plugins/typescript/index.js +7 -3
- package/dist/plugins/unocss/index.js +2 -2
- package/dist/plugins/vite-plugin-pwa/index.js +1 -4
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +0 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vite-pwa-assets-generator/index.js +2 -2
- package/dist/plugins/vitest/helpers.js +4 -7
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/plugins/webpack/index.d.ts +2 -0
- package/dist/plugins/webpack/index.js +11 -6
- package/dist/plugins/yarn/index.js +2 -4
- package/dist/reporters/codeclimate.d.ts +2 -2
- package/dist/reporters/codeclimate.js +2 -4
- package/dist/reporters/codeowners.d.ts +2 -2
- package/dist/reporters/codeowners.js +9 -9
- package/dist/reporters/compact.d.ts +2 -2
- package/dist/reporters/compact.js +8 -7
- package/dist/reporters/cycles.d.ts +2 -2
- package/dist/reporters/cycles.js +7 -6
- package/dist/reporters/disclosure.d.ts +2 -2
- package/dist/reporters/disclosure.js +6 -4
- package/dist/reporters/github-actions.d.ts +2 -2
- package/dist/reporters/github-actions.js +7 -5
- package/dist/reporters/index.d.ts +10 -10
- package/dist/reporters/json.d.ts +2 -2
- package/dist/reporters/json.js +2 -4
- package/dist/reporters/markdown.d.ts +2 -2
- package/dist/reporters/markdown.js +11 -9
- package/dist/reporters/sarif.d.ts +2 -2
- package/dist/reporters/sarif.js +2 -3
- package/dist/reporters/symbols.d.ts +2 -2
- package/dist/reporters/symbols.js +6 -4
- package/dist/run.d.ts +1 -1
- package/dist/run.js +3 -10
- package/dist/schema/configuration.d.ts +60 -0
- package/dist/schema/plugins.d.ts +20 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/session/configuration.d.ts +15 -0
- package/dist/session/configuration.js +62 -0
- package/dist/session/incremental.d.ts +54 -0
- package/dist/session/incremental.js +49 -0
- package/dist/session/session.d.ts +1 -1
- package/dist/session/session.js +63 -27
- package/dist/session/watch.d.ts +2 -0
- package/dist/session/watch.js +41 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/package-json.d.ts +0 -3
- package/dist/typescript/get-imports-and-exports.js +2 -0
- package/dist/typescript/visitors/calls.js +15 -11
- package/dist/typescript/visitors/imports.d.ts +3 -1
- package/dist/typescript/visitors/imports.js +77 -53
- package/dist/typescript/visitors/members.js +23 -26
- package/dist/typescript/visitors/walk.d.ts +3 -0
- package/dist/typescript/visitors/walk.js +43 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +3 -0
- package/dist/util/create-input-handler.js +1 -1
- package/dist/util/create-options.d.ts +43 -2
- package/dist/util/create-options.js +17 -4
- package/dist/util/file-entry-cache.d.ts +2 -0
- package/dist/util/file-entry-cache.js +19 -1
- package/dist/util/gitignore-cache.d.ts +1 -0
- package/dist/util/gitignore-cache.js +1 -0
- package/dist/util/glob-core.js +4 -2
- package/dist/util/glob.d.ts +1 -0
- package/dist/util/glob.js +6 -0
- package/dist/util/input.d.ts +2 -0
- package/dist/util/loader.d.ts +1 -0
- package/dist/util/loader.js +29 -1
- package/dist/util/modules.js +5 -2
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/reporter.d.ts +1 -1
- package/dist/util/reporter.js +53 -9
- package/dist/util/watch.d.ts +5 -11
- package/dist/util/watch.js +84 -68
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +16 -0
package/dist/util/path.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const extname: typeof path.extname;
|
|
|
5
5
|
export declare const basename: typeof path.basename;
|
|
6
6
|
export declare const join: typeof path.join;
|
|
7
7
|
export declare const toPosix: (value: string) => string;
|
|
8
|
+
export declare const toNative: (value: string) => string;
|
|
8
9
|
export declare const resolve: typeof path.resolve;
|
|
9
10
|
export declare const resolveCwd: (dir: string) => string;
|
|
10
11
|
export declare const relative: (from: string, to: string) => string;
|
package/dist/util/path.js
CHANGED
|
@@ -6,6 +6,7 @@ export const extname = path.posix.extname;
|
|
|
6
6
|
export const basename = path.posix.basename;
|
|
7
7
|
export const join = path.posix.join;
|
|
8
8
|
export const toPosix = isWin ? (value) => value.split(path.sep).join(path.posix.sep) : (value) => value;
|
|
9
|
+
export const toNative = isWin ? path.win32.normalize : (value) => value;
|
|
9
10
|
export const resolve = path.posix.resolve;
|
|
10
11
|
export const resolveCwd = (dir) => toPosix(path.resolve(dir));
|
|
11
12
|
export const relative = (from, to) => {
|
package/dist/util/reporter.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ReporterOptions } from '../types/issues.ts';
|
|
2
|
-
export declare const runReporters: (reporter: string[], options: ReporterOptions) => Promise<void>;
|
|
2
|
+
export declare const runReporters: (reporter: string[], outputFiles: string[], options: ReporterOptions) => Promise<void>;
|
package/dist/util/reporter.js
CHANGED
|
@@ -1,12 +1,56 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
1
3
|
import internalReporters from '../reporters/index.js';
|
|
4
|
+
import { ConfigurationError } from './errors.js';
|
|
2
5
|
import { _load } from './loader.js';
|
|
3
|
-
import { isAbsolute, isInternal, resolve } from './path.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { dirname, isAbsolute, isInternal, resolve, toAbsolute, toPosix } from './path.js';
|
|
7
|
+
const writeStdout = (output) => {
|
|
8
|
+
if (!output)
|
|
9
|
+
return;
|
|
10
|
+
process.stdout._handle?.setBlocking?.(true);
|
|
11
|
+
process.stdout.write(`${output}\n`);
|
|
12
|
+
};
|
|
13
|
+
const getOutputFiles = (reporters, outputFiles, cwd) => {
|
|
14
|
+
const targets = new Map();
|
|
15
|
+
for (const outputFile of outputFiles) {
|
|
16
|
+
const index = outputFile.indexOf('=');
|
|
17
|
+
const name = index === -1 ? reporters[0] : outputFile.slice(0, index);
|
|
18
|
+
const filePath = index === -1 ? outputFile : outputFile.slice(index + 1);
|
|
19
|
+
if (index === -1 && reporters.length > 1) {
|
|
20
|
+
throw new ConfigurationError(`Option --output-file needs a reporter prefix when using multiple reporters (${reporters.join(', ')}), e.g. --output-file ${reporters[0]}=${outputFile}`);
|
|
21
|
+
}
|
|
22
|
+
if (!reporters.includes(name)) {
|
|
23
|
+
throw new ConfigurationError(`Option --output-file refers to reporter "${name}", but it is not selected with --reporter`);
|
|
24
|
+
}
|
|
25
|
+
targets.set(name, toAbsolute(toPosix(filePath), cwd));
|
|
26
|
+
}
|
|
27
|
+
return targets;
|
|
28
|
+
};
|
|
29
|
+
const loadReporter = (reporter) => reporter in internalReporters
|
|
30
|
+
? Promise.resolve(internalReporters[reporter])
|
|
31
|
+
: _load(isInternal(reporter) && !isAbsolute(reporter) ? resolve(reporter) : reporter);
|
|
32
|
+
export const runReporters = async (reporter, outputFiles, options) => {
|
|
33
|
+
const targets = getOutputFiles(reporter, outputFiles, options.cwd);
|
|
34
|
+
const reporters = await Promise.all(reporter.map(loadReporter));
|
|
35
|
+
for (let i = 0; i < reporters.length; i++) {
|
|
36
|
+
const target = targets.get(reporter[i]);
|
|
37
|
+
if (!target) {
|
|
38
|
+
await reporters[i]({ ...options, write: writeStdout });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
let output = '';
|
|
42
|
+
const write = (text) => {
|
|
43
|
+
if (text)
|
|
44
|
+
output += `${text}\n`;
|
|
45
|
+
};
|
|
46
|
+
await reporters[i]({ ...options, write });
|
|
47
|
+
try {
|
|
48
|
+
await mkdir(dirname(target), { recursive: true });
|
|
49
|
+
await writeFile(target, stripVTControlCharacters(output));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
throw new ConfigurationError(`Option --output-file failed to write: ${message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
12
56
|
};
|
package/dist/util/watch.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { WatchListener } from 'node:fs';
|
|
2
1
|
import type { ConfigurationChief } from '../ConfigurationChief.ts';
|
|
3
2
|
import type { IssueCollector } from '../IssueCollector.ts';
|
|
4
3
|
import type { ProjectPrincipal } from '../ProjectPrincipal.ts';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ConfigurationFiles } from '../session/configuration.ts';
|
|
6
5
|
import type { ModuleGraph } from '../types/module-graph.ts';
|
|
7
6
|
import type { MainOptions } from './create-options.ts';
|
|
8
|
-
export type OnFileChange = (options: {
|
|
9
|
-
issues: Issues;
|
|
10
|
-
duration?: number;
|
|
11
|
-
mem?: number;
|
|
12
|
-
}) => void;
|
|
13
7
|
export type WatchChange = {
|
|
14
8
|
type: 'added' | 'deleted' | 'modified';
|
|
15
9
|
filePath: string;
|
|
@@ -23,13 +17,12 @@ type WatchOptions = {
|
|
|
23
17
|
analyze: () => Promise<void>;
|
|
24
18
|
principal: ProjectPrincipal;
|
|
25
19
|
graph: ModuleGraph;
|
|
20
|
+
configurationFiles?: ConfigurationFiles;
|
|
26
21
|
isIgnored: (path: string) => boolean;
|
|
27
|
-
onFileChange?: OnFileChange;
|
|
28
22
|
unreferencedFiles: Set<string>;
|
|
29
23
|
entryPaths: Set<string>;
|
|
30
24
|
};
|
|
31
|
-
export declare const getSessionHandler: (options: MainOptions, { analyzedFiles, analyzeSourceFile, chief, collector, analyze, principal, graph,
|
|
32
|
-
listener: WatchListener<string | Buffer<ArrayBufferLike>>;
|
|
25
|
+
export declare const getSessionHandler: (options: MainOptions, { analyzedFiles, analyzeSourceFile, chief, collector, analyze, principal, graph, configurationFiles, isIgnored, unreferencedFiles, entryPaths, }: WatchOptions) => Promise<{
|
|
33
26
|
handleFileChanges: (changes: WatchChange[]) => Promise<{
|
|
34
27
|
duration: number;
|
|
35
28
|
mem: number;
|
|
@@ -37,11 +30,12 @@ export declare const getSessionHandler: (options: MainOptions, { analyzedFiles,
|
|
|
37
30
|
getEntryPaths: () => Set<string>;
|
|
38
31
|
getGraph: () => ModuleGraph;
|
|
39
32
|
getIssues: () => {
|
|
40
|
-
issues: Issues;
|
|
33
|
+
issues: import("../types/issues.ts").Issues;
|
|
41
34
|
counters: import("../types/issues.ts").Counters;
|
|
42
35
|
tagHints: Set<import("../types/issues.ts").TagHint>;
|
|
43
36
|
configurationHints: import("../types/issues.ts").ConfigurationHint[];
|
|
44
37
|
hasConfigLoadErrors: boolean;
|
|
45
38
|
};
|
|
39
|
+
configurationFiles: ConfigurationFiles | undefined;
|
|
46
40
|
}>;
|
|
47
41
|
export {};
|
package/dist/util/watch.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { invalidateCache } from '../graph-explorer/cache.js';
|
|
2
|
+
import { getFileTopology, hasSameTopology, isIncrementalFile } from '../session/incremental.js';
|
|
2
3
|
import { debugLog } from './debug.js';
|
|
3
|
-
import { hasErrorCause } from './errors.js';
|
|
4
|
-
import { isFile } from './fs.js';
|
|
5
|
-
import { logError } from './log.js';
|
|
6
4
|
import { updateImportMap } from './module-graph.js';
|
|
7
|
-
import { toAbsolute,
|
|
5
|
+
import { toAbsolute, toRelative } from './path.js';
|
|
8
6
|
import { clearModuleResolutionCaches } from '../typescript/resolve-module-names.js';
|
|
9
7
|
import { clearGlobCache } from './glob-cache.js';
|
|
10
8
|
import { clearResolverCache } from './resolve.js';
|
|
@@ -13,13 +11,18 @@ const createUpdate = (options) => {
|
|
|
13
11
|
const mem = process.memoryUsage().heapUsed;
|
|
14
12
|
return { duration, mem };
|
|
15
13
|
};
|
|
16
|
-
export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceFile, chief, collector, analyze, principal, graph,
|
|
14
|
+
export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceFile, chief, collector, analyze, principal, graph, configurationFiles, isIgnored, unreferencedFiles, entryPaths, }) => {
|
|
17
15
|
const added = new Set();
|
|
18
16
|
const deleted = new Set();
|
|
19
17
|
const modified = new Set();
|
|
18
|
+
if (configurationFiles)
|
|
19
|
+
principal.collectConfigurationImports(configurationFiles);
|
|
20
20
|
const processFileChanges = async (changes) => {
|
|
21
21
|
const startTime = performance.now();
|
|
22
22
|
let hasRelevantChanges = false;
|
|
23
|
+
const configurationChange = configurationFiles?.getChange(changes, options.cwd);
|
|
24
|
+
if (configurationChange)
|
|
25
|
+
throw configurationChange;
|
|
23
26
|
for (const change of changes) {
|
|
24
27
|
const filePath = toAbsolute(change.filePath, options.cwd);
|
|
25
28
|
const relativePath = toRelative(change.filePath, options.cwd);
|
|
@@ -60,76 +63,104 @@ export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceF
|
|
|
60
63
|
}
|
|
61
64
|
if (!hasRelevantChanges || (added.size === 0 && deleted.size === 0 && modified.size === 0))
|
|
62
65
|
return;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const filePath of added)
|
|
71
|
-
cachedUnusedFiles.add(filePath);
|
|
72
|
-
for (const filePath of deleted)
|
|
73
|
-
cachedUnusedFiles.delete(filePath);
|
|
74
|
-
if (added.size > 0 || deleted.size > 0) {
|
|
75
|
-
graph.clear();
|
|
76
|
-
for (const filePath of filePaths) {
|
|
77
|
-
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
78
|
-
if (workspace) {
|
|
79
|
-
await analyzeSourceFile(filePath);
|
|
66
|
+
let incremental = added.size === 0 && deleted.size === 0;
|
|
67
|
+
if (incremental) {
|
|
68
|
+
for (const filePath of modified) {
|
|
69
|
+
const file = graph.get(filePath);
|
|
70
|
+
if (!file || !analyzedFiles.has(filePath) || !isIncrementalFile(file)) {
|
|
71
|
+
incremental = false;
|
|
72
|
+
break;
|
|
80
73
|
}
|
|
81
74
|
}
|
|
82
75
|
}
|
|
83
|
-
|
|
84
|
-
for (const
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
if (incremental) {
|
|
77
|
+
for (const filePath of modified) {
|
|
78
|
+
const file = graph.get(filePath);
|
|
79
|
+
if (!file) {
|
|
80
|
+
incremental = false;
|
|
81
|
+
break;
|
|
87
82
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cachedUnusedFiles.add(filePath);
|
|
83
|
+
const before = getFileTopology(file);
|
|
84
|
+
await analyzeSourceFile(filePath);
|
|
85
|
+
if (!hasSameTopology(before, file)) {
|
|
86
|
+
incremental = false;
|
|
87
|
+
break;
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
}
|
|
91
|
+
if (incremental) {
|
|
92
|
+
invalidateCache(graph, true);
|
|
93
|
+
collector.purge();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
clearResolverCache();
|
|
97
|
+
clearModuleResolutionCaches();
|
|
98
|
+
clearGlobCache();
|
|
99
|
+
invalidateCache(graph);
|
|
100
|
+
const filePaths = await principal.getUsedResolvedFiles();
|
|
101
|
+
const cachedUnusedFiles = collector.purge();
|
|
102
|
+
for (const filePath of added)
|
|
103
|
+
cachedUnusedFiles.add(filePath);
|
|
104
|
+
for (const filePath of deleted)
|
|
105
|
+
cachedUnusedFiles.delete(filePath);
|
|
106
|
+
if (added.size > 0 || deleted.size > 0) {
|
|
107
|
+
graph.clear();
|
|
108
|
+
for (const filePath of filePaths) {
|
|
98
109
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
99
110
|
if (workspace) {
|
|
100
111
|
await analyzeSourceFile(filePath);
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
else {
|
|
116
|
+
for (const [filePath, file] of graph) {
|
|
117
|
+
if (filePaths.has(filePath)) {
|
|
118
|
+
file.importedBy = undefined;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
graph.delete(filePath);
|
|
122
|
+
analyzedFiles.delete(filePath);
|
|
123
|
+
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
124
|
+
if (workspace && principal.projectPaths.has(filePath))
|
|
125
|
+
cachedUnusedFiles.add(filePath);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const filePath of filePaths) {
|
|
129
|
+
if (!graph.has(filePath) || !analyzedFiles.has(filePath)) {
|
|
130
|
+
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
131
|
+
if (workspace) {
|
|
109
132
|
await analyzeSourceFile(filePath);
|
|
110
133
|
}
|
|
111
134
|
}
|
|
112
135
|
}
|
|
136
|
+
for (const filePath of modified) {
|
|
137
|
+
if (!cachedUnusedFiles.has(filePath)) {
|
|
138
|
+
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
139
|
+
if (workspace) {
|
|
140
|
+
if (principal.projectPaths.has(filePath) || graph.has(filePath)) {
|
|
141
|
+
await analyzeSourceFile(filePath);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const filePath of filePaths) {
|
|
147
|
+
const file = graph.get(filePath);
|
|
148
|
+
if (file?.internalImportCache)
|
|
149
|
+
updateImportMap(file, file.internalImportCache, graph);
|
|
150
|
+
}
|
|
113
151
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
152
|
+
const unusedFiles = [...cachedUnusedFiles].filter(filePath => !analyzedFiles.has(filePath));
|
|
153
|
+
unreferencedFiles.clear();
|
|
154
|
+
for (const filePath of unusedFiles)
|
|
155
|
+
unreferencedFiles.add(filePath);
|
|
119
156
|
}
|
|
120
|
-
await analyze();
|
|
121
|
-
const unusedFiles = [...cachedUnusedFiles].filter(filePath => !analyzedFiles.has(filePath));
|
|
122
|
-
collector.addFilesIssues(unusedFiles);
|
|
123
|
-
collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
|
|
124
157
|
for (const issue of collector.getRetainedIssues())
|
|
125
158
|
collector.addIssue(issue);
|
|
159
|
+
await analyze();
|
|
126
160
|
added.clear();
|
|
127
161
|
deleted.clear();
|
|
128
162
|
modified.clear();
|
|
129
|
-
|
|
130
|
-
if (onFileChange)
|
|
131
|
-
onFileChange(Object.assign({ issues: getIssues().issues }, update));
|
|
132
|
-
return update;
|
|
163
|
+
return createUpdate({ startTime });
|
|
133
164
|
};
|
|
134
165
|
const clearSourceText = () => principal.fileManager.sourceTextCache.clear();
|
|
135
166
|
let pending = Promise.resolve();
|
|
@@ -138,23 +169,8 @@ export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceF
|
|
|
138
169
|
pending = update.then(clearSourceText, clearSourceText);
|
|
139
170
|
return update;
|
|
140
171
|
};
|
|
141
|
-
const listener = (eventType, filePath) => {
|
|
142
|
-
debugLog('*', `(raw) ${eventType} ${filePath}`);
|
|
143
|
-
if (typeof filePath === 'string') {
|
|
144
|
-
const normalizedPath = toPosix(filePath);
|
|
145
|
-
const type = eventType === 'rename' ? (isFile(options.cwd, normalizedPath) ? 'added' : 'deleted') : 'modified';
|
|
146
|
-
handleFileChanges([{ type, filePath: normalizedPath }]).catch(error => {
|
|
147
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
148
|
-
const reason = error instanceof Error && hasErrorCause(error) ? `\nReason: ${error.cause.message}` : '';
|
|
149
|
-
logError(message + reason);
|
|
150
|
-
process.exitCode = 2;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
172
|
const getIssues = () => collector.getIssues();
|
|
155
173
|
const getEntryPaths = () => entryPaths;
|
|
156
174
|
const getGraph = () => graph;
|
|
157
|
-
|
|
158
|
-
onFileChange({ issues: getIssues().issues });
|
|
159
|
-
return { listener, handleFileChanges, getEntryPaths, getGraph, getIssues };
|
|
175
|
+
return { handleFileChanges, getEntryPaths, getGraph, getIssues, configurationFiles };
|
|
160
176
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.44.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.44.1';
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -638,6 +638,10 @@
|
|
|
638
638
|
"title": "knex plugin configuration (https://knip.dev/reference/plugins/knex)",
|
|
639
639
|
"$ref": "#/definitions/plugin"
|
|
640
640
|
},
|
|
641
|
+
"kysely-codegen": {
|
|
642
|
+
"title": "kysely-codegen plugin configuration (https://knip.dev/reference/plugins/kysely-codegen)",
|
|
643
|
+
"$ref": "#/definitions/plugin"
|
|
644
|
+
},
|
|
641
645
|
"ladle": {
|
|
642
646
|
"title": "ladle plugin configuration (https://knip.dev/reference/plugins/ladle)",
|
|
643
647
|
"$ref": "#/definitions/plugin"
|
|
@@ -650,6 +654,10 @@
|
|
|
650
654
|
"title": "lefthook plugin configuration (https://knip.dev/reference/plugins/lefthook)",
|
|
651
655
|
"$ref": "#/definitions/plugin"
|
|
652
656
|
},
|
|
657
|
+
"lingui": {
|
|
658
|
+
"title": "lingui plugin configuration (https://knip.dev/reference/plugins/lingui)",
|
|
659
|
+
"$ref": "#/definitions/plugin"
|
|
660
|
+
},
|
|
653
661
|
"lint-staged": {
|
|
654
662
|
"title": "lint-staged plugin configuration (https://knip.dev/reference/plugins/lint-staged)",
|
|
655
663
|
"$ref": "#/definitions/plugin"
|
|
@@ -682,6 +690,10 @@
|
|
|
682
690
|
"title": "marko plugin configuration (https://knip.dev/reference/plugins/marko)",
|
|
683
691
|
"$ref": "#/definitions/plugin"
|
|
684
692
|
},
|
|
693
|
+
"mastra": {
|
|
694
|
+
"title": "mastra plugin configuration (https://knip.dev/reference/plugins/mastra)",
|
|
695
|
+
"$ref": "#/definitions/plugin"
|
|
696
|
+
},
|
|
685
697
|
"mcp": {
|
|
686
698
|
"title": "mcp plugin configuration (https://knip.dev/reference/plugins/mcp)",
|
|
687
699
|
"$ref": "#/definitions/plugin"
|
|
@@ -862,6 +874,10 @@
|
|
|
862
874
|
"title": "Prisma plugin configuration (https://knip.dev/reference/plugins/prisma)",
|
|
863
875
|
"$ref": "#/definitions/plugin"
|
|
864
876
|
},
|
|
877
|
+
"purgecss": {
|
|
878
|
+
"title": "purgecss plugin configuration (https://knip.dev/reference/plugins/purgecss)",
|
|
879
|
+
"$ref": "#/definitions/plugin"
|
|
880
|
+
},
|
|
865
881
|
"quasar": {
|
|
866
882
|
"title": "quasar plugin configuration (https://knip.dev/reference/plugins/quasar)",
|
|
867
883
|
"$ref": "#/definitions/plugin"
|