knip 6.32.2 → 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 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-square&color=f56e0f
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 = new Set([
15
15
  'completions',
16
16
  'config',
17
17
  'create',
18
+ 'dedupe',
18
19
  'deploy',
19
20
  'discord',
20
21
  'exec',
@@ -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
@@ -108,6 +108,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
108
108
  'powershell.exe',
109
109
  'pr',
110
110
  'printenv',
111
+ 'printf',
111
112
  'ps',
112
113
  'pulumi',
113
114
  'pwd',
@@ -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) === '.yml') {
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 => ['lefthook.yml', ...getGitHookPaths('.git/hooks', true, options.cwd)],
44
+ config: options => [...configFiles, ...getGitHookPaths('.git/hooks', true, options.cwd)],
37
45
  resolveConfig,
38
46
  };
39
47
  export default plugin;
@@ -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 entry = ['**/*.{bench,test,test-d,spec,spec-d}.?(c|m)[jt]s?(x)', ...mocks];
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.map(id => toDependency(id)),
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 dir = toAbsolute(cfg.test?.root ?? '.', options.cwd);
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 ?? 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, dir))
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(dir, specifier))
185
+ .map(specifier => join(vitestRoot, specifier))
182
186
  .map(id => toEntry(id));
183
187
  for (const dependency of deps)
184
188
  inputs.add(dependency);
@@ -17,6 +17,7 @@ interface VitestConfig {
17
17
  provider: string;
18
18
  };
19
19
  root?: string;
20
+ dir?: string;
20
21
  environment?: string;
21
22
  globalSetup?: string | string[];
22
23
  reporters?: (string | [string, unknown] | unknown)[];
@@ -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)
@@ -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(toPosix(filePath));
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.2";
1
+ export declare const version = "6.32.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.32.2';
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.2",
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",