knip 5.50.5 → 5.51.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/README.md +1 -1
- package/dist/ConfigurationChief.d.ts +4 -1
- package/dist/ConfigurationChief.js +3 -0
- package/dist/binaries/package-manager/bun.js +2 -0
- package/dist/binaries/package-manager/pnpm.js +7 -7
- package/dist/cli.js +3 -3
- package/dist/compilers/astro.js +5 -1
- package/dist/compilers/compilers.js +1 -1
- package/dist/compilers/index.d.ts +44 -13
- package/dist/compilers/index.js +9 -6
- package/dist/compilers/types.d.ts +1 -0
- package/dist/graph/build.js +12 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -1
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +1 -1
- package/dist/plugins/bun/index.d.ts +11 -0
- package/dist/plugins/bun/index.js +28 -0
- package/dist/plugins/eslint/index.js +1 -2
- package/dist/plugins/index.d.ts +37 -10
- package/dist/plugins/index.js +8 -2
- package/dist/plugins/lint-staged/index.d.ts +0 -1
- package/dist/plugins/lint-staged/index.js +0 -2
- package/dist/plugins/nano-staged/index.d.ts +10 -0
- package/dist/plugins/nano-staged/index.js +33 -0
- package/dist/plugins/nano-staged/types.d.ts +7 -0
- package/dist/plugins/next/index.js +2 -1
- package/dist/plugins/oxlint/index.d.ts +12 -0
- package/dist/plugins/oxlint/index.js +16 -0
- package/dist/plugins/preconstruct/index.js +2 -2
- package/dist/plugins/prettier/index.js +3 -3
- package/dist/plugins/relay/index.d.ts +15 -0
- package/dist/plugins/relay/index.js +31 -0
- package/dist/plugins/relay/types.d.ts +12 -0
- package/dist/plugins/relay/types.js +1 -0
- package/dist/plugins/starlight/index.js +1 -1
- package/dist/plugins/tsup/index.js +1 -1
- package/dist/plugins/xo/index.js +1 -1
- package/dist/schema/configuration.d.ts +241 -70
- package/dist/schema/configuration.js +2 -1
- package/dist/schema/plugins.d.ts +92 -23
- package/dist/schema/plugins.js +4 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/ast-helpers.d.ts +16 -3
- package/dist/typescript/ast-helpers.js +21 -15
- package/dist/typescript/visitors/dynamic-imports/importCall.js +47 -53
- package/dist/typescript/visitors/exports/exportAssignment.js +17 -2
- package/dist/typescript/visitors/exports/exportKeyword.js +3 -22
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/codeowners.js +1 -1
- package/dist/util/glob-core.d.ts +0 -8
- package/dist/util/glob-core.js +16 -49
- package/dist/util/glob.d.ts +4 -0
- package/dist/util/glob.js +2 -0
- package/dist/util/input.d.ts +3 -1
- package/dist/util/package-json.d.ts +1 -4
- package/dist/util/package-json.js +2 -3
- package/dist/util/parse-and-convert-gitignores.d.ts +8 -0
- package/dist/util/parse-and-convert-gitignores.js +40 -0
- package/dist/util/to-source-path.d.ts +1 -0
- package/dist/util/to-source-path.js +23 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/schema.json +20 -4
- package/dist/plugins/tanstack-router/index.d.ts +0 -12
- package/dist/plugins/tanstack-router/index.js +0 -46
- package/dist/plugins/tanstack-router/resolveFromAST.d.ts +0 -2
- package/dist/plugins/tanstack-router/resolveFromAST.js +0 -28
- package/dist/plugins/tanstack-router/types.d.ts +0 -7
- /package/dist/plugins/{tanstack-router → nano-staged}/types.js +0 -0
package/dist/util/codeowners.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import picomatch from 'picomatch';
|
|
3
3
|
import { debugLog } from './debug.js';
|
|
4
|
-
import { convertGitignoreToPicomatchIgnorePatterns } from './
|
|
4
|
+
import { convertGitignoreToPicomatchIgnorePatterns } from './parse-and-convert-gitignores.js';
|
|
5
5
|
export function parseCodeowners(content) {
|
|
6
6
|
const matchers = content
|
|
7
7
|
.split(/\r?\n/)
|
package/dist/util/glob-core.d.ts
CHANGED
|
@@ -10,14 +10,6 @@ type GlobOptions = {
|
|
|
10
10
|
label?: string;
|
|
11
11
|
} & FastGlobOptionsWithoutCwd;
|
|
12
12
|
type FastGlobOptionsWithoutCwd = Pick<FastGlobOptions, 'onlyDirectories' | 'ignore' | 'absolute' | 'dot'>;
|
|
13
|
-
export declare const convertGitignoreToPicomatchIgnorePatterns: (pattern: string) => {
|
|
14
|
-
negated: boolean;
|
|
15
|
-
patterns: string[];
|
|
16
|
-
};
|
|
17
|
-
export declare const parseAndConvertGitignorePatterns: (patterns: string, ancestor?: string) => {
|
|
18
|
-
negated: boolean;
|
|
19
|
-
patterns: string[];
|
|
20
|
-
}[];
|
|
21
13
|
export declare const findAndParseGitignores: (cwd: string) => Promise<{
|
|
22
14
|
gitignoreFiles: string[];
|
|
23
15
|
ignores: Set<string>;
|
package/dist/util/glob-core.js
CHANGED
|
@@ -8,51 +8,12 @@ import { timerify } from './Performance.js';
|
|
|
8
8
|
import { compact } from './array.js';
|
|
9
9
|
import { debugLogObject } from './debug.js';
|
|
10
10
|
import { isFile } from './fs.js';
|
|
11
|
+
import { parseAndConvertGitignorePatterns } from './parse-and-convert-gitignores.js';
|
|
11
12
|
import { dirname, join, relative, toPosix } from './path.js';
|
|
12
13
|
const walk = promisify(_walk);
|
|
13
14
|
const _picomatch = timerify(picomatch);
|
|
14
15
|
const cachedGitIgnores = new Map();
|
|
15
16
|
const cachedGlobIgnores = new Map();
|
|
16
|
-
export const convertGitignoreToPicomatchIgnorePatterns = (pattern) => {
|
|
17
|
-
const negated = pattern[0] === '!';
|
|
18
|
-
if (negated)
|
|
19
|
-
pattern = pattern.slice(1);
|
|
20
|
-
let extPattern;
|
|
21
|
-
if (pattern.endsWith('/'))
|
|
22
|
-
pattern = pattern.slice(0, -1);
|
|
23
|
-
if (pattern.startsWith('*/**/'))
|
|
24
|
-
pattern = pattern.slice(5);
|
|
25
|
-
if (pattern.startsWith('/'))
|
|
26
|
-
pattern = pattern.slice(1);
|
|
27
|
-
else if (!pattern.startsWith('**/'))
|
|
28
|
-
pattern = `**/${pattern}`;
|
|
29
|
-
if (pattern.endsWith('/*'))
|
|
30
|
-
extPattern = pattern;
|
|
31
|
-
else
|
|
32
|
-
extPattern = `${pattern}/**`;
|
|
33
|
-
return { negated, patterns: [pattern, extPattern] };
|
|
34
|
-
};
|
|
35
|
-
export const parseAndConvertGitignorePatterns = (patterns, ancestor) => {
|
|
36
|
-
const matchFrom = ancestor ? new RegExp(`^(!?/?)(${ancestor})`) : undefined;
|
|
37
|
-
return patterns
|
|
38
|
-
.split(/\r?\n/)
|
|
39
|
-
.filter(line => line.trim() && !line.startsWith('#'))
|
|
40
|
-
.flatMap(line => {
|
|
41
|
-
const pattern = line.replace(/^\\(?=#)/, '').trim();
|
|
42
|
-
if (ancestor && matchFrom) {
|
|
43
|
-
if (pattern.match(matchFrom))
|
|
44
|
-
return [pattern.replace(matchFrom, '$1')];
|
|
45
|
-
if (pattern.startsWith('/**/'))
|
|
46
|
-
return [pattern.slice(1)];
|
|
47
|
-
if (pattern.startsWith('!/**/'))
|
|
48
|
-
return [`!${pattern.slice(2)}`];
|
|
49
|
-
if (pattern.startsWith('/') || pattern.startsWith('!/'))
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return [pattern];
|
|
53
|
-
})
|
|
54
|
-
.map(pattern => convertGitignoreToPicomatchIgnorePatterns(pattern));
|
|
55
|
-
};
|
|
56
17
|
const findAncestorGitignoreFiles = (cwd) => {
|
|
57
18
|
const gitignorePaths = [];
|
|
58
19
|
let dir = dirname(cwd);
|
|
@@ -129,7 +90,7 @@ export const findAndParseGitignores = async (cwd) => {
|
|
|
129
90
|
}
|
|
130
91
|
const cacheDir = ancestor ? cwd : dir;
|
|
131
92
|
const cacheForDir = cachedGitIgnores.get(cwd);
|
|
132
|
-
if (
|
|
93
|
+
if (cacheForDir) {
|
|
133
94
|
for (const pattern of dirIgnores)
|
|
134
95
|
cacheForDir?.ignores.add(pattern);
|
|
135
96
|
cacheForDir.unignores = Array.from(new Set([...cacheForDir.unignores, ...dirUnignores]));
|
|
@@ -162,9 +123,9 @@ const _parseFindGitignores = timerify(findAndParseGitignores);
|
|
|
162
123
|
export async function glob(patterns, options) {
|
|
163
124
|
if (Array.isArray(patterns) && patterns.length === 0)
|
|
164
125
|
return [];
|
|
165
|
-
const
|
|
166
|
-
const willCache =
|
|
167
|
-
const cachedIgnores =
|
|
126
|
+
const hasCache = cachedGlobIgnores.has(options.dir);
|
|
127
|
+
const willCache = !hasCache && options.gitignore && options.label;
|
|
128
|
+
const cachedIgnores = options.gitignore ? cachedGlobIgnores.get(options.dir) : undefined;
|
|
168
129
|
const _ignore = options.gitignore && Array.isArray(options.ignore) ? [...options.ignore] : [];
|
|
169
130
|
if (options.gitignore) {
|
|
170
131
|
if (willCache) {
|
|
@@ -185,19 +146,25 @@ export async function glob(patterns, options) {
|
|
|
185
146
|
_ignore.push(...GLOBAL_IGNORE_PATTERNS);
|
|
186
147
|
}
|
|
187
148
|
const ignore = cachedIgnores || compact(_ignore);
|
|
149
|
+
if (willCache)
|
|
150
|
+
cachedGlobIgnores.set(options.dir, compact(_ignore));
|
|
188
151
|
const { dir, label, ...fgOptions } = { ...options, ignore };
|
|
189
152
|
const paths = await fg.glob(patterns, fgOptions);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
153
|
+
const name = relative(options.cwd, dir);
|
|
154
|
+
debugLogObject(name || ROOT_WORKSPACE_NAME, label ? `Finding ${label}` : 'Finding paths', () => ({
|
|
155
|
+
patterns,
|
|
156
|
+
...fgOptions,
|
|
157
|
+
ignore: hasCache ? `// identical to ${name}` : ignore,
|
|
158
|
+
paths,
|
|
159
|
+
}));
|
|
193
160
|
return paths;
|
|
194
161
|
}
|
|
195
162
|
export async function getGitIgnoredHandler(options) {
|
|
196
163
|
cachedGitIgnores.clear();
|
|
197
164
|
if (options.gitignore === false)
|
|
198
165
|
return () => false;
|
|
199
|
-
const
|
|
200
|
-
const matcher = _picomatch(Array.from(
|
|
166
|
+
const { ignores, unignores } = await _parseFindGitignores(options.cwd);
|
|
167
|
+
const matcher = _picomatch(Array.from(ignores), { ignore: unignores });
|
|
201
168
|
const isGitIgnored = (filePath) => matcher(relative(options.cwd, filePath));
|
|
202
169
|
return timerify(isGitIgnored);
|
|
203
170
|
}
|
package/dist/util/glob.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare const negate: (pattern: string) => string;
|
|
|
11
11
|
export declare const hasProductionSuffix: (pattern: string) => boolean;
|
|
12
12
|
export declare const hasNoProductionSuffix: (pattern: string) => boolean;
|
|
13
13
|
export declare const _glob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
|
|
14
|
+
export declare const _syncGlob: ({ cwd, patterns }: {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
patterns: string | string[];
|
|
17
|
+
}) => string[];
|
|
14
18
|
export declare const _firstGlob: ({ cwd, patterns }: GlobOptions) => Promise<string | Buffer<ArrayBufferLike> | undefined>;
|
|
15
19
|
export declare const _dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
|
|
16
20
|
export {};
|
package/dist/util/glob.js
CHANGED
|
@@ -34,6 +34,7 @@ const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }
|
|
|
34
34
|
label,
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
+
const syncGlob = ({ cwd, patterns }) => fg.sync(patterns, { cwd });
|
|
37
38
|
const firstGlob = async ({ cwd, patterns }) => {
|
|
38
39
|
const stream = fg.globStream(patterns.map(removeProductionSuffix), { cwd, ignore: GLOBAL_IGNORE_PATTERNS });
|
|
39
40
|
for await (const entry of stream) {
|
|
@@ -47,5 +48,6 @@ const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns, {
|
|
|
47
48
|
gitignore,
|
|
48
49
|
});
|
|
49
50
|
export const _glob = timerify(defaultGlob);
|
|
51
|
+
export const _syncGlob = timerify(syncGlob);
|
|
50
52
|
export const _firstGlob = timerify(firstGlob);
|
|
51
53
|
export const _dirGlob = timerify(dirGlob);
|
package/dist/util/input.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface Input {
|
|
|
7
7
|
optional?: boolean;
|
|
8
8
|
dir?: string;
|
|
9
9
|
containingFilePath?: string;
|
|
10
|
-
|
|
10
|
+
allowIncludeExports?: boolean;
|
|
11
|
+
skipExportsAnalysis?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface ConfigInput extends Input {
|
|
13
14
|
type: 'config';
|
|
@@ -18,6 +19,7 @@ type Options = {
|
|
|
18
19
|
optional?: boolean;
|
|
19
20
|
dir?: string;
|
|
20
21
|
containingFilePath?: string;
|
|
22
|
+
allowIncludeExports?: boolean;
|
|
21
23
|
};
|
|
22
24
|
export declare const fromBinary: (input: Input) => string;
|
|
23
25
|
export declare const toBinary: (specifier: string, options?: Options) => Input;
|
|
@@ -7,8 +7,5 @@ interface ExtendedPackageJson extends PackageJson {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
|
|
9
9
|
export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
|
|
10
|
-
export declare const getEntryPathsFromManifest: (manifest: PackageJson
|
|
11
|
-
cwd: string;
|
|
12
|
-
ignore: string[];
|
|
13
|
-
}) => Promise<string[]>;
|
|
10
|
+
export declare const getEntryPathsFromManifest: (manifest: PackageJson) => Set<string>;
|
|
14
11
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { _glob } from './glob.js';
|
|
3
2
|
const INDENT = Symbol.for('indent');
|
|
4
3
|
const NEWLINE = Symbol.for('newline');
|
|
5
4
|
const DEFAULT_NEWLINE = '\n';
|
|
@@ -46,7 +45,7 @@ export const save = async (filePath, content) => {
|
|
|
46
45
|
const fileContent = `${JSON.stringify(content, null, space)}\n`.replace(/\n/g, EOL);
|
|
47
46
|
await writeFile(filePath, fileContent);
|
|
48
47
|
};
|
|
49
|
-
export const getEntryPathsFromManifest = (manifest
|
|
48
|
+
export const getEntryPathsFromManifest = (manifest) => {
|
|
50
49
|
const { main, module, browser, bin, exports, types, typings } = manifest;
|
|
51
50
|
const entryPaths = new Set();
|
|
52
51
|
if (typeof main === 'string')
|
|
@@ -77,5 +76,5 @@ export const getEntryPathsFromManifest = (manifest, options) => {
|
|
|
77
76
|
entryPaths.add(types);
|
|
78
77
|
if (typeof typings === 'string')
|
|
79
78
|
entryPaths.add(typings);
|
|
80
|
-
return
|
|
79
|
+
return entryPaths;
|
|
81
80
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const convertGitignoreToPicomatchIgnorePatterns: (pattern: string) => {
|
|
2
|
+
negated: boolean;
|
|
3
|
+
patterns: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare const parseAndConvertGitignorePatterns: (patterns: string, ancestor?: string) => {
|
|
6
|
+
negated: boolean;
|
|
7
|
+
patterns: string[];
|
|
8
|
+
}[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const convertGitignoreToPicomatchIgnorePatterns = (pattern) => {
|
|
2
|
+
const negated = pattern[0] === '!';
|
|
3
|
+
if (negated)
|
|
4
|
+
pattern = pattern.slice(1);
|
|
5
|
+
let extPattern;
|
|
6
|
+
if (pattern.endsWith('/'))
|
|
7
|
+
pattern = pattern.slice(0, -1);
|
|
8
|
+
if (pattern.startsWith('*/**/'))
|
|
9
|
+
pattern = pattern.slice(5);
|
|
10
|
+
if (pattern.startsWith('/'))
|
|
11
|
+
pattern = pattern.slice(1);
|
|
12
|
+
else if (!pattern.startsWith('**/'))
|
|
13
|
+
pattern = `**/${pattern}`;
|
|
14
|
+
if (pattern.endsWith('/*'))
|
|
15
|
+
extPattern = pattern;
|
|
16
|
+
else
|
|
17
|
+
extPattern = `${pattern}/**`;
|
|
18
|
+
return { negated, patterns: [pattern, extPattern] };
|
|
19
|
+
};
|
|
20
|
+
export const parseAndConvertGitignorePatterns = (patterns, ancestor) => {
|
|
21
|
+
const matchFrom = ancestor ? new RegExp(`^(!?/?)(${ancestor})`) : undefined;
|
|
22
|
+
return patterns
|
|
23
|
+
.split(/\r?\n/)
|
|
24
|
+
.filter(line => line.trim() && !line.startsWith('#'))
|
|
25
|
+
.flatMap(line => {
|
|
26
|
+
const pattern = line.replace(/^\\(?=#)/, '').trim();
|
|
27
|
+
if (ancestor && matchFrom) {
|
|
28
|
+
if (pattern.match(matchFrom))
|
|
29
|
+
return [pattern.replace(matchFrom, '$1')];
|
|
30
|
+
if (pattern.startsWith('/**/'))
|
|
31
|
+
return [pattern.slice(1)];
|
|
32
|
+
if (pattern.startsWith('!/**/'))
|
|
33
|
+
return [`!${pattern.slice(2)}`];
|
|
34
|
+
if (pattern.startsWith('/') || pattern.startsWith('!/'))
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return [pattern];
|
|
38
|
+
})
|
|
39
|
+
.map(pattern => convertGitignoreToPicomatchIgnorePatterns(pattern));
|
|
40
|
+
};
|
|
@@ -2,4 +2,5 @@ import type { CompilerOptions } from 'typescript';
|
|
|
2
2
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
3
3
|
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
|
|
4
4
|
export declare const getToSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
5
|
+
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, cwd: string, extensions?: string) => Promise<string[]>;
|
|
5
6
|
export type ToSourceFilePath = ReturnType<typeof getToSourcePathHandler>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fastGlob from 'fast-glob';
|
|
2
1
|
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
3
|
-
import { debugLog } from './debug.js';
|
|
2
|
+
import { debugLog, debugLogArray } from './debug.js';
|
|
4
3
|
import { isDirectory } from './fs.js';
|
|
5
|
-
import {
|
|
4
|
+
import { _glob, _syncGlob } from './glob.js';
|
|
5
|
+
import { isAbsolute, isInternal, join, toRelative } from './path.js';
|
|
6
6
|
const defaultExtensions = `.{${DEFAULT_EXTENSIONS.map(ext => ext.slice(1)).join(',')}}`;
|
|
7
7
|
const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
|
|
8
8
|
const hasDTSExt = /.d\.(m|c)?ts$/;
|
|
@@ -24,7 +24,7 @@ export const getToSourcePathHandler = (chief) => {
|
|
|
24
24
|
if ((!filePath.startsWith(workspace.srcDir) && filePath.startsWith(workspace.outDir)) ||
|
|
25
25
|
(workspace.srcDir === workspace.outDir && hasDTSExt.test(filePath))) {
|
|
26
26
|
const pattern = filePath.replace(workspace.outDir, workspace.srcDir).replace(matchExt, defaultExtensions);
|
|
27
|
-
const
|
|
27
|
+
const srcFilePath = _syncGlob({ patterns: pattern })[0];
|
|
28
28
|
toSourceMapCache.set(filePath, srcFilePath);
|
|
29
29
|
if (srcFilePath && srcFilePath !== filePath) {
|
|
30
30
|
debugLog('*', `Source mapping ${toRelative(filePath)} → ${toRelative(srcFilePath)}`);
|
|
@@ -34,3 +34,22 @@ export const getToSourcePathHandler = (chief) => {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
+
export const getToSourcePathsHandler = (chief) => {
|
|
38
|
+
return async (specifiers, cwd, extensions = defaultExtensions) => {
|
|
39
|
+
const patterns = new Set();
|
|
40
|
+
for (const specifier of specifiers) {
|
|
41
|
+
const absSpecifier = isAbsolute(specifier) ? specifier : join(cwd, specifier);
|
|
42
|
+
const ws = chief.findWorkspaceByFilePath(absSpecifier);
|
|
43
|
+
if (ws?.srcDir && ws.outDir && !absSpecifier.startsWith(ws.srcDir) && absSpecifier.startsWith(ws.outDir)) {
|
|
44
|
+
const pattern = absSpecifier.replace(ws.outDir, ws.srcDir).replace(matchExt, extensions);
|
|
45
|
+
patterns.add(pattern);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
patterns.add(absSpecifier);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const filePaths = await _glob({ patterns: Array.from(patterns), cwd });
|
|
52
|
+
debugLogArray(toRelative(cwd), 'Source mapping (package.json)', filePaths);
|
|
53
|
+
return filePaths;
|
|
54
|
+
};
|
|
55
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.51.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.51.1';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "Find and fix unused
|
|
3
|
+
"version": "5.51.1",
|
|
4
|
+
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"test": "bun test test/*.test.ts test/**/*.test.ts",
|
|
44
44
|
"test:watch": "bun test test/*.test.ts test/**/*.test.ts --reporter=junit --reporter-outfile=junit.xml || bun test --watch $(grep -o 'name=\"[^\"]*\".*failures=\"[^0]' junit.xml | grep -v 'name=\"bun test\"' | grep -o 'name=\"[^\"]*\"' | cut -d'\"' -f2)",
|
|
45
45
|
"test:node": "glob -c \"npx -y tsx --test --import ./transform-test.js\" \"test/**/*.test.ts\"",
|
|
46
|
+
"test:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
|
|
46
47
|
"watch": "npm link && tsc --watch",
|
|
47
48
|
"prebuild": "npm run generate-plugin-defs && node rmdir.js dist",
|
|
48
49
|
"build": "tsc",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"@wdio/types": "^9.5.0",
|
|
90
91
|
"codeclimate-types": "^0.3.1",
|
|
91
92
|
"glob": "^10.4.2",
|
|
92
|
-
"release-it": "^19.0.
|
|
93
|
+
"release-it": "^19.0.1",
|
|
93
94
|
"type-fest": "^4.31.0",
|
|
94
95
|
"typescript": "^5.5.2"
|
|
95
96
|
},
|
package/schema.json
CHANGED
|
@@ -168,6 +168,10 @@
|
|
|
168
168
|
"$ref": "#/definitions/ruleValue"
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
+
},
|
|
172
|
+
"treatConfigHintsAsErrors": {
|
|
173
|
+
"title": "Exit with non-zero code (1) if there are any configuration hints",
|
|
174
|
+
"type": "boolean"
|
|
171
175
|
}
|
|
172
176
|
},
|
|
173
177
|
"unevaluatedProperties": false,
|
|
@@ -311,6 +315,10 @@
|
|
|
311
315
|
"title": "Babel plugin configuration (https://knip.dev/reference/plugins/babel)",
|
|
312
316
|
"$ref": "#/definitions/plugin"
|
|
313
317
|
},
|
|
318
|
+
"bun": {
|
|
319
|
+
"title": "bun plugin configuration (https://knip.dev/reference/plugins/bun)",
|
|
320
|
+
"$ref": "#/definitions/plugin"
|
|
321
|
+
},
|
|
314
322
|
"c8": {
|
|
315
323
|
"title": "c8 plugin configuration (https://knip.dev/reference/plugins/c8)",
|
|
316
324
|
"$ref": "#/definitions/plugin"
|
|
@@ -447,6 +455,10 @@
|
|
|
447
455
|
"title": "Mocha plugin configuration (https://knip.dev/reference/plugins/msw)",
|
|
448
456
|
"$ref": "#/definitions/plugin"
|
|
449
457
|
},
|
|
458
|
+
"nano-staged": {
|
|
459
|
+
"title": "nano-staged plugin configuration (https://knip.dev/reference/plugins/nano-staged)",
|
|
460
|
+
"$ref": "#/definitions/plugin"
|
|
461
|
+
},
|
|
450
462
|
"nest": {
|
|
451
463
|
"title": "nest plugin configuration (https://knip.dev/reference/plugins/nest)",
|
|
452
464
|
"$ref": "#/definitions/plugin"
|
|
@@ -491,6 +503,10 @@
|
|
|
491
503
|
"title": "oclif plugin configuration (https://knip.dev/reference/plugins/oclif)",
|
|
492
504
|
"$ref": "#/definitions/plugin"
|
|
493
505
|
},
|
|
506
|
+
"oxlint": {
|
|
507
|
+
"title": "oxlint plugin configuration (https://knip.dev/reference/plugins/oxlint)",
|
|
508
|
+
"$ref": "#/definitions/plugin"
|
|
509
|
+
},
|
|
494
510
|
"playwright": {
|
|
495
511
|
"title": "Playwright plugin configuration (https://knip.dev/reference/plugins/playwright)",
|
|
496
512
|
"$ref": "#/definitions/plugin"
|
|
@@ -523,6 +539,10 @@
|
|
|
523
539
|
"title": "react-router plugin configuration (https://knip.dev/reference/plugins/react-router)",
|
|
524
540
|
"$ref": "#/definitions/plugin"
|
|
525
541
|
},
|
|
542
|
+
"relay": {
|
|
543
|
+
"title": "relay plugin configuration (https://knip.dev/reference/plugins/relay)",
|
|
544
|
+
"$ref": "#/definitions/plugin"
|
|
545
|
+
},
|
|
526
546
|
"release-it": {
|
|
527
547
|
"title": "Release It plugin configuration (https://knip.dev/reference/plugins/release-it)",
|
|
528
548
|
"$ref": "#/definitions/plugin"
|
|
@@ -595,10 +615,6 @@
|
|
|
595
615
|
"title": "tailwind plugin configuration (https://knip.dev/reference/plugins/tailwind)",
|
|
596
616
|
"$ref": "#/definitions/plugin"
|
|
597
617
|
},
|
|
598
|
-
"tanstack-router": {
|
|
599
|
-
"title": "tanstack-router plugin configuration (https://knip.dev/reference/plugins/tanstack-router)",
|
|
600
|
-
"$ref": "#/definitions/plugin"
|
|
601
|
-
},
|
|
602
618
|
"travis": {
|
|
603
619
|
"title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
|
|
604
620
|
"$ref": "#/definitions/plugin"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveEntryPaths, ResolveFromAST } from '../../types/config.js';
|
|
2
|
-
import type { TanstackRouterConfig } from './types.js';
|
|
3
|
-
declare const _default: {
|
|
4
|
-
title: string;
|
|
5
|
-
enablers: string[];
|
|
6
|
-
isEnabled: IsPluginEnabled;
|
|
7
|
-
config: string[];
|
|
8
|
-
production: string[];
|
|
9
|
-
resolveEntryPaths: ResolveEntryPaths<TanstackRouterConfig>;
|
|
10
|
-
resolveFromAST: ResolveFromAST;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { toEntry } from '../../util/input.js';
|
|
2
|
-
import { extname, join } from '../../util/path.js';
|
|
3
|
-
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
-
import { getCustomConfig } from './resolveFromAST.js';
|
|
5
|
-
const title = 'TanStack Router';
|
|
6
|
-
const enablers = ['@tanstack/react-router', '@tanstack/router-plugin', '@tanstack/router-cli'];
|
|
7
|
-
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
-
const config = [
|
|
9
|
-
'tsr.config.json',
|
|
10
|
-
'vite.config.{js,mjs,ts,cjs,mts,cts}',
|
|
11
|
-
'rs{pack,build}.config.{js,mjs,ts,cjs,mts,cts}',
|
|
12
|
-
'webpack.config.{js,mjs,ts,cjs,mts,cts}',
|
|
13
|
-
];
|
|
14
|
-
const production = ['./src/routeTree.gen.ts', './src/routes/**/*.{ts,tsx}', '!src/routes/**/-*/**'];
|
|
15
|
-
const getEntryPatterns = (config) => {
|
|
16
|
-
const dir = config.routesDirectory ?? 'src/routes';
|
|
17
|
-
const entries = [
|
|
18
|
-
toEntry(join(config.generatedRouteTree ?? './src/routeTree.gen.ts')),
|
|
19
|
-
toEntry(join(dir, '**', `${config.routeFilePrefix ?? ''}*`)),
|
|
20
|
-
toEntry(join(`!${dir}`, '**', `${config.routeFileIgnorePrefix ?? '-'}*`)),
|
|
21
|
-
];
|
|
22
|
-
if (config.routeFileIgnorePattern) {
|
|
23
|
-
entries.push(toEntry(join(`!${dir}`, '**', `*${config.routeFileIgnorePattern}*`)));
|
|
24
|
-
}
|
|
25
|
-
return entries;
|
|
26
|
-
};
|
|
27
|
-
const resolveEntryPaths = (localConfig, options) => {
|
|
28
|
-
if (extname(options.configFileName) !== '.json')
|
|
29
|
-
return [];
|
|
30
|
-
return getEntryPatterns(localConfig);
|
|
31
|
-
};
|
|
32
|
-
const resolveFromAST = (sourceFile, options) => {
|
|
33
|
-
if (extname(options.configFileName) === '.json')
|
|
34
|
-
return [];
|
|
35
|
-
const resolvedConfig = getCustomConfig(sourceFile);
|
|
36
|
-
return getEntryPatterns(resolvedConfig);
|
|
37
|
-
};
|
|
38
|
-
export default {
|
|
39
|
-
title,
|
|
40
|
-
enablers,
|
|
41
|
-
isEnabled,
|
|
42
|
-
config,
|
|
43
|
-
production,
|
|
44
|
-
resolveEntryPaths,
|
|
45
|
-
resolveFromAST,
|
|
46
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { getPropertyValueEntries } from '../../typescript/ast-helpers.js';
|
|
3
|
-
const CONFIG_KEYS = new Set([
|
|
4
|
-
'routeFilePrefix',
|
|
5
|
-
'routeFileIgnorePrefix',
|
|
6
|
-
'routeFileIgnorePattern',
|
|
7
|
-
'routesDirectory',
|
|
8
|
-
'generatedRouteTree',
|
|
9
|
-
]);
|
|
10
|
-
const FUNCTIONS = new Set(['TanStackRouterVite', 'TanStackRouterRspack', 'TanStackRouterWebpack']);
|
|
11
|
-
export const getCustomConfig = (sourceFile) => {
|
|
12
|
-
const config = {};
|
|
13
|
-
function visit(node) {
|
|
14
|
-
if (ts.isCallExpression(node)) {
|
|
15
|
-
const callee = node.expression;
|
|
16
|
-
if (ts.isIdentifier(callee) && FUNCTIONS.has(callee.text)) {
|
|
17
|
-
const firstArg = node.arguments[0];
|
|
18
|
-
if (ts.isObjectLiteralExpression(firstArg)) {
|
|
19
|
-
for (const [key, value] of getPropertyValueEntries(firstArg, CONFIG_KEYS))
|
|
20
|
-
config[key] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
ts.forEachChild(node, visit);
|
|
25
|
-
}
|
|
26
|
-
visit(sourceFile);
|
|
27
|
-
return config;
|
|
28
|
-
};
|
|
File without changes
|