knip 6.5.0 → 6.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.d.ts +8 -3
- package/dist/WorkspaceWorker.d.ts +6 -4
- package/dist/WorkspaceWorker.js +22 -4
- package/dist/binaries/plugins.js +2 -2
- package/dist/binaries/resolvers/bun.js +3 -3
- package/dist/binaries/resolvers/npm.js +2 -2
- package/dist/binaries/resolvers/pnpm.js +2 -2
- package/dist/binaries/resolvers/yarn.js +3 -3
- package/dist/compilers/index.d.ts +10 -0
- package/dist/graph/build.js +24 -14
- package/dist/plugins/astro/index.js +4 -2
- package/dist/plugins/astro/resolveFromAST.d.ts +1 -0
- package/dist/plugins/astro/resolveFromAST.js +40 -1
- package/dist/plugins/eslint/index.js +2 -7
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/react-email/index.js +5 -3
- package/dist/plugins/rslib/index.js +8 -5
- package/dist/plugins/rslib/resolveFromAST.d.ts +2 -0
- package/dist/plugins/rslib/resolveFromAST.js +4 -0
- package/dist/plugins/sveltejs-package/helpers.d.ts +8 -0
- package/dist/plugins/sveltejs-package/helpers.js +65 -0
- package/dist/plugins/sveltejs-package/index.d.ts +3 -0
- package/dist/plugins/sveltejs-package/index.js +27 -0
- package/dist/plugins/vitest/helpers.d.ts +3 -1
- package/dist/plugins/vitest/helpers.js +18 -0
- package/dist/plugins/vitest/index.js +5 -19
- package/dist/reporters/trace.js +3 -3
- package/dist/reporters/util/util.d.ts +2 -2
- package/dist/reporters/util/util.js +13 -12
- package/dist/reporters/watch.js +4 -4
- package/dist/schema/configuration.d.ts +15 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/args.d.ts +2 -0
- package/dist/types/config.d.ts +17 -4
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +3 -3
- package/dist/util/colors.d.ts +18 -0
- package/dist/util/colors.js +24 -0
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/debug.js +2 -4
- package/dist/util/glob-core.js +18 -14
- package/dist/util/log.js +3 -3
- package/dist/util/package-json.d.ts +5 -0
- package/dist/util/package-json.js +9 -0
- package/dist/util/to-source-path.d.ts +3 -1
- package/dist/util/to-source-path.js +43 -20
- package/dist/util/trace.js +8 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/dist/plugins/rslib/types.d.ts +0 -1
- package/dist/plugins/rslib/types.js +0 -1
|
@@ -7,11 +7,26 @@ const defaultExtensions = `.{${[...DEFAULT_EXTENSIONS].map(ext => ext.slice(1)).
|
|
|
7
7
|
const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
|
|
8
8
|
const matchExt = /(\.d)?\.(m|c)?(j|t)s$/;
|
|
9
9
|
const sourceExtensions = [...DEFAULT_EXTENSIONS];
|
|
10
|
-
|
|
10
|
+
const tsconfigSourceMap = (dir, compilerOptions) => {
|
|
11
11
|
const srcDir = join(dir, 'src');
|
|
12
12
|
const outDirHasSrc = compilerOptions.outDir && isDirectory(compilerOptions.outDir, 'src');
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const resolvedSrc = compilerOptions.rootDir ?? (outDirHasSrc ? dir : isDirectory(srcDir) ? srcDir : dir);
|
|
14
|
+
return { srcDir: resolvedSrc, outDir: compilerOptions.outDir || resolvedSrc };
|
|
15
|
+
};
|
|
16
|
+
export const augmentWorkspace = (workspace, dir, compilerOptions, pluginSourceMaps = []) => {
|
|
17
|
+
const all = compilerOptions ? [...pluginSourceMaps, tsconfigSourceMap(dir, compilerOptions)] : pluginSourceMaps;
|
|
18
|
+
if (all.length === 0)
|
|
19
|
+
return;
|
|
20
|
+
workspace.sourceMaps = all.sort((a, b) => b.outDir.length - a.outDir.length);
|
|
21
|
+
};
|
|
22
|
+
const isUnderOutDir = (absPath, outDir) => absPath === outDir || absPath.startsWith(`${outDir}/`);
|
|
23
|
+
const isUnderSrcDir = (absPath, srcDir) => absPath === srcDir || absPath.startsWith(`${srcDir}/`);
|
|
24
|
+
const rewritePattern = (sourceMaps, absSpecifier, extensions) => {
|
|
25
|
+
for (const { srcDir, outDir } of sourceMaps) {
|
|
26
|
+
if (!isUnderSrcDir(absSpecifier, srcDir) && isUnderOutDir(absSpecifier, outDir)) {
|
|
27
|
+
return srcDir + absSpecifier.slice(outDir.length).replace(matchExt, extensions);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
15
30
|
};
|
|
16
31
|
export const getModuleSourcePathHandler = (chief) => {
|
|
17
32
|
const toSourceMapCache = new Map();
|
|
@@ -21,16 +36,18 @@ export const getModuleSourcePathHandler = (chief) => {
|
|
|
21
36
|
if (toSourceMapCache.has(filePath))
|
|
22
37
|
return toSourceMapCache.get(filePath);
|
|
23
38
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
24
|
-
if (workspace?.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
if (!workspace?.sourceMaps)
|
|
40
|
+
return;
|
|
41
|
+
for (const { srcDir, outDir } of workspace.sourceMaps) {
|
|
42
|
+
if (!(isUnderOutDir(filePath, outDir) || srcDir === outDir))
|
|
43
|
+
continue;
|
|
44
|
+
const basePath = (srcDir + filePath.slice(outDir.length)).replace(matchExt, '');
|
|
45
|
+
const srcFilePath = findFileWithExtensions(basePath, sourceExtensions);
|
|
46
|
+
if (srcFilePath) {
|
|
47
|
+
toSourceMapCache.set(filePath, srcFilePath);
|
|
48
|
+
if (srcFilePath !== filePath) {
|
|
49
|
+
debugLog('*', `Source mapping ${toRelative(filePath, chief.cwd)} → ${toRelative(srcFilePath, chief.cwd)}`);
|
|
50
|
+
return srcFilePath;
|
|
34
51
|
}
|
|
35
52
|
}
|
|
36
53
|
}
|
|
@@ -42,16 +59,22 @@ export const getToSourcePathsHandler = (chief) => {
|
|
|
42
59
|
for (const specifier of specifiers) {
|
|
43
60
|
const absSpecifier = isAbsolute(specifier) ? specifier : prependDirToPattern(dir, specifier);
|
|
44
61
|
const ws = chief.findWorkspaceByFilePath(absSpecifier);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
patterns.add(pattern);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
patterns.add(absSpecifier);
|
|
51
|
-
}
|
|
62
|
+
const mapped = ws?.sourceMaps && rewritePattern(ws.sourceMaps, absSpecifier, extensions);
|
|
63
|
+
patterns.add(mapped ?? absSpecifier);
|
|
52
64
|
}
|
|
53
65
|
const filePaths = await _glob({ patterns: Array.from(patterns), cwd: dir, label });
|
|
54
66
|
debugLogArray(toRelative(dir, chief.cwd), 'Source mapping (package.json)', filePaths);
|
|
55
67
|
return filePaths;
|
|
56
68
|
};
|
|
57
69
|
};
|
|
70
|
+
export const toSourceMappedSpecifiers = (ws, absSpecifier, extensions = defaultExtensions) => {
|
|
71
|
+
const out = [];
|
|
72
|
+
if (!ws?.sourceMaps)
|
|
73
|
+
return out;
|
|
74
|
+
for (const { srcDir, outDir } of ws.sourceMaps) {
|
|
75
|
+
if (!isUnderSrcDir(absSpecifier, srcDir) && isUnderOutDir(absSpecifier, outDir)) {
|
|
76
|
+
out.push(srcDir + absSpecifier.slice(outDir.length).replace(matchExt, extensions));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
};
|
package/dist/util/trace.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import st from './colors.js';
|
|
2
2
|
export const formatTrace = (node, toRelative, isReferenced, memberStatuses) => {
|
|
3
3
|
const lines = [];
|
|
4
|
-
const file =
|
|
5
|
-
const id =
|
|
6
|
-
const ref =
|
|
7
|
-
const via =
|
|
8
|
-
const ok =
|
|
9
|
-
const fail =
|
|
10
|
-
const dim =
|
|
4
|
+
const file = st.white;
|
|
5
|
+
const id = st.cyanBright;
|
|
6
|
+
const ref = st.cyanBright;
|
|
7
|
+
const via = st.dim;
|
|
8
|
+
const ok = st.green;
|
|
9
|
+
const fail = st.red;
|
|
10
|
+
const dim = st.dim;
|
|
11
11
|
const entryMarker = node.isEntry ? dim(' ⎆') : '';
|
|
12
12
|
lines.push(`${file(toRelative(node.filePath))}${dim(':')}${id(node.identifier)}${entryMarker}`);
|
|
13
13
|
const formatVia = (child) => {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.6.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.6.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.1",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -77,14 +77,13 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"
|
|
80
|
+
"fdir": "^6.5.0",
|
|
81
81
|
"formatly": "^0.3.0",
|
|
82
82
|
"get-tsconfig": "4.14.0",
|
|
83
83
|
"jiti": "^2.6.0",
|
|
84
84
|
"minimist": "^1.2.8",
|
|
85
85
|
"oxc-parser": "^0.126.0",
|
|
86
86
|
"oxc-resolver": "^11.19.1",
|
|
87
|
-
"picocolors": "^1.1.1",
|
|
88
87
|
"picomatch": "^4.0.4",
|
|
89
88
|
"smol-toml": "^1.6.1",
|
|
90
89
|
"strip-json-comments": "5.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type RslibConfig = {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|