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.
- package/dist/CacheConsultant.js +1 -1
- package/dist/ConfigurationChief.d.ts +20 -8
- package/dist/DependencyDeputy.js +5 -4
- package/dist/IssueCollector.js +1 -1
- package/dist/IssueFixer.js +3 -1
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/ProjectPrincipal.js +2 -2
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/WorkspaceWorker.js +2 -2
- package/dist/binaries/bash-parser.d.ts +1 -0
- package/dist/binaries/bash-parser.js +3 -0
- package/dist/binaries/fallback.js +3 -2
- package/dist/binaries/index.js +1 -1
- package/dist/binaries/package-manager/bun.js +1 -0
- package/dist/binaries/plugins.js +3 -1
- package/dist/cli.js +9 -9
- package/dist/compilers/index.d.ts +57 -30
- package/dist/compilers/index.js +1 -1
- package/dist/constants.js +2 -0
- package/dist/graph/analyze.js +7 -4
- package/dist/graph/build.js +9 -9
- package/dist/index.js +2 -2
- package/dist/manifest/index.js +1 -1
- package/dist/plugins/angular/index.js +2 -3
- package/dist/plugins/bumpp/index.d.ts +8 -0
- package/dist/plugins/bumpp/index.js +11 -0
- package/dist/plugins/changelogen/index.js +1 -1
- package/dist/plugins/changelogithub/index.js +1 -1
- package/dist/plugins/commitlint/index.js +1 -1
- package/dist/plugins/eslint/index.d.ts +7 -0
- package/dist/plugins/eslint/index.js +12 -0
- package/dist/plugins/glob/index.d.ts +0 -1
- package/dist/plugins/glob/index.js +0 -1
- package/dist/plugins/index.d.ts +19 -7
- package/dist/plugins/index.js +6 -2
- package/dist/plugins/karma/helpers.js +1 -1
- package/dist/plugins/lint-staged/index.js +1 -1
- package/dist/plugins/linthtml/index.js +1 -1
- package/dist/plugins/lockfile-lint/index.js +1 -1
- package/dist/plugins/node-modules-inspector/index.d.ts +0 -1
- package/dist/plugins/node-modules-inspector/index.js +1 -2
- package/dist/plugins/npm-package-json-lint/index.js +1 -1
- package/dist/plugins/nuxt/index.js +7 -1
- package/dist/plugins/nuxt/types.d.ts +1 -1
- package/dist/plugins/oxlint/index.d.ts +0 -1
- package/dist/plugins/oxlint/index.js +0 -1
- package/dist/plugins/playwright/index.d.ts +0 -1
- package/dist/plugins/playwright/index.js +0 -1
- package/dist/plugins/playwright-test/index.d.ts +0 -1
- package/dist/plugins/playwright-test/index.js +0 -1
- package/dist/plugins/pnpm/index.d.ts +1 -0
- package/dist/plugins/pnpm/index.js +5 -1
- package/dist/plugins/postcss/index.js +1 -1
- package/dist/plugins/prisma/index.d.ts +0 -1
- package/dist/plugins/prisma/index.js +0 -1
- package/dist/plugins/react-router/index.js +1 -1
- package/dist/plugins/rslib/index.js +1 -1
- package/dist/plugins/rstest/index.d.ts +10 -0
- package/dist/plugins/rstest/index.js +29 -0
- package/dist/plugins/rstest/types.d.ts +6 -0
- package/dist/plugins/rstest/types.js +1 -0
- package/dist/plugins/semantic-release/index.js +1 -1
- package/dist/plugins/size-limit/index.js +1 -1
- package/dist/plugins/stylelint/index.js +1 -1
- package/dist/plugins/syncpack/index.js +1 -1
- package/dist/plugins/ts-node/index.d.ts +0 -1
- package/dist/plugins/ts-node/index.js +0 -1
- package/dist/plugins/unocss/index.js +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/reporters/githubActions.d.ts +3 -0
- package/dist/reporters/githubActions.js +94 -0
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.js +2 -0
- package/dist/reporters/json.js +1 -1
- package/dist/reporters/util/configuration-hints.d.ts +13 -1
- package/dist/reporters/util/configuration-hints.js +1 -0
- package/dist/schema/configuration.d.ts +1187 -6393
- package/dist/schema/configuration.js +54 -51
- package/dist/schema/plugins.d.ts +579 -2595
- package/dist/schema/plugins.js +6 -4
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/types/args.d.ts +2 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/imports.d.ts +1 -1
- package/dist/types/module-graph.d.ts +5 -4
- package/dist/typescript/SourceFile.d.ts +2 -2
- package/dist/typescript/ast-helpers.d.ts +4 -0
- package/dist/typescript/ast-helpers.js +29 -0
- package/dist/typescript/find-internal-references.js +10 -1
- package/dist/typescript/get-imports-and-exports.js +28 -18
- package/dist/typescript/resolve-module-names.js +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.js +6 -1
- package/dist/util/cli-arguments.d.ts +3 -2
- package/dist/util/cli-arguments.js +2 -2
- package/dist/util/create-options.d.ts +61 -35
- package/dist/util/create-options.js +1 -1
- package/dist/util/errors.d.ts +4 -4
- package/dist/util/errors.js +8 -8
- package/dist/util/file-entry-cache.js +1 -1
- package/dist/util/glob-core.js +1 -1
- package/dist/util/glob.js +1 -1
- package/dist/util/input.d.ts +1 -1
- package/dist/util/load-config.d.ts +2 -1
- package/dist/util/load-config.js +4 -4
- package/dist/util/loader.js +1 -1
- package/dist/util/modules.js +18 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +18 -19
- 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;
|
package/dist/reporters/index.js
CHANGED
|
@@ -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
|
};
|
package/dist/reporters/json.js
CHANGED
|
@@ -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'],
|