knip 5.63.1 → 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 (112) hide show
  1. package/dist/CacheConsultant.js +1 -1
  2. package/dist/ConfigurationChief.d.ts +20 -8
  3. package/dist/DependencyDeputy.js +5 -4
  4. package/dist/IssueCollector.js +1 -1
  5. package/dist/IssueFixer.js +3 -1
  6. package/dist/ProjectPrincipal.d.ts +1 -1
  7. package/dist/ProjectPrincipal.js +2 -2
  8. package/dist/WorkspaceWorker.d.ts +1 -1
  9. package/dist/WorkspaceWorker.js +2 -2
  10. package/dist/binaries/bash-parser.d.ts +1 -0
  11. package/dist/binaries/bash-parser.js +3 -0
  12. package/dist/binaries/fallback.js +3 -2
  13. package/dist/binaries/index.js +1 -1
  14. package/dist/binaries/package-manager/bun.js +1 -0
  15. package/dist/binaries/plugins.js +3 -1
  16. package/dist/cli.js +9 -9
  17. package/dist/compilers/index.d.ts +57 -30
  18. package/dist/compilers/index.js +1 -1
  19. package/dist/constants.js +2 -0
  20. package/dist/graph/analyze.js +7 -4
  21. package/dist/graph/build.js +9 -9
  22. package/dist/index.js +2 -2
  23. package/dist/manifest/index.js +1 -1
  24. package/dist/plugins/angular/index.js +2 -3
  25. package/dist/plugins/bumpp/index.d.ts +8 -0
  26. package/dist/plugins/bumpp/index.js +11 -0
  27. package/dist/plugins/changelogen/index.js +1 -1
  28. package/dist/plugins/changelogithub/index.js +1 -1
  29. package/dist/plugins/commitlint/index.js +1 -1
  30. package/dist/plugins/eslint/index.d.ts +7 -0
  31. package/dist/plugins/eslint/index.js +12 -0
  32. package/dist/plugins/glob/index.d.ts +0 -1
  33. package/dist/plugins/glob/index.js +0 -1
  34. package/dist/plugins/index.d.ts +19 -7
  35. package/dist/plugins/index.js +6 -2
  36. package/dist/plugins/karma/helpers.js +1 -1
  37. package/dist/plugins/lint-staged/index.js +1 -1
  38. package/dist/plugins/linthtml/index.js +1 -1
  39. package/dist/plugins/lockfile-lint/index.js +1 -1
  40. package/dist/plugins/node-modules-inspector/index.d.ts +0 -1
  41. package/dist/plugins/node-modules-inspector/index.js +1 -2
  42. package/dist/plugins/npm-package-json-lint/index.js +1 -1
  43. package/dist/plugins/nuxt/index.js +7 -1
  44. package/dist/plugins/nuxt/types.d.ts +1 -1
  45. package/dist/plugins/oxlint/index.d.ts +0 -1
  46. package/dist/plugins/oxlint/index.js +0 -1
  47. package/dist/plugins/playwright/index.d.ts +0 -1
  48. package/dist/plugins/playwright/index.js +0 -1
  49. package/dist/plugins/playwright-test/index.d.ts +0 -1
  50. package/dist/plugins/playwright-test/index.js +0 -1
  51. package/dist/plugins/pnpm/index.d.ts +1 -0
  52. package/dist/plugins/pnpm/index.js +5 -1
  53. package/dist/plugins/postcss/index.js +1 -1
  54. package/dist/plugins/prisma/index.d.ts +0 -1
  55. package/dist/plugins/prisma/index.js +0 -1
  56. package/dist/plugins/react-router/index.js +1 -1
  57. package/dist/plugins/rslib/index.js +1 -1
  58. package/dist/plugins/rstest/index.d.ts +10 -0
  59. package/dist/plugins/rstest/index.js +29 -0
  60. package/dist/plugins/rstest/types.d.ts +6 -0
  61. package/dist/plugins/rstest/types.js +1 -0
  62. package/dist/plugins/semantic-release/index.js +1 -1
  63. package/dist/plugins/size-limit/index.js +1 -1
  64. package/dist/plugins/stylelint/index.js +1 -1
  65. package/dist/plugins/syncpack/index.js +1 -1
  66. package/dist/plugins/ts-node/index.d.ts +0 -1
  67. package/dist/plugins/ts-node/index.js +0 -1
  68. package/dist/plugins/unocss/index.js +1 -1
  69. package/dist/plugins.d.ts +1 -1
  70. package/dist/reporters/githubActions.d.ts +3 -0
  71. package/dist/reporters/githubActions.js +94 -0
  72. package/dist/reporters/index.d.ts +1 -0
  73. package/dist/reporters/index.js +2 -0
  74. package/dist/reporters/json.js +1 -1
  75. package/dist/reporters/util/configuration-hints.d.ts +13 -1
  76. package/dist/reporters/util/configuration-hints.js +1 -0
  77. package/dist/schema/configuration.d.ts +1187 -6393
  78. package/dist/schema/configuration.js +54 -51
  79. package/dist/schema/plugins.d.ts +579 -2595
  80. package/dist/schema/plugins.js +6 -4
  81. package/dist/types/PluginNames.d.ts +2 -2
  82. package/dist/types/PluginNames.js +2 -0
  83. package/dist/types/args.d.ts +2 -0
  84. package/dist/types/config.d.ts +2 -2
  85. package/dist/types/exports.d.ts +1 -1
  86. package/dist/types/imports.d.ts +1 -1
  87. package/dist/types/module-graph.d.ts +5 -4
  88. package/dist/typescript/SourceFile.d.ts +2 -2
  89. package/dist/typescript/ast-helpers.d.ts +4 -0
  90. package/dist/typescript/ast-helpers.js +29 -0
  91. package/dist/typescript/find-internal-references.js +10 -1
  92. package/dist/typescript/get-imports-and-exports.js +28 -18
  93. package/dist/typescript/resolve-module-names.js +1 -1
  94. package/dist/typescript/visitors/dynamic-imports/importCall.js +6 -1
  95. package/dist/util/cli-arguments.d.ts +3 -2
  96. package/dist/util/cli-arguments.js +2 -2
  97. package/dist/util/create-options.d.ts +61 -35
  98. package/dist/util/create-options.js +1 -1
  99. package/dist/util/errors.d.ts +4 -4
  100. package/dist/util/errors.js +8 -8
  101. package/dist/util/file-entry-cache.js +1 -1
  102. package/dist/util/glob-core.js +1 -1
  103. package/dist/util/glob.js +1 -1
  104. package/dist/util/input.d.ts +1 -1
  105. package/dist/util/load-config.d.ts +2 -1
  106. package/dist/util/load-config.js +4 -4
  107. package/dist/util/loader.js +1 -1
  108. package/dist/util/modules.js +18 -7
  109. package/dist/version.d.ts +1 -1
  110. package/dist/version.js +1 -1
  111. package/package.json +18 -19
  112. package/schema.json +8 -0
@@ -1,5 +1,5 @@
1
- import { timerify } from './util/Performance.js';
2
1
  import { FileEntryCache } from './util/file-entry-cache.js';
2
+ import { timerify } from './util/Performance.js';
3
3
  import { version } from './version.js';
4
4
  const dummyFileDescriptor = { key: '', changed: true, notFound: true };
5
5
  export class CacheConsultant {
@@ -52,13 +52,6 @@ export declare class ConfigurationChief {
52
52
  getNegatedWorkspacePatterns(name: string): string[];
53
53
  private getConfigKeyForWorkspace;
54
54
  getWorkspaceConfig(workspaceName: string): {
55
- node?: string | boolean | string[] | {
56
- config?: string | string[] | undefined;
57
- entry?: string | string[] | undefined;
58
- project?: string | string[] | undefined;
59
- } | undefined;
60
- entry?: string | string[] | undefined;
61
- project?: string | string[] | undefined;
62
55
  angular?: string | boolean | string[] | {
63
56
  config?: string | string[] | undefined;
64
57
  entry?: string | string[] | undefined;
@@ -84,6 +77,11 @@ export declare class ConfigurationChief {
84
77
  entry?: string | string[] | undefined;
85
78
  project?: string | string[] | undefined;
86
79
  } | undefined;
80
+ bumpp?: string | boolean | string[] | {
81
+ config?: string | string[] | undefined;
82
+ entry?: string | string[] | undefined;
83
+ project?: string | string[] | undefined;
84
+ } | undefined;
87
85
  bun?: string | boolean | string[] | {
88
86
  config?: string | string[] | undefined;
89
87
  entry?: string | string[] | undefined;
@@ -309,6 +307,11 @@ export declare class ConfigurationChief {
309
307
  entry?: string | string[] | undefined;
310
308
  project?: string | string[] | undefined;
311
309
  } | undefined;
310
+ node?: string | boolean | string[] | {
311
+ config?: string | string[] | undefined;
312
+ entry?: string | string[] | undefined;
313
+ project?: string | string[] | undefined;
314
+ } | undefined;
312
315
  'node-modules-inspector'?: string | boolean | string[] | {
313
316
  config?: string | string[] | undefined;
314
317
  entry?: string | string[] | undefined;
@@ -444,6 +447,11 @@ export declare class ConfigurationChief {
444
447
  entry?: string | string[] | undefined;
445
448
  project?: string | string[] | undefined;
446
449
  } | undefined;
450
+ rstest?: string | boolean | string[] | {
451
+ config?: string | string[] | undefined;
452
+ entry?: string | string[] | undefined;
453
+ project?: string | string[] | undefined;
454
+ } | undefined;
447
455
  'semantic-release'?: string | boolean | string[] | {
448
456
  config?: string | string[] | undefined;
449
457
  entry?: string | string[] | undefined;
@@ -614,6 +622,8 @@ export declare class ConfigurationChief {
614
622
  entry?: string | string[] | undefined;
615
623
  project?: string | string[] | undefined;
616
624
  } | undefined;
625
+ entry?: string | string[] | undefined;
626
+ project?: string | string[] | undefined;
617
627
  paths?: Record<string, string[]> | undefined;
618
628
  ignore?: string | string[] | undefined;
619
629
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -628,12 +638,12 @@ export declare class ConfigurationChief {
628
638
  ignoreUnresolved: (string | RegExp)[];
629
639
  };
630
640
  getConfigForWorkspace(workspaceName: string, extensions?: string[]): {
631
- node?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
632
641
  angular?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
633
642
  astro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
634
643
  ava?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
635
644
  babel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
636
645
  biome?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
646
+ bumpp?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
637
647
  bun?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
638
648
  c8?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
639
649
  capacitor?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -679,6 +689,7 @@ export declare class ConfigurationChief {
679
689
  nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
680
690
  netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
681
691
  next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
692
+ node?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
682
693
  "node-modules-inspector"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
683
694
  nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
684
695
  "npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -706,6 +717,7 @@ export declare class ConfigurationChief {
706
717
  rsbuild?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
707
718
  rslib?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
708
719
  rspack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
720
+ rstest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
709
721
  "semantic-release"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
710
722
  sentry?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
711
723
  "simple-git-hooks"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -1,9 +1,10 @@
1
1
  import { isBuiltin } from 'node:module';
2
- import { PackagePeeker } from './PackagePeeker.js';
3
- import { DT_SCOPE, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES, IGNORE_DEFINITELY_TYPED, ROOT_WORKSPACE_NAME, } from './constants.js';
2
+ import { DT_SCOPE, IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES, ROOT_WORKSPACE_NAME, } from './constants.js';
4
3
  import { getDependencyMetaData } from './manifest/index.js';
4
+ import { PackagePeeker } from './PackagePeeker.js';
5
5
  import { getDefinitelyTypedFor, getPackageFromDefinitelyTyped, getPackageNameFromModuleSpecifier, isDefinitelyTyped, } from './util/modules.js';
6
6
  import { findMatch, toRegexOrString } from './util/regex.js';
7
+ const filterIsProduction = (id, isProduction) => typeof id === 'string' ? (isProduction || !id.endsWith('!') ? id.replace(/!$/, '') : []) : id;
7
8
  export class DependencyDeputy {
8
9
  isProduction;
9
10
  isStrict;
@@ -46,8 +47,8 @@ export class DependencyDeputy {
46
47
  this.setHostDependencies(name, hostDependencies);
47
48
  this.setInstalledBinaries(name, installedBinaries);
48
49
  this.setHasTypesIncluded(name, hasTypesIncluded);
49
- const ignoreDependencies = id.map(toRegexOrString);
50
- const ignoreBinaries = ib.map(toRegexOrString);
50
+ const ignoreDependencies = id.flatMap(id => filterIsProduction(id, this.isProduction)).map(toRegexOrString);
51
+ const ignoreBinaries = ib.flatMap(ib => filterIsProduction(ib, this.isProduction)).map(toRegexOrString);
51
52
  const ignoreUnresolved = iu.map(toRegexOrString);
52
53
  this._manifests.set(name, {
53
54
  workspaceDir: dir,
@@ -1,6 +1,6 @@
1
1
  import picomatch from 'picomatch';
2
- import { timerify } from './util/Performance.js';
3
2
  import { initCounters, initIssues } from './util/issue-initializers.js';
3
+ import { timerify } from './util/Performance.js';
4
4
  import { join, relative } from './util/path.js';
5
5
  const hasConfigurationHint = (hints, hint) => Array.from(hints).some(item => item.identifier === hint.identifier && item.type === hint.type && item.workspaceName === hint.workspaceName);
6
6
  const isMatch = timerify(picomatch.isMatch, 'isMatch');
@@ -62,7 +62,9 @@ export class IssueFixer {
62
62
  for (const filePath of filePaths) {
63
63
  const types = (this.options.isFixUnusedTypes && this.unusedTypeNodes.get(filePath)) || [];
64
64
  const exports = (this.options.isFixUnusedExports && this.unusedExportNodes.get(filePath)) || [];
65
- const exportPositions = [...types, ...exports].filter(fix => fix !== undefined).sort((a, b) => b[0] - a[0]);
65
+ const exportPositions = [...types, ...exports]
66
+ .filter((fix) => fix !== undefined)
67
+ .sort((a, b) => b[0] - a[0]);
66
68
  if (exportPositions.length > 0) {
67
69
  const sourceFileText = exportPositions.reduce((text, [start, end, flags]) => removeExport({ text, start, end, flags }), await readFile(filePath, 'utf-8'));
68
70
  await writeFile(filePath, sourceFileText);
@@ -4,8 +4,8 @@ import type { AsyncCompilers, SyncCompilers } from './compilers/types.js';
4
4
  import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile } from './types/config.js';
5
5
  import type { Export, ExportMember, FileNode, ModuleGraph } from './types/module-graph.js';
6
6
  import type { Paths, PrincipalOptions } from './types/project.js';
7
- import { SourceFileManager } from './typescript/SourceFileManager.js';
8
7
  import type { ResolveModuleNames } from './typescript/resolve-module-names.js';
8
+ import { SourceFileManager } from './typescript/SourceFileManager.js';
9
9
  import type { MainOptions } from './util/create-options.js';
10
10
  import type { ToSourceFilePath } from './util/to-source-path.js';
11
11
  export declare class ProjectPrincipal {
@@ -2,11 +2,11 @@ import ts from 'typescript';
2
2
  import { CacheConsultant } from './CacheConsultant.js';
3
3
  import { getCompilerExtensions } from './compilers/index.js';
4
4
  import { ANONYMOUS, DEFAULT_EXTENSIONS, PUBLIC_TAG } from './constants.js';
5
- import { SourceFileManager } from './typescript/SourceFileManager.js';
6
5
  import { createHosts } from './typescript/create-hosts.js';
7
6
  import { _getImportsAndExports } from './typescript/get-imports-and-exports.js';
8
- import { timerify } from './util/Performance.js';
7
+ import { SourceFileManager } from './typescript/SourceFileManager.js';
9
8
  import { compact } from './util/array.js';
9
+ import { timerify } from './util/Performance.js';
10
10
  import { extname, isInNodeModules, toAbsolute } from './util/path.js';
11
11
  const baseCompilerOptions = {
12
12
  allowJs: true,
@@ -1,8 +1,8 @@
1
1
  import { CacheConsultant } from './CacheConsultant.js';
2
2
  import { type Workspace } from './ConfigurationChief.js';
3
- import type { PluginName } from './types/PluginNames.js';
4
3
  import type { Configuration, GetReferencedInternalFilePath, GetSourceFile, WorkspaceConfiguration } from './types/config.js';
5
4
  import type { ConfigurationHints } from './types/issues.js';
5
+ import type { PluginName } from './types/PluginNames.js';
6
6
  import type { PackageJson } from './types/package-json.js';
7
7
  import type { DependencySet } from './types/workspace.js';
8
8
  import type { MainOptions } from './util/create-options.js';
@@ -1,16 +1,16 @@
1
1
  import picomatch from 'picomatch';
2
+ import { _getInputsFromScripts } from './binaries/index.js';
2
3
  import { CacheConsultant } from './CacheConsultant.js';
3
4
  import { isDefaultPattern } from './ConfigurationChief.js';
4
- import { _getInputsFromScripts } from './binaries/index.js';
5
5
  import { ROOT_WORKSPACE_NAME } from './constants.js';
6
6
  import { getFilteredScripts } from './manifest/helpers.js';
7
7
  import { PluginEntries, Plugins } from './plugins.js';
8
- import { timerify } from './util/Performance.js';
9
8
  import { compact } from './util/array.js';
10
9
  import { debugLogArray, debugLogObject } from './util/debug.js';
11
10
  import { _glob, hasNoProductionSuffix, hasProductionSuffix, negate, prependDirToPattern } from './util/glob.js';
12
11
  import { isConfig, toConfig, toDebugString, toEntry, toProductionEntry, } from './util/input.js';
13
12
  import { getKeysByValue } from './util/object.js';
13
+ import { timerify } from './util/Performance.js';
14
14
  import { basename, dirname, join } from './util/path.js';
15
15
  import { loadConfigForPlugin } from './util/plugin.js';
16
16
  import { ELLIPSIS } from './util/string.js';
@@ -1,3 +1,4 @@
1
1
  import type { GetInputsFromScriptsOptions } from '../types/config.js';
2
2
  import { type Input } from '../util/input.js';
3
+ export declare const isValidBinary: (str: string) => boolean;
3
4
  export declare const getDependenciesFromScript: (script: string, options: GetInputsFromScriptsOptions) => Input[];
@@ -12,10 +12,13 @@ import { parseNodeArgs } from './util.js';
12
12
  const spawningBinaries = ['cross-env', 'retry-cli'];
13
13
  const isExpansion = (node) => 'expansion' in node;
14
14
  const isAssignment = (node) => 'type' in node && node.type === 'AssignmentWord';
15
+ export const isValidBinary = (str) => !/[*:!()]/.test(str);
15
16
  export const getDependenciesFromScript = (script, options) => {
16
17
  if (!script)
17
18
  return [];
18
19
  const fromArgs = (args, opts) => {
20
+ if (args.length === 0 || !isValidBinary(args[0]))
21
+ return [];
19
22
  return getDependenciesFromScript(args.filter(arg => arg !== '--').join(' '), {
20
23
  ...options,
21
24
  ...opts,
@@ -1,13 +1,14 @@
1
1
  import parseArgs from 'minimist';
2
2
  import { compact } from '../util/array.js';
3
3
  import { toBinary, toDeferResolve, toEntry } from '../util/input.js';
4
+ import { isValidBinary } from './bash-parser.js';
4
5
  const spawningBinaries = ['cross-env', 'retry-cli'];
5
- const endOfCommandBinaries = ['dotenvx'];
6
+ const endOfCommandBinaries = ['dotenvx', 'env-cmd'];
6
7
  const positionals = new Set(['babel-node', 'esbuild', 'execa', 'jiti', 'oxnode', 'vite-node', 'zx']);
7
8
  const positionalBinaries = new Set(['concurrently']);
8
9
  export const resolve = (binary, args, { fromArgs }) => {
9
10
  const parsed = parseArgs(args, { boolean: ['quiet', 'verbose'], '--': endOfCommandBinaries.includes(binary) });
10
- const bin = binary.startsWith('.') ? toEntry(binary) : /[*:]/.test(binary) ? undefined : toBinary(binary);
11
+ const bin = binary.startsWith('.') ? toEntry(binary) : isValidBinary(binary) ? toBinary(binary) : undefined;
11
12
  const shiftedArgs = spawningBinaries.includes(binary) ? fromArgs(args) : [];
12
13
  const pos = positionals.has(binary) ? [toDeferResolve(parsed._[0])] : [];
13
14
  const newCommand = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--']) : [];
@@ -1,5 +1,5 @@
1
- import { timerify } from '../util/Performance.js';
2
1
  import { fromBinary, isBinary, isDependency } from '../util/input.js';
2
+ import { timerify } from '../util/Performance.js';
3
3
  import { getDependenciesFromScript } from './bash-parser.js';
4
4
  const getInputsFromScripts = (npmScripts, options) => {
5
5
  const scripts = typeof npmScripts === 'string' ? [npmScripts] : Array.from(npmScripts);
@@ -6,6 +6,7 @@ import { resolveX } from './bunx.js';
6
6
  const commands = [
7
7
  'add',
8
8
  'audit',
9
+ 'ci',
9
10
  'create',
10
11
  'init',
11
12
  'install',
@@ -48,7 +48,7 @@ export const resolve = (binary, _args, options) => {
48
48
  const resolvedFromArgs = typeof pluginArgs.fromArgs === 'function'
49
49
  ? fromArgs(pluginArgs.fromArgs(parsed, args))
50
50
  : Array.isArray(pluginArgs.fromArgs)
51
- ? fromArgs(pluginArgs.fromArgs.flatMap(mapToParsedKey))
51
+ ? fromArgs(pluginArgs.fromArgs.flatMap(mapToParsedKey).filter(Boolean))
52
52
  : [];
53
53
  const config = pluginArgs.config === true ? ['config'] : pluginArgs.config || [];
54
54
  const mapToConfigPattern = (value) => {
@@ -58,6 +58,7 @@ export const resolve = (binary, _args, options) => {
58
58
  return parsed[id] && pluginName ? [toConfig(pluginName, fn(parsed[id]), inputOpts)] : [];
59
59
  };
60
60
  const configFilePaths = config.flatMap(mapToConfigPattern);
61
+ const inputs = pluginArgs.resolveInputs?.(parsed, args) ?? [];
61
62
  return [
62
63
  toBinary(binary, inputOpts),
63
64
  ...positionals,
@@ -65,5 +66,6 @@ export const resolve = (binary, _args, options) => {
65
66
  ...resolvedImports.map(id => toDeferResolve(id)),
66
67
  ...resolvedFromArgs,
67
68
  ...configFilePaths,
69
+ ...inputs,
68
70
  ];
69
71
  };
package/dist/cli.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { main } from './index.js';
2
- import { perfObserver } from './util/Performance.js';
3
- import { helpText } from './util/cli-arguments.js';
4
- import parseArgs from './util/cli-arguments.js';
2
+ import parseArgs, { helpText } from './util/cli-arguments.js';
5
3
  import { createOptions } from './util/create-options.js';
6
- import { getKnownError, isConfigurationError, isDisplayReason, isKnownError } from './util/errors.js';
4
+ import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError } from './util/errors.js';
7
5
  import { logError, logWarning } from './util/log.js';
6
+ import { perfObserver } from './util/Performance.js';
8
7
  import { runPreprocessors, runReporters } from './util/reporter.js';
9
8
  import { prettyMilliseconds } from './util/string.js';
10
9
  import { version } from './version.js';
@@ -80,11 +79,12 @@ const run = async () => {
80
79
  catch (error) {
81
80
  process.exitCode = 2;
82
81
  if (!parsedCLIArgs.debug && error instanceof Error && isKnownError(error)) {
83
- const knownError = getKnownError(error);
84
- logError('ERROR', knownError.message);
85
- if (isDisplayReason(knownError))
86
- console.error('Reason:', knownError.cause.message);
87
- if (isConfigurationError(knownError))
82
+ const knownErrors = getKnownErrors(error);
83
+ for (const knownError of knownErrors)
84
+ logError('ERROR', knownError.message);
85
+ if (hasErrorCause(knownErrors[0]))
86
+ console.error('Reason:', knownErrors[0].cause.message);
87
+ if (isConfigurationError(knownErrors[0]))
88
88
  console.log('\nRun `knip --help` or visit https://knip.dev for help');
89
89
  process.exit(2);
90
90
  }
@@ -4,13 +4,6 @@ import type { AsyncCompilerFn, AsyncCompilers, RawSyncCompilers, SyncCompilerFn,
4
4
  export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
5
5
  syncCompilers: Record<string, SyncCompilerFn>;
6
6
  asyncCompilers: Record<string, AsyncCompilerFn>;
7
- node?: string | boolean | string[] | {
8
- config?: string | string[] | undefined;
9
- entry?: string | string[] | undefined;
10
- project?: string | string[] | undefined;
11
- } | undefined;
12
- entry?: string | string[] | undefined;
13
- project?: string | string[] | undefined;
14
7
  angular?: string | boolean | string[] | {
15
8
  config?: string | string[] | undefined;
16
9
  entry?: string | string[] | undefined;
@@ -36,6 +29,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
36
29
  entry?: string | string[] | undefined;
37
30
  project?: string | string[] | undefined;
38
31
  } | undefined;
32
+ bumpp?: string | boolean | string[] | {
33
+ config?: string | string[] | undefined;
34
+ entry?: string | string[] | undefined;
35
+ project?: string | string[] | undefined;
36
+ } | undefined;
39
37
  bun?: string | boolean | string[] | {
40
38
  config?: string | string[] | undefined;
41
39
  entry?: string | string[] | undefined;
@@ -261,6 +259,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
261
259
  entry?: string | string[] | undefined;
262
260
  project?: string | string[] | undefined;
263
261
  } | undefined;
262
+ node?: string | boolean | string[] | {
263
+ config?: string | string[] | undefined;
264
+ entry?: string | string[] | undefined;
265
+ project?: string | string[] | undefined;
266
+ } | undefined;
264
267
  'node-modules-inspector'?: string | boolean | string[] | {
265
268
  config?: string | string[] | undefined;
266
269
  entry?: string | string[] | undefined;
@@ -396,6 +399,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
396
399
  entry?: string | string[] | undefined;
397
400
  project?: string | string[] | undefined;
398
401
  } | undefined;
402
+ rstest?: string | boolean | string[] | {
403
+ config?: string | string[] | undefined;
404
+ entry?: string | string[] | undefined;
405
+ project?: string | string[] | undefined;
406
+ } | undefined;
399
407
  'semantic-release'?: string | boolean | string[] | {
400
408
  config?: string | string[] | undefined;
401
409
  entry?: string | string[] | undefined;
@@ -566,30 +574,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
566
574
  entry?: string | string[] | undefined;
567
575
  project?: string | string[] | undefined;
568
576
  } | undefined;
569
- exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
570
- $schema?: string | undefined;
571
- rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
572
- paths?: Record<string, string[]> | undefined;
573
- ignore?: string | string[] | undefined;
574
- ignoreBinaries?: (string | RegExp)[] | undefined;
575
- ignoreDependencies?: (string | RegExp)[] | undefined;
576
- ignoreMembers?: (string | RegExp)[] | undefined;
577
- ignoreUnresolved?: (string | RegExp)[] | undefined;
578
- ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
579
- ignoreWorkspaces?: string[] | undefined;
580
- includeEntryExports?: boolean | undefined;
581
- compilers?: Record<string, true | ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
582
- tags?: string[] | undefined;
583
- treatConfigHintsAsErrors?: boolean | undefined;
584
- include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
585
577
  workspaces?: Record<string, {
586
- node?: string | boolean | string[] | {
587
- config?: string | string[] | undefined;
588
- entry?: string | string[] | undefined;
589
- project?: string | string[] | undefined;
590
- } | undefined;
591
- entry?: string | string[] | undefined;
592
- project?: string | string[] | undefined;
593
578
  angular?: string | boolean | string[] | {
594
579
  config?: string | string[] | undefined;
595
580
  entry?: string | string[] | undefined;
@@ -615,6 +600,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
615
600
  entry?: string | string[] | undefined;
616
601
  project?: string | string[] | undefined;
617
602
  } | undefined;
603
+ bumpp?: string | boolean | string[] | {
604
+ config?: string | string[] | undefined;
605
+ entry?: string | string[] | undefined;
606
+ project?: string | string[] | undefined;
607
+ } | undefined;
618
608
  bun?: string | boolean | string[] | {
619
609
  config?: string | string[] | undefined;
620
610
  entry?: string | string[] | undefined;
@@ -840,6 +830,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
840
830
  entry?: string | string[] | undefined;
841
831
  project?: string | string[] | undefined;
842
832
  } | undefined;
833
+ node?: string | boolean | string[] | {
834
+ config?: string | string[] | undefined;
835
+ entry?: string | string[] | undefined;
836
+ project?: string | string[] | undefined;
837
+ } | undefined;
843
838
  'node-modules-inspector'?: string | boolean | string[] | {
844
839
  config?: string | string[] | undefined;
845
840
  entry?: string | string[] | undefined;
@@ -975,6 +970,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
975
970
  entry?: string | string[] | undefined;
976
971
  project?: string | string[] | undefined;
977
972
  } | undefined;
973
+ rstest?: string | boolean | string[] | {
974
+ config?: string | string[] | undefined;
975
+ entry?: string | string[] | undefined;
976
+ project?: string | string[] | undefined;
977
+ } | undefined;
978
978
  'semantic-release'?: string | boolean | string[] | {
979
979
  config?: string | string[] | undefined;
980
980
  entry?: string | string[] | undefined;
@@ -1145,6 +1145,8 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1145
1145
  entry?: string | string[] | undefined;
1146
1146
  project?: string | string[] | undefined;
1147
1147
  } | undefined;
1148
+ entry?: string | string[] | undefined;
1149
+ project?: string | string[] | undefined;
1148
1150
  paths?: Record<string, string[]> | undefined;
1149
1151
  ignore?: string | string[] | undefined;
1150
1152
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -1153,6 +1155,31 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1153
1155
  ignoreUnresolved?: (string | RegExp)[] | undefined;
1154
1156
  includeEntryExports?: boolean | undefined;
1155
1157
  }> | undefined;
1158
+ include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
1159
+ exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
1160
+ $schema?: string | undefined;
1161
+ rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
1162
+ entry?: string | string[] | undefined;
1163
+ project?: string | string[] | undefined;
1164
+ paths?: Record<string, string[]> | undefined;
1165
+ ignore?: string | string[] | undefined;
1166
+ ignoreBinaries?: (string | RegExp)[] | undefined;
1167
+ ignoreDependencies?: (string | RegExp)[] | undefined;
1168
+ ignoreMembers?: (string | RegExp)[] | undefined;
1169
+ ignoreUnresolved?: (string | RegExp)[] | undefined;
1170
+ ignoreExportsUsedInFile?: boolean | {
1171
+ class?: boolean | undefined;
1172
+ enum?: boolean | undefined;
1173
+ function?: boolean | undefined;
1174
+ interface?: boolean | undefined;
1175
+ member?: boolean | undefined;
1176
+ type?: boolean | undefined;
1177
+ } | undefined;
1178
+ ignoreWorkspaces?: string[] | undefined;
1179
+ includeEntryExports?: boolean | undefined;
1180
+ compilers?: Record<string, true | ((filename: string, contents: string) => string) | ((filename: string, contents: string) => Promise<string>)> | undefined;
1181
+ tags?: string[] | undefined;
1182
+ treatConfigHintsAsErrors?: boolean | undefined;
1156
1183
  };
1157
1184
  export declare const getIncludedCompilers: (syncCompilers: RawSyncCompilers, asyncCompilers: AsyncCompilers, dependencies: DependencySet) => [SyncCompilers, AsyncCompilers];
1158
1185
  export declare const getCompilerExtensions: (compilers: [SyncCompilers, AsyncCompilers]) => string[];
@@ -1,5 +1,5 @@
1
- import AstroMDX from './astro-mdx.js';
2
1
  import Astro from './astro.js';
2
+ import AstroMDX from './astro-mdx.js';
3
3
  import MDX from './mdx.js';
4
4
  import Svelte from './svelte.js';
5
5
  import Vue from './vue.js';
package/dist/constants.js CHANGED
@@ -106,6 +106,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
106
106
  'tac',
107
107
  'tee',
108
108
  'test',
109
+ 'time',
109
110
  'timeout',
110
111
  'touch',
111
112
  'tr',
@@ -115,6 +116,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
115
116
  'uname',
116
117
  'unexpand',
117
118
  'uniq',
119
+ 'unzip',
118
120
  'wc',
119
121
  'who',
120
122
  'whoami',
@@ -172,16 +172,19 @@ export const analyze = async ({ analyzedFiles, chief, collector, deputy, entryPa
172
172
  }
173
173
  }
174
174
  if (file.imports?.external) {
175
- for (const specifier of file.imports.external) {
176
- const packageName = getPackageNameFromModuleSpecifier(specifier);
175
+ for (const extImport of file.imports.external) {
176
+ const packageName = getPackageNameFromModuleSpecifier(extImport.specifier);
177
177
  const isHandled = packageName && deputy.maybeAddReferencedExternalDependency(ws, packageName);
178
178
  if (!isHandled)
179
179
  collector.addIssue({
180
180
  type: 'unlisted',
181
181
  filePath,
182
182
  workspace: ws.name,
183
- symbol: packageName ?? specifier,
184
- specifier,
183
+ symbol: packageName ?? extImport.specifier,
184
+ specifier: extImport.specifier,
185
+ pos: extImport.pos,
186
+ line: extImport.line,
187
+ col: extImport.col,
185
188
  });
186
189
  }
187
190
  }
@@ -1,8 +1,6 @@
1
- import { WorkspaceWorker } from '../WorkspaceWorker.js';
2
1
  import { _getInputsFromScripts } from '../binaries/index.js';
3
2
  import { getCompilerExtensions, getIncludedCompilers } from '../compilers/index.js';
4
3
  import { DEFAULT_EXTENSIONS, FOREIGN_FILE_EXTENSIONS } from '../constants.js';
5
- import { perfObserver } from '../util/Performance.js';
6
4
  import { debugLog, debugLogArray } from '../util/debug.js';
7
5
  import { getReferencedInputsHandler } from '../util/get-referenced-inputs.js';
8
6
  import { _glob, _syncGlob, negate } from '../util/glob.js';
@@ -10,9 +8,11 @@ import { isAlias, isConfig, isDeferResolveEntry, isDeferResolveProductionEntry,
10
8
  import { loadTSConfig } from '../util/load-tsconfig.js';
11
9
  import { getOrCreateFileNode, updateImportMap } from '../util/module-graph.js';
12
10
  import { getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
11
+ import { perfObserver } from '../util/Performance.js';
13
12
  import { getEntrySpecifiersFromManifest, getManifestImportDependencies } from '../util/package-json.js';
14
13
  import { dirname, extname, isAbsolute, join, relative, toRelative } from '../util/path.js';
15
14
  import { augmentWorkspace, getToSourcePathHandler, getToSourcePathsHandler } from '../util/to-source-path.js';
15
+ import { WorkspaceWorker } from '../WorkspaceWorker.js';
16
16
  export async function build({ chief, collector, deputy, factory, isGitIgnored, streamer, workspaces, options, }) {
17
17
  const configFilesMap = new Map();
18
18
  const enabledPluginsStore = new Map();
@@ -266,14 +266,14 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
266
266
  const workspace = chief.findWorkspaceByFilePath(filePath);
267
267
  if (workspace) {
268
268
  const file = principal.analyzeSourceFile(filePath, analyzeOpts, chief.config.ignoreExportsUsedInFile);
269
- const _unresolved = new Set();
269
+ const unresolvedImports = new Set();
270
270
  for (const unresolvedImport of file.imports.unresolved) {
271
271
  const { specifier } = unresolvedImport;
272
272
  if (specifier.startsWith('http'))
273
273
  continue;
274
274
  const sanitizedSpecifier = sanitizeSpecifier(specifier);
275
275
  if (isStartsLikePackageName(sanitizedSpecifier)) {
276
- file.imports.external.add(sanitizedSpecifier);
276
+ file.imports.external.add({ ...unresolvedImport, specifier: sanitizedSpecifier });
277
277
  }
278
278
  else {
279
279
  const isIgnored = isGitIgnored(join(dirname(filePath), sanitizedSpecifier));
@@ -281,7 +281,7 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
281
281
  const ext = extname(sanitizedSpecifier);
282
282
  const hasIgnoredExtension = FOREIGN_FILE_EXTENSIONS.has(ext);
283
283
  if (!ext || (ext !== '.json' && !hasIgnoredExtension))
284
- _unresolved.add(unresolvedImport);
284
+ unresolvedImports.add(unresolvedImport);
285
285
  }
286
286
  }
287
287
  }
@@ -290,10 +290,10 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
290
290
  if (!isIgnored)
291
291
  principal.addEntryPath(filePath, { skipExportsAnalysis: true });
292
292
  }
293
- for (const [specifier, specifierFilePath] of file.imports.specifiers) {
294
- const packageName = getPackageNameFromModuleSpecifier(specifier);
293
+ for (const [import_, specifierFilePath] of file.imports.specifiers) {
294
+ const packageName = getPackageNameFromModuleSpecifier(import_.specifier);
295
295
  if (packageName && isInternalWorkspace(packageName)) {
296
- file.imports.external.add(packageName);
296
+ file.imports.external.add({ ...import_, specifier: packageName });
297
297
  const principal = getPrincipalByFilePath(specifierFilePath);
298
298
  if (principal && !isGitIgnored(specifierFilePath)) {
299
299
  principal.addNonEntryPath(specifierFilePath);
@@ -321,7 +321,7 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
321
321
  }
322
322
  }
323
323
  const node = getOrCreateFileNode(graph, filePath);
324
- file.imports.unresolved = _unresolved;
324
+ file.imports.unresolved = unresolvedImports;
325
325
  Object.assign(node, file);
326
326
  updateImportMap(node, file.imports.internal, graph);
327
327
  node.internalImportCache = file.imports.internal;
package/dist/index.js CHANGED
@@ -3,11 +3,11 @@ import { formatly } from 'formatly';
3
3
  import { ConfigurationChief } from './ConfigurationChief.js';
4
4
  import { ConsoleStreamer } from './ConsoleStreamer.js';
5
5
  import { DependencyDeputy } from './DependencyDeputy.js';
6
+ import { analyze } from './graph/analyze.js';
7
+ import { build } from './graph/build.js';
6
8
  import { IssueCollector } from './IssueCollector.js';
7
9
  import { IssueFixer } from './IssueFixer.js';
8
10
  import { PrincipalFactory } from './PrincipalFactory.js';
9
- import { analyze } from './graph/analyze.js';
10
- import { build } from './graph/build.js';
11
11
  import { debugLogArray, debugLogObject } from './util/debug.js';
12
12
  import { getGitIgnoredHandler } from './util/glob-core.js';
13
13
  import { getWatchHandler } from './util/watch.js';
@@ -1,5 +1,5 @@
1
- import { timerify } from '../util/Performance.js';
2
1
  import { isDefinitelyTyped } from '../util/modules.js';
2
+ import { timerify } from '../util/Performance.js';
3
3
  import { loadPackageManifest } from './helpers.js';
4
4
  const getMetaDataFromPackageJson = ({ cwd, dir, packageNames }) => {
5
5
  const hostDependencies = new Map();