knip 6.32.1 → 6.32.3
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 +1 -1
- package/dist/binaries/resolvers/bun.js +1 -0
- package/dist/binaries/resolvers/pnpm.js +10 -0
- package/dist/constants.js +1 -0
- package/dist/plugins/lefthook/index.js +10 -2
- package/dist/plugins/lint-staged/index.js +4 -6
- package/dist/plugins/oxfmt/index.js +1 -1
- package/dist/plugins/oxlint/index.js +1 -1
- package/dist/plugins/tsup/index.js +1 -1
- package/dist/plugins/vitest/index.js +14 -10
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/plugins/webdriver-io/index.js +1 -1
- package/dist/util/glob-core.js +9 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ following projects:
|
|
|
51
51
|
[3]: https://img.shields.io/npm/dm/knip?color=f56e0f
|
|
52
52
|
[4]: https://github.com/webpro-nl/knip
|
|
53
53
|
[5]:
|
|
54
|
-
https://img.shields.io/github/stars/webpro-nl/knip?style=flat
|
|
54
|
+
https://img.shields.io/github/stars/webpro-nl/knip?style=flat&color=f56e0f
|
|
55
55
|
[6]: https://knip.dev
|
|
56
56
|
[7]: https://www.npmx.dev/package/@knip/create-config
|
|
57
57
|
[8]: https://www.npmx.dev/package/@knip/language-server
|
|
@@ -15,6 +15,7 @@ const commands = [
|
|
|
15
15
|
'clean-install',
|
|
16
16
|
'clean',
|
|
17
17
|
'config',
|
|
18
|
+
'create',
|
|
18
19
|
'dedupe',
|
|
19
20
|
'deploy',
|
|
20
21
|
'dlx',
|
|
@@ -28,6 +29,7 @@ const commands = [
|
|
|
28
29
|
'ic',
|
|
29
30
|
'ignored-builds',
|
|
30
31
|
'import',
|
|
32
|
+
'info',
|
|
31
33
|
'init',
|
|
32
34
|
'install-clean',
|
|
33
35
|
'install-test',
|
|
@@ -39,6 +41,8 @@ const commands = [
|
|
|
39
41
|
'list',
|
|
40
42
|
'll',
|
|
41
43
|
'ln',
|
|
44
|
+
'login',
|
|
45
|
+
'logout',
|
|
42
46
|
'ls',
|
|
43
47
|
'outdated',
|
|
44
48
|
'pack-app',
|
|
@@ -70,6 +74,7 @@ const commands = [
|
|
|
70
74
|
'store',
|
|
71
75
|
't',
|
|
72
76
|
'test',
|
|
77
|
+
'token',
|
|
73
78
|
'tst',
|
|
74
79
|
'un',
|
|
75
80
|
'uninstall',
|
|
@@ -78,9 +83,11 @@ const commands = [
|
|
|
78
83
|
'update',
|
|
79
84
|
'upgrade',
|
|
80
85
|
'version',
|
|
86
|
+
'view',
|
|
81
87
|
'why',
|
|
82
88
|
'with',
|
|
83
89
|
];
|
|
90
|
+
const recursiveCommands = ['recursive', 'multi', 'm'];
|
|
84
91
|
export const resolve = (_binary, words, options) => {
|
|
85
92
|
const parsed = parseArgs(words, {
|
|
86
93
|
boolean: ['aggregate-output', 'if-present', 'parallel', 'recursive', 'reverse', 'shell-mode', 'silent', 'stream'],
|
|
@@ -92,6 +99,9 @@ export const resolve = (_binary, words, options) => {
|
|
|
92
99
|
const wordsForDlx = words.filter(word => word.value !== 'dlx');
|
|
93
100
|
return resolveDlx(wordsForDlx, options);
|
|
94
101
|
}
|
|
102
|
+
if (recursiveCommands.includes(command)) {
|
|
103
|
+
return resolve(_binary, argsAfter(words, command), options);
|
|
104
|
+
}
|
|
95
105
|
const { manifest, fromArgs } = options;
|
|
96
106
|
if (parsed.filter && !parsed.recursive)
|
|
97
107
|
return [];
|
package/dist/constants.js
CHANGED
|
@@ -6,12 +6,20 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
6
6
|
const title = 'Lefthook';
|
|
7
7
|
const enablers = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthook'];
|
|
8
8
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
9
|
+
const configFiles = [
|
|
10
|
+
'lefthook.{yml,yaml,json,jsonc,toml}',
|
|
11
|
+
'.lefthook.{yml,yaml,json,jsonc,toml}',
|
|
12
|
+
'.config/lefthook.{yml,yaml,json,jsonc,toml}',
|
|
13
|
+
'lefthook-local.{yml,yaml,json,jsonc,toml}',
|
|
14
|
+
'.lefthook-local.{yml,yaml,json,jsonc,toml}',
|
|
15
|
+
'.config/lefthook-local.{yml,yaml,json,jsonc,toml}',
|
|
16
|
+
];
|
|
9
17
|
const resolveConfig = async (localConfig, options) => {
|
|
10
18
|
if (options.isProduction)
|
|
11
19
|
return [];
|
|
12
20
|
const { manifest, configFileName, cwd, getInputsFromScripts } = options;
|
|
13
21
|
const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(id => toDependency(id)) : [];
|
|
14
|
-
if (extname(configFileName)
|
|
22
|
+
if (extname(configFileName) !== '') {
|
|
15
23
|
const scripts = findByKeyDeep(localConfig, 'run').flatMap(command => {
|
|
16
24
|
const deps = getInputsFromScripts([command.run], { ...options, knownBinsOnly: true });
|
|
17
25
|
const dir = command.root ?? cwd;
|
|
@@ -33,7 +41,7 @@ const plugin = {
|
|
|
33
41
|
title,
|
|
34
42
|
enablers,
|
|
35
43
|
isEnabled,
|
|
36
|
-
config: options => [
|
|
44
|
+
config: options => [...configFiles, ...getGitHookPaths('.git/hooks', true, options.cwd)],
|
|
37
45
|
resolveConfig,
|
|
38
46
|
};
|
|
39
47
|
export default plugin;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
-
import { toLilconfig } from '../../util/plugin-config.js';
|
|
3
2
|
const title = 'lint-staged';
|
|
4
3
|
const enablers = ['lint-staged'];
|
|
5
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
5
|
const config = [
|
|
7
|
-
'package.json',
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
|
|
11
|
-
...toLilconfig('lintstaged'),
|
|
6
|
+
'package.{json,yaml,yml}',
|
|
7
|
+
'.lintstagedrc',
|
|
8
|
+
'.lintstagedrc.{json,yaml,yml,mjs,mts,js,ts,cjs,cts}',
|
|
9
|
+
'lint-staged.config.{mjs,mts,js,ts,cjs,cts}',
|
|
12
10
|
];
|
|
13
11
|
const resolveEntry = async (value) => {
|
|
14
12
|
if (Array.isArray(value))
|
|
@@ -2,7 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
2
2
|
const title = 'Oxfmt';
|
|
3
3
|
const enablers = ['oxfmt'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.ts'];
|
|
5
|
+
const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.{ts,mts}'];
|
|
6
6
|
const args = {
|
|
7
7
|
config: true,
|
|
8
8
|
};
|
|
@@ -6,7 +6,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
6
6
|
const title = 'Oxlint';
|
|
7
7
|
const enablers = ['oxlint', 'vite-plus'];
|
|
8
8
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
9
|
-
const config = ['.oxlintrc.json', 'oxlint.config.ts', 'vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
9
|
+
const config = ['.oxlintrc.json', 'oxlint.config.{ts,mts}', 'vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
10
10
|
const isViteConfig = (configFileName) => configFileName.startsWith('vite.config.');
|
|
11
11
|
const args = {
|
|
12
12
|
config: true,
|
|
@@ -4,7 +4,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
4
4
|
const title = 'tsup';
|
|
5
5
|
const enablers = ['tsup'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
-
const config = ['tsup.config.{js,ts,cjs,mjs,json}', 'package.json'];
|
|
7
|
+
const config = ['tsup.config.{js,ts,cjs,mjs,cts,mts,json}', 'package.json'];
|
|
8
8
|
const isLoadConfig = ({ configFileName }) => configFileName === 'package.json' || configFileName.endsWith('.json');
|
|
9
9
|
const resolveConfig = async (config) => {
|
|
10
10
|
if (typeof config === 'function')
|
|
@@ -11,7 +11,8 @@ const enablers = ['vitest', 'vite-plus'];
|
|
|
11
11
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
12
12
|
const config = ['vitest.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{js,mjs,ts,cjs,mts,cts,json}'];
|
|
13
13
|
const mocks = ['**/__mocks__/**/*.?(c|m)[jt]s?(x)'];
|
|
14
|
-
const
|
|
14
|
+
const testEntry = ['**/*.{bench,test,test-d,spec,spec-d}.?(c|m)[jt]s?(x)'];
|
|
15
|
+
const entry = [...testEntry, ...mocks];
|
|
15
16
|
const benchmark = ['**/*.bench.?(c|m)[jt]s?(x)'];
|
|
16
17
|
const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
17
18
|
const { configFileDir: dir } = options;
|
|
@@ -24,7 +25,9 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
|
24
25
|
? [toDeferResolve(env)]
|
|
25
26
|
: [toDependency(getEnvSpecifier(env))]
|
|
26
27
|
: [];
|
|
27
|
-
const reporters = getExternalReporters(testConfig.reporters)
|
|
28
|
+
const reporters = getExternalReporters(testConfig.reporters).map(specifier => isInternal(specifier) || isAbsolute(specifier)
|
|
29
|
+
? { ...toDeferResolve(specifier), dir: vitestRoot }
|
|
30
|
+
: toDependency(specifier));
|
|
28
31
|
const hasCoverage = testConfig.coverage && (testConfig.coverage.enabled !== false || testConfig.coverage.provider);
|
|
29
32
|
const coverage = hasCoverage ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
|
|
30
33
|
const setupFiles = [testConfig.setupFiles ?? []]
|
|
@@ -51,7 +54,7 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
|
51
54
|
}
|
|
52
55
|
return [
|
|
53
56
|
...environments,
|
|
54
|
-
...reporters
|
|
57
|
+
...reporters,
|
|
55
58
|
...coverage.map(id => toDependency(id)),
|
|
56
59
|
...setupFiles,
|
|
57
60
|
...snapshotSerializers,
|
|
@@ -133,22 +136,23 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
133
136
|
for (const entry of await getIndexHtmlEntries(viteRoot))
|
|
134
137
|
inputs.add(entry);
|
|
135
138
|
}
|
|
136
|
-
const
|
|
139
|
+
const vitestRoot = toAbsolute(cfg.test?.root ?? '.', options.cwd);
|
|
140
|
+
const dir = cfg.test?.dir ? toAbsolute(cfg.test.dir, vitestRoot) : vitestRoot;
|
|
137
141
|
if (cfg.test) {
|
|
138
142
|
if (cfg.test?.include) {
|
|
139
143
|
for (const dependency of cfg.test.include)
|
|
140
144
|
dependency[0] !== '!' && inputs.add(toEntry(join(dir, dependency)));
|
|
141
|
-
if (!options.config.entry)
|
|
142
|
-
for (const dependency of mocks)
|
|
143
|
-
inputs.add(toEntry(join(dir, dependency)));
|
|
144
145
|
const benchmarkInclude = cfg.test.benchmark?.include ?? benchmark;
|
|
145
146
|
for (const dependency of benchmarkInclude)
|
|
146
147
|
dependency[0] !== '!' && inputs.add(toEntry(join(dir, dependency)));
|
|
147
148
|
}
|
|
148
149
|
else {
|
|
149
|
-
for (const dependency of options.config.entry ??
|
|
150
|
+
for (const dependency of options.config.entry ?? testEntry)
|
|
150
151
|
inputs.add(toEntry(join(dir, dependency)));
|
|
151
152
|
}
|
|
153
|
+
if (!options.config.entry)
|
|
154
|
+
for (const dependency of mocks)
|
|
155
|
+
inputs.add(toEntry(join(vitestRoot, dependency)));
|
|
152
156
|
if (cfg.test.alias)
|
|
153
157
|
addAliases(cfg.test.alias);
|
|
154
158
|
}
|
|
@@ -174,11 +178,11 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
174
178
|
inputs.add(toEntry(`src/**/*${ext}`));
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
|
-
for (const dependency of findConfigDependencies(cfg, options,
|
|
181
|
+
for (const dependency of findConfigDependencies(cfg, options, vitestRoot))
|
|
178
182
|
inputs.add(dependency);
|
|
179
183
|
const _entry = cfg.build?.lib?.entry ?? [];
|
|
180
184
|
const deps = (typeof _entry === 'string' ? [_entry] : Object.values(_entry))
|
|
181
|
-
.map(specifier => join(
|
|
185
|
+
.map(specifier => join(vitestRoot, specifier))
|
|
182
186
|
.map(id => toEntry(id));
|
|
183
187
|
for (const dependency of deps)
|
|
184
188
|
inputs.add(dependency);
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'WebdriverIO';
|
|
4
4
|
const enablers = ['@wdio/cli'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['wdio.conf.{js,ts}'];
|
|
6
|
+
const config = ['wdio.conf.{js,cjs,mjs,ts,cts,mts}'];
|
|
7
7
|
const resolveConfig = async (config) => {
|
|
8
8
|
const cfg = config?.config;
|
|
9
9
|
if (!cfg)
|
package/dist/util/glob-core.js
CHANGED
|
@@ -91,9 +91,14 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
91
91
|
}
|
|
92
92
|
return deepFilterMatcher;
|
|
93
93
|
};
|
|
94
|
+
const seenGitignoreFiles = new Set();
|
|
94
95
|
const addFile = (filePath, baseDir) => {
|
|
96
|
+
const absPath = toPosix(filePath);
|
|
97
|
+
if (seenGitignoreFiles.has(absPath))
|
|
98
|
+
return;
|
|
99
|
+
seenGitignoreFiles.add(absPath);
|
|
95
100
|
gitignoreFiles.push(relative(cwd, filePath));
|
|
96
|
-
const dir = baseDir ?? dirname(
|
|
101
|
+
const dir = baseDir ?? dirname(absPath);
|
|
97
102
|
const base = relative(cwd, dir);
|
|
98
103
|
const ancestor = base.startsWith('..') ? `${relative(dir, cwd)}/` : undefined;
|
|
99
104
|
const ignoresForDir = new Set(base === '' ? GLOBAL_IGNORE_PATTERNS : []);
|
|
@@ -154,6 +159,9 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
154
159
|
if (isFile(excludePath))
|
|
155
160
|
addFile(excludePath, cwd);
|
|
156
161
|
}
|
|
162
|
+
const rootGitignorePath = join(cwd, '.gitignore');
|
|
163
|
+
if (isFile(rootGitignorePath))
|
|
164
|
+
addFile(rootGitignorePath);
|
|
157
165
|
let isRelevantDir;
|
|
158
166
|
if (workspaceDirs && workspaceDirs.size > 0) {
|
|
159
167
|
const relevantAncestors = new Set();
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.32.
|
|
1
|
+
export declare const version = "6.32.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.32.
|
|
1
|
+
export const version = '6.32.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "6.32.
|
|
3
|
+
"version": "6.32.3",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"formatly": "^0.3.0",
|
|
82
82
|
"get-tsconfig": "4.14.1",
|
|
83
83
|
"jiti": "^2.7.0",
|
|
84
|
-
"oxc-parser": "^0.
|
|
84
|
+
"oxc-parser": "^0.143.0",
|
|
85
85
|
"oxc-resolver": "11.24.2",
|
|
86
86
|
"picomatch": "^4.0.5",
|
|
87
87
|
"smol-toml": "^1.7.1",
|
|
88
88
|
"strip-json-comments": "5.0.3",
|
|
89
89
|
"tinyglobby": "^0.2.17",
|
|
90
|
-
"unbash": "^4.0.
|
|
90
|
+
"unbash": "^4.0.9",
|
|
91
91
|
"yaml": "^2.9.0",
|
|
92
92
|
"zod": "^4.4.3"
|
|
93
93
|
},
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@types/webpack": "^5.28.5",
|
|
99
99
|
"codeclimate-types": "^0.3.1",
|
|
100
100
|
"prettier": "^3.9.6",
|
|
101
|
-
"tsx": "^4.23.
|
|
101
|
+
"tsx": "^4.23.11",
|
|
102
102
|
"typescript": "7.0.2"
|
|
103
103
|
},
|
|
104
104
|
"engines": {
|