knip 5.64.0 → 5.64.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.
Files changed (50) hide show
  1. package/dist/CacheConsultant.js +1 -1
  2. package/dist/ConfigurationChief.d.ts +8 -8
  3. package/dist/DependencyDeputy.js +2 -2
  4. package/dist/IssueCollector.js +1 -1
  5. package/dist/ProjectPrincipal.d.ts +1 -1
  6. package/dist/ProjectPrincipal.js +2 -2
  7. package/dist/WorkspaceWorker.d.ts +1 -1
  8. package/dist/WorkspaceWorker.js +2 -2
  9. package/dist/binaries/index.js +1 -1
  10. package/dist/cli.js +9 -9
  11. package/dist/compilers/index.d.ts +37 -30
  12. package/dist/compilers/index.js +1 -1
  13. package/dist/graph/build.js +2 -2
  14. package/dist/index.js +2 -2
  15. package/dist/manifest/index.js +1 -1
  16. package/dist/plugins/changelogen/index.js +1 -1
  17. package/dist/plugins/changelogithub/index.js +1 -1
  18. package/dist/plugins/commitlint/index.js +1 -1
  19. package/dist/plugins/index.js +2 -2
  20. package/dist/plugins/lint-staged/index.js +1 -1
  21. package/dist/plugins/linthtml/index.js +1 -1
  22. package/dist/plugins/lockfile-lint/index.js +1 -1
  23. package/dist/plugins/node-modules-inspector/index.js +1 -1
  24. package/dist/plugins/npm-package-json-lint/index.js +1 -1
  25. package/dist/plugins/postcss/index.js +1 -1
  26. package/dist/plugins/react-router/index.js +1 -1
  27. package/dist/plugins/semantic-release/index.js +1 -1
  28. package/dist/plugins/size-limit/index.js +1 -1
  29. package/dist/plugins/stylelint/index.js +1 -1
  30. package/dist/plugins/syncpack/index.js +1 -1
  31. package/dist/plugins/unocss/index.js +1 -1
  32. package/dist/plugins.d.ts +1 -1
  33. package/dist/schema/configuration.d.ts +1187 -6505
  34. package/dist/schema/configuration.js +54 -51
  35. package/dist/schema/plugins.d.ts +579 -2641
  36. package/dist/schema/plugins.js +4 -4
  37. package/dist/types/config.d.ts +2 -2
  38. package/dist/typescript/get-imports-and-exports.js +1 -1
  39. package/dist/typescript/resolve-module-names.js +1 -1
  40. package/dist/util/create-options.d.ts +39 -32
  41. package/dist/util/errors.d.ts +4 -4
  42. package/dist/util/errors.js +8 -8
  43. package/dist/util/file-entry-cache.js +1 -1
  44. package/dist/util/glob-core.js +1 -1
  45. package/dist/util/glob.js +1 -1
  46. package/dist/util/input.d.ts +1 -1
  47. package/dist/util/loader.js +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/package.json +17 -18
@@ -1,12 +1,12 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod/mini';
2
2
  export const globSchema = z.union([z.string(), z.array(z.string())]);
3
3
  export const pluginSchema = z.union([
4
4
  z.boolean(),
5
5
  globSchema,
6
6
  z.object({
7
- config: globSchema.optional(),
8
- entry: globSchema.optional(),
9
- project: globSchema.optional(),
7
+ config: z.optional(globSchema),
8
+ entry: z.optional(globSchema),
9
+ project: z.optional(globSchema),
10
10
  }),
11
11
  ]);
12
12
  export const pluginsSchema = z.object({
@@ -1,13 +1,13 @@
1
1
  import type ts from 'typescript';
2
- import type { z } from 'zod';
2
+ import type { z } from 'zod/mini';
3
3
  import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
4
4
  import type { knipConfigurationSchema } from '../schema/configuration.js';
5
5
  import type { pluginSchema } from '../schema/plugins.js';
6
6
  import type { Input } from '../util/input.js';
7
- import type { PluginName } from './PluginNames.js';
8
7
  import type { Args } from './args.js';
9
8
  import type { SymbolType } from './issues.js';
10
9
  import type { Tags } from './options.js';
10
+ import type { PluginName } from './PluginNames.js';
11
11
  import type { PackageJson } from './package-json.js';
12
12
  export interface GetInputsFromScriptsOptions extends BaseOptions {
13
13
  knownBinsOnly?: boolean;
@@ -1,9 +1,9 @@
1
1
  import { isBuiltin } from 'node:module';
2
2
  import ts from 'typescript';
3
3
  import { ALIAS_TAG, ANONYMOUS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
4
- import { timerify } from '../util/Performance.js';
5
4
  import { addNsValue, addValue, createImports } from '../util/module-graph.js';
6
5
  import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
6
+ import { timerify } from '../util/Performance.js';
7
7
  import { isInNodeModules } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
9
9
  import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeRef, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isInForIteration, isObjectEnumerationCallExpressionArgument, isReferencedInExport, } from './ast-helpers.js';
@@ -2,8 +2,8 @@ import { existsSync } from 'node:fs';
2
2
  import { isBuiltin } from 'node:module';
3
3
  import ts from 'typescript';
4
4
  import { DEFAULT_EXTENSIONS } from '../constants.js';
5
- import { timerify } from '../util/Performance.js';
6
5
  import { sanitizeSpecifier } from '../util/modules.js';
6
+ import { timerify } from '../util/Performance.js';
7
7
  import { dirname, extname, isAbsolute, isInNodeModules, join } from '../util/path.js';
8
8
  import { _createSyncResolver, _resolveSync } from '../util/resolve.js';
9
9
  import { isDeclarationFileExtension } from './ast-helpers.js';
@@ -38,13 +38,6 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
38
38
  isTreatConfigHintsAsErrors: boolean;
39
39
  isWatch: boolean;
40
40
  parsedConfig: {
41
- node?: string | boolean | string[] | {
42
- config?: string | string[] | undefined;
43
- entry?: string | string[] | undefined;
44
- project?: string | string[] | undefined;
45
- } | undefined;
46
- entry?: string | string[] | undefined;
47
- project?: string | string[] | undefined;
48
41
  angular?: string | boolean | string[] | {
49
42
  config?: string | string[] | undefined;
50
43
  entry?: string | string[] | undefined;
@@ -300,6 +293,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
300
293
  entry?: string | string[] | undefined;
301
294
  project?: string | string[] | undefined;
302
295
  } | undefined;
296
+ node?: string | boolean | string[] | {
297
+ config?: string | string[] | undefined;
298
+ entry?: string | string[] | undefined;
299
+ project?: string | string[] | undefined;
300
+ } | undefined;
303
301
  'node-modules-inspector'?: string | boolean | string[] | {
304
302
  config?: string | string[] | undefined;
305
303
  entry?: string | string[] | undefined;
@@ -610,32 +608,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
610
608
  entry?: string | string[] | undefined;
611
609
  project?: string | string[] | undefined;
612
610
  } | undefined;
613
- exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
614
- $schema?: string | undefined;
615
- rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
616
- paths?: Record<string, string[]> | undefined;
617
- ignore?: string | string[] | undefined;
618
- ignoreBinaries?: (string | RegExp)[] | undefined;
619
- ignoreDependencies?: (string | RegExp)[] | undefined;
620
- ignoreMembers?: (string | RegExp)[] | undefined;
621
- ignoreUnresolved?: (string | RegExp)[] | undefined;
622
- ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
623
- ignoreWorkspaces?: string[] | undefined;
624
- includeEntryExports?: boolean | undefined;
625
- compilers?: Record<string, true | ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
626
- syncCompilers?: Record<string, true | ((args_0: string, args_1: string, ...args: unknown[]) => string)> | undefined;
627
- asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => Promise<string>> | undefined;
628
- tags?: string[] | undefined;
629
- treatConfigHintsAsErrors?: boolean | undefined;
630
- include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
631
611
  workspaces?: Record<string, {
632
- node?: string | boolean | string[] | {
633
- config?: string | string[] | undefined;
634
- entry?: string | string[] | undefined;
635
- project?: string | string[] | undefined;
636
- } | undefined;
637
- entry?: string | string[] | undefined;
638
- project?: string | string[] | undefined;
639
612
  angular?: string | boolean | string[] | {
640
613
  config?: string | string[] | undefined;
641
614
  entry?: string | string[] | undefined;
@@ -891,6 +864,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
891
864
  entry?: string | string[] | undefined;
892
865
  project?: string | string[] | undefined;
893
866
  } | undefined;
867
+ node?: string | boolean | string[] | {
868
+ config?: string | string[] | undefined;
869
+ entry?: string | string[] | undefined;
870
+ project?: string | string[] | undefined;
871
+ } | undefined;
894
872
  'node-modules-inspector'?: string | boolean | string[] | {
895
873
  config?: string | string[] | undefined;
896
874
  entry?: string | string[] | undefined;
@@ -1201,6 +1179,8 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1201
1179
  entry?: string | string[] | undefined;
1202
1180
  project?: string | string[] | undefined;
1203
1181
  } | undefined;
1182
+ entry?: string | string[] | undefined;
1183
+ project?: string | string[] | undefined;
1204
1184
  paths?: Record<string, string[]> | undefined;
1205
1185
  ignore?: string | string[] | undefined;
1206
1186
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -1209,6 +1189,33 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1209
1189
  ignoreUnresolved?: (string | RegExp)[] | undefined;
1210
1190
  includeEntryExports?: boolean | undefined;
1211
1191
  }> | undefined;
1192
+ include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
1193
+ exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
1194
+ $schema?: string | undefined;
1195
+ rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
1196
+ entry?: string | string[] | undefined;
1197
+ project?: string | string[] | undefined;
1198
+ paths?: Record<string, string[]> | undefined;
1199
+ ignore?: string | string[] | undefined;
1200
+ ignoreBinaries?: (string | RegExp)[] | undefined;
1201
+ ignoreDependencies?: (string | RegExp)[] | undefined;
1202
+ ignoreMembers?: (string | RegExp)[] | undefined;
1203
+ ignoreUnresolved?: (string | RegExp)[] | undefined;
1204
+ ignoreExportsUsedInFile?: boolean | {
1205
+ class?: boolean | undefined;
1206
+ enum?: boolean | undefined;
1207
+ function?: boolean | undefined;
1208
+ interface?: boolean | undefined;
1209
+ member?: boolean | undefined;
1210
+ type?: boolean | undefined;
1211
+ } | undefined;
1212
+ ignoreWorkspaces?: string[] | undefined;
1213
+ includeEntryExports?: boolean | undefined;
1214
+ compilers?: Record<string, true | ((filename: string, contents: string) => string) | ((filename: string, contents: string) => Promise<string>)> | undefined;
1215
+ syncCompilers?: Record<string, true | ((filename: string, contents: string) => string)> | undefined;
1216
+ asyncCompilers?: Record<string, (filename: string, contents: string) => Promise<string>> | undefined;
1217
+ tags?: string[] | undefined;
1218
+ treatConfigHintsAsErrors?: boolean | undefined;
1212
1219
  };
1213
1220
  rules: {
1214
1221
  files: import("../types/issues.js").IssueSeverity;
@@ -1,4 +1,4 @@
1
- import { ZodError } from 'zod';
1
+ import { core } from 'zod/mini';
2
2
  interface ErrorWithCause extends Error {
3
3
  cause: Error;
4
4
  }
@@ -6,8 +6,8 @@ export declare class ConfigurationError extends Error {
6
6
  }
7
7
  export declare class LoaderError extends Error {
8
8
  }
9
- export declare const isKnownError: (error: Error) => error is ZodError<any> | ConfigurationError | LoaderError;
10
- export declare const isDisplayReason: (error: Error) => error is ErrorWithCause;
9
+ export declare const isKnownError: (error: Error) => error is core.$ZodError<any> | ConfigurationError | LoaderError;
10
+ export declare const hasErrorCause: (error: Error) => error is ErrorWithCause;
11
11
  export declare const isConfigurationError: (error: Error) => error is ConfigurationError;
12
- export declare const getKnownError: (error: Error) => Error;
12
+ export declare const getKnownErrors: (error: Error) => Error[];
13
13
  export {};
@@ -1,14 +1,14 @@
1
- import { ZodError } from 'zod';
2
- import { fromZodError, isValidationError } from 'zod-validation-error';
1
+ import { core } from 'zod/mini';
2
+ const isZodErrorLike = (error) => error instanceof core.$ZodError;
3
3
  export class ConfigurationError extends Error {
4
4
  }
5
5
  export class LoaderError extends Error {
6
6
  }
7
- export const isKnownError = (error) => error instanceof ConfigurationError || error instanceof LoaderError || error instanceof ZodError;
8
- export const isDisplayReason = (error) => !isValidationError(error) && error.cause instanceof Error;
7
+ export const isKnownError = (error) => error instanceof ConfigurationError || error instanceof LoaderError || isZodErrorLike(error);
8
+ export const hasErrorCause = (error) => !isZodErrorLike(error) && error.cause instanceof Error;
9
9
  export const isConfigurationError = (error) => error instanceof ConfigurationError;
10
- export const getKnownError = (error) => {
11
- if (error instanceof ZodError)
12
- return fromZodError(error);
13
- return error;
10
+ export const getKnownErrors = (error) => {
11
+ if (isZodErrorLike(error))
12
+ return [...error.issues].map(error => new Error(error.message));
13
+ return [error];
14
14
  };
@@ -1,9 +1,9 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { deserialize, serialize } from 'node:v8';
4
- import { timerify } from './Performance.js';
5
4
  import { debugLog } from './debug.js';
6
5
  import { isDirectory, isFile } from './fs.js';
6
+ import { timerify } from './Performance.js';
7
7
  import { dirname, isAbsolute, resolve } from './path.js';
8
8
  const createCache = (filePath) => {
9
9
  try {
@@ -4,10 +4,10 @@ import { walk as _walk } from '@nodelib/fs.walk';
4
4
  import fg, {} from 'fast-glob';
5
5
  import picomatch from 'picomatch';
6
6
  import { GLOBAL_IGNORE_PATTERNS, ROOT_WORKSPACE_NAME } from '../constants.js';
7
- import { timerify } from './Performance.js';
8
7
  import { compact, partition } from './array.js';
9
8
  import { debugLogObject } from './debug.js';
10
9
  import { isDirectory, isFile } from './fs.js';
10
+ import { timerify } from './Performance.js';
11
11
  import { parseAndConvertGitignorePatterns } from './parse-and-convert-gitignores.js';
12
12
  import { dirname, join, relative, toPosix } from './path.js';
13
13
  const walk = promisify(_walk);
package/dist/util/glob.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import fg from 'fast-glob';
2
2
  import { GLOBAL_IGNORE_PATTERNS } from '../constants.js';
3
- import { timerify } from './Performance.js';
4
3
  import { compact } from './array.js';
5
4
  import { glob } from './glob-core.js';
5
+ import { timerify } from './Performance.js';
6
6
  import { isAbsolute, join, relative } from './path.js';
7
7
  const prepend = (pattern, relativePath) => isAbsolute(pattern.replace(/^!/, '')) ? pattern : prependDirToPattern(relativePath, pattern);
8
8
  const prependDirToPatterns = (cwd, dir, patterns) => {
@@ -1,5 +1,5 @@
1
- import type { PluginName } from '../types/PluginNames.js';
2
1
  import type { IssueType } from '../types/issues.js';
2
+ import type { PluginName } from '../types/PluginNames.js';
3
3
  type InputType = 'binary' | 'entry' | 'project' | 'config' | 'dependency' | 'deferResolve' | 'deferResolveEntry' | 'alias' | 'ignore';
4
4
  export interface Input {
5
5
  type: InputType;
@@ -1,7 +1,7 @@
1
- import { timerify } from './Performance.js';
2
1
  import { LoaderError } from './errors.js';
3
2
  import { loadFile, loadJSON, loadTOML, loadYAML, parseJSON, parseYAML } from './fs.js';
4
3
  import { jiti } from './jiti.js';
4
+ import { timerify } from './Performance.js';
5
5
  import { extname, isInternal } from './path.js';
6
6
  const load = async (filePath) => {
7
7
  try {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.64.0";
1
+ export declare const version = "5.64.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.64.0';
1
+ export const version = '5.64.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.64.0",
3
+ "version": "5.64.1",
4
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": {
@@ -34,20 +34,20 @@
34
34
  "scripts": {
35
35
  "knip": "node ./dist/cli.js --directory ../..",
36
36
  "knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
37
- "lint": "biome lint ../..",
38
- "format": "biome format --write .",
39
- "test": "bun test test/*.test.ts test/**/*.test.ts",
40
- "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)",
41
- "test:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
42
- "test:node": "glob -c \"tsx --test --import ./transform-test.js\" \"test/**/*.test.ts\"",
43
- "test:node:smoke": "glob -c \"tsx --test --import ./transform-test.js\" \"test/*.test.ts\" && glob -c \"tsx --test --import ./transform-test.js\" \"test/{plugins,util}/*.test.ts\"",
37
+ "lint": "biome lint",
38
+ "format": "biome format --write",
39
+ "test": "node scripts/run-test.ts",
40
+ "test:node": "tsx --test test/*.test.ts test/**/*.test.ts",
41
+ "test:bun": "bun test test/*.test.ts test/**/*.test.ts",
42
+ "test:smoke": "glob -c \"tsx --test\" \"test/*.test.ts\" && glob -c \"tsx --test\" \"test/{plugins,util}/*.test.ts\"",
43
+ "test:bun:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
44
44
  "watch": "npm link && tsc --watch",
45
- "prebuild": "npm run generate-plugin-defs && node rmdir.js dist",
45
+ "prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
46
46
  "build": "tsc",
47
- "qa": "bun lint && bun run build && bun knip && bun knip:production && bun run test",
47
+ "qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm run test",
48
48
  "release": "release-it",
49
- "create-plugin": "bun ./scripts/create-new-plugin.ts",
50
- "postcreate-plugin": "bun run build && biome format --write schema.json schema-jsonc.json src/schema/plugins.ts",
49
+ "create-plugin": "node ./scripts/create-new-plugin.ts",
50
+ "postcreate-plugin": "pnpm run build && biome format --write schema.json schema-jsonc.json src/schema/plugins.ts",
51
51
  "generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && biome check --write src/plugins/index.ts src/types/PluginNames.ts src/schema/plugins.ts"
52
52
  },
53
53
  "files": [
@@ -60,25 +60,24 @@
60
60
  "@nodelib/fs.walk": "^1.2.3",
61
61
  "fast-glob": "^3.3.3",
62
62
  "formatly": "^0.3.0",
63
- "jiti": "^2.5.1",
63
+ "jiti": "^2.6.0",
64
64
  "js-yaml": "^4.1.0",
65
65
  "minimist": "^1.2.8",
66
- "oxc-resolver": "^11.8.2",
66
+ "oxc-resolver": "^11.8.3",
67
67
  "picocolors": "^1.1.1",
68
68
  "picomatch": "^4.0.1",
69
69
  "smol-toml": "^1.4.1",
70
70
  "strip-json-comments": "5.0.2",
71
- "zod": "^3.25.0",
72
- "zod-validation-error": "^3.0.3"
71
+ "zod": "^4.1.11"
73
72
  },
74
73
  "peerDependencies": {
75
74
  "@types/node": ">=18",
76
- "typescript": ">=5.0.4"
75
+ "typescript": ">=5.0.4 <7"
77
76
  },
78
77
  "devDependencies": {
79
78
  "@jest/types": "^29.6.3",
80
79
  "@release-it/bumper": "^7.0.5",
81
- "@types/bun": "1.2.19",
80
+ "@types/bun": "1.2.22",
82
81
  "@types/js-yaml": "^4.0.9",
83
82
  "@types/minimist": "^1.2.5",
84
83
  "@types/picomatch": "3.0.1",