knip 6.24.0 → 6.25.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/dist/ConfigurationChief.d.ts +13 -1
- package/dist/ConfigurationChief.js +3 -0
- package/dist/ProjectPrincipal.d.ts +2 -0
- package/dist/ProjectPrincipal.js +4 -1
- package/dist/binaries/bash-parser.js +55 -83
- package/dist/binaries/index.js +3 -0
- package/dist/compilers/index.d.ts +29 -5
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +5 -0
- package/dist/graph/analyze.js +37 -2
- package/dist/graph/build.js +9 -0
- package/dist/graph-explorer/explorer.d.ts +1 -0
- package/dist/graph-explorer/explorer.js +2 -0
- package/dist/graph-explorer/operations/find-all-cycles.d.ts +3 -0
- package/dist/graph-explorer/operations/find-all-cycles.js +43 -0
- package/dist/graph-explorer/operations/find-cycles.js +3 -9
- package/dist/graph-explorer/utils.d.ts +10 -1
- package/dist/graph-explorer/utils.js +53 -0
- package/dist/plugins/bun/index.js +28 -14
- package/dist/plugins/eve/index.d.ts +3 -0
- package/dist/plugins/eve/index.js +22 -0
- package/dist/plugins/execa/visitors/execa.js +10 -18
- package/dist/plugins/fumadocs/index.d.ts +3 -0
- package/dist/plugins/fumadocs/index.js +18 -0
- package/dist/plugins/graphql-codegen/index.js +9 -7
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/jest/index.js +13 -3
- package/dist/plugins/next/index.js +23 -10
- package/dist/plugins/node/index.js +4 -1
- package/dist/plugins/pnpm/index.js +21 -1
- package/dist/plugins/pnpm/types.d.ts +6 -0
- package/dist/plugins/pnpm/types.js +1 -0
- package/dist/plugins/prettier/index.js +19 -3
- package/dist/plugins/prettier/types.d.ts +6 -1
- package/dist/plugins/rspack/index.js +5 -0
- package/dist/plugins/serverless-framework/index.js +12 -1
- package/dist/plugins/serverless-framework/types.d.ts +5 -2
- package/dist/plugins/storybook/index.js +7 -0
- package/dist/plugins/typedoc/index.js +9 -3
- package/dist/plugins/typedoc/types.d.ts +2 -0
- package/dist/plugins/vite/visitors/importMetaGlob.js +1 -8
- package/dist/plugins/webpack/visitors/requireContext.js +2 -13
- package/dist/plugins/yarn/index.js +13 -4
- package/dist/plugins/yarn/types.d.ts +10 -0
- package/dist/plugins/yarn/types.js +1 -0
- package/dist/plugins/zx/visitors/zx.js +4 -4
- package/dist/reporters/cycles.d.ts +3 -0
- package/dist/reporters/cycles.js +79 -0
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.js +2 -0
- package/dist/reporters/json.d.ts +3 -0
- package/dist/reporters/json.js +2 -1
- package/dist/reporters/util/util.d.ts +3 -1
- package/dist/reporters/util/util.js +5 -1
- package/dist/schema/configuration.d.ts +40 -6
- package/dist/schema/configuration.js +6 -0
- package/dist/schema/plugins.d.ts +10 -0
- package/dist/schema/plugins.js +2 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/types/config.d.ts +9 -0
- package/dist/types/issues.d.ts +3 -0
- package/dist/types/module-graph.d.ts +7 -0
- package/dist/types/package-json.d.ts +4 -1
- package/dist/typescript/ast-nodes.d.ts +3 -1
- package/dist/typescript/ast-nodes.js +9 -1
- package/dist/typescript/get-imports-and-exports.js +10 -0
- package/dist/typescript/glob-imports.d.ts +3 -0
- package/dist/typescript/glob-imports.js +49 -0
- package/dist/typescript/resolve-module-names.d.ts +2 -0
- package/dist/typescript/resolve-module-names.js +35 -1
- package/dist/typescript/visitors/calls.js +4 -6
- package/dist/typescript/visitors/imports.js +8 -8
- package/dist/typescript/visitors/script-visitors.js +4 -4
- package/dist/typescript/visitors/walk.js +2 -3
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +4 -2
- package/dist/util/create-options.d.ts +32 -5
- package/dist/util/create-options.js +4 -1
- package/dist/util/get-included-issue-types.d.ts +1 -0
- package/dist/util/get-included-issue-types.js +4 -2
- package/dist/util/issue-initializers.js +1 -1
- package/dist/util/load-tsconfig.js +17 -4
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.js +25 -4
- package/dist/util/scripts.d.ts +7 -0
- package/dist/util/scripts.js +75 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +40 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export type IgnorePatterns = (string | RegExp)[];
|
|
|
30
30
|
type IgnorableExport = Exclude<SymbolType, 'unknown'>;
|
|
31
31
|
export type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
32
32
|
export type IgnoreIssues = Record<string, IssueType[]>;
|
|
33
|
+
export type CyclesConfig = {
|
|
34
|
+
allow?: string[][];
|
|
35
|
+
dynamicImports?: boolean;
|
|
36
|
+
};
|
|
33
37
|
export type GetImportsAndExportsOptions = {
|
|
34
38
|
skipTypeOnly: boolean;
|
|
35
39
|
isFixExports: boolean;
|
|
@@ -43,6 +47,7 @@ export interface Configuration {
|
|
|
43
47
|
ignoreDependencies: IgnorePatterns;
|
|
44
48
|
ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
|
|
45
49
|
ignoreFiles: NormalizedGlob;
|
|
50
|
+
cycles: CyclesConfig;
|
|
46
51
|
ignoreIssues: IgnoreIssues;
|
|
47
52
|
ignoreMembers: IgnorePatterns;
|
|
48
53
|
ignoreUnresolved: IgnorePatterns;
|
|
@@ -130,6 +135,10 @@ export type PluginVisitorContext = {
|
|
|
130
135
|
sourceText: string;
|
|
131
136
|
addScript: (script: string) => void;
|
|
132
137
|
addImport: (specifier: string, pos: number, modifiers: number) => void;
|
|
138
|
+
addImportGlob: (patterns: string[], options?: {
|
|
139
|
+
base?: string;
|
|
140
|
+
filter?: RegExp;
|
|
141
|
+
}) => void;
|
|
133
142
|
markExportRegistered: (name: string) => void;
|
|
134
143
|
};
|
|
135
144
|
export type PluginVisitorObject = VisitorObject;
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Fixes } from './exports.ts';
|
|
|
3
3
|
export type SymbolType = (typeof SYMBOL_TYPE)[keyof typeof SYMBOL_TYPE];
|
|
4
4
|
export interface IssueSymbol {
|
|
5
5
|
symbol: string;
|
|
6
|
+
kind?: string;
|
|
7
|
+
specifier?: string;
|
|
6
8
|
pos?: number;
|
|
7
9
|
line?: number;
|
|
8
10
|
col?: number;
|
|
@@ -40,6 +42,7 @@ export type Issues = {
|
|
|
40
42
|
enumMembers: IssueRecords;
|
|
41
43
|
namespaceMembers: IssueRecords;
|
|
42
44
|
catalog: IssueRecords;
|
|
45
|
+
cycles: IssueRecords;
|
|
43
46
|
};
|
|
44
47
|
export type IssueType = keyof Issues;
|
|
45
48
|
export type Report = {
|
|
@@ -29,6 +29,7 @@ export interface Import extends Position {
|
|
|
29
29
|
readonly filePath: string | undefined;
|
|
30
30
|
readonly identifier: string | undefined;
|
|
31
31
|
readonly isTypeOnly: boolean;
|
|
32
|
+
readonly modifiers: number;
|
|
32
33
|
}
|
|
33
34
|
export interface ExternalRef {
|
|
34
35
|
readonly specifier: string;
|
|
@@ -68,8 +69,14 @@ export type FileNode = {
|
|
|
68
69
|
exports: ExportMap;
|
|
69
70
|
duplicates: Iterable<Array<IssueSymbol>>;
|
|
70
71
|
scripts: Set<string>;
|
|
72
|
+
importGlobs: ImportGlob[];
|
|
71
73
|
importedBy: undefined | ImportMaps;
|
|
72
74
|
internalImportCache: undefined | ImportMap;
|
|
73
75
|
};
|
|
76
|
+
export interface ImportGlob {
|
|
77
|
+
patterns: string[];
|
|
78
|
+
base?: string;
|
|
79
|
+
filter?: RegExp;
|
|
80
|
+
}
|
|
74
81
|
export type ModuleGraph = Map<FilePath, FileNode>;
|
|
75
82
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { PluginMap, WorkspaceConfiguration } from './config.ts';
|
|
2
2
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
3
3
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
4
|
-
type Dependencies = Record<string, string>;
|
|
5
4
|
type C = 'import' | 'require' | 'node' | 'node-addons' | 'deno' | 'browser' | 'electron' | 'react-native' | 'default';
|
|
6
5
|
type ExportCondition = LiteralUnion<C, string>;
|
|
7
6
|
type Exports = null | string | string[] | {
|
|
@@ -25,6 +24,7 @@ type Plugins = PluginConfig<PluginMap>;
|
|
|
25
24
|
export type Scripts = Record<string, string>;
|
|
26
25
|
export type Catalog = Record<string, string>;
|
|
27
26
|
export type Catalogs = Record<string, Catalog>;
|
|
27
|
+
export type Dependencies = Record<string, string>;
|
|
28
28
|
export type PackageJson = {
|
|
29
29
|
name?: string;
|
|
30
30
|
main?: string;
|
|
@@ -57,6 +57,9 @@ export type PackageJson = {
|
|
|
57
57
|
engines?: Record<string, string>;
|
|
58
58
|
pnpm?: {
|
|
59
59
|
overrides?: Dependencies;
|
|
60
|
+
packageExtensions?: Record<string, {
|
|
61
|
+
peerDependencies?: Dependencies;
|
|
62
|
+
}>;
|
|
60
63
|
};
|
|
61
64
|
knip?: WorkspaceConfiguration;
|
|
62
65
|
} & Plugins;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TSEnumDeclaration, type TSModuleDeclaration } from 'oxc-parser';
|
|
1
|
+
import { type TemplateLiteral, type TSEnumDeclaration, type TSModuleDeclaration } from 'oxc-parser';
|
|
2
2
|
import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile } from '../types/config.ts';
|
|
3
3
|
import type { SymbolType } from '../types/issues.ts';
|
|
4
4
|
import type { ExportMember } from '../types/module-graph.ts';
|
|
@@ -16,6 +16,8 @@ export declare const getLineAndCol: (lineStarts: number[], pos: number) => {
|
|
|
16
16
|
export declare const stripQuotes: (name: string) => string;
|
|
17
17
|
export declare const isStringLiteral: (node: any) => boolean;
|
|
18
18
|
export declare const getStringValue: (node: any) => string | undefined;
|
|
19
|
+
export declare const getScriptFromTemplate: (template: TemplateLiteral) => string;
|
|
20
|
+
export declare const getScriptFromArg: (arg: any) => string | undefined;
|
|
19
21
|
export declare const getSafeScriptFromArgs: (executable: any, argsArray: any) => string | undefined;
|
|
20
22
|
export declare const shouldCountRefs: (ignoreExportsUsedInFile: IgnoreExportsUsedInFile, type: SymbolType) => boolean | undefined;
|
|
21
23
|
export declare function extractNamespaceMembers(decl: TSModuleDeclaration, options: GetImportsAndExportsOptions, lineStarts: number[], getJSDocTags: (start: number) => Set<string>, prefix?: string): ExportMember[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseSync, rawTransferSupported, visitorKeys, } from 'oxc-parser';
|
|
2
|
-
import { DEFAULT_EXTENSIONS, FIX_FLAGS, SYMBOL_TYPE } from '../constants.js';
|
|
2
|
+
import { DEFAULT_EXTENSIONS, FIX_FLAGS, SCRIPT_INTERPOLATION, SYMBOL_TYPE } from '../constants.js';
|
|
3
3
|
import { extname } from '../util/path.js';
|
|
4
4
|
import { timerify } from '../util/Performance.js';
|
|
5
5
|
import { EMPTY_TAGS } from './visitors/jsdoc.js';
|
|
@@ -53,6 +53,14 @@ export const getStringValue = (node) => {
|
|
|
53
53
|
return node.quasis[0].value?.cooked ?? node.quasis[0].value?.raw;
|
|
54
54
|
return undefined;
|
|
55
55
|
};
|
|
56
|
+
export const getScriptFromTemplate = (template) => {
|
|
57
|
+
const { quasis } = template;
|
|
58
|
+
let script = quasis[0].value.raw;
|
|
59
|
+
for (let i = 1; i < quasis.length; i++)
|
|
60
|
+
script += SCRIPT_INTERPOLATION + quasis[i].value.raw;
|
|
61
|
+
return script;
|
|
62
|
+
};
|
|
63
|
+
export const getScriptFromArg = (arg) => isStringLiteral(arg) ? getStringValue(arg) : arg?.type === 'TemplateLiteral' ? getScriptFromTemplate(arg) : undefined;
|
|
56
64
|
const SAFE_SCRIPT_ARG = /^[\w@.,:/=+~-]+$/;
|
|
57
65
|
export const getSafeScriptFromArgs = (executable, argsArray) => {
|
|
58
66
|
if (!isStringLiteral(executable))
|
|
@@ -24,6 +24,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
24
24
|
const aliasedExports = new Map();
|
|
25
25
|
const specifierExportNames = new Set();
|
|
26
26
|
const scripts = new Set();
|
|
27
|
+
const importGlobs = [];
|
|
27
28
|
const importAliases = new Map();
|
|
28
29
|
const addImportAlias = (aliasName, id, importFilePath) => {
|
|
29
30
|
const aliases = importAliases.get(aliasName);
|
|
@@ -58,6 +59,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
58
59
|
line: opts.line,
|
|
59
60
|
col: opts.col,
|
|
60
61
|
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
62
|
+
modifiers,
|
|
61
63
|
});
|
|
62
64
|
const file = internal.get(importFilePath);
|
|
63
65
|
const importMaps = file ?? createImports();
|
|
@@ -93,6 +95,10 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
93
95
|
if (!specifier || isBuiltin(specifier))
|
|
94
96
|
return;
|
|
95
97
|
const module = preResolvedModule ?? resolveModule(specifier, filePath);
|
|
98
|
+
if (modifiers & IMPORT_FLAGS.AUGMENT &&
|
|
99
|
+
(!module || module.isExternalLibraryImport || isInNodeModules(module.resolvedFileName))) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
96
102
|
if (module) {
|
|
97
103
|
const resolvedFileName = module.resolvedFileName;
|
|
98
104
|
if (resolvedFileName) {
|
|
@@ -134,6 +140,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
134
140
|
line,
|
|
135
141
|
col,
|
|
136
142
|
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
143
|
+
modifiers,
|
|
137
144
|
});
|
|
138
145
|
}
|
|
139
146
|
}
|
|
@@ -158,6 +165,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
158
165
|
line,
|
|
159
166
|
col,
|
|
160
167
|
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
168
|
+
modifiers,
|
|
161
169
|
});
|
|
162
170
|
}
|
|
163
171
|
}
|
|
@@ -266,6 +274,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
266
274
|
pluginCtx.sourceText = sourceText;
|
|
267
275
|
pluginCtx.addScript = (s) => scripts.add(s);
|
|
268
276
|
pluginCtx.addImport = (spec, pos, mod) => addImport(spec, undefined, undefined, undefined, pos, mod);
|
|
277
|
+
pluginCtx.addImportGlob = (patterns, opts) => importGlobs.push({ patterns, base: opts?.base, filter: opts?.filter });
|
|
269
278
|
pluginCtx.markExportRegistered = (name) => registeredCustomElements.add(name);
|
|
270
279
|
}
|
|
271
280
|
const localRefs = _walkAST(result.program, sourceText, filePath, {
|
|
@@ -314,6 +323,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
314
323
|
exports,
|
|
315
324
|
duplicates: [...aliasedExports.values()],
|
|
316
325
|
scripts,
|
|
326
|
+
importGlobs,
|
|
317
327
|
importedBy: undefined,
|
|
318
328
|
internalImportCache: undefined,
|
|
319
329
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ImportGlob } from '../types/module-graph.ts';
|
|
2
|
+
import type { ResolveGlobPattern } from './resolve-module-names.ts';
|
|
3
|
+
export declare function resolveImportGlobs(items: ImportGlob[], containingFile: string, resolveGlobPattern: ResolveGlobPattern, workspaceRoot: string): string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { _syncGlob } from '../util/glob.js';
|
|
3
|
+
import { dirname, isAbsolute, join, toRelative } from '../util/path.js';
|
|
4
|
+
function resolveBaseDir(base, dir, resolveGlobPattern) {
|
|
5
|
+
if (base.startsWith('.'))
|
|
6
|
+
return join(dir, base);
|
|
7
|
+
if (isAbsolute(base))
|
|
8
|
+
return base;
|
|
9
|
+
for (const resolved of resolveGlobPattern(base, dir)) {
|
|
10
|
+
if (resolved !== base && existsSync(resolved))
|
|
11
|
+
return resolved;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export function resolveImportGlobs(items, containingFile, resolveGlobPattern, workspaceRoot) {
|
|
16
|
+
const filePaths = [];
|
|
17
|
+
const dir = dirname(containingFile);
|
|
18
|
+
for (const { patterns, base, filter } of items) {
|
|
19
|
+
if (base !== undefined) {
|
|
20
|
+
const cwd = resolveBaseDir(base, dir, resolveGlobPattern);
|
|
21
|
+
if (!cwd)
|
|
22
|
+
continue;
|
|
23
|
+
for (const filePath of _syncGlob({ patterns, cwd })) {
|
|
24
|
+
if (!filter || filter.test(`./${toRelative(filePath, cwd)}`))
|
|
25
|
+
filePaths.push(filePath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const resolved = [];
|
|
30
|
+
for (const pattern of patterns) {
|
|
31
|
+
const isNegated = pattern[0] === '!';
|
|
32
|
+
const specifier = isNegated ? pattern.slice(1) : pattern;
|
|
33
|
+
if (specifier[0] === '/') {
|
|
34
|
+
const rooted = join(workspaceRoot, specifier);
|
|
35
|
+
resolved.push(isNegated ? `!${rooted}` : rooted);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (const p of resolveGlobPattern(pattern, dir))
|
|
39
|
+
resolved.push(p);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (resolved.length === 0)
|
|
43
|
+
continue;
|
|
44
|
+
for (const filePath of _syncGlob({ patterns: resolved, cwd: dir }))
|
|
45
|
+
filePaths.push(filePath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return filePaths;
|
|
49
|
+
}
|
|
@@ -9,6 +9,8 @@ type ScopedRootDirs = Array<{
|
|
|
9
9
|
rootDirs: string[];
|
|
10
10
|
}>;
|
|
11
11
|
export declare function clearModuleResolutionCaches(): void;
|
|
12
|
+
export type ResolveGlobPattern = (pattern: string, dir: string) => string[];
|
|
13
|
+
export declare function createGlobAliasResolver(scopedPaths: ScopedPaths | undefined): ResolveGlobPattern;
|
|
12
14
|
export declare function createCustomModuleResolver(compilerOptions: {
|
|
13
15
|
scopedPaths?: ScopedPaths;
|
|
14
16
|
scopedRootDirs?: ScopedRootDirs;
|
|
@@ -3,7 +3,7 @@ import { isBuiltin } from 'node:module';
|
|
|
3
3
|
import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS } from '../constants.js';
|
|
4
4
|
import { sanitizeSpecifier } from '../util/modules.js';
|
|
5
5
|
import { timerify } from '../util/Performance.js';
|
|
6
|
-
import { dirname, extname, isAbsolute, isInNodeModules, join } from '../util/path.js';
|
|
6
|
+
import { dirname, extname, isAbsolute, isInNodeModules, join, toPosix } from '../util/path.js';
|
|
7
7
|
import { _createSyncModuleResolver, _resolveModuleSync } from '../util/resolve.js';
|
|
8
8
|
function pickStringTarget(value) {
|
|
9
9
|
if (typeof value === 'string')
|
|
@@ -56,6 +56,40 @@ function compileRootDirs(scopedRootDirs) {
|
|
|
56
56
|
scoped.sort((a, b) => b.scope.length - a.scope.length);
|
|
57
57
|
return scoped;
|
|
58
58
|
}
|
|
59
|
+
export function createGlobAliasResolver(scopedPaths) {
|
|
60
|
+
const mappings = compilePathMappings(scopedPaths);
|
|
61
|
+
return (pattern, dir) => {
|
|
62
|
+
if (!mappings)
|
|
63
|
+
return [pattern];
|
|
64
|
+
const isNegated = pattern[0] === '!';
|
|
65
|
+
const specifier = isNegated ? pattern.slice(1) : pattern;
|
|
66
|
+
let best;
|
|
67
|
+
for (const mapping of mappings) {
|
|
68
|
+
const { prefix, wildcard, scope } = mapping;
|
|
69
|
+
if (dir !== scope && !dir.startsWith(`${scope}/`))
|
|
70
|
+
continue;
|
|
71
|
+
const matches = wildcard
|
|
72
|
+
? specifier.startsWith(prefix)
|
|
73
|
+
: specifier === prefix || specifier.startsWith(`${prefix}/`);
|
|
74
|
+
if (!matches)
|
|
75
|
+
continue;
|
|
76
|
+
if (!best ||
|
|
77
|
+
scope.length > best.scope.length ||
|
|
78
|
+
(scope.length === best.scope.length && prefix.length > best.prefix.length))
|
|
79
|
+
best = mapping;
|
|
80
|
+
}
|
|
81
|
+
if (!best)
|
|
82
|
+
return [pattern];
|
|
83
|
+
const captured = specifier.slice(best.prefix.length);
|
|
84
|
+
const resolved = [];
|
|
85
|
+
for (const value of best.values) {
|
|
86
|
+
const starIdx = value.indexOf('*');
|
|
87
|
+
const mapped = toPosix(starIdx >= 0 ? value.slice(0, starIdx) + captured + value.slice(starIdx + 1) : value + captured);
|
|
88
|
+
resolved.push(isNegated ? `!${mapped}` : mapped);
|
|
89
|
+
}
|
|
90
|
+
return resolved;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
59
93
|
export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, findWorkspaceManifestImports, tsConfigFile) {
|
|
60
94
|
const customCompilerExtensionsSet = new Set(customCompilerExtensions);
|
|
61
95
|
const hasCustomExts = customCompilerExtensionsSet.size > 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMPORT_FLAGS, OPAQUE } from '../../constants.js';
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
|
-
import { getSafeScriptFromArgs, getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
3
|
+
import { getSafeScriptFromArgs, getScriptFromArg, getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
4
4
|
import { isShadowed } from './walk.js';
|
|
5
5
|
function getRegisteredCustomElement(node, s) {
|
|
6
6
|
const callee = node.callee;
|
|
@@ -162,11 +162,9 @@ export function handleCallExpression(node, s) {
|
|
|
162
162
|
if (method) {
|
|
163
163
|
const arg = node.arguments[0];
|
|
164
164
|
if (CHILD_PROCESS_COMMAND_METHODS.has(method)) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
s.scripts.add(command);
|
|
169
|
-
}
|
|
165
|
+
const command = getScriptFromArg(arg);
|
|
166
|
+
if (command)
|
|
167
|
+
s.scripts.add(command);
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
170
|
if (CHILD_PROCESS_FILE_METHODS.has(method)) {
|
|
@@ -26,16 +26,16 @@ export function handleVariableDeclarator(node, s) {
|
|
|
26
26
|
: undefined;
|
|
27
27
|
const localName = prop.value?.type === 'Identifier' ? prop.value.name : importedName;
|
|
28
28
|
const alias = localName !== importedName ? localName : undefined;
|
|
29
|
-
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.
|
|
29
|
+
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
30
30
|
}
|
|
31
31
|
else if (prop.type === 'RestElement' && prop.argument?.type === 'Identifier') {
|
|
32
|
-
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.
|
|
32
|
+
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
else if (node.id.type === 'Identifier') {
|
|
37
37
|
if (init.type === 'AwaitExpression') {
|
|
38
|
-
s.addImport(specifier, 'default', node.id.name, undefined, importExpr.source.start, IMPORT_FLAGS.
|
|
38
|
+
s.addImport(specifier, 'default', node.id.name, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
39
39
|
const resolved = s.resolveModule(specifier, s.filePath);
|
|
40
40
|
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
41
41
|
s.localImportMap.set(node.id.name, {
|
|
@@ -47,11 +47,11 @@ export function handleVariableDeclarator(node, s) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.OPAQUE);
|
|
50
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.OPAQUE);
|
|
54
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
55
55
|
}
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -117,10 +117,10 @@ export function handleVariableDeclarator(node, s) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
else if (binding?.type === 'Identifier') {
|
|
120
|
-
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.
|
|
120
|
+
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
|
-
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.SIDE_EFFECTS);
|
|
123
|
+
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.SIDE_EFFECTS);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -257,6 +257,6 @@ export function handleImportExpression(node, s) {
|
|
|
257
257
|
return;
|
|
258
258
|
const specifier = getStringValue(node.source);
|
|
259
259
|
if (specifier) {
|
|
260
|
-
s.addImport(specifier, undefined, undefined, undefined, node.source.start, IMPORT_FLAGS.OPAQUE);
|
|
260
|
+
s.addImport(specifier, undefined, undefined, undefined, node.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { getScriptFromTemplate } from '../ast-nodes.js';
|
|
1
2
|
export function createBunShellVisitor(ctx) {
|
|
2
3
|
return {
|
|
3
4
|
TaggedTemplateExpression(node) {
|
|
4
5
|
const tag = node.tag;
|
|
5
6
|
if (tag.type === 'Identifier' && tag.name === '$') {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
const script = getScriptFromTemplate(node.quasi);
|
|
8
|
+
if (script)
|
|
9
|
+
ctx.addScript(script);
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
};
|
|
@@ -213,9 +213,8 @@ const coreVisitorObject = {
|
|
|
213
213
|
state.nsRanges.push([node.start, node.end]);
|
|
214
214
|
if (node.kind !== 'global' && isStringLiteral(node.id)) {
|
|
215
215
|
const specifier = getStringValue(node.id);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
state.addImport(specifier, name, undefined, undefined, node.id.start, IMPORT_FLAGS.TYPE_ONLY);
|
|
216
|
+
for (const name of collectAugmentationRefs(node))
|
|
217
|
+
state.addImport(specifier, name, undefined, undefined, node.id.start, IMPORT_FLAGS.TYPE_ONLY | IMPORT_FLAGS.AUGMENT);
|
|
219
218
|
}
|
|
220
219
|
},
|
|
221
220
|
ClassDeclaration(node) {
|
|
@@ -1,9 +1,10 @@
|
|
|
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 -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\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,catalog\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\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 (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print total running time (zero overhead, no instrumentation)\n --trace Show trace output\n --trace-dependency [name] Show files that import the named dependency\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog\n(2) Fixable issue types: dependencies, exports, types, files, catalog\n(3) Built-in reporters: symbols (default), compact, codeowners, json, codeclimate, markdown, disclosure, github-actions\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip --workspace @myorg/* --workspace '!@myorg/legacy'\n$ knip --workspace './apps/*' --workspace '@shared/utils'\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 -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\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,catalog\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --cycles Shortcut for --include cycles (circular dependencies)\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\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 (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print total running time (zero overhead, no instrumentation)\n --trace Show trace output\n --trace-dependency [name] Show files that import the named dependency\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, cycles\n(2) Fixable issue types: dependencies, exports, types, files, catalog\n(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip --workspace @myorg/* --workspace '!@myorg/legacy'\n$ knip --workspace './apps/*' --workspace '@shared/utils'\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
|
export type ParsedCLIArgs = ReturnType<typeof parseCLIArgs>;
|
|
3
3
|
export default function parseCLIArgs(): {
|
|
4
4
|
cache?: boolean | undefined;
|
|
5
5
|
'cache-location'?: string | undefined;
|
|
6
6
|
config?: string | undefined;
|
|
7
|
+
cycles?: boolean | undefined;
|
|
7
8
|
debug?: boolean | undefined;
|
|
8
9
|
dependencies?: boolean | undefined;
|
|
9
10
|
directory?: string | undefined;
|
|
@@ -29,6 +29,7 @@ Scope
|
|
|
29
29
|
--dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved,catalog
|
|
30
30
|
--exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates
|
|
31
31
|
--files Shortcut for --include files
|
|
32
|
+
--cycles Shortcut for --include cycles (circular dependencies)
|
|
32
33
|
--tags Include or exclude tagged exports
|
|
33
34
|
|
|
34
35
|
Fix
|
|
@@ -62,9 +63,9 @@ Troubleshooting
|
|
|
62
63
|
--trace-export [name] Show trace output for named export(s)
|
|
63
64
|
--trace-file [file] Show trace output for exports in file
|
|
64
65
|
|
|
65
|
-
(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog
|
|
66
|
+
(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, cycles
|
|
66
67
|
(2) Fixable issue types: dependencies, exports, types, files, catalog
|
|
67
|
-
(3) Built-in reporters: symbols (default), compact, codeowners, json, codeclimate, markdown, disclosure, github-actions
|
|
68
|
+
(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions
|
|
68
69
|
|
|
69
70
|
Examples:
|
|
70
71
|
|
|
@@ -84,6 +85,7 @@ export default function parseCLIArgs() {
|
|
|
84
85
|
cache: { type: 'boolean' },
|
|
85
86
|
'cache-location': { type: 'string' },
|
|
86
87
|
config: { type: 'string', short: 'c' },
|
|
88
|
+
cycles: { type: 'boolean' },
|
|
87
89
|
debug: { type: 'boolean', short: 'd' },
|
|
88
90
|
dependencies: { type: 'boolean' },
|
|
89
91
|
directory: { type: 'string', short: 'D' },
|
|
@@ -9,6 +9,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
9
9
|
config: string | undefined;
|
|
10
10
|
configFilePath: string | undefined;
|
|
11
11
|
cwd: string;
|
|
12
|
+
cycles: boolean;
|
|
12
13
|
dependencies: boolean;
|
|
13
14
|
exports: boolean;
|
|
14
15
|
files: boolean;
|
|
@@ -30,6 +31,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
30
31
|
isProduction: boolean;
|
|
31
32
|
isReportDependencies: boolean;
|
|
32
33
|
isReportExports: boolean;
|
|
34
|
+
isReportCycles: boolean;
|
|
33
35
|
isReportFiles: boolean;
|
|
34
36
|
isReportTypes: boolean;
|
|
35
37
|
isReportValues: boolean;
|
|
@@ -193,6 +195,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
193
195
|
entry?: string | string[] | undefined;
|
|
194
196
|
project?: string | string[] | undefined;
|
|
195
197
|
} | undefined;
|
|
198
|
+
eve?: string | boolean | string[] | {
|
|
199
|
+
config?: string | string[] | undefined;
|
|
200
|
+
entry?: string | string[] | undefined;
|
|
201
|
+
project?: string | string[] | undefined;
|
|
202
|
+
} | undefined;
|
|
196
203
|
execa?: string | boolean | string[] | {
|
|
197
204
|
config?: string | string[] | undefined;
|
|
198
205
|
entry?: string | string[] | undefined;
|
|
@@ -213,6 +220,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
213
220
|
entry?: string | string[] | undefined;
|
|
214
221
|
project?: string | string[] | undefined;
|
|
215
222
|
} | undefined;
|
|
223
|
+
fumadocs?: string | boolean | string[] | {
|
|
224
|
+
config?: string | string[] | undefined;
|
|
225
|
+
entry?: string | string[] | undefined;
|
|
226
|
+
project?: string | string[] | undefined;
|
|
227
|
+
} | undefined;
|
|
216
228
|
gatsby?: string | boolean | string[] | {
|
|
217
229
|
config?: string | string[] | undefined;
|
|
218
230
|
entry?: string | string[] | undefined;
|
|
@@ -829,7 +841,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
829
841
|
project?: string | string[] | undefined;
|
|
830
842
|
} | undefined;
|
|
831
843
|
$schema?: string | undefined;
|
|
832
|
-
rules?: Partial<Record<"binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
|
|
844
|
+
rules?: Partial<Record<"binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
|
|
833
845
|
entry?: string | string[] | undefined;
|
|
834
846
|
project?: string | string[] | undefined;
|
|
835
847
|
paths?: Record<string, string[]> | undefined;
|
|
@@ -840,7 +852,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
840
852
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
841
853
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
842
854
|
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
843
|
-
ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
855
|
+
ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
856
|
+
cycles?: {
|
|
857
|
+
allow?: string[][] | undefined;
|
|
858
|
+
dynamicImports?: boolean | undefined;
|
|
859
|
+
} | undefined;
|
|
844
860
|
ignoreWorkspaces?: string[] | undefined;
|
|
845
861
|
includeEntryExports?: boolean | undefined;
|
|
846
862
|
compilers?: Record<string, true | import("../compilers/types.ts").CompilerAsync | import("../compilers/types.ts").CompilerSync> | undefined;
|
|
@@ -849,8 +865,8 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
849
865
|
tags?: string[] | undefined;
|
|
850
866
|
treatConfigHintsAsErrors?: boolean | undefined;
|
|
851
867
|
treatTagHintsAsErrors?: boolean | undefined;
|
|
852
|
-
include?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
853
|
-
exclude?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
868
|
+
include?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
869
|
+
exclude?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
854
870
|
workspaces?: Record<string, {
|
|
855
871
|
angular?: string | boolean | string[] | {
|
|
856
872
|
config?: string | string[] | undefined;
|
|
@@ -1002,6 +1018,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1002
1018
|
entry?: string | string[] | undefined;
|
|
1003
1019
|
project?: string | string[] | undefined;
|
|
1004
1020
|
} | undefined;
|
|
1021
|
+
eve?: string | boolean | string[] | {
|
|
1022
|
+
config?: string | string[] | undefined;
|
|
1023
|
+
entry?: string | string[] | undefined;
|
|
1024
|
+
project?: string | string[] | undefined;
|
|
1025
|
+
} | undefined;
|
|
1005
1026
|
execa?: string | boolean | string[] | {
|
|
1006
1027
|
config?: string | string[] | undefined;
|
|
1007
1028
|
entry?: string | string[] | undefined;
|
|
@@ -1022,6 +1043,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1022
1043
|
entry?: string | string[] | undefined;
|
|
1023
1044
|
project?: string | string[] | undefined;
|
|
1024
1045
|
} | undefined;
|
|
1046
|
+
fumadocs?: string | boolean | string[] | {
|
|
1047
|
+
config?: string | string[] | undefined;
|
|
1048
|
+
entry?: string | string[] | undefined;
|
|
1049
|
+
project?: string | string[] | undefined;
|
|
1050
|
+
} | undefined;
|
|
1025
1051
|
gatsby?: string | boolean | string[] | {
|
|
1026
1052
|
config?: string | string[] | undefined;
|
|
1027
1053
|
entry?: string | string[] | undefined;
|
|
@@ -1647,13 +1673,14 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1647
1673
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
1648
1674
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
1649
1675
|
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
1650
|
-
ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
1676
|
+
ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
1651
1677
|
includeEntryExports?: boolean | undefined;
|
|
1652
1678
|
}> | undefined;
|
|
1653
1679
|
};
|
|
1654
1680
|
rules: {
|
|
1655
1681
|
binaries: import("../types/issues.ts").IssueSeverity;
|
|
1656
1682
|
catalog: import("../types/issues.ts").IssueSeverity;
|
|
1683
|
+
cycles: import("../types/issues.ts").IssueSeverity;
|
|
1657
1684
|
dependencies: import("../types/issues.ts").IssueSeverity;
|
|
1658
1685
|
devDependencies: import("../types/issues.ts").IssueSeverity;
|
|
1659
1686
|
duplicates: import("../types/issues.ts").IssueSeverity;
|
|
@@ -4,7 +4,7 @@ import { knipConfigurationSchema } from '../schema/configuration.js';
|
|
|
4
4
|
import { getCatalogContainer } from './catalog.js';
|
|
5
5
|
import { ConfigurationError } from './errors.js';
|
|
6
6
|
import { findFile, loadJSON } from './fs.js';
|
|
7
|
-
import { getIncludedIssueTypes, shorthandDeps, shorthandExports, shorthandFiles } from './get-included-issue-types.js';
|
|
7
|
+
import { getIncludedIssueTypes, shorthandCycles, shorthandDeps, shorthandExports, shorthandFiles, } from './get-included-issue-types.js';
|
|
8
8
|
import { defaultRules } from './issue-initializers.js';
|
|
9
9
|
import { loadResolvedConfigFile } from './load-config.js';
|
|
10
10
|
import { _load } from './loader.js';
|
|
@@ -82,6 +82,7 @@ export const createOptions = async (options) => {
|
|
|
82
82
|
...(args.dependencies ? shorthandDeps : []),
|
|
83
83
|
...(args.exports ? shorthandExports : []),
|
|
84
84
|
...(args.files ? shorthandFiles : []),
|
|
85
|
+
...(args.cycles ? shorthandCycles : []),
|
|
85
86
|
],
|
|
86
87
|
});
|
|
87
88
|
for (const [key, value] of Object.entries(includedIssueTypes)) {
|
|
@@ -98,6 +99,7 @@ export const createOptions = async (options) => {
|
|
|
98
99
|
config: args.config,
|
|
99
100
|
configFilePath,
|
|
100
101
|
cwd,
|
|
102
|
+
cycles: args.cycles ?? false,
|
|
101
103
|
dependencies: args.dependencies ?? false,
|
|
102
104
|
exports: args.exports ?? false,
|
|
103
105
|
files: args.files ?? false,
|
|
@@ -128,6 +130,7 @@ export const createOptions = async (options) => {
|
|
|
128
130
|
includedIssueTypes.enumMembers ||
|
|
129
131
|
includedIssueTypes.namespaceMembers ||
|
|
130
132
|
includedIssueTypes.duplicates,
|
|
133
|
+
isReportCycles: includedIssueTypes.cycles,
|
|
131
134
|
isReportFiles: includedIssueTypes.files,
|
|
132
135
|
isReportTypes: includedIssueTypes.types ||
|
|
133
136
|
includedIssueTypes.nsTypes ||
|
|
@@ -10,5 +10,6 @@ export declare const defaultExcludedIssueTypes: string[];
|
|
|
10
10
|
export declare const shorthandDeps: string[];
|
|
11
11
|
export declare const shorthandExports: string[];
|
|
12
12
|
export declare const shorthandFiles: string[];
|
|
13
|
+
export declare const shorthandCycles: string[];
|
|
13
14
|
export declare const getIncludedIssueTypes: (options: GetIncludedIssueTypesOptions) => Report;
|
|
14
15
|
export {};
|