knip 5.9.0 → 5.9.2
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/ConfigurationChief.d.ts +6 -6
- package/dist/ConfigurationChief.js +10 -8
- package/dist/ConsoleStreamer.js +1 -1
- package/dist/DependencyDeputy.d.ts +1 -1
- package/dist/DependencyDeputy.js +22 -18
- package/dist/IssueCollector.js +10 -9
- package/dist/IssueFixer.js +9 -7
- package/dist/PrincipalFactory.d.ts +2 -2
- package/dist/PrincipalFactory.js +3 -5
- package/dist/ProjectPrincipal.d.ts +6 -6
- package/dist/ProjectPrincipal.js +12 -10
- package/dist/WorkspaceWorker.d.ts +2 -2
- package/dist/WorkspaceWorker.js +13 -9
- package/dist/binaries/index.js +1 -1
- package/dist/binaries/resolvers/bun.js +1 -1
- package/dist/binaries/resolvers/index.d.ts +12 -12
- package/dist/binaries/util.js +1 -1
- package/dist/cli.js +10 -9
- package/dist/compilers/index.d.ts +1 -1
- package/dist/index.js +65 -57
- package/dist/issues/initializers.d.ts +1 -1
- package/dist/manifest/helpers.js +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +4 -4
- package/dist/plugins/ava/index.js +8 -8
- package/dist/plugins/babel/index.js +2 -2
- package/dist/plugins/babel/types.d.ts +1 -1
- package/dist/plugins/babel/types.js +1 -1
- package/dist/plugins/commitlint/index.d.ts +1 -1
- package/dist/plugins/cspell/index.d.ts +1 -1
- package/dist/plugins/drizzle/index.d.ts +1 -1
- package/dist/plugins/eleventy/helpers.d.ts +0 -1
- package/dist/plugins/eleventy/helpers.js +1 -2
- package/dist/plugins/eleventy/index.d.ts +1 -1
- package/dist/plugins/eslint/helpers.d.ts +1 -1
- package/dist/plugins/eslint/helpers.js +5 -2
- package/dist/plugins/eslint/index.d.ts +0 -1
- package/dist/plugins/eslint/index.js +1 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/graphql-codegen/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +5 -4
- package/dist/plugins/lint-staged/index.d.ts +1 -1
- package/dist/plugins/lint-staged/index.js +2 -1
- package/dist/plugins/linthtml/index.d.ts +1 -1
- package/dist/plugins/markdownlint/index.d.ts +1 -1
- package/dist/plugins/npm-package-json-lint/index.d.ts +1 -1
- package/dist/plugins/nyc/index.d.ts +1 -1
- package/dist/plugins/playwright/index.d.ts +1 -1
- package/dist/plugins/playwright-ct/index.js +1 -1
- package/dist/plugins/postcss/index.d.ts +1 -1
- package/dist/plugins/prettier/index.d.ts +1 -1
- package/dist/plugins/release-it/index.d.ts +1 -1
- package/dist/plugins/remark/index.d.ts +1 -1
- package/dist/plugins/semantic-release/index.d.ts +1 -1
- package/dist/plugins/stryker/index.d.ts +1 -1
- package/dist/plugins/stylelint/index.d.ts +1 -1
- package/dist/plugins/tsup/index.d.ts +1 -1
- package/dist/plugins/typescript/index.d.ts +0 -1
- package/dist/plugins/typescript/index.js +4 -3
- package/dist/plugins/unbuild/index.d.ts +1 -1
- package/dist/plugins/vite/index.d.ts +2 -2
- package/dist/plugins/vite/index.js +1 -1
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +8 -4
- package/dist/plugins/vue/index.d.ts +1 -1
- package/dist/plugins/vue/index.js +2 -1
- package/dist/plugins/vue/types.d.ts +1 -1
- package/dist/plugins/webpack/index.js +4 -4
- package/dist/plugins/wireit/index.d.ts +1 -1
- package/dist/plugins/yorkie/index.d.ts +1 -1
- package/dist/plugins/yorkie/index.js +2 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +6 -3
- package/dist/reporters/codeowners.js +9 -7
- package/dist/reporters/compact.js +1 -1
- package/dist/reporters/index.d.ts +5 -5
- package/dist/reporters/json.js +3 -3
- package/dist/reporters/markdown.js +7 -7
- package/dist/reporters/symbols.js +8 -8
- package/dist/reporters/util.js +3 -2
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.js +1 -3
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/exports.js +1 -1
- package/dist/types/imports.d.ts +1 -1
- package/dist/types/imports.js +1 -1
- package/dist/typescript/SourceFile.d.ts +1 -1
- package/dist/typescript/SourceFile.js +1 -1
- package/dist/typescript/SourceFileManager.d.ts +1 -1
- package/dist/typescript/ast-helpers.js +2 -2
- package/dist/typescript/createHosts.d.ts +1 -1
- package/dist/typescript/createHosts.js +1 -1
- package/dist/typescript/getImportsAndExports.d.ts +1 -1
- package/dist/typescript/getImportsAndExports.js +15 -12
- package/dist/typescript/resolveModuleNames.js +2 -2
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.js +24 -30
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +2 -2
- package/dist/typescript/visitors/dynamic-imports/index.js +0 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +14 -22
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.js +10 -12
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +2 -2
- package/dist/typescript/visitors/exports/index.js +0 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +2 -4
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.js +18 -20
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +2 -2
- package/dist/typescript/visitors/imports/index.js +0 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.js +14 -16
- package/dist/typescript/visitors/index.d.ts +1 -1
- package/dist/typescript/visitors/index.js +0 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +2 -2
- package/dist/typescript/visitors/scripts/index.js +0 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/Performance.d.ts +1 -1
- package/dist/util/Performance.js +5 -5
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/debug.js +1 -1
- package/dist/util/fs.d.ts +2 -2
- package/dist/util/fs.js +3 -3
- package/dist/util/get-included-issue-types.js +8 -5
- package/dist/util/get-reexporting-entry-file.js +12 -16
- package/dist/util/git.js +5 -5
- package/dist/util/glob.js +2 -2
- package/dist/util/globby.d.ts +1 -1
- package/dist/util/globby.js +11 -12
- package/dist/util/handle-dependency.d.ts +1 -1
- package/dist/util/handle-dependency.js +1 -2
- package/dist/util/is-identifier-referenced.js +4 -4
- package/dist/util/loader.js +3 -5
- package/dist/util/modules.js +7 -5
- package/dist/util/object.js +1 -1
- package/dist/util/plugin.d.ts +1 -1
- package/dist/util/plugin.js +12 -14
- package/dist/util/regex.js +1 -1
- package/dist/util/require.js +2 -2
- package/dist/util/tag.js +4 -2
- package/dist/util/type.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -23
|
@@ -19,7 +19,8 @@ const resolveConfig = async (config, options) => {
|
|
|
19
19
|
const dependencies = new Set();
|
|
20
20
|
for (const entry of Object.values(config).flat()) {
|
|
21
21
|
const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
|
|
22
|
-
getDependenciesFromScripts(scripts, options)
|
|
22
|
+
for (const id of getDependenciesFromScripts(scripts, options))
|
|
23
|
+
dependencies.add(id);
|
|
23
24
|
}
|
|
24
25
|
return Array.from(dependencies);
|
|
25
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveEntryPaths, ResolveConfig } from '#p/types/plugins.js';
|
|
2
1
|
import type { PlaywrightTestConfig } from 'playwright/test';
|
|
2
|
+
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
3
3
|
export declare const entry: string[];
|
|
4
4
|
export declare const resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig>;
|
|
5
5
|
export declare const resolveConfig: ResolveConfig<PlaywrightTestConfig>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasDependency } from '#p/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);
|
|
@@ -19,15 +19,16 @@ const getExtends = async (configFilePath, internalExtends = new Set()) => {
|
|
|
19
19
|
await getExtends(presetConfigPath, internalExtends);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
for (const extend of extends_)
|
|
23
|
+
internalExtends.add(extend);
|
|
23
24
|
return internalExtends;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
const resolveConfig = async (localConfig, options) => {
|
|
26
27
|
const { isProduction, configFileDir, configFileName } = options;
|
|
27
28
|
const configFilePath = join(configFileDir, configFileName);
|
|
28
29
|
const { compilerOptions } = await loadTSConfig(configFilePath);
|
|
29
30
|
const extend = await getExtends(configFilePath);
|
|
30
|
-
if (!compilerOptions
|
|
31
|
+
if (!(compilerOptions && localConfig))
|
|
31
32
|
return [];
|
|
32
33
|
const jsx = compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : [];
|
|
33
34
|
if (isProduction)
|
|
@@ -6,7 +6,7 @@ declare const _default: {
|
|
|
6
6
|
isEnabled: IsPluginEnabled;
|
|
7
7
|
config: string[];
|
|
8
8
|
production: string[];
|
|
9
|
-
resolveEntryPaths: import("#p/types/plugins.js").ResolveEntryPaths<import("
|
|
10
|
-
resolveConfig: import("#p/types/plugins.js").ResolveConfig<import("
|
|
9
|
+
resolveEntryPaths: import("#p/types/plugins.js").ResolveEntryPaths<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
|
|
10
|
+
resolveConfig: import("#p/types/plugins.js").ResolveConfig<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
|
|
11
11
|
};
|
|
12
12
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasDependency } from '#p/util/plugin.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveConfig, resolveEntryPaths } from '../vitest/index.js';
|
|
3
3
|
const title = 'Vite';
|
|
4
4
|
const enablers = ['vite'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IsPluginEnabled,
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
2
2
|
import type { ViteConfigOrFn, VitestWorkspaceConfig } from './types.js';
|
|
3
3
|
export declare const resolveEntryPaths: ResolveEntryPaths<ViteConfigOrFn | VitestWorkspaceConfig>;
|
|
4
4
|
export declare const resolveConfig: ResolveConfig<ViteConfigOrFn | VitestWorkspaceConfig>;
|
|
@@ -59,10 +59,12 @@ export const resolveEntryPaths = async (localConfig, options) => {
|
|
|
59
59
|
const configs = await getConfigs(localConfig);
|
|
60
60
|
for (const cfg of configs) {
|
|
61
61
|
if (cfg.test?.include) {
|
|
62
|
-
cfg.test.include
|
|
62
|
+
for (const dependency of cfg.test.include)
|
|
63
|
+
dependencies.add(dependency);
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
|
-
(options.config.entry ?? entry)
|
|
66
|
+
for (const dependency of options.config.entry ?? entry)
|
|
67
|
+
dependencies.add(dependency);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
return Array.from(dependencies).map(toEntryPattern);
|
|
@@ -71,10 +73,12 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
71
73
|
const dependencies = new Set();
|
|
72
74
|
const configs = await getConfigs(localConfig);
|
|
73
75
|
for (const cfg of configs) {
|
|
74
|
-
findConfigDependencies(cfg, options)
|
|
76
|
+
for (const dependency of findConfigDependencies(cfg, options))
|
|
77
|
+
dependencies.add(dependency);
|
|
75
78
|
const entry = cfg.build?.lib?.entry ?? [];
|
|
76
79
|
const deps = (typeof entry === 'string' ? [entry] : Object.values(entry)).map(specifier => resolveEntry(options, specifier));
|
|
77
|
-
|
|
80
|
+
for (const dependency of deps)
|
|
81
|
+
dependencies.add(dependency);
|
|
78
82
|
}
|
|
79
83
|
return Array.from(dependencies);
|
|
80
84
|
};
|
|
@@ -20,7 +20,8 @@ const resolveConfig = async (config, options) => {
|
|
|
20
20
|
config: modifiedConfig ?? baseConfig,
|
|
21
21
|
cwd,
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
for (const dependency of dependencies)
|
|
24
|
+
deps.push(dependency);
|
|
24
25
|
}
|
|
25
26
|
if (!isProduction &&
|
|
26
27
|
manifest.scripts &&
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
2
|
export type VueConfig = {
|
|
3
|
-
configureWebpack?: Configuration | ((config: Configuration) => Configuration |
|
|
3
|
+
configureWebpack?: Configuration | ((config: Configuration) => Configuration | undefined);
|
|
4
4
|
};
|
|
5
5
|
export type { Configuration as WebpackConfiguration };
|
|
@@ -62,7 +62,7 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
62
62
|
else if (Array.isArray(options.entry))
|
|
63
63
|
entries.push(...options.entry);
|
|
64
64
|
else if (typeof options.entry === 'object') {
|
|
65
|
-
Object.values(options.entry)
|
|
65
|
+
for (const entry of Object.values(options.entry)) {
|
|
66
66
|
if (typeof entry === 'string')
|
|
67
67
|
entries.push(entry);
|
|
68
68
|
else if (Array.isArray(entry))
|
|
@@ -71,9 +71,9 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
71
71
|
entries.push(entry());
|
|
72
72
|
else if (entry && typeof entry === 'object' && 'filename' in entry)
|
|
73
73
|
entries.push(entry['filename']);
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
for (const entry of entries) {
|
|
77
77
|
if (!isInternal(entry)) {
|
|
78
78
|
dependencies.add(entry);
|
|
79
79
|
}
|
|
@@ -82,7 +82,7 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
82
82
|
const value = options.mode === 'development' ? toEntryPattern(item) : toProductionEntryPattern(item);
|
|
83
83
|
entryPatterns.add(value);
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return { dependencies, entryPatterns };
|
|
@@ -8,7 +8,8 @@ const resolveConfig = (config, options) => {
|
|
|
8
8
|
const dependencies = new Set();
|
|
9
9
|
for (const script of Object.values(config).flat()) {
|
|
10
10
|
const scripts = [script].flat();
|
|
11
|
-
getDependenciesFromScripts(scripts, options)
|
|
11
|
+
for (const identifier of getDependenciesFromScripts(scripts, options))
|
|
12
|
+
dependencies.add(identifier);
|
|
12
13
|
}
|
|
13
14
|
return ['yorkie', ...dependencies];
|
|
14
15
|
};
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Plugin } from './types/plugins.js';
|
|
2
|
-
declare const plugins: Record<"
|
|
2
|
+
declare const plugins: Record<"moonrepo" | "astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "vue" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", Plugin>;
|
|
3
3
|
export { plugins };
|
package/dist/plugins.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as originalPlugins from './plugins/index.js';
|
|
2
|
-
import parsedArgValues from './util/cli-arguments.js';
|
|
3
2
|
import { timerify } from './util/Performance.js';
|
|
3
|
+
import parsedArgValues from './util/cli-arguments.js';
|
|
4
4
|
const { performance: isEnabled = false } = parsedArgValues;
|
|
5
5
|
const plugins = (isEnabled ? {} : originalPlugins);
|
|
6
6
|
const methods = ['resolve', 'resolveConfig', 'resolveEntryPaths'];
|
|
7
7
|
if (isEnabled) {
|
|
8
8
|
for (const [name, plugin] of Object.entries(originalPlugins)) {
|
|
9
9
|
plugins[name] = plugin;
|
|
10
|
-
|
|
11
|
-
(
|
|
10
|
+
for (const method of methods) {
|
|
11
|
+
if (method in plugin) {
|
|
12
|
+
plugins[name][method] = timerify(plugin[method], `${method} (${plugin.title})`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
export { plugins };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { OwnershipEngine } from '@snyk/github-codeowners/dist/lib/ownership/index.js';
|
|
2
2
|
import picocolors from 'picocolors';
|
|
3
|
-
import {
|
|
4
|
-
import { getTitle,
|
|
3
|
+
import { relative, resolve, toRelative } from '../util/path.js';
|
|
4
|
+
import { getTitle, logIssueLine, logTitle } from './util.js';
|
|
5
5
|
const logIssueSet = (issues) => {
|
|
6
|
-
issues
|
|
7
|
-
.
|
|
8
|
-
|
|
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
9
|
};
|
|
10
10
|
const logIssueRecord = (issues) => {
|
|
11
11
|
const sortedByFilePath = issues.sort((a, b) => (a.owner < b.owner ? -1 : 1));
|
|
12
|
-
|
|
12
|
+
for (const { filePath, symbols, owner, parentSymbol } of sortedByFilePath) {
|
|
13
|
+
logIssueLine({ owner, filePath, symbols, parentSymbol });
|
|
14
|
+
}
|
|
13
15
|
};
|
|
14
16
|
export default ({ report, issues, isShowProgress, options }) => {
|
|
15
17
|
let opts = {};
|
|
@@ -37,7 +39,7 @@ export default ({ report, issues, isShowProgress, options }) => {
|
|
|
37
39
|
.map(toIssue)
|
|
38
40
|
.map(addOwner)
|
|
39
41
|
: reportType === 'duplicates'
|
|
40
|
-
? Object.values(issues[reportType]).
|
|
42
|
+
? Object.values(issues[reportType]).flatMap(Object.values).map(addOwner)
|
|
41
43
|
: Object.values(issues[reportType]).map(issues => {
|
|
42
44
|
const symbols = Object.values(issues);
|
|
43
45
|
return addOwner({ ...symbols[0], symbols });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTitle,
|
|
1
|
+
import { getTitle, logIssueLine, logIssueSet, logTitle } from './util.js';
|
|
2
2
|
const logIssueRecord = (issues) => {
|
|
3
3
|
const sortedByFilePath = issues.sort((a, b) => (a.filePath > b.filePath ? 1 : -1));
|
|
4
4
|
sortedByFilePath.forEach(logIssueLine);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("
|
|
3
|
-
compact: ({ report, issues, isShowProgress }: import("
|
|
4
|
-
codeowners: ({ report, issues, isShowProgress, options }: import("
|
|
5
|
-
json: ({ report, issues, options }: import("
|
|
6
|
-
markdown: ({ report, issues }: import("
|
|
2
|
+
symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
3
|
+
compact: ({ report, issues, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
4
|
+
codeowners: ({ report, issues, isShowProgress, options }: import("../index.js").ReporterOptions) => void;
|
|
5
|
+
json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
6
|
+
markdown: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
package/dist/reporters/json.js
CHANGED
|
@@ -40,7 +40,7 @@ export default async ({ report, issues, options }) => {
|
|
|
40
40
|
if (type === 'files') {
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
flatten(issues[type])
|
|
43
|
+
for (const issue of flatten(issues[type])) {
|
|
44
44
|
const { filePath, symbol, symbols, parentSymbol } = issue;
|
|
45
45
|
json[filePath] = json[filePath] ?? initRow(filePath);
|
|
46
46
|
if (type === 'duplicates') {
|
|
@@ -61,7 +61,7 @@ export default async ({ report, issues, options }) => {
|
|
|
61
61
|
json[filePath][type]?.push({ name: symbol });
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -70,5 +70,5 @@ export default async ({ report, issues, options }) => {
|
|
|
70
70
|
issues: Object.values(json),
|
|
71
71
|
});
|
|
72
72
|
process.stdout._handle?.setBlocking?.(true);
|
|
73
|
-
process.stdout.write(output
|
|
73
|
+
process.stdout.write(`${output}\n`);
|
|
74
74
|
};
|
|
@@ -3,7 +3,7 @@ import { getTitle } from './util.js';
|
|
|
3
3
|
export default ({ report, issues }) => {
|
|
4
4
|
console.log('# Knip report\n');
|
|
5
5
|
const getFilePath = (issue) => {
|
|
6
|
-
if (!issue.line
|
|
6
|
+
if (!(issue.line && issue.col))
|
|
7
7
|
return relative(issue.filePath);
|
|
8
8
|
return `${relative(issue.filePath)}:${issue.line}:${issue.col}`;
|
|
9
9
|
};
|
|
@@ -15,23 +15,23 @@ export default ({ report, issues }) => {
|
|
|
15
15
|
const isSet = issues[reportType] instanceof Set;
|
|
16
16
|
const issuesForType = isSet
|
|
17
17
|
? Array.from(issues[reportType])
|
|
18
|
-
: Object.values(issues[reportType]).
|
|
18
|
+
: Object.values(issues[reportType]).flatMap(Object.values);
|
|
19
19
|
if (issuesForType.length > 0) {
|
|
20
20
|
console.log(`## ${title} (${issuesForType.length})\n`);
|
|
21
21
|
if (isSet) {
|
|
22
|
-
issuesForType.sort()
|
|
22
|
+
for (const issue of issuesForType.sort()) {
|
|
23
23
|
console.log(`* ${toRelative(issue)}`);
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
const longestSymbol = issuesForType.sort(sortLongestSymbol)[0].symbol.length;
|
|
28
28
|
const sortedByFilePath = issuesForType.sort(sortLongestFilePath);
|
|
29
29
|
const longestFilePath = getFilePath(sortedByFilePath[0]).length;
|
|
30
|
-
console.log(`| ${
|
|
30
|
+
console.log(`| ${'Name'.padEnd(longestSymbol)} | ${'Location'.padEnd(longestFilePath)} | Severity |`);
|
|
31
31
|
console.log(`| :${'-'.repeat(longestSymbol - 1)} | :${'-'.repeat(longestFilePath - 1)} | :------- |`);
|
|
32
|
-
|
|
32
|
+
for (const issue of sortedByFilePath) {
|
|
33
33
|
console.log(`| ${issue.symbol.padEnd(longestSymbol)} | ${getFilePath(issue).padEnd(longestFilePath)} | ${(issue.severity ?? '').padEnd(8)} |`);
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
console.log('');
|
|
37
37
|
}
|
|
@@ -2,12 +2,12 @@ import EasyTable from 'easy-table';
|
|
|
2
2
|
import picocolors from 'picocolors';
|
|
3
3
|
import { ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
4
4
|
import { relative } from '../util/path.js';
|
|
5
|
-
import { getTitle,
|
|
5
|
+
import { getTitle, identity, logIssueSet, logTitle } from './util.js';
|
|
6
6
|
const TRUNCATE_WIDTH = 40;
|
|
7
|
-
const truncate = (text) => (text.length > TRUNCATE_WIDTH ? text.slice(0, TRUNCATE_WIDTH - 3)
|
|
7
|
+
const truncate = (text) => (text.length > TRUNCATE_WIDTH ? `${text.slice(0, TRUNCATE_WIDTH - 3)}...` : text);
|
|
8
8
|
const logIssueRecord = (issues) => {
|
|
9
9
|
const table = new EasyTable();
|
|
10
|
-
|
|
10
|
+
for (const issue of issues) {
|
|
11
11
|
const print = issue.severity === 'warn' ? picocolors.gray : identity;
|
|
12
12
|
table.cell('symbol', print(issue.symbols ? truncate(issue.symbols.map(s => s.symbol).join(', ')) : issue.symbol));
|
|
13
13
|
issue.parentSymbol && table.cell('parentSymbol', print(issue.parentSymbol));
|
|
@@ -15,7 +15,7 @@ const logIssueRecord = (issues) => {
|
|
|
15
15
|
const filePath = `${relative(issue.filePath)}${issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`}`;
|
|
16
16
|
table.cell('filePath', print(filePath));
|
|
17
17
|
table.newRow();
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
|
|
20
20
|
};
|
|
21
21
|
export default ({ report, issues, configurationHints, noConfigHints, isShowProgress }) => {
|
|
@@ -27,7 +27,7 @@ export default ({ report, issues, configurationHints, noConfigHints, isShowProgr
|
|
|
27
27
|
const isSet = issues[reportType] instanceof Set;
|
|
28
28
|
const issuesForType = isSet
|
|
29
29
|
? Array.from(issues[reportType])
|
|
30
|
-
: Object.values(issues[reportType]).
|
|
30
|
+
: Object.values(issues[reportType]).flatMap(Object.values);
|
|
31
31
|
if (issuesForType.length > 0) {
|
|
32
32
|
title && logTitle(title, issuesForType.length);
|
|
33
33
|
if (isSet) {
|
|
@@ -42,12 +42,12 @@ export default ({ report, issues, configurationHints, noConfigHints, isShowProgr
|
|
|
42
42
|
}
|
|
43
43
|
if (!noConfigHints && configurationHints.size > 0) {
|
|
44
44
|
logTitle('Configuration issues', configurationHints.size);
|
|
45
|
-
|
|
45
|
+
for (const hint of configurationHints) {
|
|
46
46
|
const { type, workspaceName, identifier } = hint;
|
|
47
47
|
const message = `Unused item in ${type}`;
|
|
48
|
-
const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` :
|
|
48
|
+
const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : '';
|
|
49
49
|
console.warn(picocolors.gray(`${message}${workspace}:`), identifier);
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
}
|
|
52
52
|
if (totalIssues === 0 && isShowProgress) {
|
|
53
53
|
console.log('✂️ Excellent, Knip found no issues.');
|
package/dist/reporters/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import picocolors from 'picocolors';
|
|
2
2
|
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { relative, toRelative } from '../util/path.js';
|
|
4
4
|
export const identity = (text) => text;
|
|
5
5
|
export const getTitle = (reportType) => {
|
|
6
6
|
return ISSUE_TYPE_TITLE[reportType];
|
|
@@ -13,7 +13,8 @@ export const logIssueLine = ({ owner, filePath, symbols, parentSymbol, severity
|
|
|
13
13
|
console.log(`${owner ? `${picocolors.cyan(owner)} ` : ''}${print(`${relative(filePath)}${symbol}${parent}`)}`);
|
|
14
14
|
};
|
|
15
15
|
export const logIssueSet = (issues) => {
|
|
16
|
-
|
|
16
|
+
for (const value of issues.sort())
|
|
17
|
+
console.log(toRelative(value));
|
|
17
18
|
};
|
|
18
19
|
export const convert = (issue) => ({
|
|
19
20
|
name: issue.symbol,
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
|
|
3
|
-
import
|
|
4
|
-
import type
|
|
5
|
-
import type {
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
|
|
3
|
+
import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
|
|
4
|
+
import type * as Plugins from '../plugins/index.js';
|
|
5
|
+
import type { IssueType, Rules } from './issues.js';
|
|
6
6
|
export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
|
|
7
7
|
export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
|
|
8
8
|
type NormalizedGlob = string[];
|
package/dist/types/config.js
CHANGED
package/dist/types/exports.d.ts
CHANGED
package/dist/types/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/types/imports.d.ts
CHANGED
package/dist/types/imports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
|
|
3
3
|
interface SourceFileManagerOptions {
|
|
4
4
|
isSkipLibs: boolean;
|
|
5
5
|
compilers: [SyncCompilers, AsyncCompilers];
|
|
@@ -55,7 +55,7 @@ export function findAncestor(node, callback) {
|
|
|
55
55
|
if (result === 'STOP') {
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
if (result) {
|
|
59
59
|
return node;
|
|
60
60
|
}
|
|
61
61
|
node = node.parent;
|
|
@@ -71,7 +71,7 @@ export function findDescendants(node, callback) {
|
|
|
71
71
|
if (result === 'STOP') {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
if (result) {
|
|
75
75
|
results.push(node);
|
|
76
76
|
}
|
|
77
77
|
ts.forEachChild(node, visit);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
|
|
2
3
|
import { SourceFileManager } from './SourceFileManager.js';
|
|
3
|
-
import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
|
|
4
4
|
type CreateHostsOptions = {
|
|
5
5
|
cwd: string;
|
|
6
6
|
compilerOptions: ts.CompilerOptions;
|