knip 6.43.0 → 6.44.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/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 +9 -4
- package/dist/IssueCollector.js +1 -0
- package/dist/ProjectPrincipal.d.ts +3 -2
- package/dist/ProjectPrincipal.js +32 -10
- package/dist/WorkspaceWorker.d.ts +5 -2
- package/dist/WorkspaceWorker.js +20 -7
- 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 +1 -0
- package/dist/constants.js +1 -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/biome/index.js +1 -1
- package/dist/plugins/cspell/index.js +1 -0
- 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/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 +42 -3
- package/dist/plugins/mocha/types.d.ts +1 -0
- 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/remix/index.js +1 -1
- 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/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.js +4 -2
- 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 +12 -0
- package/dist/session/configuration.js +43 -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 +62 -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 +2 -1
- package/dist/typescript/visitors/imports.js +25 -19
- package/dist/typescript/visitors/members.js +23 -26
- package/dist/typescript/visitors/walk.d.ts +3 -0
- package/dist/typescript/visitors/walk.js +42 -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 +42 -1
- package/dist/util/create-options.js +13 -2
- 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 +38 -2
- package/dist/util/modules.js +3 -1
- 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/types/config.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
|
17
17
|
optionalBinaries?: boolean;
|
|
18
18
|
containingFilePath: string;
|
|
19
19
|
expandedScripts?: Set<string>;
|
|
20
|
+
manifestDir?: string;
|
|
20
21
|
}
|
|
21
22
|
export type GetInputsFromScripts<T = GetInputsFromScriptsOptions> = (npmScripts: string | string[] | Set<string>, options: T) => Input[];
|
|
22
23
|
export type GetInputsFromScriptsPartial = (npmScripts: string | string[] | Set<string>, options?: Partial<GetInputsFromScriptsOptions>) => Input[];
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -71,6 +71,10 @@ export type ReporterOptions = {
|
|
|
71
71
|
selectedWorkspaces: string[] | undefined;
|
|
72
72
|
configFilePath: string | undefined;
|
|
73
73
|
maxShowIssues?: number;
|
|
74
|
+
write?: (output: string) => void;
|
|
75
|
+
};
|
|
76
|
+
export type InternalReporterOptions = ReporterOptions & {
|
|
77
|
+
write: (output: string) => void;
|
|
74
78
|
};
|
|
75
79
|
export type Reporter = (options: ReporterOptions) => void;
|
|
76
80
|
export type Preprocessor = (options: ReporterOptions) => ReporterOptions;
|
|
@@ -28,9 +28,6 @@ type Dependencies = Record<string, string>;
|
|
|
28
28
|
type TypesVersions = Record<string, Record<string, string[]>>;
|
|
29
29
|
export type PackageExtensions = Record<string, {
|
|
30
30
|
peerDependencies?: Dependencies;
|
|
31
|
-
peerDependenciesMeta?: Record<string, {
|
|
32
|
-
optional?: boolean;
|
|
33
|
-
}>;
|
|
34
31
|
}>;
|
|
35
32
|
export type PackageJson = {
|
|
36
33
|
name?: string;
|
|
@@ -26,6 +26,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
26
26
|
const scripts = new Set();
|
|
27
27
|
const importGlobs = [];
|
|
28
28
|
const handledImportExpressions = new Set();
|
|
29
|
+
const caughtImportExpressions = new Set();
|
|
29
30
|
const importAliases = new Map();
|
|
30
31
|
const addImportAlias = (aliasName, id, importFilePath) => {
|
|
31
32
|
const aliases = importAliases.get(aliasName);
|
|
@@ -342,6 +343,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
342
343
|
programFiles,
|
|
343
344
|
entryFiles,
|
|
344
345
|
handledImportExpressions,
|
|
346
|
+
caughtImportExpressions,
|
|
345
347
|
visitor,
|
|
346
348
|
getJSDocTags,
|
|
347
349
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IMPORT_FLAGS, OPAQUE } from '../../constants.js';
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
|
+
import { isStartsLikePackageName } from '../../util/modules.js';
|
|
3
4
|
import { getSafeScriptFromArgs, getScriptFromArg, getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
4
5
|
import { isShadowed } from './walk.js';
|
|
5
6
|
function getRegisteredCustomElement(node, s) {
|
|
@@ -136,23 +137,26 @@ export function handleCallExpression(node, s) {
|
|
|
136
137
|
s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
|
-
if (s.hasNodeModuleImport &&
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
if (s.hasNodeModuleImport && node.arguments.length >= 1 && isStringLiteral(node.arguments[0])) {
|
|
141
|
+
const { callee } = node;
|
|
142
|
+
const nodeModuleMethod = callee.type === 'Identifier'
|
|
143
|
+
? callee.name
|
|
144
|
+
: callee.type === 'MemberExpression' &&
|
|
145
|
+
!callee.computed &&
|
|
146
|
+
callee.object.type === 'Identifier' &&
|
|
147
|
+
callee.object.name === 'module' &&
|
|
148
|
+
callee.property.type === 'Identifier' &&
|
|
149
|
+
callee.property.name;
|
|
148
150
|
const specifier = getStringValue(node.arguments[0]);
|
|
149
151
|
const arg1 = node.arguments[1];
|
|
150
|
-
if (
|
|
152
|
+
if ((nodeModuleMethod === 'register' &&
|
|
153
|
+
specifier &&
|
|
151
154
|
(!specifier.startsWith('.') ||
|
|
152
155
|
(arg1?.type === 'MemberExpression' &&
|
|
153
156
|
!arg1.computed &&
|
|
154
157
|
arg1.object.type === 'MetaProperty' &&
|
|
155
|
-
arg1.property.name === 'url')))
|
|
158
|
+
arg1.property.name === 'url'))) ||
|
|
159
|
+
(nodeModuleMethod === 'findPackageJSON' && isStartsLikePackageName(specifier) && !URL.canParse(specifier))) {
|
|
156
160
|
s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
|
|
157
161
|
return;
|
|
158
162
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ImportExpression, VariableDeclarator } from 'oxc-parser';
|
|
1
|
+
import type { ArrayExpression, Expression, ImportExpression, VariableDeclarator } from 'oxc-parser';
|
|
2
2
|
import type { WalkState } from './walk.ts';
|
|
3
|
+
export declare function getPromiseAllElements(expression: Expression): ArrayExpression['elements'] | undefined;
|
|
3
4
|
export declare function handleVariableDeclarator(node: VariableDeclarator, s: WalkState): void;
|
|
4
5
|
export declare function handleImportExpression(node: ImportExpression, s: WalkState): void;
|
|
@@ -2,6 +2,17 @@ import { IMPORT_FLAGS, IMPORT_STAR, OPAQUE } from '../../constants.js';
|
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
3
|
import { isInNodeModules } from '../../util/path.js';
|
|
4
4
|
import { getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
5
|
+
export function getPromiseAllElements(expression) {
|
|
6
|
+
if (expression.type === 'CallExpression' &&
|
|
7
|
+
expression.callee.type === 'MemberExpression' &&
|
|
8
|
+
!expression.callee.computed &&
|
|
9
|
+
expression.callee.object.type === 'Identifier' &&
|
|
10
|
+
expression.callee.object.name === 'Promise' &&
|
|
11
|
+
expression.callee.property.name === 'all' &&
|
|
12
|
+
expression.arguments[0]?.type === 'ArrayExpression') {
|
|
13
|
+
return expression.arguments[0].elements;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
export function handleVariableDeclarator(node, s) {
|
|
6
17
|
const init = node.init;
|
|
7
18
|
if (!init)
|
|
@@ -16,6 +27,7 @@ export function handleVariableDeclarator(node, s) {
|
|
|
16
27
|
if (importExpr && isStringLiteral(importExpr.source)) {
|
|
17
28
|
s.handledImportExpressions.add(importExpr.start);
|
|
18
29
|
const specifier = getStringValue(importExpr.source);
|
|
30
|
+
const caughtFlag = init.type === 'AwaitExpression' && s.caughtTryBlockEnds.length > 0 ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
19
31
|
if (node.id.type === 'ObjectPattern') {
|
|
20
32
|
for (const prop of node.id.properties) {
|
|
21
33
|
if (prop.type === 'Property') {
|
|
@@ -26,16 +38,16 @@ export function handleVariableDeclarator(node, s) {
|
|
|
26
38
|
: undefined;
|
|
27
39
|
const localName = prop.value?.type === 'Identifier' ? prop.value.name : importedName;
|
|
28
40
|
const alias = localName !== importedName ? localName : undefined;
|
|
29
|
-
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
41
|
+
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
30
42
|
}
|
|
31
43
|
else if (prop.type === 'RestElement' && prop.argument?.type === 'Identifier') {
|
|
32
|
-
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
44
|
+
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
else if (node.id.type === 'Identifier') {
|
|
37
49
|
if (init.type === 'AwaitExpression') {
|
|
38
|
-
s.addImport(specifier, 'default', node.id.name, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
50
|
+
s.addImport(specifier, 'default', node.id.name, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
39
51
|
const resolved = s.resolveModule(specifier, s.filePath);
|
|
40
52
|
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
41
53
|
s.localImportMap.set(node.id.name, {
|
|
@@ -47,11 +59,11 @@ export function handleVariableDeclarator(node, s) {
|
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
else {
|
|
50
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
62
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
else {
|
|
54
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
66
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
55
67
|
}
|
|
56
68
|
return;
|
|
57
69
|
}
|
|
@@ -87,16 +99,8 @@ export function handleVariableDeclarator(node, s) {
|
|
|
87
99
|
}
|
|
88
100
|
return;
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
init.argument.callee.type === 'MemberExpression' &&
|
|
93
|
-
!init.argument.callee.computed &&
|
|
94
|
-
init.argument.callee.object.type === 'Identifier' &&
|
|
95
|
-
init.argument.callee.object.name === 'Promise' &&
|
|
96
|
-
init.argument.callee.property.name === 'all' &&
|
|
97
|
-
init.argument.arguments[0]?.type === 'ArrayExpression' &&
|
|
98
|
-
node.id.type === 'ArrayPattern') {
|
|
99
|
-
const imports = init.argument.arguments[0].elements;
|
|
102
|
+
const imports = init.type === 'AwaitExpression' ? getPromiseAllElements(init.argument) : undefined;
|
|
103
|
+
if (imports && node.id.type === 'ArrayPattern') {
|
|
100
104
|
const bindings = node.id.elements;
|
|
101
105
|
for (let i = 0; i < imports.length; i++) {
|
|
102
106
|
const imp = imports[i];
|
|
@@ -106,6 +110,7 @@ export function handleVariableDeclarator(node, s) {
|
|
|
106
110
|
if (imp?.type === 'ImportExpression' && isStringLiteral(imp.source)) {
|
|
107
111
|
s.handledImportExpressions.add(imp.start);
|
|
108
112
|
const specifier = getStringValue(imp.source);
|
|
113
|
+
const caughtFlag = s.caughtTryBlockEnds.length > 0 ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
109
114
|
if (binding?.type === 'ObjectPattern') {
|
|
110
115
|
for (const prop of binding.properties) {
|
|
111
116
|
if (prop.type === 'Property') {
|
|
@@ -114,12 +119,12 @@ export function handleVariableDeclarator(node, s) {
|
|
|
114
119
|
: prop.key?.type === 'Literal' && typeof prop.key.value === 'string'
|
|
115
120
|
? prop.key.value
|
|
116
121
|
: undefined;
|
|
117
|
-
s.addImport(specifier, importedName, undefined, undefined, prop.key?.start ?? prop.start,
|
|
122
|
+
s.addImport(specifier, importedName, undefined, undefined, prop.key?.start ?? prop.start, caughtFlag);
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
else if (binding?.type === 'Identifier') {
|
|
122
|
-
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
127
|
+
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
123
128
|
const resolved = s.resolveModule(specifier, s.filePath);
|
|
124
129
|
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
125
130
|
s.localImportMap.set(binding.name, {
|
|
@@ -131,7 +136,7 @@ export function handleVariableDeclarator(node, s) {
|
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
else {
|
|
134
|
-
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.SIDE_EFFECTS);
|
|
139
|
+
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.SIDE_EFFECTS | caughtFlag);
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
}
|
|
@@ -268,6 +273,7 @@ export function handleImportExpression(node, s) {
|
|
|
268
273
|
return;
|
|
269
274
|
const specifier = getStringValue(node.source);
|
|
270
275
|
if (specifier) {
|
|
271
|
-
s.
|
|
276
|
+
const caughtFlag = s.caughtImportExpressions.has(node.start) ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
277
|
+
s.addImport(specifier, undefined, undefined, undefined, node.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
272
278
|
}
|
|
273
279
|
}
|
|
@@ -2,6 +2,7 @@ import { OPAQUE } from '../../constants.js';
|
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
3
|
import { getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
4
4
|
import { isShadowed } from './walk.js';
|
|
5
|
+
const chainNames = [];
|
|
5
6
|
function markWholeObjectRead(internalImport, id) {
|
|
6
7
|
(internalImport.enumerated ??= new Set()).add(id);
|
|
7
8
|
}
|
|
@@ -9,7 +10,10 @@ function isNumericKey(value) {
|
|
|
9
10
|
return value != null && Number.isFinite(Number(value)) && String(Number(value)) === value;
|
|
10
11
|
}
|
|
11
12
|
export function handleMemberExpression(node, s) {
|
|
12
|
-
if (node.object.type === 'MemberExpression' &&
|
|
13
|
+
if (node.object.type === 'MemberExpression' &&
|
|
14
|
+
node.object.object.type === 'MemberExpression' &&
|
|
15
|
+
!node.computed &&
|
|
16
|
+
node.property.type === 'Identifier') {
|
|
13
17
|
s.chainedMemberExprs.add(node.object);
|
|
14
18
|
}
|
|
15
19
|
if (node.object.type === 'Identifier') {
|
|
@@ -143,34 +147,27 @@ export function handleMemberExpression(node, s) {
|
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
if (node.object.type === 'MemberExpression' &&
|
|
146
|
-
!node.object.computed &&
|
|
147
150
|
node.object.object.type === 'MemberExpression' &&
|
|
148
|
-
!
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!isShadowed(
|
|
156
|
-
const _import = s.localImportMap.get(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
151
|
+
!s.chainedMemberExprs.has(node)) {
|
|
152
|
+
chainNames.length = 0;
|
|
153
|
+
let root = node;
|
|
154
|
+
while (root.type === 'MemberExpression' && !root.computed && root.property.type === 'Identifier') {
|
|
155
|
+
chainNames.push(root.property.name);
|
|
156
|
+
root = root.object;
|
|
157
|
+
}
|
|
158
|
+
if (root.type === 'Identifier' && !isShadowed(root.name, root.start)) {
|
|
159
|
+
const _import = s.localImportMap.get(root.name);
|
|
160
|
+
const internalImport = _import && s.internal.get(_import.filePath);
|
|
161
|
+
if (internalImport || !_import) {
|
|
162
|
+
let path = '';
|
|
163
|
+
for (let i = chainNames.length - 1; i >= 0; i--) {
|
|
164
|
+
path = path ? `${path}.${chainNames[i]}` : chainNames[i];
|
|
165
|
+
if (internalImport)
|
|
166
|
+
s.addNsMemberRefs(internalImport, root.name, path);
|
|
167
|
+
else
|
|
168
|
+
s.memberRefsInFile.push(root.name, path);
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
|
-
else {
|
|
169
|
-
const a = node.object.object.property.name;
|
|
170
|
-
const b = node.object.property.name;
|
|
171
|
-
const c = node.property.name;
|
|
172
|
-
s.memberRefsInFile.push(rootName, a, rootName, `${a}.${b}`, rootName, `${a}.${b}.${c}`);
|
|
173
|
-
}
|
|
174
171
|
}
|
|
175
172
|
}
|
|
176
173
|
if (node.object.type === 'MemberExpression' &&
|
|
@@ -44,6 +44,7 @@ interface WalkContext {
|
|
|
44
44
|
programFiles: Set<string>;
|
|
45
45
|
entryFiles: Set<string>;
|
|
46
46
|
handledImportExpressions: Set<number>;
|
|
47
|
+
caughtImportExpressions: Set<number>;
|
|
47
48
|
visitor: Visitor;
|
|
48
49
|
getJSDocTags: (nodeStart: number) => Set<string>;
|
|
49
50
|
}
|
|
@@ -53,6 +54,8 @@ export interface WalkState extends WalkContext {
|
|
|
53
54
|
isJS: boolean;
|
|
54
55
|
isModuleFile: boolean;
|
|
55
56
|
handledImportExpressions: Set<number>;
|
|
57
|
+
caughtTryBlockEnds: number[];
|
|
58
|
+
functionCaughtTryBlockEnds: number[][];
|
|
56
59
|
bareExprRefs: Set<string>;
|
|
57
60
|
accessedAliases: Set<string>;
|
|
58
61
|
nsContainers: Map<string, Map<string, string>>;
|
|
@@ -7,7 +7,7 @@ import { collectAugmentationRefs, getLineAndCol, getStringValue, isStringLiteral
|
|
|
7
7
|
import { EMPTY_TAGS } from './jsdoc.js';
|
|
8
8
|
import { handleCallExpression, handleNewExpression, trackCustomElementRegistry } from './calls.js';
|
|
9
9
|
import { handleExportAssignment, handleExportDefault, handleExportNamed, handleExpressionStatement, } from './exports.js';
|
|
10
|
-
import { handleImportExpression, handleVariableDeclarator } from './imports.js';
|
|
10
|
+
import { getPromiseAllElements, handleImportExpression, handleVariableDeclarator } from './imports.js';
|
|
11
11
|
import { handleJSXMemberExpression, handleMemberExpression } from './members.js';
|
|
12
12
|
let state;
|
|
13
13
|
const _getFix = (start, end, flags) => state.options.isFixExports ? [start, end, flags ?? FIX_FLAGS.NONE] : undefined;
|
|
@@ -267,8 +267,10 @@ const coreVisitorObject = {
|
|
|
267
267
|
state.scopeEnds[state.scopeDepth] = node.end;
|
|
268
268
|
state.scopeDepth++;
|
|
269
269
|
},
|
|
270
|
-
'BlockStatement:exit'() {
|
|
270
|
+
'BlockStatement:exit'(node) {
|
|
271
271
|
state.scopeDepth--;
|
|
272
|
+
if (state.caughtTryBlockEnds[state.caughtTryBlockEnds.length - 1] === node.end)
|
|
273
|
+
state.caughtTryBlockEnds.pop();
|
|
272
274
|
},
|
|
273
275
|
TSModuleDeclaration(node) {
|
|
274
276
|
state.nsRanges.push([node.start, node.end]);
|
|
@@ -319,6 +321,8 @@ const coreVisitorObject = {
|
|
|
319
321
|
state.staticBlockDepth--;
|
|
320
322
|
},
|
|
321
323
|
FunctionDeclaration(node) {
|
|
324
|
+
state.functionCaughtTryBlockEnds.push(state.caughtTryBlockEnds);
|
|
325
|
+
state.caughtTryBlockEnds = [];
|
|
322
326
|
if (node.id?.name) {
|
|
323
327
|
state.localDeclarationTypes.set(node.id.name, SYMBOL_TYPE.FUNCTION);
|
|
324
328
|
state.localDeclarations.set(node.id.name, node);
|
|
@@ -327,12 +331,25 @@ const coreVisitorObject = {
|
|
|
327
331
|
}
|
|
328
332
|
_addParamShadows(node.params, node.body);
|
|
329
333
|
},
|
|
334
|
+
'FunctionDeclaration:exit'() {
|
|
335
|
+
state.caughtTryBlockEnds = state.functionCaughtTryBlockEnds.pop();
|
|
336
|
+
},
|
|
330
337
|
FunctionExpression(node) {
|
|
338
|
+
state.functionCaughtTryBlockEnds.push(state.caughtTryBlockEnds);
|
|
339
|
+
state.caughtTryBlockEnds = [];
|
|
331
340
|
_addParamShadows(node.params, node.body);
|
|
332
341
|
},
|
|
342
|
+
'FunctionExpression:exit'() {
|
|
343
|
+
state.caughtTryBlockEnds = state.functionCaughtTryBlockEnds.pop();
|
|
344
|
+
},
|
|
333
345
|
ArrowFunctionExpression(node) {
|
|
346
|
+
state.functionCaughtTryBlockEnds.push(state.caughtTryBlockEnds);
|
|
347
|
+
state.caughtTryBlockEnds = [];
|
|
334
348
|
_addParamShadows(node.params, node.body);
|
|
335
349
|
},
|
|
350
|
+
'ArrowFunctionExpression:exit'() {
|
|
351
|
+
state.caughtTryBlockEnds = state.functionCaughtTryBlockEnds.pop();
|
|
352
|
+
},
|
|
336
353
|
CatchClause(node) {
|
|
337
354
|
if (node.param?.type === 'Identifier' && node.body) {
|
|
338
355
|
_addShadowRange(node.param.name, [node.body.start, node.body.end]);
|
|
@@ -380,6 +397,27 @@ const coreVisitorObject = {
|
|
|
380
397
|
ImportExpression(node) {
|
|
381
398
|
handleImportExpression(node, state);
|
|
382
399
|
},
|
|
400
|
+
TryStatement(node) {
|
|
401
|
+
if (node.handler)
|
|
402
|
+
state.caughtTryBlockEnds.push(node.block.end);
|
|
403
|
+
},
|
|
404
|
+
AwaitExpression(node) {
|
|
405
|
+
if (state.caughtTryBlockEnds.length === 0)
|
|
406
|
+
return;
|
|
407
|
+
const { argument } = node;
|
|
408
|
+
if (argument.type === 'ImportExpression') {
|
|
409
|
+
state.caughtImportExpressions.add(argument.start);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
const elements = getPromiseAllElements(argument);
|
|
413
|
+
if (!elements)
|
|
414
|
+
return;
|
|
415
|
+
for (const element of elements) {
|
|
416
|
+
if (element?.type === 'ImportExpression')
|
|
417
|
+
state.caughtImportExpressions.add(element.start);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
},
|
|
383
421
|
CallExpression(node) {
|
|
384
422
|
handleCallExpression(node, state);
|
|
385
423
|
},
|
|
@@ -833,6 +871,8 @@ function walkAST(program, sourceText, filePath, hasModuleSyntax, ctx) {
|
|
|
833
871
|
localToExports: new Map(),
|
|
834
872
|
customElementRegistries: new Set(),
|
|
835
873
|
classNameStack: [],
|
|
874
|
+
caughtTryBlockEnds: [],
|
|
875
|
+
functionCaughtTryBlockEnds: [],
|
|
836
876
|
staticBlockDepth: 0,
|
|
837
877
|
addExport: _addExport,
|
|
838
878
|
getFix: _getFix,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -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 Include 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,catalogReferences\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, catalogReferences, 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, sarif\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 Include 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,catalogReferences\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 --output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated\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, catalogReferences, 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, sarif\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 --reporter symbols --reporter json --output-file json=knip.json\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
|
|
2
2
|
export type ParsedCLIArgs = ReturnType<typeof parseCLIArgs>;
|
|
3
3
|
export declare const parseNumericOption: (value: string | undefined, option: string) => number | undefined;
|
|
4
4
|
export default function parseCLIArgs(): {
|
|
@@ -29,6 +29,7 @@ export default function parseCLIArgs(): {
|
|
|
29
29
|
'no-gitignore'?: boolean | undefined;
|
|
30
30
|
'no-progress'?: boolean | undefined;
|
|
31
31
|
'no-tag-hints'?: boolean | undefined;
|
|
32
|
+
'output-file'?: string[] | undefined;
|
|
32
33
|
performance?: boolean | undefined;
|
|
33
34
|
'performance-fn'?: string | undefined;
|
|
34
35
|
production?: boolean | undefined;
|
|
@@ -44,6 +44,7 @@ Output
|
|
|
44
44
|
--preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)
|
|
45
45
|
--reporter Select reporter (default: symbols), can be repeated (3)
|
|
46
46
|
--reporter-options Pass extra options to the reporter (as JSON string, see example)
|
|
47
|
+
--output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated
|
|
47
48
|
--no-config-hints Suppress configuration hints
|
|
48
49
|
--no-tag-hints Suppress tag hints
|
|
49
50
|
--treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints
|
|
@@ -77,6 +78,7 @@ $ knip --workspace @myorg/* --workspace '!@myorg/legacy'
|
|
|
77
78
|
$ knip --workspace './apps/*' --workspace '@shared/utils'
|
|
78
79
|
$ knip -c ./config/knip.json --reporter compact
|
|
79
80
|
$ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
|
|
81
|
+
$ knip --reporter symbols --reporter json --output-file json=knip.json
|
|
80
82
|
$ knip --tags=-lintignore
|
|
81
83
|
|
|
82
84
|
Website: https://knip.dev`;
|
|
@@ -118,6 +120,7 @@ export default function parseCLIArgs() {
|
|
|
118
120
|
'no-gitignore': { type: 'boolean' },
|
|
119
121
|
'no-progress': { type: 'boolean', short: 'n' },
|
|
120
122
|
'no-tag-hints': { type: 'boolean' },
|
|
123
|
+
'output-file': { type: 'string', multiple: true },
|
|
121
124
|
performance: { type: 'boolean' },
|
|
122
125
|
'performance-fn': { type: 'string' },
|
|
123
126
|
production: { type: 'boolean', short: 'p' },
|
|
@@ -60,7 +60,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
60
60
|
isDevOnly: isConfig(input),
|
|
61
61
|
isTypeOnly: input.isTypeOnly,
|
|
62
62
|
});
|
|
63
|
-
if (input.
|
|
63
|
+
if (input.alsoReferenceOwner && input.containingFilePath) {
|
|
64
64
|
const owningWorkspace = chief.findWorkspaceByFilePath(input.containingFilePath);
|
|
65
65
|
if (owningWorkspace && owningWorkspace !== inputWorkspace) {
|
|
66
66
|
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owningWorkspace, packageName, {
|
|
@@ -4,8 +4,9 @@ interface CreateOptions extends Partial<Options> {
|
|
|
4
4
|
args?: ParsedCLIArgs;
|
|
5
5
|
}
|
|
6
6
|
export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
7
|
+
createdFrom: CreateOptions;
|
|
7
8
|
cacheLocation: string;
|
|
8
|
-
catalog: import("../CatalogCounselor.ts").CatalogContainer;
|
|
9
|
+
catalog: import("../CatalogCounselor.ts").CatalogContainer[];
|
|
9
10
|
config: string | undefined;
|
|
10
11
|
configFilePath: string | undefined;
|
|
11
12
|
cwd: string;
|
|
@@ -326,6 +327,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
326
327
|
entry?: string | string[] | undefined;
|
|
327
328
|
project?: string | string[] | undefined;
|
|
328
329
|
} | undefined;
|
|
330
|
+
'kysely-codegen'?: string | boolean | string[] | {
|
|
331
|
+
config?: string | string[] | undefined;
|
|
332
|
+
entry?: string | string[] | undefined;
|
|
333
|
+
project?: string | string[] | undefined;
|
|
334
|
+
} | undefined;
|
|
329
335
|
ladle?: string | boolean | string[] | {
|
|
330
336
|
config?: string | string[] | undefined;
|
|
331
337
|
entry?: string | string[] | undefined;
|
|
@@ -341,6 +347,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
341
347
|
entry?: string | string[] | undefined;
|
|
342
348
|
project?: string | string[] | undefined;
|
|
343
349
|
} | undefined;
|
|
350
|
+
lingui?: string | boolean | string[] | {
|
|
351
|
+
config?: string | string[] | undefined;
|
|
352
|
+
entry?: string | string[] | undefined;
|
|
353
|
+
project?: string | string[] | undefined;
|
|
354
|
+
} | undefined;
|
|
344
355
|
'lint-staged'?: string | boolean | string[] | {
|
|
345
356
|
config?: string | string[] | undefined;
|
|
346
357
|
entry?: string | string[] | undefined;
|
|
@@ -381,6 +392,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
381
392
|
entry?: string | string[] | undefined;
|
|
382
393
|
project?: string | string[] | undefined;
|
|
383
394
|
} | undefined;
|
|
395
|
+
mastra?: string | boolean | string[] | {
|
|
396
|
+
config?: string | string[] | undefined;
|
|
397
|
+
entry?: string | string[] | undefined;
|
|
398
|
+
project?: string | string[] | undefined;
|
|
399
|
+
} | undefined;
|
|
384
400
|
mcp?: string | boolean | string[] | {
|
|
385
401
|
config?: string | string[] | undefined;
|
|
386
402
|
entry?: string | string[] | undefined;
|
|
@@ -611,6 +627,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
611
627
|
entry?: string | string[] | undefined;
|
|
612
628
|
project?: string | string[] | undefined;
|
|
613
629
|
} | undefined;
|
|
630
|
+
purgecss?: string | boolean | string[] | {
|
|
631
|
+
config?: string | string[] | undefined;
|
|
632
|
+
entry?: string | string[] | undefined;
|
|
633
|
+
project?: string | string[] | undefined;
|
|
634
|
+
} | undefined;
|
|
614
635
|
quasar?: string | boolean | string[] | {
|
|
615
636
|
config?: string | string[] | undefined;
|
|
616
637
|
entry?: string | string[] | undefined;
|
|
@@ -1348,6 +1369,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1348
1369
|
entry?: string | string[] | undefined;
|
|
1349
1370
|
project?: string | string[] | undefined;
|
|
1350
1371
|
} | undefined;
|
|
1372
|
+
'kysely-codegen'?: string | boolean | string[] | {
|
|
1373
|
+
config?: string | string[] | undefined;
|
|
1374
|
+
entry?: string | string[] | undefined;
|
|
1375
|
+
project?: string | string[] | undefined;
|
|
1376
|
+
} | undefined;
|
|
1351
1377
|
ladle?: string | boolean | string[] | {
|
|
1352
1378
|
config?: string | string[] | undefined;
|
|
1353
1379
|
entry?: string | string[] | undefined;
|
|
@@ -1363,6 +1389,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1363
1389
|
entry?: string | string[] | undefined;
|
|
1364
1390
|
project?: string | string[] | undefined;
|
|
1365
1391
|
} | undefined;
|
|
1392
|
+
lingui?: string | boolean | string[] | {
|
|
1393
|
+
config?: string | string[] | undefined;
|
|
1394
|
+
entry?: string | string[] | undefined;
|
|
1395
|
+
project?: string | string[] | undefined;
|
|
1396
|
+
} | undefined;
|
|
1366
1397
|
'lint-staged'?: string | boolean | string[] | {
|
|
1367
1398
|
config?: string | string[] | undefined;
|
|
1368
1399
|
entry?: string | string[] | undefined;
|
|
@@ -1403,6 +1434,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1403
1434
|
entry?: string | string[] | undefined;
|
|
1404
1435
|
project?: string | string[] | undefined;
|
|
1405
1436
|
} | undefined;
|
|
1437
|
+
mastra?: string | boolean | string[] | {
|
|
1438
|
+
config?: string | string[] | undefined;
|
|
1439
|
+
entry?: string | string[] | undefined;
|
|
1440
|
+
project?: string | string[] | undefined;
|
|
1441
|
+
} | undefined;
|
|
1406
1442
|
mcp?: string | boolean | string[] | {
|
|
1407
1443
|
config?: string | string[] | undefined;
|
|
1408
1444
|
entry?: string | string[] | undefined;
|
|
@@ -1633,6 +1669,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1633
1669
|
entry?: string | string[] | undefined;
|
|
1634
1670
|
project?: string | string[] | undefined;
|
|
1635
1671
|
} | undefined;
|
|
1672
|
+
purgecss?: string | boolean | string[] | {
|
|
1673
|
+
config?: string | string[] | undefined;
|
|
1674
|
+
entry?: string | string[] | undefined;
|
|
1675
|
+
project?: string | string[] | undefined;
|
|
1676
|
+
} | undefined;
|
|
1636
1677
|
quasar?: string | boolean | string[] | {
|
|
1637
1678
|
config?: string | string[] | undefined;
|
|
1638
1679
|
entry?: string | string[] | undefined;
|
|
@@ -60,6 +60,16 @@ export const createOptions = async (options) => {
|
|
|
60
60
|
configFilePath = manifestPath;
|
|
61
61
|
const pnpmWorkspacePath = findFile(cwd, 'pnpm-workspace.yaml');
|
|
62
62
|
const pnpmWorkspace = pnpmWorkspacePath && (await _load(pnpmWorkspacePath));
|
|
63
|
+
const catalog = [await getCatalogContainer(cwd, manifest, manifestPath, pnpmWorkspacePath, pnpmWorkspace)];
|
|
64
|
+
for (const source in pnpmWorkspace?.include) {
|
|
65
|
+
if (!source.startsWith('.'))
|
|
66
|
+
continue;
|
|
67
|
+
const filePath = join(cwd, source);
|
|
68
|
+
const included = await _load(filePath);
|
|
69
|
+
if (!included)
|
|
70
|
+
continue;
|
|
71
|
+
catalog.push({ filePath, catalog: included.catalog, catalogs: included.catalogs, overrides: included.overrides });
|
|
72
|
+
}
|
|
63
73
|
const workspaces = pnpmWorkspace?.packages ??
|
|
64
74
|
(manifest.workspaces
|
|
65
75
|
? Array.isArray(manifest.workspaces)
|
|
@@ -102,8 +112,9 @@ export const createOptions = async (options) => {
|
|
|
102
112
|
const preprocessorOptions = args['preprocessor-options'] ??
|
|
103
113
|
(parsedConfig.preprocessorOptions ? JSON.stringify(parsedConfig.preprocessorOptions) : '');
|
|
104
114
|
return {
|
|
115
|
+
createdFrom: options,
|
|
105
116
|
cacheLocation: args['cache-location'] ?? join(cwd, 'node_modules', '.cache', 'knip'),
|
|
106
|
-
catalog
|
|
117
|
+
catalog,
|
|
107
118
|
config: args.config,
|
|
108
119
|
configFilePath,
|
|
109
120
|
cwd,
|
|
@@ -145,7 +156,7 @@ export const createOptions = async (options) => {
|
|
|
145
156
|
includedIssueTypes.enumMembers ||
|
|
146
157
|
includedIssueTypes.namespaceMembers,
|
|
147
158
|
isReportValues: includedIssueTypes.exports || includedIssueTypes.nsExports,
|
|
148
|
-
isSession: options.isSession ?? false,
|
|
159
|
+
isSession: options.isSession ?? args.watch ?? options.isWatch ?? false,
|
|
149
160
|
isShowProgress: !isDebug &&
|
|
150
161
|
!isTrace &&
|
|
151
162
|
args['no-progress'] !== true &&
|
|
@@ -14,8 +14,10 @@ export declare class FileEntryCache<T> {
|
|
|
14
14
|
filePath: string;
|
|
15
15
|
cache: Map<string, MetaData<T>>;
|
|
16
16
|
normalizedEntries: Map<string, FileDescriptor<T>>;
|
|
17
|
+
private isDirty;
|
|
17
18
|
constructor(cacheId: string, _path: string);
|
|
18
19
|
getFileDescriptor(filePath: string): FileDescriptor<T>;
|
|
20
|
+
setFileData(filePath: string, data: T): void;
|
|
19
21
|
removeEntry(entryName: string): void;
|
|
20
22
|
reconcile(): void;
|
|
21
23
|
}
|