@ljharb/unused-files 0.1.1 → 0.2.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/CHANGELOG.md +24 -0
- package/bin.mjs +7 -7
- package/help.txt +1 -1
- package/index.mjs +64 -1
- package/package.json +19 -15
- package/jsr.json +0 -17
- package/pargs.d.ts +0 -5
- package/pargs.mjs +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ 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.0](https://github.com/ljharb/unused-files/compare/v0.1.2...v0.2.0) - 2025-10-31
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [Refactor] use `pargs` package [`4742989`](https://github.com/ljharb/unused-files/commit/474298940a86f4a60e99d860d12f217d9f19dba8)
|
|
13
|
+
- [Fix] handle new API requirements inside knip [`91b7795`](https://github.com/ljharb/unused-files/commit/91b77959a27407a5d8ec23f77b8f829046f0ed9b)
|
|
14
|
+
- [Breaking] update `engines.node` [`2945c2f`](https://github.com/ljharb/unused-files/commit/2945c2fabc93fcdcc0896e1b19fba4f80278edc2)
|
|
15
|
+
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `playwright` [`ddc5f59`](https://github.com/ljharb/unused-files/commit/ddc5f5962db7c642698d3b05e88034aa7b676934)
|
|
16
|
+
- [Dev Deps] update `@types/micromatch` [`aaef372`](https://github.com/ljharb/unused-files/commit/aaef3722dddb3fc4b1c250ba459e798d5e32889b)
|
|
17
|
+
- [Dev Deps] update `playwright` [`fdc1376`](https://github.com/ljharb/unused-files/commit/fdc137615f2d2a6915fe23ef9a518e60c2811367)
|
|
18
|
+
- [Dev Deps] update `playwright` [`dc73725`](https://github.com/ljharb/unused-files/commit/dc73725fc08fef10edb3d909ecf11fd962fd85c8)
|
|
19
|
+
- [types] ignore incomplete knip types [`7a05e3e`](https://github.com/ljharb/unused-files/commit/7a05e3e1d74e90dfff7f72c35fef8b667c5e5b26)
|
|
20
|
+
|
|
21
|
+
## [v0.1.2](https://github.com/ljharb/unused-files/compare/v0.1.1...v0.1.2) - 2025-05-29
|
|
22
|
+
|
|
23
|
+
### Commits
|
|
24
|
+
|
|
25
|
+
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/micromatch`, `@types/tape`, `auto-changelog`, `c8`, `playwright`, `tape` [`5ea2a9b`](https://github.com/ljharb/unused-files/commit/5ea2a9b60474033374e143a524b13dfeaeac3e9b)
|
|
26
|
+
- [jsr] v0.1.1 [`3c9b832`](https://github.com/ljharb/unused-files/commit/3c9b8326b3b3d203fea7467d80f2d39246f53c69)
|
|
27
|
+
- [Deps] update `knip`, `micromatch` [`ae13f9e`](https://github.com/ljharb/unused-files/commit/ae13f9e01ca10e7de50a11fb1af4c5a45a0c4ece)
|
|
28
|
+
- [Tests] replace `aud` with `npm audit` [`9cd7f44`](https://github.com/ljharb/unused-files/commit/9cd7f44ca05ae87d1be364113d732e897c622ddb)
|
|
29
|
+
- [Dev Deps] add missing peer dep [`d893df4`](https://github.com/ljharb/unused-files/commit/d893df4293dd7a73ba2cca2b0682e057a9b41416)
|
|
30
|
+
- [Dev Deps] add `playwright` because `knip` and TS needs it [`444359d`](https://github.com/ljharb/unused-files/commit/444359db8c78b4d15371c10aeacecebcc72c62f9)
|
|
31
|
+
|
|
8
32
|
## [v0.1.1](https://github.com/ljharb/unused-files/compare/v0.1.0...v0.1.1) - 2024-04-12
|
|
9
33
|
|
|
10
34
|
### Commits
|
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,20 +15,83 @@ 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({
|
|
22
|
+
cacheLocation: '',
|
|
23
|
+
config: undefined,
|
|
24
|
+
configFilePath: undefined,
|
|
21
25
|
cwd,
|
|
26
|
+
dependencies: true,
|
|
27
|
+
experimentalTags: [[], []],
|
|
28
|
+
exports: true,
|
|
29
|
+
files: false,
|
|
22
30
|
fixTypes: [],
|
|
23
31
|
gitignore: true,
|
|
32
|
+
includedIssueTypes: {
|
|
33
|
+
_files: true,
|
|
34
|
+
binaries: true,
|
|
35
|
+
classMembers: true,
|
|
36
|
+
dependencies: true,
|
|
37
|
+
devDependencies: true,
|
|
38
|
+
duplicates: true,
|
|
39
|
+
enumMembers: true,
|
|
40
|
+
exports: true,
|
|
41
|
+
files: true,
|
|
42
|
+
nsExports: true,
|
|
43
|
+
nsTypes: true,
|
|
44
|
+
optionalPeerDependencies: true,
|
|
45
|
+
types: true,
|
|
46
|
+
unlisted: true,
|
|
47
|
+
unresolved: true,
|
|
48
|
+
},
|
|
49
|
+
isCache: false,
|
|
50
|
+
isDebug: false,
|
|
51
|
+
isDisableConfigHints: false,
|
|
24
52
|
isFix: false,
|
|
53
|
+
isFixDependencies: false,
|
|
54
|
+
isFixFiles: false,
|
|
55
|
+
isFixUnusedExports: false,
|
|
56
|
+
isFixUnusedTypes: false,
|
|
57
|
+
isFormat: false,
|
|
25
58
|
isIncludeEntryExports: true,
|
|
26
|
-
isIncludeLibs: true,
|
|
27
59
|
isIsolateWorkspaces: false,
|
|
28
60
|
isProduction: true,
|
|
61
|
+
isReportClassMembers: false,
|
|
62
|
+
isReportDependencies: false,
|
|
63
|
+
isReportTypes: false,
|
|
64
|
+
isReportValues: false,
|
|
29
65
|
isShowProgress: false,
|
|
66
|
+
isSkipLibs: false,
|
|
30
67
|
isStrict: true,
|
|
68
|
+
isTrace: false,
|
|
69
|
+
isTreatConfigHintsAsErrors: false,
|
|
70
|
+
isWatch: false,
|
|
71
|
+
parsedConfig: {},
|
|
72
|
+
rules: {
|
|
73
|
+
_files: 'error',
|
|
74
|
+
binaries: 'error',
|
|
75
|
+
classMembers: 'error',
|
|
76
|
+
dependencies: 'error',
|
|
77
|
+
devDependencies: 'error',
|
|
78
|
+
duplicates: 'error',
|
|
79
|
+
enumMembers: 'error',
|
|
80
|
+
exports: 'error',
|
|
81
|
+
files: 'error',
|
|
82
|
+
nsExports: 'error',
|
|
83
|
+
nsTypes: 'error',
|
|
84
|
+
optionalPeerDependencies: 'error',
|
|
85
|
+
types: 'error',
|
|
86
|
+
unlisted: 'error',
|
|
87
|
+
unresolved: 'error',
|
|
88
|
+
},
|
|
31
89
|
tags: [[], []],
|
|
90
|
+
traceExport: undefined,
|
|
91
|
+
traceFile: undefined,
|
|
92
|
+
tsConfigFile: '',
|
|
93
|
+
workspace: undefined,
|
|
94
|
+
workspaces: [],
|
|
32
95
|
}));
|
|
33
96
|
} finally {
|
|
34
97
|
process.argv = origArgv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ljharb/unused-files",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "List unused files in your package.",
|
|
5
5
|
"bin": "./bin.mjs",
|
|
6
6
|
"main": false,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"pretest": "npm run lint",
|
|
18
18
|
"tests-only": "c8 tape 'test/**/*.mjs'",
|
|
19
19
|
"test": "npm run tests-only",
|
|
20
|
-
"posttest": "
|
|
20
|
+
"posttest": "npx npm@\">= 10.2\" audit --production",
|
|
21
21
|
"version": "auto-changelog && git add CHANGELOG.md",
|
|
22
22
|
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
23
23
|
},
|
|
@@ -37,31 +37,34 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/ljharb/unused-files#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"knip": "^5.
|
|
41
|
-
"micromatch": "^4.0.
|
|
42
|
-
"object.groupby": "^1.0.3"
|
|
40
|
+
"knip": "^5.59.1",
|
|
41
|
+
"micromatch": "^4.0.8",
|
|
42
|
+
"object.groupby": "^1.0.3",
|
|
43
|
+
"pargs": "^1.0.3"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@arethetypeswrong/cli": "^0.
|
|
46
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
46
47
|
"@jest/types": "^29.6.3",
|
|
47
|
-
"@ljharb/eslint-config": "^21.
|
|
48
|
-
"@ljharb/tsconfig": "^0.2
|
|
49
|
-
"@types/micromatch": "^4.0.
|
|
48
|
+
"@ljharb/eslint-config": "^21.2.0",
|
|
49
|
+
"@ljharb/tsconfig": "^0.3.2",
|
|
50
|
+
"@types/micromatch": "^4.0.10",
|
|
51
|
+
"@types/minimist": "^1.2.5",
|
|
50
52
|
"@types/object.groupby": "^1.0.4",
|
|
51
|
-
"@types/tape": "^5.
|
|
53
|
+
"@types/tape": "^5.8.1",
|
|
52
54
|
"@types/webpack": "^5.28.5",
|
|
53
|
-
"
|
|
54
|
-
"auto-changelog": "^2.4.0",
|
|
55
|
+
"auto-changelog": "^2.5.0",
|
|
55
56
|
"c8": "^9.1.0",
|
|
57
|
+
"encoding": "^0.1.13",
|
|
56
58
|
"eslint": "=8.8.0",
|
|
57
59
|
"in-publish": "^2.0.1",
|
|
58
60
|
"npmignore": "^0.3.1",
|
|
61
|
+
"playwright": "^1.55.0",
|
|
59
62
|
"safe-publish-latest": "^2.0.0",
|
|
60
|
-
"tape": "^5.
|
|
63
|
+
"tape": "^5.9.0",
|
|
61
64
|
"typescript": "next"
|
|
62
65
|
},
|
|
63
66
|
"engines": {
|
|
64
|
-
"node": "^20.
|
|
67
|
+
"node": "^22.20 || ^24.10 || >= 25"
|
|
65
68
|
},
|
|
66
69
|
"auto-changelog": {
|
|
67
70
|
"output": "CHANGELOG.md",
|
|
@@ -77,7 +80,8 @@
|
|
|
77
80
|
".github/workflows",
|
|
78
81
|
".eslintrc",
|
|
79
82
|
".nycrc",
|
|
80
|
-
"test"
|
|
83
|
+
"test",
|
|
84
|
+
"jsr.json"
|
|
81
85
|
]
|
|
82
86
|
}
|
|
83
87
|
}
|
package/jsr.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ljharb/unused-files",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"bin": "./bin.mjs",
|
|
5
|
-
"exports": {
|
|
6
|
-
"./package.json": "./package.json"
|
|
7
|
-
},
|
|
8
|
-
"publish": {
|
|
9
|
-
"include": ["**/*"],
|
|
10
|
-
"exclude": [
|
|
11
|
-
".github/workflows",
|
|
12
|
-
".eslintrc",
|
|
13
|
-
".nycrc",
|
|
14
|
-
"test"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
}
|
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
|
-
}
|