knip 5.55.1 → 5.57.0
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/README.md +44 -20
- package/dist/CacheConsultant.d.ts +1 -0
- package/dist/CacheConsultant.js +1 -1
- package/dist/ConfigurationChief.d.ts +5 -0
- package/dist/DependencyDeputy.d.ts +2 -0
- package/dist/DependencyDeputy.js +6 -0
- package/dist/PrincipalFactory.d.ts +2 -9
- package/dist/PrincipalFactory.js +10 -6
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/ProjectPrincipal.js +3 -3
- package/dist/WorkspaceWorker.js +1 -1
- package/dist/cli.js +6 -5
- package/dist/compilers/index.d.ts +50 -0
- package/dist/graph/build.js +11 -2
- package/dist/plugins/changelogen/index.d.ts +9 -0
- package/dist/plugins/changelogen/index.js +14 -0
- package/dist/plugins/changelogithub/index.d.ts +9 -0
- package/dist/plugins/changelogithub/index.js +14 -0
- package/dist/plugins/convex/index.d.ts +8 -0
- package/dist/plugins/convex/index.js +11 -0
- package/dist/plugins/docusaurus/helpers.d.ts +5 -0
- package/dist/plugins/docusaurus/helpers.js +89 -0
- package/dist/plugins/docusaurus/index.d.ts +12 -0
- package/dist/plugins/docusaurus/index.js +36 -0
- package/dist/plugins/docusaurus/types.d.ts +40 -0
- package/dist/plugins/docusaurus/types.js +1 -0
- package/dist/plugins/hardhat/index.d.ts +9 -0
- package/dist/plugins/hardhat/index.js +16 -0
- package/dist/plugins/index.d.ts +40 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/mocha/index.js +5 -2
- package/dist/plugins/nx/index.js +1 -1
- package/dist/plugins/nx/types.d.ts +3 -1
- package/dist/plugins/tsx/index.d.ts +6 -0
- package/dist/plugins/tsx/index.js +24 -0
- package/dist/reporters/codeclimate.js +3 -3
- package/dist/reporters/codeowners.js +15 -30
- package/dist/reporters/compact.js +10 -4
- package/dist/reporters/disclosure.js +5 -24
- package/dist/reporters/markdown.js +2 -2
- package/dist/reporters/symbols.d.ts +1 -1
- package/dist/reporters/symbols.js +10 -45
- package/dist/reporters/util.d.ts +11 -7
- package/dist/reporters/util.js +45 -14
- package/dist/reporters/watch.js +7 -21
- package/dist/schema/configuration.d.ts +280 -0
- package/dist/schema/plugins.d.ts +115 -0
- package/dist/schema/plugins.js +5 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/project.d.ts +1 -0
- package/dist/typescript/resolve-module-names.js +2 -2
- package/dist/util/Performance.d.ts +7 -7
- package/dist/util/Performance.js +20 -16
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/util/input.d.ts +8 -1
- package/dist/util/input.js +6 -0
- package/dist/util/math.js +1 -1
- package/dist/util/plugin-config.d.ts +8 -0
- package/dist/util/plugin-config.js +1 -0
- package/dist/util/resolve.d.ts +3 -1
- package/dist/util/resolve.js +7 -9
- package/dist/util/table.d.ts +4 -2
- package/dist/util/table.js +20 -24
- package/dist/util/watch.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/schema.json +20 -0
- package/license +0 -12
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toAlias, toDependency, toEntry, toIgnore, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { CORE_CLIENT_API, resolveConfigItems } from './helpers.js';
|
|
4
|
+
const title = 'Docusaurus';
|
|
5
|
+
const enablers = ['@docusaurus/core'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['docusaurus.config.{js,mjs,ts}'];
|
|
8
|
+
const production = ['src/pages/**/*.{js,ts,jsx,tsx}', '{blog,docs}/**/*.mdx', 'versioned_docs/**/*.{mdx,jsx,tsx}'];
|
|
9
|
+
const entry = ['babel.config.{js,cjs,mjs,cts}'];
|
|
10
|
+
const resolveConfig = async (config, options) => {
|
|
11
|
+
const themes = await resolveConfigItems(config.themes ?? [], 'theme', options);
|
|
12
|
+
const plugins = await resolveConfigItems(config.plugins ?? [], 'plugin', options);
|
|
13
|
+
const presets = await resolveConfigItems(config.presets ?? [], 'preset', options);
|
|
14
|
+
const hasClassicTheme = options.manifest.dependencies?.['@docusaurus/theme-classic'] ||
|
|
15
|
+
options.manifest.dependencies?.['@docusaurus/preset-classic'];
|
|
16
|
+
return [
|
|
17
|
+
toAlias('@site/*', './*'),
|
|
18
|
+
toDependency('@docusaurus/module-type-aliases', { optional: true }),
|
|
19
|
+
...(hasClassicTheme ? [toIgnore('(@theme|@theme-init|@theme-original)/*', 'dependencies')] : []),
|
|
20
|
+
toIgnore(`@docusaurus/(${CORE_CLIENT_API.join('|')})`, 'dependencies'),
|
|
21
|
+
...production.map(id => toProductionEntry(id)),
|
|
22
|
+
...entry.map(id => toEntry(id)),
|
|
23
|
+
...themes,
|
|
24
|
+
...plugins,
|
|
25
|
+
...presets,
|
|
26
|
+
];
|
|
27
|
+
};
|
|
28
|
+
export default {
|
|
29
|
+
title,
|
|
30
|
+
enablers,
|
|
31
|
+
isEnabled,
|
|
32
|
+
config,
|
|
33
|
+
entry,
|
|
34
|
+
production,
|
|
35
|
+
resolveConfig,
|
|
36
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { WebpackConfig } from '../webpack/types.js';
|
|
2
|
+
export type ModuleType = 'plugin' | 'theme' | 'preset';
|
|
3
|
+
type DocsConfig = {
|
|
4
|
+
sidebarPath?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type PluginOptions = {
|
|
8
|
+
sidebarPath?: string;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type PresetOptions = {
|
|
12
|
+
docs?: DocsConfig;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
type Loader = unknown;
|
|
16
|
+
type PluginConfig = string | [string, PluginOptions] | false | null | {
|
|
17
|
+
name?: string;
|
|
18
|
+
configureWebpack?: (config?: PluginConfig, isServer?: boolean, utils?: {
|
|
19
|
+
getStyleLoaders(isServer: boolean, cssOptions: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}): Loader[];
|
|
22
|
+
getJSLoader(isServer: boolean, cacheOptions?: {}): Loader | null;
|
|
23
|
+
}, content?: unknown) => WebpackConfig;
|
|
24
|
+
configurePostCss?: (postcssOptions: {
|
|
25
|
+
plugins: unknown[];
|
|
26
|
+
}) => {
|
|
27
|
+
plugins: unknown[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type PresetConfig = string | [string, PresetOptions] | false | null;
|
|
31
|
+
type Config = PresetConfig | PluginConfig;
|
|
32
|
+
export type ConfigItem = Config | (() => Config);
|
|
33
|
+
export type DocusaurusConfig = {
|
|
34
|
+
title: string;
|
|
35
|
+
url: string;
|
|
36
|
+
themes?: PluginConfig[];
|
|
37
|
+
plugins?: PluginConfig[];
|
|
38
|
+
presets: PresetConfig[];
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { toDependency } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
const title = 'Hardhat';
|
|
4
|
+
const enablers = ['hardhat'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const entry = ['hardhat.config.{js,cjs,mjs,ts}'];
|
|
7
|
+
const resolve = async () => {
|
|
8
|
+
return [toDependency('hardhat')];
|
|
9
|
+
};
|
|
10
|
+
export default {
|
|
11
|
+
title,
|
|
12
|
+
enablers,
|
|
13
|
+
isEnabled,
|
|
14
|
+
entry,
|
|
15
|
+
resolve,
|
|
16
|
+
};
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -54,6 +54,20 @@ export declare const Plugins: {
|
|
|
54
54
|
config: string[];
|
|
55
55
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./capacitor/types.js").CapacitorConfig>;
|
|
56
56
|
};
|
|
57
|
+
changelogen: {
|
|
58
|
+
title: string;
|
|
59
|
+
enablers: string[];
|
|
60
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
61
|
+
isRootOnly: true;
|
|
62
|
+
entry: string[];
|
|
63
|
+
};
|
|
64
|
+
changelogithub: {
|
|
65
|
+
title: string;
|
|
66
|
+
enablers: string[];
|
|
67
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
68
|
+
isRootOnly: true;
|
|
69
|
+
entry: string[];
|
|
70
|
+
};
|
|
57
71
|
changesets: {
|
|
58
72
|
title: string;
|
|
59
73
|
enablers: string[];
|
|
@@ -78,6 +92,12 @@ export declare const Plugins: {
|
|
|
78
92
|
config: string[];
|
|
79
93
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./commitlint/types.js").CommitLintConfig>;
|
|
80
94
|
};
|
|
95
|
+
convex: {
|
|
96
|
+
title: string;
|
|
97
|
+
enablers: string[];
|
|
98
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
99
|
+
entry: string[];
|
|
100
|
+
};
|
|
81
101
|
'create-typescript-app': {
|
|
82
102
|
enablers: string[];
|
|
83
103
|
entry: string[];
|
|
@@ -117,6 +137,15 @@ export declare const Plugins: {
|
|
|
117
137
|
config: boolean;
|
|
118
138
|
};
|
|
119
139
|
};
|
|
140
|
+
docusaurus: {
|
|
141
|
+
title: string;
|
|
142
|
+
enablers: string[];
|
|
143
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
144
|
+
config: string[];
|
|
145
|
+
entry: string[];
|
|
146
|
+
production: string[];
|
|
147
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./docusaurus/types.js").DocusaurusConfig>;
|
|
148
|
+
};
|
|
120
149
|
dotenv: {
|
|
121
150
|
title: string;
|
|
122
151
|
args: {
|
|
@@ -197,6 +226,13 @@ export declare const Plugins: {
|
|
|
197
226
|
config: string[];
|
|
198
227
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./graphql-codegen/types.js").GraphqlCodegenTypes | import("./graphql-codegen/types.js").GraphqlConfigTypes | import("./graphql-codegen/types.js").GraphqlProjectsConfigTypes>;
|
|
199
228
|
};
|
|
229
|
+
hardhat: {
|
|
230
|
+
title: string;
|
|
231
|
+
enablers: string[];
|
|
232
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
233
|
+
entry: string[];
|
|
234
|
+
resolve: import("../types/config.js").Resolve;
|
|
235
|
+
};
|
|
200
236
|
husky: {
|
|
201
237
|
title: string;
|
|
202
238
|
enablers: string[];
|
|
@@ -687,6 +723,10 @@ export declare const Plugins: {
|
|
|
687
723
|
};
|
|
688
724
|
tsx: {
|
|
689
725
|
title: string;
|
|
726
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
727
|
+
packageJsonPath: (id: import("../types/package-json.js").PackageJson) => import("../types/package-json.js").PackageJson;
|
|
728
|
+
config: string[];
|
|
729
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("../types/package-json.js").PackageJson>;
|
|
690
730
|
args: {
|
|
691
731
|
positional: boolean;
|
|
692
732
|
nodeImportArgs: boolean;
|
package/dist/plugins/index.js
CHANGED
|
@@ -5,14 +5,18 @@ import { default as babel } from './babel/index.js';
|
|
|
5
5
|
import { default as bun } from './bun/index.js';
|
|
6
6
|
import { default as c8 } from './c8/index.js';
|
|
7
7
|
import { default as capacitor } from './capacitor/index.js';
|
|
8
|
+
import { default as changelogen } from './changelogen/index.js';
|
|
9
|
+
import { default as changelogithub } from './changelogithub/index.js';
|
|
8
10
|
import { default as changesets } from './changesets/index.js';
|
|
9
11
|
import { default as commitizen } from './commitizen/index.js';
|
|
10
12
|
import { default as commitlint } from './commitlint/index.js';
|
|
13
|
+
import { default as convex } from './convex/index.js';
|
|
11
14
|
import { default as createTypescriptApp } from './create-typescript-app/index.js';
|
|
12
15
|
import { default as cspell } from './cspell/index.js';
|
|
13
16
|
import { default as cucumber } from './cucumber/index.js';
|
|
14
17
|
import { default as cypress } from './cypress/index.js';
|
|
15
18
|
import { default as dependencyCruiser } from './dependency-cruiser/index.js';
|
|
19
|
+
import { default as docusaurus } from './docusaurus/index.js';
|
|
16
20
|
import { default as dotenv } from './dotenv/index.js';
|
|
17
21
|
import { default as drizzle } from './drizzle/index.js';
|
|
18
22
|
import { default as eleventy } from './eleventy/index.js';
|
|
@@ -23,6 +27,7 @@ import { default as githubAction } from './github-action/index.js';
|
|
|
23
27
|
import { default as githubActions } from './github-actions/index.js';
|
|
24
28
|
import { default as glob } from './glob/index.js';
|
|
25
29
|
import { default as graphqlCodegen } from './graphql-codegen/index.js';
|
|
30
|
+
import { default as hardhat } from './hardhat/index.js';
|
|
26
31
|
import { default as husky } from './husky/index.js';
|
|
27
32
|
import { default as i18nextParser } from './i18next-parser/index.js';
|
|
28
33
|
import { default as jest } from './jest/index.js';
|
|
@@ -108,14 +113,18 @@ export const Plugins = {
|
|
|
108
113
|
bun,
|
|
109
114
|
c8,
|
|
110
115
|
capacitor,
|
|
116
|
+
changelogen,
|
|
117
|
+
changelogithub,
|
|
111
118
|
changesets,
|
|
112
119
|
commitizen,
|
|
113
120
|
commitlint,
|
|
121
|
+
convex,
|
|
114
122
|
'create-typescript-app': createTypescriptApp,
|
|
115
123
|
cspell,
|
|
116
124
|
cucumber,
|
|
117
125
|
cypress,
|
|
118
126
|
'dependency-cruiser': dependencyCruiser,
|
|
127
|
+
docusaurus,
|
|
119
128
|
dotenv,
|
|
120
129
|
drizzle,
|
|
121
130
|
eleventy,
|
|
@@ -126,6 +135,7 @@ export const Plugins = {
|
|
|
126
135
|
'github-actions': githubActions,
|
|
127
136
|
glob,
|
|
128
137
|
'graphql-codegen': graphqlCodegen,
|
|
138
|
+
hardhat,
|
|
129
139
|
husky,
|
|
130
140
|
'i18next-parser': i18nextParser,
|
|
131
141
|
jest,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toEntry } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
3
|
const title = 'Mocha';
|
|
4
4
|
const enablers = ['mocha'];
|
|
@@ -8,7 +8,10 @@ const entry = ['**/test/*.{js,cjs,mjs}'];
|
|
|
8
8
|
const resolveConfig = localConfig => {
|
|
9
9
|
const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : entry;
|
|
10
10
|
const require = localConfig.require ? [localConfig.require].flat() : [];
|
|
11
|
-
|
|
11
|
+
const inputs = [];
|
|
12
|
+
inputs.push(...entryPatterns.map(id => toEntry(id)));
|
|
13
|
+
inputs.push(...require.map(id => toDeferResolve(id)));
|
|
14
|
+
return inputs;
|
|
12
15
|
};
|
|
13
16
|
const args = {
|
|
14
17
|
nodeImportArgs: true,
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
42
42
|
if (target.options?.command)
|
|
43
43
|
return [target.options.command];
|
|
44
44
|
if (target.options?.commands)
|
|
45
|
-
return target.options.commands;
|
|
45
|
+
return target.options.commands.map(commandConfig => typeof commandConfig === 'string' ? commandConfig : commandConfig.command);
|
|
46
46
|
return [];
|
|
47
47
|
});
|
|
48
48
|
const inputs = options.getInputsFromScripts(scripts);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
+
import type { PackageJson } from '../../types/package-json.js';
|
|
1
3
|
declare const _default: {
|
|
2
4
|
title: string;
|
|
5
|
+
isEnabled: IsPluginEnabled;
|
|
6
|
+
packageJsonPath: (id: PackageJson) => PackageJson;
|
|
7
|
+
config: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<PackageJson>;
|
|
3
9
|
args: {
|
|
4
10
|
positional: boolean;
|
|
5
11
|
nodeImportArgs: boolean;
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
1
3
|
const title = 'tsx';
|
|
4
|
+
const enablers = ['tsx'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const config = ['package.json'];
|
|
7
|
+
const packageJsonPath = (id) => id;
|
|
8
|
+
const resolveConfig = localConfig => {
|
|
9
|
+
const scripts = localConfig.scripts;
|
|
10
|
+
const entries = [];
|
|
11
|
+
if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)tsx\s(.*)--test/.test(scripts[script]))) {
|
|
12
|
+
const patterns = [
|
|
13
|
+
'**/*{.,-,_}test.?(c|m)(j|t)s',
|
|
14
|
+
'**/test-*.?(c|m)(j|t)s',
|
|
15
|
+
'**/test.?(c|m)(j|t)s',
|
|
16
|
+
'**/test/**/*.?(c|m)(j|t)s',
|
|
17
|
+
];
|
|
18
|
+
entries.push(...patterns.map(id => toEntry(id)));
|
|
19
|
+
}
|
|
20
|
+
return entries;
|
|
21
|
+
};
|
|
2
22
|
const args = {
|
|
3
23
|
positional: true,
|
|
4
24
|
nodeImportArgs: true,
|
|
@@ -6,5 +26,9 @@ const args = {
|
|
|
6
26
|
};
|
|
7
27
|
export default {
|
|
8
28
|
title,
|
|
29
|
+
isEnabled,
|
|
30
|
+
packageJsonPath,
|
|
31
|
+
config,
|
|
32
|
+
resolveConfig,
|
|
9
33
|
args,
|
|
10
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
3
3
|
import { toRelative } from '../util/path.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getIssueTypeTitle } from './util.js';
|
|
5
5
|
export default async ({ report, issues }) => {
|
|
6
6
|
const entries = [];
|
|
7
7
|
for (const [type, isReportType] of Object.entries(report)) {
|
|
@@ -14,7 +14,7 @@ export default async ({ report, issues }) => {
|
|
|
14
14
|
if (fixedType === 'duplicates' && issue.symbols) {
|
|
15
15
|
entries.push(...issue.symbols.map(symbol => ({
|
|
16
16
|
type: 'issue',
|
|
17
|
-
check_name:
|
|
17
|
+
check_name: getIssueTypeTitle(fixedType),
|
|
18
18
|
description: getSymbolDescription({ type: issue.type, symbol, parentSymbol: issue.parentSymbol }),
|
|
19
19
|
categories: ['Duplication'],
|
|
20
20
|
location: createLocation(filePath, symbol.line, symbol.col),
|
|
@@ -25,7 +25,7 @@ export default async ({ report, issues }) => {
|
|
|
25
25
|
else {
|
|
26
26
|
entries.push({
|
|
27
27
|
type: 'issue',
|
|
28
|
-
check_name:
|
|
28
|
+
check_name: getIssueTypeTitle(fixedType),
|
|
29
29
|
description: getIssueDescription(issue),
|
|
30
30
|
categories: ['Bug Risk'],
|
|
31
31
|
location: createLocation(filePath, issue.line, issue.col),
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import picocolors from 'picocolors';
|
|
2
1
|
import { createOwnershipEngine } from '../util/codeowners.js';
|
|
3
|
-
import { relative, resolve
|
|
4
|
-
import {
|
|
5
|
-
const logIssueSet = (issues) => {
|
|
6
|
-
for (const issue of issues.sort((a, b) => (a.owner < b.owner ? -1 : 1))) {
|
|
7
|
-
console.log(picocolors.cyan(issue.owner), toRelative(issue.symbol));
|
|
8
|
-
}
|
|
9
|
-
};
|
|
2
|
+
import { relative, resolve } from '../util/path.js';
|
|
3
|
+
import { getColoredTitle, getIssueLine, getIssueTypeTitle } from './util.js';
|
|
10
4
|
const logIssueRecord = (issues) => {
|
|
11
5
|
const sortedByFilePath = issues.sort((a, b) => (a.owner < b.owner ? -1 : 1));
|
|
12
6
|
for (const { filePath, symbols, owner, parentSymbol } of sortedByFilePath) {
|
|
13
|
-
|
|
7
|
+
console.log(getIssueLine({ owner, filePath, symbols, parentSymbol }));
|
|
14
8
|
}
|
|
15
9
|
};
|
|
16
10
|
export default ({ report, issues, isShowProgress, options }) => {
|
|
@@ -31,31 +25,22 @@ export default ({ report, issues, isShowProgress, options }) => {
|
|
|
31
25
|
...issue,
|
|
32
26
|
owner: calcFileOwnership(issue.filePath),
|
|
33
27
|
});
|
|
34
|
-
for (
|
|
28
|
+
for (let [reportType, isReportType] of Object.entries(report)) {
|
|
29
|
+
if (reportType === 'files')
|
|
30
|
+
reportType = '_files';
|
|
35
31
|
if (isReportType) {
|
|
36
|
-
const title = reportMultipleGroups &&
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
: reportType === 'duplicates'
|
|
44
|
-
? Object.values(issues[reportType]).flatMap(Object.values).map(addOwner)
|
|
45
|
-
: Object.values(issues[reportType]).map(issues => {
|
|
46
|
-
const symbols = Object.values(issues);
|
|
47
|
-
return addOwner({ ...symbols[0], symbols });
|
|
48
|
-
});
|
|
32
|
+
const title = reportMultipleGroups && getIssueTypeTitle(reportType);
|
|
33
|
+
const issuesForType = Object.values(issues[reportType]).flatMap(issues => {
|
|
34
|
+
if (reportType === 'duplicates')
|
|
35
|
+
return Object.values(issues).map(addOwner);
|
|
36
|
+
const symbols = Object.values(issues);
|
|
37
|
+
return addOwner({ ...symbols[0], symbols });
|
|
38
|
+
});
|
|
49
39
|
if (issuesForType.length > 0) {
|
|
50
40
|
if (totalIssues)
|
|
51
41
|
console.log();
|
|
52
|
-
title &&
|
|
53
|
-
|
|
54
|
-
logIssueSet(issuesForType);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
logIssueRecord(issuesForType);
|
|
58
|
-
}
|
|
42
|
+
title && console.log(getColoredTitle(title, issuesForType.length));
|
|
43
|
+
logIssueRecord(issuesForType);
|
|
59
44
|
}
|
|
60
45
|
totalIssues = totalIssues + issuesForType.length;
|
|
61
46
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toRelative } from '../util/path.js';
|
|
2
|
+
import { getColoredTitle, getIssueLine, getIssueTypeTitle } from './util.js';
|
|
3
|
+
const logIssueSet = (issues) => {
|
|
4
|
+
for (const filePath of issues.sort())
|
|
5
|
+
console.log(toRelative(filePath));
|
|
6
|
+
};
|
|
2
7
|
const logIssueRecord = (issues) => {
|
|
3
8
|
const sortedByFilePath = issues.sort((a, b) => (a.filePath > b.filePath ? 1 : -1));
|
|
4
|
-
sortedByFilePath
|
|
9
|
+
for (const issue of sortedByFilePath)
|
|
10
|
+
console.log(getIssueLine(issue));
|
|
5
11
|
};
|
|
6
12
|
export default ({ report, issues, isShowProgress }) => {
|
|
7
13
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
8
14
|
let totalIssues = 0;
|
|
9
15
|
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
10
16
|
if (isReportType) {
|
|
11
|
-
const title = reportMultipleGroups &&
|
|
17
|
+
const title = reportMultipleGroups && getIssueTypeTitle(reportType);
|
|
12
18
|
const isSet = issues[reportType] instanceof Set;
|
|
13
19
|
const issuesForType = isSet
|
|
14
20
|
? Array.from(issues[reportType])
|
|
@@ -19,7 +25,7 @@ export default ({ report, issues, isShowProgress }) => {
|
|
|
19
25
|
return { ...items[0], symbols: items };
|
|
20
26
|
});
|
|
21
27
|
if (issuesForType.length > 0) {
|
|
22
|
-
title &&
|
|
28
|
+
title && console.log(getColoredTitle(title, issuesForType.length));
|
|
23
29
|
if (isSet) {
|
|
24
30
|
logIssueSet(Array.from(issues[reportType]));
|
|
25
31
|
}
|
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Table } from '../util/table.js';
|
|
3
|
-
import { getTitle } from './util.js';
|
|
4
|
-
const printHeader = (size, title) => console.log(`<details>\n${title ? `<summary>${title} (${size})</summary>\n` : ''}\n\`\`\``);
|
|
5
|
-
const printFooter = () => console.log('```\n\n</details>\n');
|
|
6
|
-
const logIssueRecord = (issues) => {
|
|
7
|
-
const table = new Table();
|
|
8
|
-
for (const issue of issues) {
|
|
9
|
-
table.cell('symbol', issue.symbols ? issue.symbols.map(s => s.symbol).join(', ') : issue.symbol);
|
|
10
|
-
table.cell('parentSymbol', issue.parentSymbol && issue.parentSymbol);
|
|
11
|
-
table.cell('symbolType', issue.symbolType && issue.symbolType);
|
|
12
|
-
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
13
|
-
const cell = issue.type === 'files' ? '' : `${relative(issue.filePath)}${pos}`;
|
|
14
|
-
table.cell('filePath', cell);
|
|
15
|
-
table.newRow();
|
|
16
|
-
}
|
|
17
|
-
console.log(table.sort('filePath').toString());
|
|
18
|
-
};
|
|
1
|
+
import { getIssueTypeTitle, getTableForType } from './util.js';
|
|
19
2
|
export default ({ report, issues }) => {
|
|
20
3
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
21
|
-
let totalIssues = 0;
|
|
22
4
|
for (let [reportType, isReportType] of Object.entries(report)) {
|
|
23
5
|
if (reportType === 'files')
|
|
24
6
|
reportType = '_files';
|
|
25
7
|
if (isReportType) {
|
|
26
|
-
const title = reportMultipleGroups ?
|
|
8
|
+
const title = reportMultipleGroups ? getIssueTypeTitle(reportType) : undefined;
|
|
27
9
|
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
28
10
|
if (issuesForType.length > 0) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
printFooter();
|
|
11
|
+
console.log(`<details>\n${title ? `<summary>${title} (${issuesForType.length})</summary>\n` : ''}\n\`\`\``);
|
|
12
|
+
console.log(getTableForType(issuesForType, { isUseColors: false }).toString());
|
|
13
|
+
console.log('```\n\n</details>\n');
|
|
33
14
|
}
|
|
34
15
|
}
|
|
35
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative, toRelative } from '../util/path.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getIssueTypeTitle } from './util.js';
|
|
3
3
|
export default ({ report, issues }) => {
|
|
4
4
|
console.log('# Knip report\n');
|
|
5
5
|
const getFilePath = (issue) => {
|
|
@@ -11,7 +11,7 @@ export default ({ report, issues }) => {
|
|
|
11
11
|
const sortLongestFilePath = (a, b) => getFilePath(b).length - getFilePath(a).length;
|
|
12
12
|
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
13
13
|
if (isReportType) {
|
|
14
|
-
const title =
|
|
14
|
+
const title = getIssueTypeTitle(reportType);
|
|
15
15
|
const isSet = issues[reportType] instanceof Set;
|
|
16
16
|
const issuesForType = isSet
|
|
17
17
|
? Array.from(issues[reportType])
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReporterOptions } from '../types/issues.js';
|
|
2
2
|
declare const _default: ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }: ReporterOptions) => void;
|
|
3
3
|
export default _default;
|
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
import picocolors from 'picocolors';
|
|
2
1
|
import { ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Table } from '../util/table.js';
|
|
6
|
-
import { getTitle, identity, logTitle, logTitleDimmed } from './util.js';
|
|
7
|
-
const dim = picocolors.gray;
|
|
8
|
-
const bright = picocolors.whiteBright;
|
|
9
|
-
const sortByPos = (a, b) => {
|
|
10
|
-
const [f, r, c] = a.filePath.value.split(':');
|
|
11
|
-
const [f2, r2, c2] = b.filePath.value.split(':');
|
|
12
|
-
return f === f2 ? (Number(r) === Number(r2) ? Number(c) - Number(c2) : Number(r) - Number(r2)) : f.localeCompare(f2);
|
|
13
|
-
};
|
|
14
|
-
const highlightPkg = (issue) => (_) => {
|
|
15
|
-
if (issue.specifier && issue.specifier !== issue.symbol && issue.specifier.includes(issue.symbol)) {
|
|
16
|
-
const parts = issue.specifier.split(issue.symbol);
|
|
17
|
-
const left = parts[0];
|
|
18
|
-
const right = parts.slice(1).join('');
|
|
19
|
-
return [dim(left), bright(issue.symbol), dim(right)].join('');
|
|
20
|
-
}
|
|
21
|
-
return issue.symbol;
|
|
22
|
-
};
|
|
23
|
-
const logIssueRecord = (issues) => {
|
|
24
|
-
const table = new Table({ truncateStart: ['filePath'], noTruncate: ['symbolType'] });
|
|
25
|
-
for (const issue of issues) {
|
|
26
|
-
table.newRow();
|
|
27
|
-
const print = issue.isFixed || issue.severity === 'warn' ? dim : identity;
|
|
28
|
-
const symbols = issue.symbols;
|
|
29
|
-
table.cell('symbol', print(symbols ? symbols.map(s => s.symbol).join(', ') : issue.symbol), highlightPkg(issue));
|
|
30
|
-
table.cell('parentSymbol', issue.parentSymbol && print(issue.parentSymbol));
|
|
31
|
-
table.cell('symbolType', issue.symbolType && issue.symbolType !== SymbolType.UNKNOWN && print(issue.symbolType));
|
|
32
|
-
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
33
|
-
const cell = issue.type === 'files' ? '' : `${relative(issue.filePath)}${pos}`;
|
|
34
|
-
table.cell('filePath', print(cell));
|
|
35
|
-
table.cell('fixed', issue.isFixed && print('(removed)'));
|
|
36
|
-
}
|
|
37
|
-
console.log(table.sort(sortByPos).toString());
|
|
38
|
-
};
|
|
2
|
+
import { toRelative } from '../util/path.js';
|
|
3
|
+
import { dim, getColoredTitle, getDimmedTitle, getIssueTypeTitle, getTableForType, plain } from './util.js';
|
|
39
4
|
export default ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }) => {
|
|
40
5
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
41
6
|
let totalIssues = 0;
|
|
@@ -43,29 +8,29 @@ export default ({ report, issues, tagHints, configurationHints, isDisableConfigH
|
|
|
43
8
|
if (reportType === 'files')
|
|
44
9
|
reportType = '_files';
|
|
45
10
|
if (isReportType) {
|
|
46
|
-
const title = reportMultipleGroups &&
|
|
11
|
+
const title = reportMultipleGroups && getIssueTypeTitle(reportType);
|
|
47
12
|
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
48
13
|
if (issuesForType.length > 0) {
|
|
49
|
-
title &&
|
|
50
|
-
|
|
14
|
+
title && console.log(getColoredTitle(title, issuesForType.length));
|
|
15
|
+
console.log(getTableForType(issuesForType).toString());
|
|
51
16
|
totalIssues = totalIssues + issuesForType.length;
|
|
52
17
|
}
|
|
53
18
|
}
|
|
54
19
|
}
|
|
55
20
|
if (!isDisableConfigHints) {
|
|
56
21
|
if (configurationHints.size > 0) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
22
|
+
const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
|
|
23
|
+
console.log(getTitle('Configuration hints', configurationHints.size));
|
|
24
|
+
const style = isTreatConfigHintsAsErrors ? plain : dim;
|
|
60
25
|
for (const hint of configurationHints) {
|
|
61
26
|
const { type, workspaceName, identifier } = hint;
|
|
62
27
|
const message = `Unused item in ${type}`;
|
|
63
28
|
const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : '';
|
|
64
|
-
console.warn(
|
|
29
|
+
console.warn(style(`${message}${workspace}:`), identifier);
|
|
65
30
|
}
|
|
66
31
|
}
|
|
67
32
|
if (tagHints.size > 0) {
|
|
68
|
-
|
|
33
|
+
console.log(getColoredTitle('Tag issues', tagHints.size));
|
|
69
34
|
for (const hint of tagHints) {
|
|
70
35
|
const { filePath, identifier, tagName } = hint;
|
|
71
36
|
const message = `Unused tag in ${toRelative(filePath)}:`;
|
package/dist/reporters/util.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
2
|
+
import { type Issue, type IssueSeverity, type IssueSymbol } from '../types/issues.js';
|
|
3
|
+
import { Table } from '../util/table.js';
|
|
4
|
+
export declare const plain: (text: string) => string;
|
|
5
|
+
export declare const dim: import("picocolors/types.js").Formatter;
|
|
6
|
+
export declare const getIssueTypeTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) => string;
|
|
7
|
+
export declare const getColoredTitle: (title: string, count: number) => string;
|
|
8
|
+
export declare const getDimmedTitle: (title: string) => string;
|
|
7
9
|
type LogIssueLine = {
|
|
8
10
|
owner?: string;
|
|
9
11
|
filePath: string;
|
|
@@ -11,12 +13,14 @@ type LogIssueLine = {
|
|
|
11
13
|
parentSymbol?: string;
|
|
12
14
|
severity?: IssueSeverity;
|
|
13
15
|
};
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const logIssueSet: (issues: string[]) => void;
|
|
16
|
+
export declare const getIssueLine: ({ owner, filePath, symbols, parentSymbol, severity }: LogIssueLine) => string;
|
|
16
17
|
export declare const convert: (issue: Issue | IssueSymbol) => {
|
|
17
18
|
name: string;
|
|
18
19
|
line: number | undefined;
|
|
19
20
|
col: number | undefined;
|
|
20
21
|
pos: number | undefined;
|
|
21
22
|
};
|
|
23
|
+
export declare const getTableForType: (issues: Issue[], options?: {
|
|
24
|
+
isUseColors?: boolean;
|
|
25
|
+
}) => Table;
|
|
22
26
|
export {};
|