knip 2.8.0 → 2.8.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/README.md +7 -8
- package/dist/DependencyDeputy.js +1 -1
- package/dist/cli.js +10 -2
- package/dist/constants.js +1 -1
- package/dist/reporters/index.d.ts +1 -1
- package/dist/reporters/symbols.d.ts +1 -1
- package/dist/reporters/symbols.js +2 -2
- package/dist/types/issues.d.ts +1 -0
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,6 +136,7 @@ Using workspaces in a monorepo? Please see [workspaces][1] for more details abou
|
|
|
136
136
|
-n, --no-progress Don't show dynamic progress updates
|
|
137
137
|
--reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
|
|
138
138
|
--reporter-options Pass extra options to the reporter (as JSON string, see example)
|
|
139
|
+
--no-config-hints Suppress configuration hints
|
|
139
140
|
--no-exit-code Always exit with code zero (0)
|
|
140
141
|
--max-issues Maximum number of issues before non-zero exit code (default: 0)
|
|
141
142
|
-d, --debug Show debug output
|
|
@@ -171,17 +172,18 @@ This example shows more output related to unused and unlisted dependencies:
|
|
|
171
172
|
|
|
172
173
|
The report contains the following types of issues:
|
|
173
174
|
|
|
174
|
-
|
|
|
175
|
+
| Key | Title | Description |
|
|
175
176
|
| :------------- | :---------------------------------- | :---------------------------------------------------- |
|
|
176
177
|
| `files` | Unused files | unable to find references to this file |
|
|
177
178
|
| `dependencies` | Unused dependencies | unable to find references to this dependency |
|
|
178
179
|
| `dependencies` | Unused devDependencies | unable to find references to this dependency |
|
|
179
|
-
| `unlisted` | Unlisted dependencies | used dependencies not listed in package.json
|
|
180
|
+
| `unlisted` | Unlisted dependencies | used dependencies not listed in package.json |
|
|
181
|
+
| `binaries` | Unlisted binaries | binaries from dependencies not in package.json |
|
|
180
182
|
| `unresolved` | Unresolved imports | unable to resolve this (import) specifier |
|
|
181
183
|
| `exports` | Unused exports | unable to find references to this export |
|
|
182
|
-
| `nsExports` | Unused exports in namespaces | unable to find direct references to this export _(
|
|
184
|
+
| `nsExports` | Unused exports in namespaces | unable to find direct references to this export _(1)_ |
|
|
183
185
|
| `types` | Unused exported types | unable to find references to this exported type |
|
|
184
|
-
| `nsTypes` | Unused exported types in namespaces | unable to find direct references to this export _(
|
|
186
|
+
| `nsTypes` | Unused exported types in namespaces | unable to find direct references to this export _(1)_ |
|
|
185
187
|
| `enumMembers` | Unused exported enum members | unable to find references to this enum member |
|
|
186
188
|
| `classMembers` | Unused exported class members | unable to find references to this class member |
|
|
187
189
|
| `duplicates` | Duplicate exports | the same thing is exported more than once |
|
|
@@ -190,10 +192,7 @@ When an issue type has zero issues, it is not shown.
|
|
|
190
192
|
|
|
191
193
|
Getting too many reported issues and false positives? Read more about [handling issues][8].
|
|
192
194
|
|
|
193
|
-
_(1)_
|
|
194
|
-
often equals the package name, but not always (e.g. `tsc` of `typescript` or `webpack` from `webpack-cli`).
|
|
195
|
-
|
|
196
|
-
_(2)_ The variable or type is not referenced directly and has become a member of a namespace. Knip can't find a
|
|
195
|
+
_(1)_ The variable or type is not referenced directly and has become a member of a namespace. Knip can't find a
|
|
197
196
|
reference to it, so you can _probably_ remove it.
|
|
198
197
|
|
|
199
198
|
## Output
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -166,7 +166,7 @@ export class DependencyDeputy {
|
|
|
166
166
|
.filter(isNotIgnoredBinary)
|
|
167
167
|
.filter(isNotReferencedDependency)
|
|
168
168
|
.forEach(symbol => devDependencyIssues.push({ type: 'devDependencies', filePath: manifestPath, symbol }));
|
|
169
|
-
const isReferencedDep = (name) => ![...pd, ...dd].includes(name) && referencedDependencies?.has(name);
|
|
169
|
+
const isReferencedDep = (name) => !([...pd, ...dd].includes(name) && referencedDependencies?.has(name));
|
|
170
170
|
const isReferencedBin = (name) => !installedBinaries?.has(name) && referencedBinaries?.has(name);
|
|
171
171
|
ignoreDependencies
|
|
172
172
|
.filter(packageName => IGNORED_DEPENDENCIES.includes(packageName) || !isReferencedDep(packageName))
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import { cwd, resolve } from './util/path.js';
|
|
|
9
9
|
import { Performance } from './util/Performance.js';
|
|
10
10
|
import { version } from './version.js';
|
|
11
11
|
import { main } from './index.js';
|
|
12
|
-
const { debug: isDebug = false, help: isHelp, 'max-issues': maxIssues = '0', 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = false, performance: isObservePerf = false, production: isProduction = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', strict: isStrict = false, tsConfig, version: isVersion, } = parsedArgValues;
|
|
12
|
+
const { debug: isDebug = false, help: isHelp, 'max-issues': maxIssues = '0', 'no-config-hints': noConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = false, performance: isObservePerf = false, production: isProduction = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', strict: isStrict = false, tsConfig, version: isVersion, } = parsedArgValues;
|
|
13
13
|
if (isHelp) {
|
|
14
14
|
console.log(helpText);
|
|
15
15
|
process.exit(0);
|
|
@@ -31,7 +31,15 @@ const run = async () => {
|
|
|
31
31
|
isProduction,
|
|
32
32
|
isShowProgress,
|
|
33
33
|
});
|
|
34
|
-
await printReport({
|
|
34
|
+
await printReport({
|
|
35
|
+
report,
|
|
36
|
+
issues,
|
|
37
|
+
configurationHints,
|
|
38
|
+
noConfigHints,
|
|
39
|
+
cwd,
|
|
40
|
+
isProduction,
|
|
41
|
+
options: reporterOptions,
|
|
42
|
+
});
|
|
35
43
|
const totalErrorCount = Object.keys(report)
|
|
36
44
|
.filter(reportGroup => report[reportGroup] && rules[reportGroup] === 'error')
|
|
37
45
|
.reduce((errorCount, reportGroup) => errorCount + counters[reportGroup], 0);
|
package/dist/constants.js
CHANGED
|
@@ -66,7 +66,7 @@ export const ISSUE_TYPE_TITLE = {
|
|
|
66
66
|
dependencies: 'Unused dependencies',
|
|
67
67
|
devDependencies: 'Unused devDependencies',
|
|
68
68
|
unlisted: 'Unlisted dependencies',
|
|
69
|
-
binaries: '
|
|
69
|
+
binaries: 'Unlisted binaries',
|
|
70
70
|
unresolved: 'Unresolved imports',
|
|
71
71
|
exports: 'Unused exports',
|
|
72
72
|
nsExports: 'Unused exports in namespaces',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
symbols: ({ report, issues, configurationHints }: import("../index.js").ReporterOptions) => void;
|
|
2
|
+
symbols: ({ report, issues, configurationHints, noConfigHints }: import("../index.js").ReporterOptions) => void;
|
|
3
3
|
compact: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
4
4
|
codeowners: ({ report, issues, options }: import("../index.js").ReporterOptions) => void;
|
|
5
5
|
json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReporterOptions } from '../types/issues.js';
|
|
2
|
-
declare const _default: ({ report, issues, configurationHints }: ReporterOptions) => void;
|
|
2
|
+
declare const _default: ({ report, issues, configurationHints, noConfigHints }: ReporterOptions) => void;
|
|
3
3
|
export default _default;
|
|
@@ -17,7 +17,7 @@ const logIssueRecord = (issues) => {
|
|
|
17
17
|
});
|
|
18
18
|
console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
|
|
19
19
|
};
|
|
20
|
-
export default ({ report, issues, configurationHints }) => {
|
|
20
|
+
export default ({ report, issues, configurationHints, noConfigHints }) => {
|
|
21
21
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
22
22
|
let totalIssues = 0;
|
|
23
23
|
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
@@ -39,7 +39,7 @@ export default ({ report, issues, configurationHints }) => {
|
|
|
39
39
|
totalIssues = totalIssues + issuesForType.length;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
if (configurationHints.size > 0) {
|
|
42
|
+
if (!noConfigHints && configurationHints.size > 0) {
|
|
43
43
|
logTitle('Configuration issues', configurationHints.size);
|
|
44
44
|
configurationHints.forEach(hint => {
|
|
45
45
|
const { type, workspaceName, identifier } = hint;
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n --workspace Analyze a single workspace (default: analyze all configured workspaces)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n -n, --no-progress Don't show dynamic progress updates\n --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --debug-file-filter Filter for files in debug output (regex as string)\n --performance Measure count and running time of expensive functions and display stats table\n --h, --help Print this help text\n --V, version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --debug --debug-file-filter '(specific|particular)-module'\n\nMore documentation and bug reports: https://github.com/webpro/knip";
|
|
1
|
+
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n --workspace Analyze a single workspace (default: analyze all configured workspaces)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n -n, --no-progress Don't show dynamic progress updates\n --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --debug-file-filter Filter for files in debug output (regex as string)\n --performance Measure count and running time of expensive functions and display stats table\n --h, --help Print this help text\n --V, version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --debug --debug-file-filter '(specific|particular)-module'\n\nMore documentation and bug reports: https://github.com/webpro/knip";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
config: string | undefined;
|
|
4
4
|
debug: boolean | undefined;
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
help: boolean | undefined;
|
|
10
10
|
include: string[] | undefined;
|
|
11
11
|
'max-issues': string | undefined;
|
|
12
|
+
'no-config-hints': boolean | undefined;
|
|
12
13
|
'no-exit-code': boolean | undefined;
|
|
13
14
|
'no-gitignore': boolean | undefined;
|
|
14
15
|
'no-progress': boolean | undefined;
|
|
@@ -17,6 +17,7 @@ Options:
|
|
|
17
17
|
-n, --no-progress Don't show dynamic progress updates
|
|
18
18
|
--reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
|
|
19
19
|
--reporter-options Pass extra options to the reporter (as JSON string, see example)
|
|
20
|
+
--no-config-hints Suppress configuration hints
|
|
20
21
|
--no-exit-code Always exit with code zero (0)
|
|
21
22
|
--max-issues Maximum number of issues before non-zero exit code (default: 0)
|
|
22
23
|
-d, --debug Show debug output
|
|
@@ -50,6 +51,7 @@ try {
|
|
|
50
51
|
help: { type: 'boolean', short: 'h' },
|
|
51
52
|
include: { type: 'string', multiple: true },
|
|
52
53
|
'max-issues': { type: 'string' },
|
|
54
|
+
'no-config-hints': { type: 'boolean' },
|
|
53
55
|
'no-exit-code': { type: 'boolean' },
|
|
54
56
|
'no-gitignore': { type: 'boolean' },
|
|
55
57
|
'no-progress': { type: 'boolean', short: 'n' },
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.8.
|
|
1
|
+
export declare const version = "2.8.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.8.
|
|
1
|
+
export const version = '2.8.2';
|
package/package.json
CHANGED