knip 2.24.1 → 2.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/ProjectPrincipal.js +1 -1
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +1 -0
- package/dist/binaries/resolvers/nx.d.ts +2 -0
- package/dist/binaries/resolvers/nx.js +9 -0
- package/dist/index.js +2 -2
- package/dist/plugins/jest/index.js +2 -1
- package/dist/plugins/typescript/index.js +3 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/typescript/ast-helpers.d.ts +1 -1
- package/dist/typescript/ast-helpers.js +9 -1
- package/dist/typescript/getImportsAndExports.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -178,7 +178,7 @@ export class ProjectPrincipal {
|
|
|
178
178
|
findUnusedMembers(filePath, members) {
|
|
179
179
|
return members
|
|
180
180
|
.filter(member => {
|
|
181
|
-
if (getJSDocTags(member.node).
|
|
181
|
+
if (getJSDocTags(member.node).has('@public'))
|
|
182
182
|
return false;
|
|
183
183
|
const referencedSymbols = this.findReferences(filePath, member.pos);
|
|
184
184
|
const files = referencedSymbols
|
|
@@ -3,6 +3,7 @@ export * as dotenv from './dotenv.js';
|
|
|
3
3
|
export * as node from './node.js';
|
|
4
4
|
export * as nodemon from './nodemon.js';
|
|
5
5
|
export * as npx from './npx.js';
|
|
6
|
+
export * as nx from './nx.js';
|
|
6
7
|
export * as pnpm from './pnpm.js';
|
|
7
8
|
export * as rollup from './rollup.js';
|
|
8
9
|
export * as yarn from './yarn.js';
|
|
@@ -3,6 +3,7 @@ export * as dotenv from './dotenv.js';
|
|
|
3
3
|
export * as node from './node.js';
|
|
4
4
|
export * as nodemon from './nodemon.js';
|
|
5
5
|
export * as npx from './npx.js';
|
|
6
|
+
export * as nx from './nx.js';
|
|
6
7
|
export * as pnpm from './pnpm.js';
|
|
7
8
|
export * as rollup from './rollup.js';
|
|
8
9
|
export * as yarn from './yarn.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import parseArgs from 'minimist';
|
|
2
|
+
import { toBinary } from '../util.js';
|
|
3
|
+
export const resolve = (binary, args, { fromArgs }) => {
|
|
4
|
+
const parsed = parseArgs(args);
|
|
5
|
+
const [command] = parsed._;
|
|
6
|
+
if (command === 'exec')
|
|
7
|
+
return [toBinary(binary), ...fromArgs(parsed._.slice(1))];
|
|
8
|
+
return [toBinary(binary)];
|
|
9
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -278,9 +278,9 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
278
278
|
continue;
|
|
279
279
|
const importingModule = importedSymbols.get(filePath);
|
|
280
280
|
for (const [symbol, exportedItem] of exportItems.entries()) {
|
|
281
|
-
if (exportedItem.jsDocTags.
|
|
281
|
+
if (exportedItem.jsDocTags.has('@public') || exportedItem.jsDocTags.has('@beta'))
|
|
282
282
|
continue;
|
|
283
|
-
if (isIgnoreInternal && exportedItem.jsDocTags.
|
|
283
|
+
if (isIgnoreInternal && exportedItem.jsDocTags.has('@internal'))
|
|
284
284
|
continue;
|
|
285
285
|
if (importingModule && isSymbolImported(symbol, importingModule)) {
|
|
286
286
|
if (importingModule.isReExport && isExportedInEntryFile(importingModule))
|
|
@@ -62,7 +62,8 @@ const findJestDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
|
62
62
|
config = await config();
|
|
63
63
|
if (!config)
|
|
64
64
|
return [];
|
|
65
|
-
const
|
|
65
|
+
const rootDir = config.rootDir ?? '';
|
|
66
|
+
const replaceRootDir = (name) => name.includes('<rootDir>') ? join(cwd, name.replace(/^.*<rootDir>/, rootDir)) : name;
|
|
66
67
|
return resolveDependencies(config).map(replaceRootDir);
|
|
67
68
|
};
|
|
68
69
|
export const findDependencies = timerify(findJestDependencies);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
1
2
|
import { compact } from '../../util/array.js';
|
|
2
3
|
import { dirname, isInternal, toAbsolute } from '../../util/path.js';
|
|
3
4
|
import { timerify } from '../../util/Performance.js';
|
|
@@ -21,6 +22,7 @@ const resolveExtensibleConfig = async (configFilePath) => {
|
|
|
21
22
|
}
|
|
22
23
|
return config;
|
|
23
24
|
};
|
|
25
|
+
const jsxWithReact = [ts.JsxEmit.React, ts.JsxEmit.ReactJSX, ts.JsxEmit.ReactJSXDev, ts.JsxEmit.ReactNative];
|
|
24
26
|
const findTypeScriptDependencies = async (configFilePath) => {
|
|
25
27
|
const compilerOptions = await loadTSConfig(configFilePath);
|
|
26
28
|
const config = await resolveExtensibleConfig(configFilePath);
|
|
@@ -34,7 +36,7 @@ const findTypeScriptDependencies = async (configFilePath) => {
|
|
|
34
36
|
const importHelpers = compilerOptions?.importHelpers ? ['tslib'] : [];
|
|
35
37
|
const jsx = compilerOptions?.jsxImportSource
|
|
36
38
|
? [compilerOptions.jsxImportSource]
|
|
37
|
-
: compilerOptions?.jsx
|
|
39
|
+
: compilerOptions?.jsx && jsxWithReact.includes(compilerOptions.jsx)
|
|
38
40
|
? ['react']
|
|
39
41
|
: [];
|
|
40
42
|
return compact([...extend, ...types, ...plugins, ...importHelpers, ...jsx]);
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export declare function findAncestor<T>(node: ts.Node | undefined, callback: (el
|
|
|
23
23
|
export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
|
|
24
24
|
export declare const isDeclarationFileExtension: (extension: string) => boolean;
|
|
25
25
|
export declare const isInModuleBlock: (node: ts.Node) => boolean;
|
|
26
|
-
export declare const getJSDocTags: (node: ts.Node) => string
|
|
26
|
+
export declare const getJSDocTags: (node: ts.Node) => Set<string>;
|
|
27
27
|
export {};
|
|
@@ -98,4 +98,12 @@ export const isInModuleBlock = (node) => {
|
|
|
98
98
|
}
|
|
99
99
|
return false;
|
|
100
100
|
};
|
|
101
|
-
export const getJSDocTags = (node) =>
|
|
101
|
+
export const getJSDocTags = (node) => {
|
|
102
|
+
const tags = new Set();
|
|
103
|
+
for (const tagNode of ts.getJSDocTags(node)) {
|
|
104
|
+
const match = tagNode.getText()?.match(/@\S+/);
|
|
105
|
+
if (match)
|
|
106
|
+
tags.add(match[0]);
|
|
107
|
+
}
|
|
108
|
+
return tags;
|
|
109
|
+
};
|
|
@@ -101,13 +101,13 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
101
101
|
if (exports.has(identifier)) {
|
|
102
102
|
const item = exports.get(identifier);
|
|
103
103
|
const crew = [...item.members, ...members];
|
|
104
|
-
const tags = [...item.jsDocTags, ...jsDocTags];
|
|
104
|
+
const tags = new Set([...item.jsDocTags, ...jsDocTags]);
|
|
105
105
|
exports.set(identifier, { ...item, node, type, pos, members: crew, jsDocTags: tags });
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
108
|
exports.set(identifier, { node, type, pos, members, jsDocTags });
|
|
109
109
|
}
|
|
110
|
-
if (!jsDocTags.
|
|
110
|
+
if (!jsDocTags.has('@alias')) {
|
|
111
111
|
if (ts.isExportAssignment(node))
|
|
112
112
|
maybeAddAliasedExport(node.expression, 'default');
|
|
113
113
|
if (ts.isVariableDeclaration(node))
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.25.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.25.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"@npmcli/package-json": "5.0.0",
|
|
66
66
|
"@release-it/bumper": "5.1.0",
|
|
67
67
|
"@swc/cli": "0.1.62",
|
|
68
|
-
"@swc/core": "1.3.
|
|
68
|
+
"@swc/core": "1.3.85",
|
|
69
69
|
"@types/eslint": "8.44.2",
|
|
70
|
-
"@types/js-yaml": "4.0.
|
|
70
|
+
"@types/js-yaml": "4.0.6",
|
|
71
71
|
"@types/micromatch": "4.0.2",
|
|
72
72
|
"@types/minimist": "1.2.2",
|
|
73
|
-
"@types/node": "20.6.
|
|
73
|
+
"@types/node": "20.6.2",
|
|
74
74
|
"@types/npmcli__map-workspaces": "3.0.1",
|
|
75
75
|
"@types/webpack": "5.28.2",
|
|
76
76
|
"@typescript-eslint/eslint-plugin": "6.7.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"release-it": "16.1.5",
|
|
85
85
|
"remark-cli": "11.0.0",
|
|
86
86
|
"remark-preset-webpro": "0.0.3",
|
|
87
|
-
"tsx": "3.12.
|
|
87
|
+
"tsx": "3.12.10",
|
|
88
88
|
"type-fest": "4.3.1"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|