knip 5.36.5 → 5.36.7
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 +5 -5
- package/dist/ConfigurationValidator.d.ts +224 -125
- package/dist/ConfigurationValidator.js +1 -95
- package/dist/compilers/index.d.ts +52 -32
- package/dist/schema/plugins.d.ts +1974 -0
- package/dist/schema/plugins.js +98 -0
- package/dist/types/config.d.ts +4 -3
- package/dist/typescript/ast-helpers.js +5 -14
- package/dist/typescript/find-internal-references.js +0 -2
- package/dist/typescript/get-imports-and-exports.js +1 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const globSchema = z.union([z.string(), z.array(z.string())]);
|
|
3
|
+
export const pluginSchema = z.union([
|
|
4
|
+
z.boolean(),
|
|
5
|
+
globSchema,
|
|
6
|
+
z.object({
|
|
7
|
+
config: globSchema.optional(),
|
|
8
|
+
entry: globSchema.optional(),
|
|
9
|
+
project: globSchema.optional(),
|
|
10
|
+
}),
|
|
11
|
+
]);
|
|
12
|
+
export const pluginsSchema = z.object({
|
|
13
|
+
angular: pluginSchema,
|
|
14
|
+
astro: pluginSchema,
|
|
15
|
+
ava: pluginSchema,
|
|
16
|
+
babel: pluginSchema,
|
|
17
|
+
c8: pluginSchema,
|
|
18
|
+
capacitor: pluginSchema,
|
|
19
|
+
changesets: pluginSchema,
|
|
20
|
+
commitizen: pluginSchema,
|
|
21
|
+
commitlint: pluginSchema,
|
|
22
|
+
cspell: pluginSchema,
|
|
23
|
+
cucumber: pluginSchema,
|
|
24
|
+
cypress: pluginSchema,
|
|
25
|
+
dotenv: pluginSchema,
|
|
26
|
+
drizzle: pluginSchema,
|
|
27
|
+
eleventy: pluginSchema,
|
|
28
|
+
eslint: pluginSchema,
|
|
29
|
+
gatsby: pluginSchema,
|
|
30
|
+
'github-actions': pluginSchema,
|
|
31
|
+
glob: pluginSchema,
|
|
32
|
+
'graphql-codegen': pluginSchema,
|
|
33
|
+
husky: pluginSchema,
|
|
34
|
+
jest: pluginSchema,
|
|
35
|
+
ladle: pluginSchema,
|
|
36
|
+
lefthook: pluginSchema,
|
|
37
|
+
'lint-staged': pluginSchema,
|
|
38
|
+
linthtml: pluginSchema,
|
|
39
|
+
'lockfile-lint': pluginSchema,
|
|
40
|
+
'lost-pixel': pluginSchema,
|
|
41
|
+
markdownlint: pluginSchema,
|
|
42
|
+
mocha: pluginSchema,
|
|
43
|
+
moonrepo: pluginSchema,
|
|
44
|
+
msw: pluginSchema,
|
|
45
|
+
nest: pluginSchema,
|
|
46
|
+
netlify: pluginSchema,
|
|
47
|
+
next: pluginSchema,
|
|
48
|
+
node: pluginSchema,
|
|
49
|
+
'node-test-runner': pluginSchema,
|
|
50
|
+
nodemon: pluginSchema,
|
|
51
|
+
'npm-package-json-lint': pluginSchema,
|
|
52
|
+
nuxt: pluginSchema,
|
|
53
|
+
nx: pluginSchema,
|
|
54
|
+
nyc: pluginSchema,
|
|
55
|
+
oclif: pluginSchema,
|
|
56
|
+
playwright: pluginSchema,
|
|
57
|
+
'playwright-ct': pluginSchema,
|
|
58
|
+
'playwright-test': pluginSchema,
|
|
59
|
+
postcss: pluginSchema,
|
|
60
|
+
preconstruct: pluginSchema,
|
|
61
|
+
prettier: pluginSchema,
|
|
62
|
+
'react-cosmos': pluginSchema,
|
|
63
|
+
'release-it': pluginSchema,
|
|
64
|
+
remark: pluginSchema,
|
|
65
|
+
remix: pluginSchema,
|
|
66
|
+
rollup: pluginSchema,
|
|
67
|
+
rsbuild: pluginSchema,
|
|
68
|
+
rspack: pluginSchema,
|
|
69
|
+
'semantic-release': pluginSchema,
|
|
70
|
+
sentry: pluginSchema,
|
|
71
|
+
'simple-git-hooks': pluginSchema,
|
|
72
|
+
'size-limit': pluginSchema,
|
|
73
|
+
storybook: pluginSchema,
|
|
74
|
+
stryker: pluginSchema,
|
|
75
|
+
stylelint: pluginSchema,
|
|
76
|
+
svelte: pluginSchema,
|
|
77
|
+
syncpack: pluginSchema,
|
|
78
|
+
tailwind: pluginSchema,
|
|
79
|
+
travis: pluginSchema,
|
|
80
|
+
'ts-node': pluginSchema,
|
|
81
|
+
tsup: pluginSchema,
|
|
82
|
+
tsx: pluginSchema,
|
|
83
|
+
typedoc: pluginSchema,
|
|
84
|
+
typescript: pluginSchema,
|
|
85
|
+
unbuild: pluginSchema,
|
|
86
|
+
unocss: pluginSchema,
|
|
87
|
+
'vercel-og': pluginSchema,
|
|
88
|
+
vike: pluginSchema,
|
|
89
|
+
vite: pluginSchema,
|
|
90
|
+
vitest: pluginSchema,
|
|
91
|
+
vue: pluginSchema,
|
|
92
|
+
'webdriver-io': pluginSchema,
|
|
93
|
+
webpack: pluginSchema,
|
|
94
|
+
wireit: pluginSchema,
|
|
95
|
+
wrangler: pluginSchema,
|
|
96
|
+
xo: pluginSchema,
|
|
97
|
+
yorkie: pluginSchema,
|
|
98
|
+
});
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { ConfigurationValidator
|
|
2
|
+
import type { ConfigurationValidator } from '../ConfigurationValidator.js';
|
|
3
3
|
import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
|
|
4
|
+
import type { pluginSchema } from '../schema/plugins.js';
|
|
4
5
|
import type { Input } from '../util/input.js';
|
|
5
6
|
import type { PluginName } from './PluginNames.js';
|
|
6
7
|
import type { Args } from './args.js';
|
|
@@ -22,7 +23,7 @@ export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
|
|
|
22
23
|
export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
|
|
23
24
|
export type IgnorePatterns = (string | RegExp)[];
|
|
24
25
|
type IgnorableExport = 'class' | 'enum' | 'function' | 'interface' | 'member' | 'type';
|
|
25
|
-
|
|
26
|
+
type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
26
27
|
export type GetImportsAndExportsOptions = {
|
|
27
28
|
skipTypeOnly: boolean;
|
|
28
29
|
skipExports: boolean;
|
|
@@ -47,7 +48,7 @@ export interface Configuration {
|
|
|
47
48
|
asyncCompilers: AsyncCompilers;
|
|
48
49
|
rootPluginConfigs: Partial<PluginsConfiguration>;
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
type NormalizedGlob = string[];
|
|
51
52
|
export type EnsuredPluginConfiguration = {
|
|
52
53
|
config: NormalizedGlob | null;
|
|
53
54
|
entry: NormalizedGlob | null;
|
|
@@ -159,26 +159,17 @@ export const isImportSpecifier = (node) => ts.isImportSpecifier(node.parent) ||
|
|
|
159
159
|
ts.isImportEqualsDeclaration(node.parent) ||
|
|
160
160
|
ts.isImportClause(node.parent) ||
|
|
161
161
|
ts.isNamespaceImport(node.parent);
|
|
162
|
-
const
|
|
162
|
+
const isInExportedNode = (node) => {
|
|
163
163
|
if (getExportKeywordNode(node))
|
|
164
164
|
return true;
|
|
165
|
-
return node.parent ?
|
|
166
|
-
};
|
|
167
|
-
const isTypeDeclaration = (node) => ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node);
|
|
168
|
-
const getAncestorTypeDeclaration = (node) => {
|
|
169
|
-
while (node) {
|
|
170
|
-
if (isTypeDeclaration(node))
|
|
171
|
-
return node;
|
|
172
|
-
node = node.parent;
|
|
173
|
-
}
|
|
165
|
+
return node.parent ? isInExportedNode(node.parent) : false;
|
|
174
166
|
};
|
|
175
167
|
export const isReferencedInExport = (node) => {
|
|
176
|
-
if (ts.isTypeQueryNode(node.parent) &&
|
|
168
|
+
if (ts.isTypeQueryNode(node.parent) && isInExportedNode(node.parent.parent))
|
|
177
169
|
return true;
|
|
178
|
-
if (ts.isTypeReferenceNode(node.parent) &&
|
|
170
|
+
if (ts.isTypeReferenceNode(node.parent) && isInExportedNode(node.parent.parent))
|
|
179
171
|
return true;
|
|
180
|
-
|
|
181
|
-
return Boolean(typeNode && isExported(typeNode));
|
|
172
|
+
return false;
|
|
182
173
|
};
|
|
183
174
|
export const getExportKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
|
|
184
175
|
export const getDefaultKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.DefaultKeyword);
|
|
@@ -25,8 +25,6 @@ export const findInternalReferences = (item, sourceFile, typeChecker, referenced
|
|
|
25
25
|
isSymbolInExport = true;
|
|
26
26
|
if (item.symbol === symbol) {
|
|
27
27
|
refCount++;
|
|
28
|
-
if (isInExport || isType(item))
|
|
29
|
-
return [refCount, isSymbolInExport];
|
|
30
28
|
if (isBindingElement)
|
|
31
29
|
return [refCount, true];
|
|
32
30
|
}
|
|
@@ -308,7 +308,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
308
308
|
for (const node of pragmaImports)
|
|
309
309
|
addImport(node, sourceFile);
|
|
310
310
|
for (const item of exports.values()) {
|
|
311
|
-
if (item.symbol && referencedSymbolsInExport.has(item.symbol)) {
|
|
311
|
+
if (!isType(item) && item.symbol && referencedSymbolsInExport.has(item.symbol)) {
|
|
312
312
|
item.refs = [1, true];
|
|
313
313
|
}
|
|
314
314
|
else {
|
|
@@ -317,7 +317,6 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
317
317
|
(typeof ignoreExportsUsedInFile === 'object' &&
|
|
318
318
|
item.type !== 'unknown' &&
|
|
319
319
|
ignoreExportsUsedInFile[item.type]) ||
|
|
320
|
-
isType(item) ||
|
|
321
320
|
isBindingElement) {
|
|
322
321
|
item.refs = findInternalReferences(item, sourceFile, typeChecker, referencedSymbolsInExport, isBindingElement);
|
|
323
322
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.36.
|
|
1
|
+
export declare const version = "5.36.7";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.36.
|
|
1
|
+
export const version = '5.36.7';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.36.
|
|
3
|
+
"version": "5.36.7",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"release": "release-it",
|
|
50
50
|
"create-plugin": "bun ./scripts/create-new-plugin.ts",
|
|
51
51
|
"postcreate-plugin": "biome format --write schema.json schema-jsonc.json src/ConfigurationValidator.ts",
|
|
52
|
-
"generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && biome check --write src/plugins/index.ts src/types/PluginNames.ts"
|
|
52
|
+
"generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && biome check --write src/plugins/index.ts src/types/PluginNames.ts src/schema/plugins.ts"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist",
|