@ljharb/unused-files 0.2.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ 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.2](https://github.com/ljharb/unused-files/compare/v0.2.1...v0.2.2) - 2026-06-19
9
+
10
+ ### Commits
11
+
12
+ - [Deps] update `knip` [`74d46f6`](https://github.com/ljharb/unused-files/commit/74d46f68120012c6805e570a1d19b1a38baac1e3)
13
+ - [Deps] update `pargs` [`3ea5df5`](https://github.com/ljharb/unused-files/commit/3ea5df5689a15d3a0379662ae9661e9e958cd648)
14
+ - [actions] update workflows [`861b83f`](https://github.com/ljharb/unused-files/commit/861b83f0586d5c8890dcea69a3d2e6ca75455523)
15
+ - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `auto-changelog`, `playwright`, `tape` [`57cabf2`](https://github.com/ljharb/unused-files/commit/57cabf2f15b407c6e05b0975a3f1f734adbf7a6a)
16
+ - [Robustness] use `void` [`9dd847c`](https://github.com/ljharb/unused-files/commit/9dd847ce96cbf0b8bc7be4ce96a44a3edf21db48)
17
+ - [Deps] update `knip` [`9688566`](https://github.com/ljharb/unused-files/commit/96885666830af026502512897e5c7da2920b765c)
18
+ - [Deps] update `pargs` [`153f236`](https://github.com/ljharb/unused-files/commit/153f236102070d4656b030f9badaa4ec1865a103)
19
+
8
20
  ## [v0.2.1](https://github.com/ljharb/unused-files/compare/v0.2.0...v0.2.1) - 2026-01-06
9
21
 
10
22
  ### Commits
package/bin.mjs CHANGED
@@ -10,12 +10,21 @@ const {
10
10
  } = await pargs(import.meta.filename, {
11
11
  options: {
12
12
  ignorePattern: {
13
- default: undefined,
13
+ default: [
14
+ '.github/**',
15
+ 'coverage/**',
16
+ 'test/**',
17
+ 'tests/**',
18
+ 'example/**',
19
+ ],
20
+ description: 'Ignore files matching the given pattern',
14
21
  multiple: true,
22
+ placeholder: 'pattern',
15
23
  type: 'string',
16
24
  },
17
25
  json: {
18
26
  default: false,
27
+ description: 'Output the result as a JSON array',
19
28
  type: 'boolean',
20
29
  },
21
30
  },
package/index.mjs CHANGED
@@ -1,6 +1,19 @@
1
- import { relative } from 'path';
1
+ import { createRequire } from 'module';
2
+ import { dirname, join, relative } from 'path';
3
+ import { pathToFileURL } from 'url';
4
+
2
5
  import micromatch from 'micromatch';
3
6
 
7
+ const require = createRequire(import.meta.url);
8
+
9
+ /*
10
+ * knip only exports `main`; the option builder it relies on lives in an internal
11
+ * module that knip's `exports` map hides from bare-specifier imports. Resolving
12
+ * knip's entry point and importing the file directly bypasses that gate, since
13
+ * the `exports` map only governs `knip/…` specifiers, not file URLs.
14
+ */
15
+ const createOptionsURL = pathToFileURL(join(dirname(require.resolve('knip')), 'util', 'create-options.js')).href;
16
+
4
17
  export default async function unusedFiles(
5
18
  cwd = process.cwd(),
6
19
  ignorePattern = [
@@ -11,100 +24,24 @@ export default async function unusedFiles(
11
24
  'example/**',
12
25
  ],
13
26
  ) {
14
- const origArgv = process.argv;
15
- let files;
16
- try {
17
- process.argv = origArgv.slice(0, 2);
18
- // @ts-expect-error knip doesn't have main in its types
19
- const { main: knip } = await import('knip');
27
+ // @ts-expect-error knip doesn't have main in its types
28
+ const { main: knip } = await import('knip');
29
+ const { createOptions } = await import(createOptionsURL);
30
+
31
+ const options = await createOptions({
32
+ cwd,
33
+ includedIssueTypes: ['files'],
34
+ isProduction: true,
35
+ isStrict: true,
36
+ });
20
37
 
21
- ({ issues: { files } } = await knip({
22
- cacheLocation: '',
23
- catalog: {
24
- filePath: '',
25
- },
26
- config: undefined,
27
- configFilePath: undefined,
28
- cwd,
29
- dependencies: true,
30
- experimentalTags: [[], []],
31
- exports: true,
32
- files: true,
33
- fixTypes: [],
34
- gitignore: true,
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
- },
52
- isCache: false,
53
- isDebug: false,
54
- isDisableConfigHints: true,
55
- isFix: false,
56
- isFixDependencies: false,
57
- isFixFiles: false,
58
- isFixUnusedExports: false,
59
- isFixUnusedTypes: false,
60
- isFormat: false,
61
- isIncludeEntryExports: true,
62
- isIsolateWorkspaces: false,
63
- isProduction: true,
64
- isReportClassMembers: true,
65
- isReportDependencies: true,
66
- isReportExports: true,
67
- isReportFiles: true,
68
- isReportTypes: true,
69
- isReportValues: true,
70
- isShowProgress: false,
71
- isSkipLibs: false,
72
- isStrict: true,
73
- isTrace: false,
74
- isTreatConfigHintsAsErrors: false,
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
- },
94
- tags: [[], []],
95
- traceExport: undefined,
96
- traceFile: undefined,
97
- tsConfigFile: '',
98
- workspace: undefined,
99
- workspaces: [],
100
- }));
101
- } finally {
102
- process.argv = origArgv;
103
- }
38
+ const { issues: { files } } = await knip(options);
104
39
 
105
- return Array.from(files).flatMap((x) => (
106
- micromatch.isMatch(relative(cwd, x), ignorePattern)
107
- ? []
108
- : `./${relative(cwd, x)}`
109
- ));
40
+ return Object.values(files)
41
+ .flatMap((bySymbol) => Object.values(bySymbol))
42
+ .flatMap((issue) => (
43
+ micromatch.isMatch(relative(cwd, issue.filePath), ignorePattern)
44
+ ? []
45
+ : `./${relative(cwd, issue.filePath)}`
46
+ ));
110
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ljharb/unused-files",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "List unused files in your package.",
5
5
  "bin": "./bin.mjs",
6
6
  "main": false,
@@ -37,30 +37,29 @@
37
37
  },
38
38
  "homepage": "https://github.com/ljharb/unused-files#readme",
39
39
  "dependencies": {
40
- "knip": "~5.78.0",
40
+ "knip": "~6.17.1",
41
41
  "micromatch": "^4.0.8",
42
42
  "object.groupby": "^1.0.3",
43
- "pargs": "^1.2.1"
43
+ "pargs": "^1.4.2"
44
44
  },
45
45
  "devDependencies": {
46
- "@arethetypeswrong/cli": "^0.18.2",
46
+ "@arethetypeswrong/cli": "^0.18.3",
47
47
  "@jest/types": "^29.6.3",
48
- "@ljharb/eslint-config": "^21.4.0",
48
+ "@ljharb/eslint-config": "^22.2.3",
49
49
  "@ljharb/tsconfig": "^0.3.2",
50
+ "@types/eslint": "^8.56.12",
50
51
  "@types/micromatch": "^4.0.10",
51
52
  "@types/minimist": "^1.2.5",
52
53
  "@types/object.groupby": "^1.0.4",
53
- "@types/tape": "^5.8.1",
54
- "@types/webpack": "^5.28.5",
55
- "auto-changelog": "^2.5.0",
54
+ "auto-changelog": "^2.6.0",
56
55
  "c8": "^10.1.3",
57
56
  "encoding": "^0.1.13",
58
57
  "eslint": "^8.57.1",
59
58
  "in-publish": "^2.0.1",
60
59
  "npmignore": "^0.3.5",
61
- "playwright": "^1.57.0",
60
+ "playwright": "^1.61.0",
62
61
  "safe-publish-latest": "^2.0.0",
63
- "tape": "^5.9.0",
62
+ "tape": "^5.10.2",
64
63
  "typescript": "next"
65
64
  },
66
65
  "engines": {
package/help.txt DELETED
@@ -1,11 +0,0 @@
1
- Usage: unused-files [options]
2
-
3
- Options:
4
- --ignorePattern <pattern> Ignore files matching the given pattern
5
- [string]
6
- [multiple]
7
- [default: .github/**, coverage/**, test/**, tests/**, example/**]
8
-
9
- --json Output the result as a JSON array
10
- [boolean]
11
- [default: false]