knip 5.0.2 → 5.0.4
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 +2 -2
- package/dist/ConfigurationValidator.d.ts +6 -6
- package/dist/ConfigurationValidator.js +2 -2
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/binaries/resolvers/index.d.ts +12 -12
- package/dist/compilers/index.d.ts +2 -2
- package/dist/plugins/eslint/index.js +5 -2
- package/dist/plugins/husky/index.js +3 -18
- package/dist/plugins/linthtml/index.js +1 -0
- package/dist/reporters/index.d.ts +5 -5
- package/dist/types/config.d.ts +3 -3
- package/dist/typescript/resolveModuleNames.js +32 -4
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/path.d.ts +3 -0
- package/dist/util/path.js +1 -0
- package/dist/util/tsconfig-loader.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -11
|
@@ -40,7 +40,7 @@ export declare class ConfigurationChief {
|
|
|
40
40
|
constructor({ cwd, isProduction, isStrict, isIncludeEntryExports }: ConfigurationManagerOptions);
|
|
41
41
|
init(): Promise<void>;
|
|
42
42
|
private loadResolvedConfigurationFile;
|
|
43
|
-
getRules(): import("
|
|
43
|
+
getRules(): import("src/types/issues.js").Rules;
|
|
44
44
|
getFilters(): {
|
|
45
45
|
dir: string;
|
|
46
46
|
} | {
|
|
@@ -129,7 +129,7 @@ export declare class ConfigurationChief {
|
|
|
129
129
|
ignore: string[];
|
|
130
130
|
isIncludeEntryExports: any;
|
|
131
131
|
};
|
|
132
|
-
getIncludedIssueTypes(): import("
|
|
132
|
+
getIncludedIssueTypes(): import("src/types/issues.js").Report;
|
|
133
133
|
findWorkspaceByFilePath(filePath: string): Workspace | undefined;
|
|
134
134
|
findWorkspaceByName(name: string): Workspace | undefined;
|
|
135
135
|
getUnusedIgnoredWorkspaces(): string[];
|
|
@@ -16,7 +16,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
16
16
|
ignoreBinaries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
|
|
17
17
|
ignoreDependencies: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
|
|
18
18
|
ignoreWorkspaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
-
exclude: z.ZodOptional<z.ZodArray<z.
|
|
19
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
|
|
20
20
|
rules: z.ZodOptional<z.ZodRecord<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, z.ZodEnum<["error", "warn", "off"]>>>;
|
|
21
21
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
22
22
|
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -27,7 +27,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
27
27
|
compilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodString>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>]>>>;
|
|
28
28
|
syncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodString>>>;
|
|
29
29
|
asyncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>>>;
|
|
30
|
-
include: z.ZodOptional<z.ZodArray<z.
|
|
30
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
|
|
31
31
|
workspaces: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
32
32
|
ignoreBinaries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
|
|
33
33
|
ignoreDependencies: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
|
|
@@ -2001,7 +2001,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2001
2001
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
2002
2002
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
2003
2003
|
ignoreWorkspaces?: string[] | undefined;
|
|
2004
|
-
exclude?:
|
|
2004
|
+
exclude?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
2005
2005
|
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
|
|
2006
2006
|
entry?: string | string[] | undefined;
|
|
2007
2007
|
project?: string | string[] | undefined;
|
|
@@ -2012,7 +2012,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2012
2012
|
compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
|
|
2013
2013
|
syncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => string> | undefined;
|
|
2014
2014
|
asyncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => Promise<string>> | undefined;
|
|
2015
|
-
include?:
|
|
2015
|
+
include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
2016
2016
|
workspaces?: Record<string, {
|
|
2017
2017
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
2018
2018
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
@@ -2566,7 +2566,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2566
2566
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
2567
2567
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
2568
2568
|
ignoreWorkspaces?: string[] | undefined;
|
|
2569
|
-
exclude?:
|
|
2569
|
+
exclude?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
2570
2570
|
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
|
|
2571
2571
|
entry?: string | string[] | undefined;
|
|
2572
2572
|
project?: string | string[] | undefined;
|
|
@@ -2577,7 +2577,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2577
2577
|
compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
|
|
2578
2578
|
syncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => string> | undefined;
|
|
2579
2579
|
asyncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => Promise<string>> | undefined;
|
|
2580
|
-
include?:
|
|
2580
|
+
include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
2581
2581
|
workspaces?: Record<string, {
|
|
2582
2582
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
2583
2583
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
@@ -49,8 +49,8 @@ const rootConfigurationSchema = z.object({
|
|
|
49
49
|
asyncCompilers: z.record(z.string(), asyncCompilerSchema).optional(),
|
|
50
50
|
});
|
|
51
51
|
const reportConfigSchema = z.object({
|
|
52
|
-
include: z.array(
|
|
53
|
-
exclude: z.array(
|
|
52
|
+
include: z.array(issueTypeSchema).optional(),
|
|
53
|
+
exclude: z.array(issueTypeSchema).optional(),
|
|
54
54
|
});
|
|
55
55
|
export const pluginSchema = z.union([
|
|
56
56
|
z.boolean(),
|
|
@@ -59,7 +59,7 @@ export declare class ProjectPrincipal {
|
|
|
59
59
|
};
|
|
60
60
|
exports: {
|
|
61
61
|
exported: import("./types/exports.js").SerializableExports;
|
|
62
|
-
duplicate: import("
|
|
62
|
+
duplicate: import("src/types/issues.js").IssueSymbol[][];
|
|
63
63
|
};
|
|
64
64
|
scripts: Set<string>;
|
|
65
65
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
bun: import("
|
|
3
|
-
c8: import("
|
|
4
|
-
dotenv: import("
|
|
5
|
-
node: import("
|
|
6
|
-
nodemon: import("
|
|
7
|
-
npx: import("
|
|
8
|
-
nx: import("
|
|
9
|
-
pnpm: import("
|
|
10
|
-
rollup: import("
|
|
11
|
-
'ts-node': import("
|
|
12
|
-
tsx: import("
|
|
13
|
-
yarn: import("
|
|
2
|
+
bun: import("src/binaries/types.js").Resolver;
|
|
3
|
+
c8: import("src/binaries/types.js").Resolver;
|
|
4
|
+
dotenv: import("src/binaries/types.js").Resolver;
|
|
5
|
+
node: import("src/binaries/types.js").Resolver;
|
|
6
|
+
nodemon: import("src/binaries/types.js").Resolver;
|
|
7
|
+
npx: import("src/binaries/types.js").Resolver;
|
|
8
|
+
nx: import("src/binaries/types.js").Resolver;
|
|
9
|
+
pnpm: import("src/binaries/types.js").Resolver;
|
|
10
|
+
rollup: import("src/binaries/types.js").Resolver;
|
|
11
|
+
'ts-node': import("src/binaries/types.js").Resolver;
|
|
12
|
+
tsx: import("src/binaries/types.js").Resolver;
|
|
13
|
+
yarn: import("src/binaries/types.js").Resolver;
|
|
14
14
|
};
|
|
15
15
|
export default _default;
|
|
@@ -7,7 +7,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
7
7
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
8
8
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
9
9
|
ignoreWorkspaces?: string[] | undefined;
|
|
10
|
-
exclude?:
|
|
10
|
+
exclude?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
11
11
|
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
|
|
12
12
|
entry?: string | string[] | undefined;
|
|
13
13
|
project?: string | string[] | undefined;
|
|
@@ -16,7 +16,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
16
16
|
ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "interface" | "enum" | "class" | "member", boolean>> | undefined;
|
|
17
17
|
includeEntryExports?: boolean | undefined;
|
|
18
18
|
compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
|
|
19
|
-
include?:
|
|
19
|
+
include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
20
20
|
workspaces?: Record<string, {
|
|
21
21
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
22
22
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
@@ -9,7 +9,7 @@ const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependen
|
|
|
9
9
|
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
|
|
10
10
|
export const PACKAGE_JSON_PATH = 'eslintConfig';
|
|
11
11
|
const CONFIG_FILE_PATTERNS = [
|
|
12
|
-
'eslint.config.js',
|
|
12
|
+
'eslint.config.{js,cjs,mjs}',
|
|
13
13
|
'.eslintrc',
|
|
14
14
|
'.eslintrc.{js,json,cjs}',
|
|
15
15
|
'.eslintrc.{yml,yaml}',
|
|
@@ -18,7 +18,10 @@ const CONFIG_FILE_PATTERNS = [
|
|
|
18
18
|
const findESLintDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
19
19
|
if (isProduction)
|
|
20
20
|
return [];
|
|
21
|
-
|
|
21
|
+
const baseFilePath = basename(configFilePath);
|
|
22
|
+
if (baseFilePath === 'eslint.config.js' ||
|
|
23
|
+
baseFilePath === 'eslint.config.cjs' ||
|
|
24
|
+
baseFilePath === 'eslint.config.mjs')
|
|
22
25
|
return [];
|
|
23
26
|
const dependencies = await getDependenciesDeep(configFilePath, { cwd, manifest });
|
|
24
27
|
return Array.from(dependencies);
|
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
1
|
import { getGitHookPaths } from '../../util/git.js';
|
|
3
2
|
import { timerify } from '../../util/Performance.js';
|
|
4
3
|
import { getDependenciesFromScripts, hasDependency, loadFile } from '../../util/plugin.js';
|
|
5
4
|
const NAME = 'husky';
|
|
6
5
|
const ENABLERS = ['husky'];
|
|
7
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const CONFIG_FILE_PATTERNS = [...gitHooksPathInV8, ...gitHookPathsInV9];
|
|
7
|
+
const gitHookPaths = getGitHookPaths('.husky', false);
|
|
8
|
+
const CONFIG_FILE_PATTERNS = [...gitHookPaths];
|
|
11
9
|
const findHuskyDependencies = async (configFilePath, options) => {
|
|
12
|
-
const { isProduction
|
|
10
|
+
const { isProduction } = options;
|
|
13
11
|
if (isProduction)
|
|
14
12
|
return [];
|
|
15
|
-
const huskyVersion = manifest.devDependencies?.husky ?? manifest.dependencies?.husky ?? '*';
|
|
16
|
-
const isV8OrLower = semver.intersects(huskyVersion, '<9', {
|
|
17
|
-
includePrerelease: true,
|
|
18
|
-
});
|
|
19
|
-
if (!isV8OrLower && gitHooksPathInV8.some(path => configFilePath.includes(path))) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
const isV9OrHigher = semver.intersects(huskyVersion, '>=9', {
|
|
23
|
-
includePrerelease: true,
|
|
24
|
-
});
|
|
25
|
-
if (!isV9OrHigher && gitHookPathsInV9.some(path => configFilePath.includes(path))) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
13
|
const script = await loadFile(configFilePath);
|
|
29
14
|
if (!script)
|
|
30
15
|
return [];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("
|
|
3
|
-
compact: ({ report, issues, isShowProgress }: import("
|
|
4
|
-
codeowners: ({ report, issues, isShowProgress, options }: import("
|
|
5
|
-
json: ({ report, issues, options }: import("
|
|
6
|
-
markdown: ({ report, issues }: import("
|
|
2
|
+
symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("src/index.js").ReporterOptions) => void;
|
|
3
|
+
compact: ({ report, issues, isShowProgress }: import("src/index.js").ReporterOptions) => void;
|
|
4
|
+
codeowners: ({ report, issues, isShowProgress, options }: import("src/index.js").ReporterOptions) => void;
|
|
5
|
+
json: ({ report, issues, options }: import("src/index.js").ReporterOptions) => Promise<void>;
|
|
6
|
+
markdown: ({ report, issues }: import("src/index.js").ReporterOptions) => void;
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
|
|
3
3
|
import * as Plugins from '../plugins/index.js';
|
|
4
|
-
import type { Rules } from './issues.js';
|
|
4
|
+
import type { Rules, IssueType } from './issues.js';
|
|
5
5
|
import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
|
|
6
6
|
export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
|
|
7
7
|
export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
|
|
@@ -28,8 +28,8 @@ export interface WorkspaceConfiguration extends BaseWorkspaceConfiguration, Part
|
|
|
28
28
|
type IgnorableExport = 'class' | 'enum' | 'function' | 'interface' | 'member' | 'type';
|
|
29
29
|
export interface Configuration {
|
|
30
30
|
rules: Rules;
|
|
31
|
-
include:
|
|
32
|
-
exclude:
|
|
31
|
+
include: IssueType[];
|
|
32
|
+
exclude: IssueType[];
|
|
33
33
|
ignore: NormalizedGlob;
|
|
34
34
|
ignoreBinaries: IgnorePatterns;
|
|
35
35
|
ignoreDependencies: IgnorePatterns;
|
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { isBuiltin } from 'node:module';
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { sanitizeSpecifier } from '../util/modules.js';
|
|
5
|
-
import { dirname, extname, isAbsolute, isInternal, join } from '../util/path.js';
|
|
5
|
+
import { basename, dirname, extname, format, isAbsolute, isInternal, join } from '../util/path.js';
|
|
6
6
|
import { isDeclarationFileExtension } from './ast-helpers.js';
|
|
7
7
|
import { ensureRealFilePath, isVirtualFilePath } from './utils.js';
|
|
8
8
|
const resolutionCache = new Map();
|
|
@@ -17,6 +17,27 @@ const fileExists = (name, containingFile) => {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
const DECLARATION_EXTENSIONS_MAP = {
|
|
21
|
+
[ts.Extension.Dts]: ts.Extension.Js,
|
|
22
|
+
[ts.Extension.Dmts]: ts.Extension.Mjs,
|
|
23
|
+
[ts.Extension.Dcts]: ts.Extension.Cjs,
|
|
24
|
+
};
|
|
25
|
+
const jsMatchingDeclarationFileExists = (resolveDtsFileName, declarationFileExtension) => {
|
|
26
|
+
const mappedExtension = DECLARATION_EXTENSIONS_MAP[declarationFileExtension];
|
|
27
|
+
const resolvedFileName = format({
|
|
28
|
+
ext: mappedExtension,
|
|
29
|
+
dir: dirname(resolveDtsFileName),
|
|
30
|
+
name: basename(resolveDtsFileName, declarationFileExtension),
|
|
31
|
+
});
|
|
32
|
+
if (existsSync(resolvedFileName)) {
|
|
33
|
+
return {
|
|
34
|
+
resolvedFileName,
|
|
35
|
+
extension: mappedExtension,
|
|
36
|
+
isExternalLibraryImport: false,
|
|
37
|
+
resolvedUsingTsExtension: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
20
41
|
export function createCustomModuleResolver(customSys, compilerOptions, virtualFileExtensions) {
|
|
21
42
|
function resolveModuleNames(moduleNames, containingFile) {
|
|
22
43
|
return moduleNames.map(moduleName => {
|
|
@@ -46,9 +67,16 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
|
|
|
46
67
|
if (tsResolvedModule &&
|
|
47
68
|
isDeclarationFileExtension(tsResolvedModule?.extension) &&
|
|
48
69
|
isInternal(tsResolvedModule.resolvedFileName)) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
{
|
|
71
|
+
const module = jsMatchingDeclarationFileExists(tsResolvedModule.resolvedFileName, tsResolvedModule.extension);
|
|
72
|
+
if (module)
|
|
73
|
+
return module;
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
const module = fileExists(sanitizedSpecifier, containingFile);
|
|
77
|
+
if (module)
|
|
78
|
+
return module;
|
|
79
|
+
}
|
|
52
80
|
}
|
|
53
81
|
if (virtualFileExtensions.length === 0)
|
|
54
82
|
return tsResolvedModule;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { ImportNode } from '../../../types/imports.js';
|
|
3
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
3
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => ImportNode | ImportNode[] | undefined;
|
|
4
4
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/exports.js").ExportNode | import("src/types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/exports.js").ExportNode | import("src/types/exports.js").ExportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => string | string[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
package/dist/util/path.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import path from 'node:path';
|
|
1
3
|
export declare const isAbsolute: (path: string) => boolean;
|
|
2
4
|
export declare const dirname: (path: string) => string;
|
|
3
5
|
export declare const extname: (path: string) => string;
|
|
4
6
|
export declare const basename: (path: string, suffix?: string | undefined) => string;
|
|
7
|
+
export declare const format: (pathObject: path.FormatInputPathObject) => string;
|
|
5
8
|
export declare const join: (...paths: string[]) => string;
|
|
6
9
|
export declare const toPosix: (value: string) => string;
|
|
7
10
|
export declare const cwd: string;
|
package/dist/util/path.js
CHANGED
|
@@ -5,6 +5,7 @@ export const isAbsolute = path.isAbsolute;
|
|
|
5
5
|
export const dirname = path.posix.dirname;
|
|
6
6
|
export const extname = path.posix.extname;
|
|
7
7
|
export const basename = path.posix.basename;
|
|
8
|
+
export const format = path.posix.format;
|
|
8
9
|
export const join = path.posix.join;
|
|
9
10
|
export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
|
|
10
11
|
export const cwd = directory ? path.posix.resolve(directory) : toPosix(process.cwd());
|
|
@@ -2,12 +2,13 @@ import ts from 'typescript';
|
|
|
2
2
|
import { isFile } from './fs.js';
|
|
3
3
|
import { FAKE_PATH } from './loader.js';
|
|
4
4
|
import { dirname } from './path.js';
|
|
5
|
+
const dtsMatch = /\.d\.(c|m)?ts$/;
|
|
5
6
|
export const loadTSConfig = async (tsConfigFilePath) => {
|
|
6
7
|
if (tsConfigFilePath !== FAKE_PATH && isFile(tsConfigFilePath)) {
|
|
7
8
|
const config = ts.readConfigFile(tsConfigFilePath, ts.sys.readFile);
|
|
8
9
|
const parsedConfig = ts.parseJsonConfigFileContent(config.config, ts.sys, dirname(tsConfigFilePath));
|
|
9
10
|
const compilerOptions = parsedConfig.options ?? {};
|
|
10
|
-
const definitionPaths = parsedConfig.fileNames.filter(filePath =>
|
|
11
|
+
const definitionPaths = parsedConfig.fileNames.filter(filePath => dtsMatch.test(filePath));
|
|
11
12
|
return { compilerOptions, definitionPaths };
|
|
12
13
|
}
|
|
13
14
|
return { compilerOptions: {}, definitionPaths: [] };
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.0.
|
|
1
|
+
export declare const version = "5.0.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.4';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@npmcli/map-workspaces": "3.0.4",
|
|
59
59
|
"@npmcli/package-json": "5.0.0",
|
|
60
60
|
"@pnpm/logger": "5.0.0",
|
|
61
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.
|
|
61
|
+
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
|
62
62
|
"@snyk/github-codeowners": "1.1.0",
|
|
63
63
|
"@types/picomatch": "2.3.3",
|
|
64
64
|
"easy-table": "1.2.0",
|
|
@@ -70,12 +70,11 @@
|
|
|
70
70
|
"picocolors": "1.0.0",
|
|
71
71
|
"picomatch": "4.0.1",
|
|
72
72
|
"pretty-ms": "9.0.0",
|
|
73
|
-
"semver": "7.6.0",
|
|
74
73
|
"smol-toml": "1.1.4",
|
|
75
74
|
"strip-json-comments": "5.0.1",
|
|
76
75
|
"summary": "2.1.0",
|
|
77
76
|
"zod": "3.22.4",
|
|
78
|
-
"zod-validation-error": "3.0.
|
|
77
|
+
"zod-validation-error": "3.0.3"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"@types/node": ">=18",
|
|
@@ -85,23 +84,22 @@
|
|
|
85
84
|
"@jest/types": "29.6.3",
|
|
86
85
|
"@knip/eslint-config": "0.0.0",
|
|
87
86
|
"@release-it/bumper": "^6.0.1",
|
|
88
|
-
"@swc/cli": "^0.3.
|
|
89
|
-
"@swc/core": "^1.4.
|
|
87
|
+
"@swc/cli": "^0.3.10",
|
|
88
|
+
"@swc/core": "^1.4.6",
|
|
90
89
|
"@types/js-yaml": "^4.0.9",
|
|
91
90
|
"@types/micromatch": "^4.0.6",
|
|
92
91
|
"@types/minimist": "^1.2.5",
|
|
93
92
|
"@types/npmcli__map-workspaces": "^3.0.4",
|
|
94
93
|
"@types/npmcli__package-json": "^4.0.4",
|
|
95
|
-
"@types/semver": "7.5.7",
|
|
96
94
|
"@types/webpack": "^5.28.5",
|
|
97
95
|
"c8": "9.1.0",
|
|
98
|
-
"eslint": "^8.
|
|
99
|
-
"playwright": "^1.
|
|
96
|
+
"eslint": "^8.57.0",
|
|
97
|
+
"playwright": "^1.42.1",
|
|
100
98
|
"prettier": "^3.2.5",
|
|
101
99
|
"release-it": "^17.1.1",
|
|
102
100
|
"tsx": "^4.7.1",
|
|
103
|
-
"type-fest": "^4.
|
|
104
|
-
"typescript": "5.
|
|
101
|
+
"type-fest": "^4.12.0",
|
|
102
|
+
"typescript": "5.4.2"
|
|
105
103
|
},
|
|
106
104
|
"engines": {
|
|
107
105
|
"node": ">=18.6.0"
|