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
@@ -0,0 +1,94 @@
1
+ import { ISSUE_TYPE_TITLE } from '../constants.js';
2
+ import { relative } from '../util/path.js';
3
+ import { hintPrinters } from './util/configuration-hints.js';
4
+ import { getIssueTypeTitle } from './util/util.js';
5
+ const createGitHubActionsLogger = () => {
6
+ const formatAnnotation = (level, message, options) => {
7
+ const params = [`file=${options.file}`];
8
+ if (options.startLine != null)
9
+ params.push(`line=${options.startLine}`);
10
+ if (options.endLine != null)
11
+ params.push(`endLine=${options.endLine}`);
12
+ if (options.startColumn != null)
13
+ params.push(`col=${options.startColumn}`);
14
+ if (options.endColumn != null)
15
+ params.push(`endColumn=${options.endColumn}`);
16
+ params.push(`title=✂️ Knip${options.title ? ` / ${options.title}` : ''}`);
17
+ const paramString = params.join(',');
18
+ console.log(`::${level} ${paramString}::${message}`);
19
+ };
20
+ return {
21
+ info: (message) => console.log(message),
22
+ error: (message, options) => formatAnnotation('error', message, options),
23
+ warning: (message, options) => formatAnnotation('warning', message, options),
24
+ notice: (message, options) => formatAnnotation('notice', message, options),
25
+ };
26
+ };
27
+ export default ({ report, issues, cwd, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, configFilePath, }) => {
28
+ const core = createGitHubActionsLogger();
29
+ const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
30
+ for (let [reportType, isReportType] of Object.entries(report)) {
31
+ if (reportType === 'files')
32
+ reportType = '_files';
33
+ if (isReportType) {
34
+ const title = reportMultipleGroups && getIssueTypeTitle(reportType);
35
+ const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
36
+ if (issuesForType.length > 0) {
37
+ title && core.info(`${title} (${issuesForType.length})`);
38
+ for (const issue of issuesForType) {
39
+ if (issue.isFixed || issue.severity === 'off')
40
+ continue;
41
+ const log = issue.severity === 'error' ? core.error : core.warning;
42
+ const filePath = relative(cwd, issue.filePath);
43
+ const message = reportType === '_files' ? issue.symbol : `${issue.symbol} in ${filePath}`;
44
+ log(message, {
45
+ file: filePath,
46
+ startLine: issue.line ?? 1,
47
+ endLine: issue.line ?? 1,
48
+ startColumn: issue.col ?? 1,
49
+ endColumn: issue.col ?? 1,
50
+ title: ISSUE_TYPE_TITLE[issue.type],
51
+ });
52
+ }
53
+ }
54
+ }
55
+ }
56
+ if (!isDisableConfigHints && configurationHints.size > 0) {
57
+ const CONFIG_HINTS_TITLE = 'Configuration hints';
58
+ core.info(`${CONFIG_HINTS_TITLE} (${configurationHints.size})`);
59
+ for (const hint of configurationHints) {
60
+ const hintPrinter = hintPrinters.get(hint.type);
61
+ const message = hintPrinter?.print({
62
+ ...hint,
63
+ filePath: hint.filePath ?? configFilePath ?? '',
64
+ configFilePath,
65
+ }) ?? '';
66
+ const file = hint.filePath
67
+ ? relative(cwd, hint.filePath)
68
+ : configFilePath
69
+ ? relative(cwd, configFilePath)
70
+ : 'knip.json';
71
+ const hintMessage = `${message}: ${hint.identifier} in ${file}`;
72
+ if (isTreatConfigHintsAsErrors) {
73
+ core.error(hintMessage, {
74
+ file,
75
+ startLine: 1,
76
+ endLine: 1,
77
+ startColumn: 1,
78
+ endColumn: 1,
79
+ title: CONFIG_HINTS_TITLE,
80
+ });
81
+ }
82
+ else {
83
+ core.notice(hintMessage, {
84
+ file,
85
+ startLine: 1,
86
+ endLine: 1,
87
+ startColumn: 1,
88
+ endColumn: 1,
89
+ title: CONFIG_HINTS_TITLE,
90
+ });
91
+ }
92
+ }
93
+ }
94
+ };
@@ -6,5 +6,6 @@ declare const _default: {
6
6
  codeclimate: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
7
7
  json: ({ report, issues, options, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
8
8
  markdown: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => void;
9
+ 'github-actions': ({ report, issues, cwd, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, configFilePath, }: import("../index.js").ReporterOptions) => void;
9
10
  };
10
11
  export default _default;
@@ -2,6 +2,7 @@ import codeclimate from './codeclimate.js';
2
2
  import codeowners from './codeowners.js';
3
3
  import compact from './compact.js';
4
4
  import disclosure from './disclosure.js';
5
+ import githubActions from './githubActions.js';
5
6
  import json from './json.js';
6
7
  import markdown from './markdown.js';
7
8
  import symbols from './symbols.js';
@@ -13,4 +14,5 @@ export default {
13
14
  codeclimate,
14
15
  json,
15
16
  markdown,
17
+ 'github-actions': githubActions,
16
18
  };
@@ -54,7 +54,7 @@ export default async ({ report, issues, options, cwd }) => {
54
54
  }
55
55
  }
56
56
  else {
57
- if (['unlisted', 'binaries'].includes(type)) {
57
+ if (type === 'binaries') {
58
58
  json[filePath][type]?.push({ name: symbol });
59
59
  }
60
60
  else {
@@ -1,2 +1,14 @@
1
- import type { ReporterOptions } from '../../types/issues.js';
1
+ import type { ConfigurationHintType, ReporterOptions } from '../../types/issues.js';
2
+ interface PrintHintOptions {
3
+ type: ConfigurationHintType;
4
+ identifier: string | RegExp;
5
+ filePath: string;
6
+ configFilePath?: string;
7
+ workspaceName?: string;
8
+ size?: number;
9
+ }
10
+ declare const hintPrinters: Map<ConfigurationHintType, {
11
+ print: (options: PrintHintOptions) => string;
12
+ }>;
13
+ export { hintPrinters };
2
14
  export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, isTreatConfigHintsAsErrors, includedWorkspaceDirs, configFilePath, }: ReporterOptions) => void;
@@ -42,6 +42,7 @@ const hintPrinters = new Map([
42
42
  ['project-top-level', { print: topLevel }],
43
43
  ['package-entry', { print: packageEntry }],
44
44
  ]);
45
+ export { hintPrinters };
45
46
  const hintTypesOrder = [
46
47
  ['workspace-unconfigured'],
47
48
  ['entry-top-level', 'project-top-level'],