@ljharb/unused-files 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +1 -1
- package/bin.mjs +7 -7
- package/help.txt +1 -1
- package/index.mjs +62 -7
- package/package.json +12 -11
- package/pargs.d.ts +0 -5
- package/pargs.mjs +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v0.2.1](https://github.com/ljharb/unused-files/compare/v0.2.0...v0.2.1) - 2026-01-06
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [Fix] fix knip compatibility [`44f00fa`](https://github.com/ljharb/unused-files/commit/44f00fa23cd17f9f05a338adcf4d92850a9a96d0)
|
|
13
|
+
- [Fix] fix knip compatibility with v5.63.1 [`d89fd7c`](https://github.com/ljharb/unused-files/commit/d89fd7c0623d0e200ffaa8150a9eff1e6e899818)
|
|
14
|
+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `c8`, `npmignore`, `playwright` [`5d95ceb`](https://github.com/ljharb/unused-files/commit/5d95cebc62f19fd370f00ad8b6a97ff52423e8f6)
|
|
15
|
+
- [Fix] fix knip compatibility with v5.69.0 [`abf7545`](https://github.com/ljharb/unused-files/commit/abf7545b69a8115bea5cc2ed3d6abfb7ab5169d1)
|
|
16
|
+
- [Fix] fix knip compatibility with v5.77.0 [`d581150`](https://github.com/ljharb/unused-files/commit/d581150b4c253d06d160911c8291463bf946f965)
|
|
17
|
+
- [Deps] update `pargs` [`a421e84`](https://github.com/ljharb/unused-files/commit/a421e84f827b88dbd19e5c49db90b1ff97b435c4)
|
|
18
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge [`9688bb9`](https://github.com/ljharb/unused-files/commit/9688bb98927de695bc69aca58763604e9c2bd2b0)
|
|
19
|
+
|
|
20
|
+
## [v0.2.0](https://github.com/ljharb/unused-files/compare/v0.1.2...v0.2.0) - 2025-10-31
|
|
21
|
+
|
|
22
|
+
### Commits
|
|
23
|
+
|
|
24
|
+
- [Refactor] use `pargs` package [`4742989`](https://github.com/ljharb/unused-files/commit/474298940a86f4a60e99d860d12f217d9f19dba8)
|
|
25
|
+
- [Fix] handle new API requirements inside knip [`91b7795`](https://github.com/ljharb/unused-files/commit/91b77959a27407a5d8ec23f77b8f829046f0ed9b)
|
|
26
|
+
- [Breaking] update `engines.node` [`2945c2f`](https://github.com/ljharb/unused-files/commit/2945c2fabc93fcdcc0896e1b19fba4f80278edc2)
|
|
27
|
+
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `playwright` [`ddc5f59`](https://github.com/ljharb/unused-files/commit/ddc5f5962db7c642698d3b05e88034aa7b676934)
|
|
28
|
+
- [Dev Deps] update `@types/micromatch` [`aaef372`](https://github.com/ljharb/unused-files/commit/aaef3722dddb3fc4b1c250ba459e798d5e32889b)
|
|
29
|
+
- [Dev Deps] update `playwright` [`fdc1376`](https://github.com/ljharb/unused-files/commit/fdc137615f2d2a6915fe23ef9a518e60c2811367)
|
|
30
|
+
- [Dev Deps] update `playwright` [`dc73725`](https://github.com/ljharb/unused-files/commit/dc73725fc08fef10edb3d909ecf11fd962fd85c8)
|
|
31
|
+
- [types] ignore incomplete knip types [`7a05e3e`](https://github.com/ljharb/unused-files/commit/7a05e3e1d74e90dfff7f72c35fef8b667c5e5b26)
|
|
32
|
+
|
|
8
33
|
## [v0.1.2](https://github.com/ljharb/unused-files/compare/v0.1.1...v0.1.2) - 2025-05-29
|
|
9
34
|
|
|
10
35
|
### Commits
|
package/README.md
CHANGED
|
@@ -55,5 +55,5 @@ MIT
|
|
|
55
55
|
[downloads-url]: https://npm-stat.com/charts.html?package=@ljharb/unused-files
|
|
56
56
|
[codecov-image]: https://codecov.io/gh/ljharb/unused-files/branch/main/graphs/badge.svg
|
|
57
57
|
[codecov-url]: https://app.codecov.io/gh/ljharb/unused-files/
|
|
58
|
-
[actions-image]: https://img.shields.io/
|
|
58
|
+
[actions-image]: https://img.shields.io/github/check-runs/ljharb/unused-files/main
|
|
59
59
|
[actions-url]: https://github.com/ljharb/unused-files/actions
|
package/bin.mjs
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { join } from 'path';
|
|
3
|
+
import pargs from 'pargs';
|
|
5
4
|
|
|
6
5
|
import unusedFiles from './index.mjs';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { values: { json, ignorePattern } } = pargs(help, import.meta.filename, {
|
|
7
|
+
const {
|
|
8
|
+
help,
|
|
9
|
+
values: { json, ignorePattern },
|
|
10
|
+
} = await pargs(import.meta.filename, {
|
|
13
11
|
options: {
|
|
14
12
|
ignorePattern: {
|
|
15
13
|
default: undefined,
|
|
@@ -23,6 +21,8 @@ const { values: { json, ignorePattern } } = pargs(help, import.meta.filename, {
|
|
|
23
21
|
},
|
|
24
22
|
});
|
|
25
23
|
|
|
24
|
+
await help();
|
|
25
|
+
|
|
26
26
|
// eslint-disable-next-line no-extra-parens
|
|
27
27
|
const files = await unusedFiles(process.cwd(), /** @type {string[] | undefined} */ (ignorePattern));
|
|
28
28
|
|
package/help.txt
CHANGED
package/index.mjs
CHANGED
|
@@ -15,33 +15,88 @@ export default async function unusedFiles(
|
|
|
15
15
|
let files;
|
|
16
16
|
try {
|
|
17
17
|
process.argv = origArgv.slice(0, 2);
|
|
18
|
+
// @ts-expect-error knip doesn't have main in its types
|
|
18
19
|
const { main: knip } = await import('knip');
|
|
19
20
|
|
|
20
21
|
({ issues: { files } } = await knip({
|
|
21
22
|
cacheLocation: '',
|
|
23
|
+
catalog: {
|
|
24
|
+
filePath: '',
|
|
25
|
+
},
|
|
26
|
+
config: undefined,
|
|
27
|
+
configFilePath: undefined,
|
|
22
28
|
cwd,
|
|
23
|
-
|
|
29
|
+
dependencies: true,
|
|
30
|
+
experimentalTags: [[], []],
|
|
31
|
+
exports: true,
|
|
32
|
+
files: true,
|
|
24
33
|
fixTypes: [],
|
|
25
34
|
gitignore: true,
|
|
26
|
-
includedIssueTypes:
|
|
35
|
+
includedIssueTypes: {
|
|
36
|
+
_files: true,
|
|
37
|
+
binaries: true,
|
|
38
|
+
classMembers: true,
|
|
39
|
+
dependencies: true,
|
|
40
|
+
devDependencies: true,
|
|
41
|
+
duplicates: true,
|
|
42
|
+
enumMembers: true,
|
|
43
|
+
exports: true,
|
|
44
|
+
files: true,
|
|
45
|
+
nsExports: true,
|
|
46
|
+
nsTypes: true,
|
|
47
|
+
optionalPeerDependencies: true,
|
|
48
|
+
types: true,
|
|
49
|
+
unlisted: true,
|
|
50
|
+
unresolved: true,
|
|
51
|
+
},
|
|
27
52
|
isCache: false,
|
|
28
53
|
isDebug: false,
|
|
29
|
-
|
|
30
|
-
isExportsShorthand: false,
|
|
31
|
-
isFilesShorthand: false,
|
|
54
|
+
isDisableConfigHints: true,
|
|
32
55
|
isFix: false,
|
|
56
|
+
isFixDependencies: false,
|
|
57
|
+
isFixFiles: false,
|
|
58
|
+
isFixUnusedExports: false,
|
|
59
|
+
isFixUnusedTypes: false,
|
|
33
60
|
isFormat: false,
|
|
34
61
|
isIncludeEntryExports: true,
|
|
35
|
-
isIncludeLibs: true,
|
|
36
62
|
isIsolateWorkspaces: false,
|
|
37
63
|
isProduction: true,
|
|
38
|
-
|
|
64
|
+
isReportClassMembers: true,
|
|
65
|
+
isReportDependencies: true,
|
|
66
|
+
isReportExports: true,
|
|
67
|
+
isReportFiles: true,
|
|
68
|
+
isReportTypes: true,
|
|
69
|
+
isReportValues: true,
|
|
39
70
|
isShowProgress: false,
|
|
71
|
+
isSkipLibs: false,
|
|
40
72
|
isStrict: true,
|
|
73
|
+
isTrace: false,
|
|
74
|
+
isTreatConfigHintsAsErrors: false,
|
|
41
75
|
isWatch: false,
|
|
76
|
+
parsedConfig: {},
|
|
77
|
+
rules: {
|
|
78
|
+
_files: 'error',
|
|
79
|
+
binaries: 'error',
|
|
80
|
+
classMembers: 'error',
|
|
81
|
+
dependencies: 'error',
|
|
82
|
+
devDependencies: 'error',
|
|
83
|
+
duplicates: 'error',
|
|
84
|
+
enumMembers: 'error',
|
|
85
|
+
exports: 'error',
|
|
86
|
+
files: 'error',
|
|
87
|
+
nsExports: 'error',
|
|
88
|
+
nsTypes: 'error',
|
|
89
|
+
optionalPeerDependencies: 'error',
|
|
90
|
+
types: 'error',
|
|
91
|
+
unlisted: 'error',
|
|
92
|
+
unresolved: 'error',
|
|
93
|
+
},
|
|
42
94
|
tags: [[], []],
|
|
95
|
+
traceExport: undefined,
|
|
96
|
+
traceFile: undefined,
|
|
43
97
|
tsConfigFile: '',
|
|
44
98
|
workspace: undefined,
|
|
99
|
+
workspaces: [],
|
|
45
100
|
}));
|
|
46
101
|
} finally {
|
|
47
102
|
process.argv = origArgv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ljharb/unused-files",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "List unused files in your package.",
|
|
5
5
|
"bin": "./bin.mjs",
|
|
6
6
|
"main": false,
|
|
@@ -37,33 +37,34 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/ljharb/unused-files#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"knip": "
|
|
40
|
+
"knip": "~5.78.0",
|
|
41
41
|
"micromatch": "^4.0.8",
|
|
42
|
-
"object.groupby": "^1.0.3"
|
|
42
|
+
"object.groupby": "^1.0.3",
|
|
43
|
+
"pargs": "^1.2.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
46
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
46
47
|
"@jest/types": "^29.6.3",
|
|
47
|
-
"@ljharb/eslint-config": "^21.
|
|
48
|
+
"@ljharb/eslint-config": "^21.4.0",
|
|
48
49
|
"@ljharb/tsconfig": "^0.3.2",
|
|
49
|
-
"@types/micromatch": "^4.0.
|
|
50
|
+
"@types/micromatch": "^4.0.10",
|
|
50
51
|
"@types/minimist": "^1.2.5",
|
|
51
52
|
"@types/object.groupby": "^1.0.4",
|
|
52
53
|
"@types/tape": "^5.8.1",
|
|
53
54
|
"@types/webpack": "^5.28.5",
|
|
54
55
|
"auto-changelog": "^2.5.0",
|
|
55
|
-
"c8": "^
|
|
56
|
+
"c8": "^10.1.3",
|
|
56
57
|
"encoding": "^0.1.13",
|
|
57
|
-
"eslint": "
|
|
58
|
+
"eslint": "^8.57.1",
|
|
58
59
|
"in-publish": "^2.0.1",
|
|
59
|
-
"npmignore": "^0.3.
|
|
60
|
-
"playwright": "^1.
|
|
60
|
+
"npmignore": "^0.3.5",
|
|
61
|
+
"playwright": "^1.57.0",
|
|
61
62
|
"safe-publish-latest": "^2.0.0",
|
|
62
63
|
"tape": "^5.9.0",
|
|
63
64
|
"typescript": "next"
|
|
64
65
|
},
|
|
65
66
|
"engines": {
|
|
66
|
-
"node": "^20.
|
|
67
|
+
"node": "^22.20 || ^24.10 || >= 25"
|
|
67
68
|
},
|
|
68
69
|
"auto-changelog": {
|
|
69
70
|
"output": "CHANGELOG.md",
|
package/pargs.d.ts
DELETED
package/pargs.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from 'util';
|
|
2
|
-
import { realpathSync } from 'fs';
|
|
3
|
-
|
|
4
|
-
import groupByPolyfill from 'object.groupby/polyfill';
|
|
5
|
-
|
|
6
|
-
const groupBy = groupByPolyfill();
|
|
7
|
-
|
|
8
|
-
/** @typedef {import('util').ParseArgsConfig} ParseArgsConfig */
|
|
9
|
-
|
|
10
|
-
/** @typedef {(Error | TypeError) & { code: 'ERR_PARSE_ARGS_UNKNOWN_OPTION' | 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE' | 'ERR_INVALID_ARG_TYPE' | 'ERR_INVALID_ARG_VALUE' | 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL'}} ParseArgsError */
|
|
11
|
-
|
|
12
|
-
/** @type {(e: unknown) => e is ParseArgsError} */
|
|
13
|
-
function isParseArgsError(e) {
|
|
14
|
-
return !!e
|
|
15
|
-
&& typeof e === 'object'
|
|
16
|
-
&& 'code' in e
|
|
17
|
-
&& (
|
|
18
|
-
e.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION'
|
|
19
|
-
|| e.code === 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE'
|
|
20
|
-
|| e.code === 'ERR_INVALID_ARG_TYPE'
|
|
21
|
-
|| e.code === 'ERR_INVALID_ARG_VALUE'
|
|
22
|
-
|| e.code === 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL'
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @type {(helpText: string, entrypointPath: string, obj: Exclude<ParseArgsConfig, 'args'>) => ReturnType<typeof parseArgs>} */
|
|
27
|
-
export default function pargs(helpText, entrypointPath, obj) {
|
|
28
|
-
const argv = process.argv.flatMap((arg) => {
|
|
29
|
-
try {
|
|
30
|
-
const realpathedArg = realpathSync(arg);
|
|
31
|
-
if (
|
|
32
|
-
realpathedArg === process.execPath
|
|
33
|
-
|| realpathedArg === entrypointPath
|
|
34
|
-
) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
} catch (e) { /**/ }
|
|
38
|
-
return arg;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if ('help' in obj) {
|
|
42
|
-
throw new TypeError('The "help" option is reserved');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const bools = obj.options ? Object.entries(obj.options).filter(([key, { type }]) => type === 'boolean' && key !== 'help') : [];
|
|
46
|
-
const inverseBools = Object.fromEntries(bools.map(([key, value]) => [
|
|
47
|
-
`no-${key}`,
|
|
48
|
-
{ default: !value.default, type: 'boolean' },
|
|
49
|
-
]));
|
|
50
|
-
/** @type {ParseArgsConfig & { tokens: true }} */
|
|
51
|
-
const newObj = {
|
|
52
|
-
args: argv,
|
|
53
|
-
...obj,
|
|
54
|
-
options: {
|
|
55
|
-
...obj.options,
|
|
56
|
-
...inverseBools,
|
|
57
|
-
help: {
|
|
58
|
-
default: false,
|
|
59
|
-
type: 'boolean',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
tokens: true,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const { tokens, ...results } = parseArgs(newObj);
|
|
67
|
-
|
|
68
|
-
if ('help' in results.values && results.values.help) {
|
|
69
|
-
console.log(helpText);
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** @typedef {Extract<typeof tokens[number], { kind: 'option' }>} OptionToken */
|
|
74
|
-
const optionTokens = tokens.filter(/** @type {(token: typeof tokens[number]) => token is OptionToken} */ (token) => token.kind === 'option');
|
|
75
|
-
const passedArgs = new Set(optionTokens.map(({ name }) => name));
|
|
76
|
-
const groups = groupBy(passedArgs, (x) => x.replace(/^no-/, ''));
|
|
77
|
-
bools.forEach(([key]) => {
|
|
78
|
-
if ((groups[key]?.length ?? 0) > 1) {
|
|
79
|
-
console.log(helpText);
|
|
80
|
-
console.error(`Error: Arguments --${key} and --no-${key} are mutually exclusive`);
|
|
81
|
-
process.exit(2);
|
|
82
|
-
}
|
|
83
|
-
if (passedArgs.has(`no-${key}`)) {
|
|
84
|
-
// @ts-expect-error
|
|
85
|
-
results.values[key] = !results.values[`no-${key}`];
|
|
86
|
-
}
|
|
87
|
-
// @ts-expect-error
|
|
88
|
-
delete results.values[`no-${key}`];
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return obj.tokens ? { ...results, tokens } : results;
|
|
92
|
-
} catch (e) {
|
|
93
|
-
if (isParseArgsError(e)) {
|
|
94
|
-
console.log(helpText);
|
|
95
|
-
console.error(`Error: ${e.message}`);
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
98
|
-
throw e;
|
|
99
|
-
}
|
|
100
|
-
}
|