knip 5.44.5 → 5.46.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 +3 -3
- package/dist/ConfigurationChief.d.ts +1 -0
- package/dist/ConfigurationChief.js +6 -0
- package/dist/IssueCollector.js +2 -1
- package/dist/IssueFixer.js +1 -1
- package/dist/WorkspaceWorker.d.ts +6 -1
- package/dist/WorkspaceWorker.js +49 -28
- package/dist/binaries/bash-parser.js +2 -1
- package/dist/binaries/package-manager/bun.js +7 -3
- package/dist/binaries/package-manager/yarn.js +5 -4
- package/dist/binaries/plugins.js +23 -20
- package/dist/cli.js +6 -4
- package/dist/compilers/index.d.ts +1 -0
- package/dist/graph/analyze.d.ts +1 -1
- package/dist/graph/analyze.js +2 -2
- package/dist/graph/build.js +9 -12
- package/dist/index.js +5 -4
- package/dist/plugins/angular/index.js +2 -2
- package/dist/plugins/eslint/helpers.d.ts +2 -2
- package/dist/plugins/eslint/helpers.js +14 -6
- package/dist/plugins/eslint/index.d.ts +5 -2
- package/dist/plugins/eslint/index.js +31 -3
- package/dist/plugins/eslint/types.d.ts +5 -4
- package/dist/plugins/index.d.ts +1 -7
- package/dist/plugins/playwright/index.d.ts +0 -6
- package/dist/plugins/playwright/index.js +1 -1
- package/dist/plugins/playwright-ct/index.d.ts +0 -6
- package/dist/plugins/playwright-ct/index.js +1 -2
- package/dist/plugins/storybook/index.js +2 -2
- package/dist/plugins/typescript/index.js +4 -2
- package/dist/plugins/xo/index.js +2 -2
- package/dist/plugins/xo/types.d.ts +2 -2
- package/dist/reporters/codeclimate.d.ts +3 -0
- package/dist/reporters/codeclimate.js +87 -0
- package/dist/reporters/compact.js +1 -1
- package/dist/reporters/disclosure.js +11 -24
- package/dist/reporters/index.d.ts +2 -1
- package/dist/reporters/index.js +2 -0
- package/dist/reporters/symbols.d.ts +1 -1
- package/dist/reporters/symbols.js +15 -32
- package/dist/schema/configuration.d.ts +3 -0
- package/dist/schema/configuration.js +1 -0
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/issues.d.ts +4 -3
- package/dist/typescript/SourceFile.d.ts +0 -1
- package/dist/typescript/find-internal-references.js +9 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +3 -1
- package/dist/util/get-referenced-inputs.js +2 -2
- package/dist/util/input.d.ts +3 -3
- package/dist/util/input.js +5 -5
- package/dist/util/issue-initializers.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- package/schema.json +5 -0
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
2
|
import { toConfig, toDeferResolve } from '../../util/input.js';
|
|
3
3
|
import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
4
|
-
import { isAbsolute, isInternal } from '../../util/path.js';
|
|
4
|
+
import { extname, isAbsolute, isInternal } from '../../util/path.js';
|
|
5
5
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
6
|
-
export const
|
|
6
|
+
export const getInputs = (config, options) => {
|
|
7
|
+
const { configFileName } = options;
|
|
8
|
+
if (extname(configFileName) === '.json' || !/eslint\.config/.test(configFileName)) {
|
|
9
|
+
return getInputsDeprecated(config, options);
|
|
10
|
+
}
|
|
11
|
+
const dependencies = config.flatMap(config => config.settings ? getDependenciesFromSettings(config.settings).filter(id => id !== '@typescript-eslint/parser') : []);
|
|
12
|
+
return compact(dependencies).map(id => toDeferResolve(id));
|
|
13
|
+
};
|
|
14
|
+
const getInputsDeprecated = (config, options) => {
|
|
7
15
|
const extendsSpecifiers = config.extends ? compact([config.extends].flat().map(resolveExtendSpecifier)) : [];
|
|
8
16
|
if (extendsSpecifiers.some(specifier => specifier?.startsWith('eslint-plugin-prettier')))
|
|
9
17
|
extendsSpecifiers.push('eslint-config-prettier');
|
|
10
|
-
const extendConfigs = extendsSpecifiers.map(specifier => toConfig('eslint', specifier, options.configFilePath));
|
|
18
|
+
const extendConfigs = extendsSpecifiers.map(specifier => toConfig('eslint', specifier, { containingFilePath: options.configFilePath }));
|
|
11
19
|
const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
|
|
12
20
|
const parser = config.parser ?? config.parserOptions?.parser;
|
|
13
21
|
const babelDependencies = config.parserOptions?.babelOptions
|
|
@@ -15,9 +23,9 @@ export const getDependencies = (config, options) => {
|
|
|
15
23
|
: [];
|
|
16
24
|
const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
|
|
17
25
|
const rules = getDependenciesFromRules({});
|
|
18
|
-
const overrides = config.overrides ? [config.overrides].flat().flatMap(d =>
|
|
19
|
-
const
|
|
20
|
-
return [...extendConfigs, ...
|
|
26
|
+
const overrides = config.overrides ? [config.overrides].flat().flatMap(d => getInputsDeprecated(d, options)) : [];
|
|
27
|
+
const deferred = compact([...extendsSpecifiers, ...plugins, parser, ...settings, ...rules]).map(toDeferResolve);
|
|
28
|
+
return [...extendConfigs, ...deferred, ...babelDependencies, ...overrides];
|
|
21
29
|
};
|
|
22
30
|
const isQualifiedSpecifier = (specifier) => specifier === 'eslint' ||
|
|
23
31
|
/\/eslint-(config|plugin)$/.test(specifier) ||
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ESLintConfigDeprecated } from './types.js';
|
|
3
|
+
export declare const docs: {
|
|
4
|
+
note: string;
|
|
5
|
+
};
|
|
3
6
|
declare const _default: {
|
|
4
7
|
title: string;
|
|
5
8
|
enablers: string[];
|
|
@@ -7,6 +10,6 @@ declare const _default: {
|
|
|
7
10
|
packageJsonPath: string;
|
|
8
11
|
entry: string[];
|
|
9
12
|
config: string[];
|
|
10
|
-
resolveConfig: ResolveConfig<
|
|
13
|
+
resolveConfig: ResolveConfig<ESLintConfigDeprecated>;
|
|
11
14
|
};
|
|
12
15
|
export default _default;
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getInputs } from './helpers.js';
|
|
3
3
|
const title = 'ESLint';
|
|
4
4
|
const enablers = ['eslint', '@eslint/js'];
|
|
5
5
|
const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, enablers) ||
|
|
6
6
|
'eslint' in config ||
|
|
7
7
|
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
|
|
8
8
|
const packageJsonPath = 'eslintConfig';
|
|
9
|
-
const entry = ['eslint.config.{js,cjs,mjs}'];
|
|
9
|
+
const entry = ['eslint.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
10
10
|
const config = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
|
|
11
|
-
const resolveConfig = (localConfig, options) =>
|
|
11
|
+
const resolveConfig = (localConfig, options) => getInputs(localConfig, options);
|
|
12
|
+
const note = `### ESLint v9
|
|
13
|
+
|
|
14
|
+
Only regular \`import\` statements are considered by default.
|
|
15
|
+
The configuration object is not resolved to find dependencies for \`settings\` such as \`"eslint-import-resolver-typescript"\`.
|
|
16
|
+
To enable this, lift the \`entry\` to a \`config\` file like so:
|
|
17
|
+
|
|
18
|
+
\`\`\`json
|
|
19
|
+
{
|
|
20
|
+
"eslint": ["eslint.config.ts"]
|
|
21
|
+
}
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
This is not enabled by default, since this exception may be thrown by a \`@rushstack/eslint-*\` package:
|
|
25
|
+
|
|
26
|
+
> \`Error: Failed to patch ESLint because the calling module was not recognized.\`
|
|
27
|
+
|
|
28
|
+
### ESLint v8
|
|
29
|
+
|
|
30
|
+
If relying on [configuration cascading](https://eslint.org/docs/v8.x/use/configure/configuration-files#cascading-and-hierarchy),
|
|
31
|
+
consider using an extended glob pattern like this:
|
|
32
|
+
|
|
33
|
+
\`\`\`json
|
|
34
|
+
{
|
|
35
|
+
"eslint": ["**/.eslintrc.js"]
|
|
36
|
+
}
|
|
37
|
+
\`\`\`
|
|
38
|
+
`;
|
|
39
|
+
export const docs = { note };
|
|
12
40
|
export default {
|
|
13
41
|
title,
|
|
14
42
|
enablers,
|
|
@@ -17,12 +17,13 @@ type BaseConfig = {
|
|
|
17
17
|
settings?: Settings;
|
|
18
18
|
rules?: Rules;
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
20
|
+
export type ESLintConfig = BaseConfig[];
|
|
21
|
+
export type OverrideConfigDeprecated = BaseConfig & {
|
|
21
22
|
files: string[];
|
|
22
|
-
overrides:
|
|
23
|
+
overrides: OverrideConfigDeprecated;
|
|
23
24
|
};
|
|
24
|
-
export type
|
|
25
|
+
export type ESLintConfigDeprecated = BaseConfig & {
|
|
25
26
|
env?: Record<string, boolean>;
|
|
26
|
-
overrides?:
|
|
27
|
+
overrides?: OverrideConfigDeprecated[];
|
|
27
28
|
};
|
|
28
29
|
export {};
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ export declare const Plugins: {
|
|
|
133
133
|
packageJsonPath: string;
|
|
134
134
|
entry: string[];
|
|
135
135
|
config: string[];
|
|
136
|
-
resolveConfig: import("../types/config.js").ResolveConfig<import("./eslint/types.js").
|
|
136
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./eslint/types.js").ESLintConfigDeprecated>;
|
|
137
137
|
};
|
|
138
138
|
expo: {
|
|
139
139
|
title: string;
|
|
@@ -403,12 +403,6 @@ export declare const Plugins: {
|
|
|
403
403
|
entry: string[];
|
|
404
404
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./playwright/types.js").PlaywrightTestConfig>;
|
|
405
405
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./playwright/types.js").PlaywrightTestConfig>;
|
|
406
|
-
args: {
|
|
407
|
-
binaries: string[];
|
|
408
|
-
positional: boolean;
|
|
409
|
-
args: (args: string[]) => string[];
|
|
410
|
-
config: boolean;
|
|
411
|
-
};
|
|
412
406
|
};
|
|
413
407
|
'playwright-test': {
|
|
414
408
|
title: string;
|
|
@@ -3,12 +3,6 @@ import type { PlaywrightTestConfig } from './types.js';
|
|
|
3
3
|
export declare const entry: string[];
|
|
4
4
|
export declare const resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig>;
|
|
5
5
|
export declare const resolveConfig: ResolveConfig<PlaywrightTestConfig>;
|
|
6
|
-
export declare const args: {
|
|
7
|
-
binaries: string[];
|
|
8
|
-
positional: boolean;
|
|
9
|
-
args: (args: string[]) => string[];
|
|
10
|
-
config: boolean;
|
|
11
|
-
};
|
|
12
6
|
declare const _default: {
|
|
13
7
|
title: string;
|
|
14
8
|
enablers: string[];
|
|
@@ -29,7 +29,7 @@ export const resolveConfig = async (config) => {
|
|
|
29
29
|
});
|
|
30
30
|
return [...reporters].map(toDeferResolve);
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
const args = {
|
|
33
33
|
binaries: ['playwright'],
|
|
34
34
|
positional: true,
|
|
35
35
|
args: (args) => args.filter(arg => arg !== 'install' && arg !== 'test'),
|
|
@@ -7,11 +7,5 @@ declare const _default: {
|
|
|
7
7
|
entry: string[];
|
|
8
8
|
resolveEntryPaths: import("../../types/config.js").ResolveEntryPaths<import("../playwright/types.js").PlaywrightTestConfig>;
|
|
9
9
|
resolveConfig: import("../../types/config.js").ResolveConfig<import("../playwright/types.js").PlaywrightTestConfig>;
|
|
10
|
-
args: {
|
|
11
|
-
binaries: string[];
|
|
12
|
-
positional: boolean;
|
|
13
|
-
args: (args: string[]) => string[];
|
|
14
|
-
config: boolean;
|
|
15
|
-
};
|
|
16
10
|
};
|
|
17
11
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
-
import {
|
|
2
|
+
import { entry, resolveConfig, resolveEntryPaths } from '../playwright/index.js';
|
|
3
3
|
const title = 'Playwright for components';
|
|
4
4
|
const enablers = [/^@playwright\/experimental-ct-/];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -12,5 +12,4 @@ export default {
|
|
|
12
12
|
entry,
|
|
13
13
|
resolveEntryPaths,
|
|
14
14
|
resolveConfig,
|
|
15
|
-
args,
|
|
16
15
|
};
|
|
@@ -4,11 +4,11 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
4
4
|
const title = 'Storybook';
|
|
5
5
|
const enablers = [/^@storybook\//, '@nrwl/storybook'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
-
const config = ['.storybook/{main,test-runner}.{js,ts}'];
|
|
7
|
+
const config = ['.storybook/{main,test-runner}.{js,ts,mts}'];
|
|
8
8
|
const stories = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
|
|
9
9
|
const restEntry = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}'];
|
|
10
10
|
const entry = [...restEntry, ...stories];
|
|
11
|
-
const project = ['.storybook/**/*.{js,jsx,ts,tsx}'];
|
|
11
|
+
const project = ['.storybook/**/*.{js,jsx,ts,tsx,mts}'];
|
|
12
12
|
const resolveEntryPaths = async (localConfig, options) => {
|
|
13
13
|
const { cwd, configFileDir } = options;
|
|
14
14
|
const strs = typeof localConfig?.stories === 'function' ? await localConfig.stories(stories) : localConfig?.stories;
|
|
@@ -9,11 +9,13 @@ const config = ['tsconfig.json'];
|
|
|
9
9
|
const resolveConfig = async (localConfig, options) => {
|
|
10
10
|
const { compilerOptions } = localConfig;
|
|
11
11
|
const extend = localConfig.extends
|
|
12
|
-
? [localConfig.extends]
|
|
12
|
+
? [localConfig.extends]
|
|
13
|
+
.flat()
|
|
14
|
+
.map(specifier => toConfig('typescript', specifier, { containingFilePath: options.configFilePath }))
|
|
13
15
|
: [];
|
|
14
16
|
const references = localConfig.references
|
|
15
17
|
?.filter(reference => reference.path.endsWith('.json'))
|
|
16
|
-
.map(reference => toConfig('typescript', reference.path, options.configFilePath)) ?? [];
|
|
18
|
+
.map(reference => toConfig('typescript', reference.path, { containingFilePath: options.configFilePath })) ?? [];
|
|
17
19
|
if (!(compilerOptions && localConfig))
|
|
18
20
|
return compact([...extend, ...references]);
|
|
19
21
|
const jsx = (compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []).map(toProductionDependency);
|
package/dist/plugins/xo/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getInputs } from '../eslint/helpers.js';
|
|
3
3
|
const title = 'xo';
|
|
4
4
|
const enablers = ['xo'];
|
|
5
5
|
const isEnabled = ({ dependencies, config }) => hasDependency(dependencies, enablers) || 'xo' in config;
|
|
6
6
|
const config = ['package.json', '.xo-config', '.xo-config.{js,cjs,json}', 'xo.config.{js,cjs}'];
|
|
7
7
|
const entry = ['.xo-config.{js,cjs}', 'xo.config.{js,cjs}'];
|
|
8
8
|
const resolveConfig = async (config, options) => {
|
|
9
|
-
const inputs =
|
|
9
|
+
const inputs = getInputs(config, options);
|
|
10
10
|
return [...inputs];
|
|
11
11
|
};
|
|
12
12
|
export default {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type XOConfig =
|
|
1
|
+
import type { ESLintConfigDeprecated } from '../eslint/types.js';
|
|
2
|
+
export type XOConfig = ESLintConfigDeprecated & {
|
|
3
3
|
envs?: string[] | undefined;
|
|
4
4
|
globals?: string[] | undefined;
|
|
5
5
|
ignores?: string[] | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { toRelative } from '../util/path.js';
|
|
3
|
+
import { getTitle } from './util.js';
|
|
4
|
+
export default async ({ report, issues }) => {
|
|
5
|
+
const entries = [];
|
|
6
|
+
for (const [type, isReportType] of Object.entries(report)) {
|
|
7
|
+
if (!isReportType) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const fixedType = type === 'files' ? '_files' : type;
|
|
11
|
+
for (const issue of flatten(issues[fixedType])) {
|
|
12
|
+
const { filePath } = issue;
|
|
13
|
+
if (fixedType === 'duplicates' && issue.symbols) {
|
|
14
|
+
entries.push(...issue.symbols.map(symbol => ({
|
|
15
|
+
type: 'issue',
|
|
16
|
+
check_name: getTitle(fixedType),
|
|
17
|
+
description: getSymbolDescription({ symbol, parentSymbol: issue.parentSymbol }),
|
|
18
|
+
categories: ['Duplication'],
|
|
19
|
+
location: createLocation(filePath, symbol.line, symbol.col),
|
|
20
|
+
severity: convertSeverity(issue.severity),
|
|
21
|
+
fingerprint: createFingerprint(filePath, symbol.symbol, symbol.pos),
|
|
22
|
+
})));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
entries.push({
|
|
26
|
+
type: 'issue',
|
|
27
|
+
check_name: getTitle(fixedType),
|
|
28
|
+
description: getIssueDescription(issue),
|
|
29
|
+
categories: ['Bug Risk'],
|
|
30
|
+
location: createLocation(filePath, issue.line, issue.col),
|
|
31
|
+
severity: convertSeverity(issue.severity),
|
|
32
|
+
fingerprint: createFingerprint(filePath, issue.symbol, issue.pos),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const output = JSON.stringify(entries);
|
|
38
|
+
process.stdout._handle?.setBlocking?.(true);
|
|
39
|
+
process.stdout.write(`${output}\n`);
|
|
40
|
+
};
|
|
41
|
+
function flatten(issues) {
|
|
42
|
+
return Object.values(issues).flatMap(Object.values);
|
|
43
|
+
}
|
|
44
|
+
function convertSeverity(severity) {
|
|
45
|
+
switch (severity) {
|
|
46
|
+
case 'error':
|
|
47
|
+
return 'major';
|
|
48
|
+
case 'warn':
|
|
49
|
+
return 'minor';
|
|
50
|
+
default:
|
|
51
|
+
return 'info';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getIssueDescription({ symbol, symbols, parentSymbol }) {
|
|
55
|
+
const symbolDescription = symbols ? `${symbols.map(s => s.symbol).join(', ')}` : symbol;
|
|
56
|
+
return `${symbolDescription}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
57
|
+
}
|
|
58
|
+
function getSymbolDescription({ symbol, parentSymbol }) {
|
|
59
|
+
return `${symbol.symbol}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
60
|
+
}
|
|
61
|
+
function createLocation(filePath, line, col) {
|
|
62
|
+
if (col !== undefined) {
|
|
63
|
+
return {
|
|
64
|
+
path: toRelative(filePath),
|
|
65
|
+
positions: {
|
|
66
|
+
begin: {
|
|
67
|
+
line: line ?? 0,
|
|
68
|
+
column: col,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
path: toRelative(filePath),
|
|
75
|
+
lines: {
|
|
76
|
+
begin: line ?? 0,
|
|
77
|
+
end: line ?? 0,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function createFingerprint(filePath, message, pos) {
|
|
82
|
+
const md5 = createHash('md5');
|
|
83
|
+
md5.update(filePath);
|
|
84
|
+
md5.update(message);
|
|
85
|
+
md5.update(pos?.toString() ?? '');
|
|
86
|
+
return md5.digest('hex');
|
|
87
|
+
}
|
|
@@ -16,7 +16,7 @@ export default ({ report, issues, isShowProgress }) => {
|
|
|
16
16
|
? Object.values(issues[reportType]).flatMap(Object.values)
|
|
17
17
|
: Object.values(issues[reportType]).map(issues => {
|
|
18
18
|
const items = Object.values(issues);
|
|
19
|
-
return { ...items[0], symbols: items
|
|
19
|
+
return { ...items[0], symbols: items };
|
|
20
20
|
});
|
|
21
21
|
if (issuesForType.length > 0) {
|
|
22
22
|
title && logTitle(title, issuesForType.length);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EasyTable from 'easy-table';
|
|
2
|
-
import { relative
|
|
2
|
+
import { relative } from '../util/path.js';
|
|
3
3
|
import { getTitle } from './util.js';
|
|
4
4
|
const printHeader = (size, title) => console.log(`<details>\n${title ? `<summary>${title} (${size})</summary>\n` : ''}\n\`\`\``);
|
|
5
5
|
const printFooter = () => console.log('```\n\n</details>\n');
|
|
@@ -10,7 +10,7 @@ const logIssueRecord = (issues) => {
|
|
|
10
10
|
issue.parentSymbol && table.cell('parentSymbol', issue.parentSymbol);
|
|
11
11
|
issue.symbolType && table.cell('symbolType', issue.symbolType);
|
|
12
12
|
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
13
|
-
const cell = `${relative(issue.filePath)}${pos}`;
|
|
13
|
+
const cell = issue.type === 'files' ? '' : `${relative(issue.filePath)}${pos}`;
|
|
14
14
|
table.cell('filePath', cell);
|
|
15
15
|
table.newRow();
|
|
16
16
|
}
|
|
@@ -19,30 +19,17 @@ const logIssueRecord = (issues) => {
|
|
|
19
19
|
export default ({ report, issues }) => {
|
|
20
20
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
21
21
|
let totalIssues = 0;
|
|
22
|
-
for (
|
|
23
|
-
if (reportType === '
|
|
24
|
-
|
|
22
|
+
for (let [reportType, isReportType] of Object.entries(report)) {
|
|
23
|
+
if (reportType === 'files')
|
|
24
|
+
reportType = '_files';
|
|
25
25
|
if (isReportType) {
|
|
26
26
|
const title = reportMultipleGroups ? getTitle(reportType) : undefined;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log(toRelative(issue.filePath));
|
|
34
|
-
totalIssues = totalIssues + issuesForType.length;
|
|
35
|
-
printFooter();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
40
|
-
if (issuesForType.length > 0) {
|
|
41
|
-
printHeader(issuesForType.length, title);
|
|
42
|
-
logIssueRecord(issuesForType);
|
|
43
|
-
totalIssues = totalIssues + issuesForType.length;
|
|
44
|
-
printFooter();
|
|
45
|
-
}
|
|
27
|
+
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
28
|
+
if (issuesForType.length > 0) {
|
|
29
|
+
printHeader(issuesForType.length, title);
|
|
30
|
+
logIssueRecord(issuesForType);
|
|
31
|
+
totalIssues = totalIssues + issuesForType.length;
|
|
32
|
+
printFooter();
|
|
46
33
|
}
|
|
47
34
|
}
|
|
48
35
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
symbols: ({ report, issues, tagHints, configurationHints,
|
|
2
|
+
symbols: ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }: import("../index.js").ReporterOptions) => void;
|
|
3
3
|
compact: ({ report, issues, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
4
4
|
codeowners: ({ report, issues, isShowProgress, options }: import("../index.js").ReporterOptions) => void;
|
|
5
5
|
disclosure: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
6
|
+
codeclimate: ({ report, issues }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
6
7
|
json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
7
8
|
markdown: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
8
9
|
};
|
package/dist/reporters/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import codeclimate from './codeclimate.js';
|
|
1
2
|
import codeowners from './codeowners.js';
|
|
2
3
|
import compact from './compact.js';
|
|
3
4
|
import disclosure from './disclosure.js';
|
|
@@ -9,6 +10,7 @@ export default {
|
|
|
9
10
|
compact,
|
|
10
11
|
codeowners,
|
|
11
12
|
disclosure,
|
|
13
|
+
codeclimate,
|
|
12
14
|
json,
|
|
13
15
|
markdown,
|
|
14
16
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReporterOptions } from '../types/issues.js';
|
|
2
|
-
declare const _default: ({ report, issues, tagHints, configurationHints,
|
|
2
|
+
declare const _default: ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }: ReporterOptions) => void;
|
|
3
3
|
export default _default;
|
|
@@ -33,56 +33,39 @@ const logIssueRecord = (issues) => {
|
|
|
33
33
|
issue.parentSymbol && table.cell('parentSymbol', print(issue.parentSymbol));
|
|
34
34
|
issue.symbolType && table.cell('symbolType', print(issue.symbolType));
|
|
35
35
|
const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
|
|
36
|
-
const cell = `${relative(issue.filePath)}${pos}`;
|
|
36
|
+
const cell = issue.type === 'files' ? '' : `${relative(issue.filePath)}${pos}`;
|
|
37
37
|
table.cell('filePath', print(cell));
|
|
38
38
|
issue.isFixed && table.cell('fixed', print('(removed)'));
|
|
39
39
|
table.newRow();
|
|
40
40
|
}
|
|
41
41
|
console.log(table.sort(sortByPos).print().trim());
|
|
42
42
|
};
|
|
43
|
-
export default ({ report, issues, tagHints, configurationHints,
|
|
43
|
+
export default ({ report, issues, tagHints, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, isShowProgress, }) => {
|
|
44
44
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
45
45
|
let totalIssues = 0;
|
|
46
|
-
for (
|
|
47
|
-
if (reportType === '
|
|
48
|
-
|
|
46
|
+
for (let [reportType, isReportType] of Object.entries(report)) {
|
|
47
|
+
if (reportType === 'files')
|
|
48
|
+
reportType = '_files';
|
|
49
49
|
if (isReportType) {
|
|
50
50
|
const title = reportMultipleGroups && getTitle(reportType);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (const issue of sortedIssues) {
|
|
57
|
-
const relPath = toRelative(issue.filePath);
|
|
58
|
-
if (issue.isFixed)
|
|
59
|
-
console.log(dim(`${relPath} (removed)`));
|
|
60
|
-
else if (issue.severity === 'warn')
|
|
61
|
-
console.log(dim(relPath));
|
|
62
|
-
else
|
|
63
|
-
console.log(relPath);
|
|
64
|
-
}
|
|
65
|
-
totalIssues = totalIssues + issuesForType.length;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
70
|
-
if (issuesForType.length > 0) {
|
|
71
|
-
title && logTitle(title, issuesForType.length);
|
|
72
|
-
logIssueRecord(issuesForType);
|
|
73
|
-
totalIssues = totalIssues + issuesForType.length;
|
|
74
|
-
}
|
|
51
|
+
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
52
|
+
if (issuesForType.length > 0) {
|
|
53
|
+
title && logTitle(title, issuesForType.length);
|
|
54
|
+
logIssueRecord(issuesForType);
|
|
55
|
+
totalIssues = totalIssues + issuesForType.length;
|
|
75
56
|
}
|
|
76
57
|
}
|
|
77
58
|
}
|
|
78
|
-
if (!
|
|
59
|
+
if (!isDisableConfigHints) {
|
|
79
60
|
if (configurationHints.size > 0) {
|
|
80
|
-
logTitleDimmed
|
|
61
|
+
const _logTitle = isTreatConfigHintsAsErrors ? logTitle : logTitleDimmed;
|
|
62
|
+
const _color = isTreatConfigHintsAsErrors ? identity : dim;
|
|
63
|
+
_logTitle('Configuration hints', configurationHints.size);
|
|
81
64
|
for (const hint of configurationHints) {
|
|
82
65
|
const { type, workspaceName, identifier } = hint;
|
|
83
66
|
const message = `Unused item in ${type}`;
|
|
84
67
|
const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : '';
|
|
85
|
-
console.warn(
|
|
68
|
+
console.warn(_color(`${message}${workspace}:`), identifier);
|
|
86
69
|
}
|
|
87
70
|
}
|
|
88
71
|
if (tagHints.size > 0) {
|
|
@@ -15,6 +15,7 @@ export declare const knipConfigurationSchema: z.ZodObject<z.objectUtil.extendSha
|
|
|
15
15
|
compilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodString>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>]>>>;
|
|
16
16
|
syncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodString>>>;
|
|
17
17
|
asyncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>>>;
|
|
18
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
19
|
}, {
|
|
19
20
|
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"optionalPeerDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
|
|
20
21
|
exclude: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"optionalPeerDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
|
|
@@ -3330,6 +3331,7 @@ export declare const knipConfigurationSchema: z.ZodObject<z.objectUtil.extendSha
|
|
|
3330
3331
|
}>]>>;
|
|
3331
3332
|
}>, "strip", z.ZodTypeAny, {
|
|
3332
3333
|
exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
3334
|
+
tags?: string[] | undefined;
|
|
3333
3335
|
include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
3334
3336
|
node?: string | boolean | string[] | {
|
|
3335
3337
|
config?: string | string[] | undefined;
|
|
@@ -4269,6 +4271,7 @@ export declare const knipConfigurationSchema: z.ZodObject<z.objectUtil.extendSha
|
|
|
4269
4271
|
}> | undefined;
|
|
4270
4272
|
}, {
|
|
4271
4273
|
exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
4274
|
+
tags?: string[] | undefined;
|
|
4272
4275
|
include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
4273
4276
|
node?: string | boolean | string[] | {
|
|
4274
4277
|
config?: string | string[] | undefined;
|
|
@@ -50,6 +50,7 @@ const rootConfigurationSchema = z.object({
|
|
|
50
50
|
compilers: compilersSchema.optional(),
|
|
51
51
|
syncCompilers: z.record(z.string(), syncCompilerSchema).optional(),
|
|
52
52
|
asyncCompilers: z.record(z.string(), asyncCompilerSchema).optional(),
|
|
53
|
+
tags: z.array(z.string()).optional(),
|
|
53
54
|
});
|
|
54
55
|
const reportConfigSchema = z.object({
|
|
55
56
|
include: z.array(issueTypeSchema).optional(),
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface CommandLineOptions {
|
|
|
11
11
|
isExportsShorthand: boolean;
|
|
12
12
|
isFilesShorthand: boolean;
|
|
13
13
|
isFix: boolean;
|
|
14
|
-
|
|
14
|
+
isDisableConfigHints: boolean;
|
|
15
15
|
isIncludeEntryExports: boolean;
|
|
16
16
|
isIncludeLibs: boolean;
|
|
17
17
|
isIsolateWorkspaces: boolean;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
|
14
14
|
}
|
|
15
15
|
export type GetInputsFromScripts<T = GetInputsFromScriptsOptions> = (npmScripts: string | string[] | Set<string>, options: T) => Input[];
|
|
16
16
|
export type GetInputsFromScriptsPartial = (npmScripts: string | string[] | Set<string>, options?: Partial<GetInputsFromScriptsOptions>) => Input[];
|
|
17
|
-
type FromArgs = (args: string[]) => Input[];
|
|
17
|
+
export type FromArgs = (args: string[], options?: Partial<GetInputsFromScriptsOptions>) => Input[];
|
|
18
18
|
export interface BinaryResolverOptions extends GetInputsFromScriptsOptions {
|
|
19
19
|
fromArgs: FromArgs;
|
|
20
20
|
}
|
|
@@ -47,6 +47,7 @@ export interface Configuration {
|
|
|
47
47
|
syncCompilers: SyncCompilers;
|
|
48
48
|
asyncCompilers: AsyncCompilers;
|
|
49
49
|
rootPluginConfigs: Partial<PluginsConfiguration>;
|
|
50
|
+
tags: string[];
|
|
50
51
|
}
|
|
51
52
|
type NormalizedGlob = string[];
|
|
52
53
|
export type EnsuredPluginConfiguration = {
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type IssueSet = Set<string>;
|
|
|
32
32
|
export type IssueRecords = Record<string, Record<string, Issue>>;
|
|
33
33
|
export type Issues = {
|
|
34
34
|
files: IssueSet;
|
|
35
|
-
_files:
|
|
35
|
+
_files: IssueRecords;
|
|
36
36
|
dependencies: IssueRecords;
|
|
37
37
|
devDependencies: IssueRecords;
|
|
38
38
|
optionalPeerDependencies: IssueRecords;
|
|
@@ -48,7 +48,7 @@ export type Issues = {
|
|
|
48
48
|
classMembers: IssueRecords;
|
|
49
49
|
};
|
|
50
50
|
export type IssueType = keyof Issues;
|
|
51
|
-
export type SymbolIssueType = Exclude<IssueType, 'files'
|
|
51
|
+
export type SymbolIssueType = Exclude<IssueType, 'files'>;
|
|
52
52
|
export type Report = {
|
|
53
53
|
[key in keyof Issues]: boolean;
|
|
54
54
|
};
|
|
@@ -59,7 +59,8 @@ export type ReporterOptions = {
|
|
|
59
59
|
counters: Counters;
|
|
60
60
|
tagHints: TagHints;
|
|
61
61
|
configurationHints: ConfigurationHints;
|
|
62
|
-
|
|
62
|
+
isDisableConfigHints: boolean;
|
|
63
|
+
isTreatConfigHintsAsErrors: boolean;
|
|
63
64
|
cwd: string;
|
|
64
65
|
isProduction: boolean;
|
|
65
66
|
isShowProgress: boolean;
|
|
@@ -27,7 +27,6 @@ type PragmaMap = {
|
|
|
27
27
|
};
|
|
28
28
|
export interface BoundSourceFile extends ts.SourceFile {
|
|
29
29
|
symbol?: SymbolWithExports;
|
|
30
|
-
resolvedModules?: ts.ModeAwareCache<ts.ResolvedModuleWithFailedLookupLocations>;
|
|
31
30
|
locals?: SymbolTable;
|
|
32
31
|
getNamedDeclarations?(): Map<string, readonly ts.Declaration[]>;
|
|
33
32
|
scriptKind?: ts.ScriptKind;
|