@ljharb/unused-files 0.2.0 → 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,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.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
+
20
+ ## [v0.2.1](https://github.com/ljharb/unused-files/compare/v0.2.0...v0.2.1) - 2026-01-06
21
+
22
+ ### Commits
23
+
24
+ - [Fix] fix knip compatibility [`44f00fa`](https://github.com/ljharb/unused-files/commit/44f00fa23cd17f9f05a338adcf4d92850a9a96d0)
25
+ - [Fix] fix knip compatibility with v5.63.1 [`d89fd7c`](https://github.com/ljharb/unused-files/commit/d89fd7c0623d0e200ffaa8150a9eff1e6e899818)
26
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `c8`, `npmignore`, `playwright` [`5d95ceb`](https://github.com/ljharb/unused-files/commit/5d95cebc62f19fd370f00ad8b6a97ff52423e8f6)
27
+ - [Fix] fix knip compatibility with v5.69.0 [`abf7545`](https://github.com/ljharb/unused-files/commit/abf7545b69a8115bea5cc2ed3d6abfb7ab5169d1)
28
+ - [Fix] fix knip compatibility with v5.77.0 [`d581150`](https://github.com/ljharb/unused-files/commit/d581150b4c253d06d160911c8291463bf946f965)
29
+ - [Deps] update `pargs` [`a421e84`](https://github.com/ljharb/unused-files/commit/a421e84f827b88dbd19e5c49db90b1ff97b435c4)
30
+ - [readme] replace runkit CI badge with shields.io check-runs badge [`9688bb9`](https://github.com/ljharb/unused-files/commit/9688bb98927de695bc69aca58763604e9c2bd2b0)
31
+
8
32
  ## [v0.2.0](https://github.com/ljharb/unused-files/compare/v0.1.2...v0.2.0) - 2025-10-31
9
33
 
10
34
  ### 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/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/unused-files
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
@@ -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,95 +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
- config: undefined,
24
- configFilePath: undefined,
25
- cwd,
26
- dependencies: true,
27
- experimentalTags: [[], []],
28
- exports: true,
29
- files: false,
30
- fixTypes: [],
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,
52
- isFix: false,
53
- isFixDependencies: false,
54
- isFixFiles: false,
55
- isFixUnusedExports: false,
56
- isFixUnusedTypes: false,
57
- isFormat: false,
58
- isIncludeEntryExports: true,
59
- isIsolateWorkspaces: false,
60
- isProduction: true,
61
- isReportClassMembers: false,
62
- isReportDependencies: false,
63
- isReportTypes: false,
64
- isReportValues: false,
65
- isShowProgress: false,
66
- isSkipLibs: false,
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
- },
89
- tags: [[], []],
90
- traceExport: undefined,
91
- traceFile: undefined,
92
- tsConfigFile: '',
93
- workspace: undefined,
94
- workspaces: [],
95
- }));
96
- } finally {
97
- process.argv = origArgv;
98
- }
38
+ const { issues: { files } } = await knip(options);
99
39
 
100
- return Array.from(files).flatMap((x) => (
101
- micromatch.isMatch(relative(cwd, x), ignorePattern)
102
- ? []
103
- : `./${relative(cwd, x)}`
104
- ));
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
+ ));
105
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ljharb/unused-files",
3
- "version": "0.2.0",
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.59.1",
40
+ "knip": "~6.17.1",
41
41
  "micromatch": "^4.0.8",
42
42
  "object.groupby": "^1.0.3",
43
- "pargs": "^1.0.3"
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.2.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",
56
- "c8": "^9.1.0",
54
+ "auto-changelog": "^2.6.0",
55
+ "c8": "^10.1.3",
57
56
  "encoding": "^0.1.13",
58
- "eslint": "=8.8.0",
57
+ "eslint": "^8.57.1",
59
58
  "in-publish": "^2.0.1",
60
- "npmignore": "^0.3.1",
61
- "playwright": "^1.55.0",
59
+ "npmignore": "^0.3.5",
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]