knip 5.0.1 → 5.0.3
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 +1 -1
- package/dist/ConfigurationChief.js +1 -1
- package/dist/ConfigurationValidator.d.ts +6 -6
- package/dist/ConfigurationValidator.js +2 -2
- package/dist/compilers/index.d.ts +2 -2
- package/dist/index.js +2 -0
- package/dist/plugins/eslint/index.js +5 -2
- package/dist/plugins/tailwind/index.d.ts +3 -2
- package/dist/plugins/tailwind/index.js +8 -2
- package/dist/reporters/json.js +4 -2
- package/dist/types/config.d.ts +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -57,7 +57,7 @@ export declare class ConfigurationChief {
|
|
|
57
57
|
private getAvailableWorkspaceManifests;
|
|
58
58
|
private getAvailableWorkspacePkgNames;
|
|
59
59
|
private determineIncludedWorkspaces;
|
|
60
|
-
getManifestForWorkspace(dir: string): PackageJson;
|
|
60
|
+
getManifestForWorkspace(dir: string): PackageJson | undefined;
|
|
61
61
|
getIncludedWorkspaces(): Workspace[];
|
|
62
62
|
private getDescendentWorkspaces;
|
|
63
63
|
private getIgnoredWorkspacesFor;
|
|
@@ -280,7 +280,7 @@ export class ConfigurationChief {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
getManifestForWorkspace(dir) {
|
|
283
|
-
return this.availableWorkspaceManifests?.find(item => item.dir === dir)?.manifest
|
|
283
|
+
return this.availableWorkspaceManifests?.find(item => item.dir === dir)?.manifest;
|
|
284
284
|
}
|
|
285
285
|
getIncludedWorkspaces() {
|
|
286
286
|
return this.includedWorkspaces;
|
|
@@ -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(),
|
|
@@ -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;
|
package/dist/index.js
CHANGED
|
@@ -93,6 +93,8 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
93
93
|
streamer.cast(`Analyzing workspace ${name}...`);
|
|
94
94
|
const manifest = chief.getManifestForWorkspace(dir);
|
|
95
95
|
const { ignoreBinaries, ignoreDependencies } = chief.getIgnores(name);
|
|
96
|
+
if (!manifest)
|
|
97
|
+
continue;
|
|
96
98
|
deputy.addWorkspace({ name, cwd, dir, manifestPath, manifest, ignoreBinaries, ignoreDependencies });
|
|
97
99
|
const dependencies = deputy.getDependencies(name);
|
|
98
100
|
const compilers = getIncludedCompilers(chief.config.syncCompilers, chief.config.asyncCompilers, dependencies);
|
|
@@ -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,8 +1,9 @@
|
|
|
1
|
-
import type { IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
1
|
+
import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
NAME: string;
|
|
4
4
|
ENABLERS: string[];
|
|
5
5
|
isEnabled: IsPluginEnabledCallback;
|
|
6
|
-
|
|
6
|
+
ENTRY_FILE_PATTERNS: string[];
|
|
7
|
+
findDependencies: GenericPluginCallback;
|
|
7
8
|
};
|
|
8
9
|
export default _default;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
2
3
|
const NAME = 'Tailwind';
|
|
3
4
|
const ENABLERS = ['tailwindcss'];
|
|
4
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
5
|
-
const
|
|
6
|
+
const ENTRY_FILE_PATTERNS = ['tailwind.config.{js,cjs,mjs,ts}'];
|
|
7
|
+
const findDependencies = async (configFilePath, options) => {
|
|
8
|
+
const { config } = options;
|
|
9
|
+
return config.entry ? config.entry.map(toEntryPattern) : ENTRY_FILE_PATTERNS.map(toEntryPattern);
|
|
10
|
+
};
|
|
6
11
|
export default {
|
|
7
12
|
NAME,
|
|
8
13
|
ENABLERS,
|
|
9
14
|
isEnabled,
|
|
10
|
-
|
|
15
|
+
ENTRY_FILE_PATTERNS,
|
|
16
|
+
findDependencies,
|
|
11
17
|
};
|
package/dist/reporters/json.js
CHANGED
|
@@ -65,8 +65,10 @@ export default async ({ report, issues, options }) => {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
const output = JSON.stringify({
|
|
69
69
|
files: Array.from(issues.files).map(filePath => relative(filePath)),
|
|
70
70
|
issues: Object.values(json),
|
|
71
|
-
})
|
|
71
|
+
});
|
|
72
|
+
process.stdout._handle?.setBlocking?.(true);
|
|
73
|
+
process.stdout.write(output + '\n');
|
|
72
74
|
};
|
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;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "5.0.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '
|
|
1
|
+
export const version = '5.0.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"strip-json-comments": "5.0.1",
|
|
76
76
|
"summary": "2.1.0",
|
|
77
77
|
"zod": "3.22.4",
|
|
78
|
-
"zod-validation-error": "3.0.
|
|
78
|
+
"zod-validation-error": "3.0.2"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@types/node": ">=18",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@knip/eslint-config": "0.0.0",
|
|
87
87
|
"@release-it/bumper": "^6.0.1",
|
|
88
88
|
"@swc/cli": "^0.3.9",
|
|
89
|
-
"@swc/core": "^1.4.
|
|
89
|
+
"@swc/core": "^1.4.2",
|
|
90
90
|
"@types/js-yaml": "^4.0.9",
|
|
91
91
|
"@types/micromatch": "^4.0.6",
|
|
92
92
|
"@types/minimist": "^1.2.5",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
"eslint": "^8.56.0",
|
|
99
99
|
"playwright": "^1.41.2",
|
|
100
100
|
"prettier": "^3.2.5",
|
|
101
|
-
"release-it": "^17.
|
|
101
|
+
"release-it": "^17.1.1",
|
|
102
102
|
"tsx": "^4.7.1",
|
|
103
|
-
"type-fest": "^4.10.
|
|
103
|
+
"type-fest": "^4.10.3",
|
|
104
104
|
"typescript": "5.3.3"
|
|
105
105
|
},
|
|
106
106
|
"engines": {
|