knip 6.44.1 → 6.44.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.
@@ -1,5 +1,5 @@
1
1
  import parseArgs from '../../util/parse-args.js';
2
- import { toBinary, toEntry } from '../../util/input.js';
2
+ import { toBinary, toDeferResolveEntry } from '../../util/input.js';
3
3
  import { isAbsolute, join } from '../../util/path.js';
4
4
  import { _resolveSync } from '../../util/resolve.js';
5
5
  import { argsAfter, expandScript, toCommandBinary } from '../util.js';
@@ -82,7 +82,7 @@ export const resolve = (_binary, words, options) => {
82
82
  const _cwd = parsed.cwd ? join(cwd, parsed.cwd) : cwd;
83
83
  const resolved = _resolveSync(isAbsolute(filePath) ? filePath : join(_cwd, filePath), _cwd);
84
84
  if (resolved)
85
- return [binary, toEntry(resolved)];
85
+ return [binary, toDeferResolveEntry(resolved, { optional: true })];
86
86
  const dir = parsed.cwd ? join(cwd, parsed.cwd) : undefined;
87
87
  const opts = dir ? { cwd: dir } : {};
88
88
  if (command !== 'run')
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  pn: import("../../types/config.ts").BinaryResolver;
11
11
  pnpx: import("../../types/config.ts").BinaryResolver;
12
12
  pnx: import("../../types/config.ts").BinaryResolver;
13
+ vp: import("../../types/config.ts").BinaryResolver;
13
14
  yarn: import("../../types/config.ts").BinaryResolver;
14
15
  find: import("../../types/config.ts").BinaryResolver;
15
16
  };
@@ -6,6 +6,7 @@ import * as npx from './npx.js';
6
6
  import * as nub from './nub.js';
7
7
  import * as pnpm from './pnpm.js';
8
8
  import * as pnpx from './pnpx.js';
9
+ import * as vp from './vp.js';
9
10
  import * as yarn from './yarn.js';
10
11
  const packageManagerResolvers = {
11
12
  bun: bun.resolve,
@@ -18,6 +19,7 @@ const packageManagerResolvers = {
18
19
  pn: pnpm.resolve,
19
20
  pnpx: pnpx.resolve,
20
21
  pnx: pnpx.resolve,
22
+ vp: vp.resolve,
21
23
  yarn: yarn.resolve,
22
24
  };
23
25
  export const isPackageManager = (binary) => binary in packageManagerResolvers;
@@ -6,17 +6,52 @@ import { argsFrom } from '../util.js';
6
6
  const noInstallFlags = new Set(['--no', '--no-install', '--yes=false', '--no-yes']);
7
7
  export const resolve = (_binary, words, options) => {
8
8
  const { fromArgs } = options;
9
- const parsed = parseArgs(words, {
9
+ const args = {
10
10
  isStorePositions: true,
11
- boolean: ['yes', 'no', 'quiet'],
12
- alias: { yes: 'y', package: 'p', call: 'c' },
13
- });
11
+ boolean: [
12
+ 'color',
13
+ 'd',
14
+ 'dangerously-allow-all-scripts',
15
+ 'dd',
16
+ 'ddd',
17
+ 'force',
18
+ 'global',
19
+ 'ignore-scripts',
20
+ 'include-workspace-root',
21
+ 'legacy-peer-deps',
22
+ 'no',
23
+ 'offline',
24
+ 'prefer-offline',
25
+ 'prefer-online',
26
+ 'progress',
27
+ 'quiet',
28
+ 'silent',
29
+ 'strict-allow-scripts',
30
+ 'timing',
31
+ 'verbose',
32
+ 'workspaces',
33
+ 'yes',
34
+ ],
35
+ alias: {
36
+ force: 'f',
37
+ global: 'g',
38
+ 'include-workspace-root': 'iwr',
39
+ quiet: 'q',
40
+ silent: 's',
41
+ workspaces: 'ws',
42
+ yes: 'y',
43
+ package: 'p',
44
+ call: 'c',
45
+ },
46
+ };
47
+ const parsed = parseArgs(words, args);
48
+ const commandIndex = parsed.positionalIndices[0] ?? words.length;
49
+ const flags = parseArgs(words.slice(0, commandIndex), args);
14
50
  const packageSpecifier = parsed._[0];
15
51
  const specifier = packageSpecifier ? stripVersionFromSpecifier(packageSpecifier) : '';
16
- const packages = parsed.package ? [parsed.package].flat().map(stripVersionFromSpecifier) : [];
17
- const command = parsed.call ? fromArgs([parsed.call]) : [];
52
+ const packages = flags.package ? [flags.package].flat().map(stripVersionFromSpecifier) : [];
53
+ const command = flags.call ? fromArgs([flags.call]) : [];
18
54
  const isBinary = specifier && !packageSpecifier.includes('@') && !isInternal(specifier);
19
- const commandIndex = parsed.positionalIndices[0] ?? words.length;
20
55
  const noInstall = words.slice(0, commandIndex).some(word => noInstallFlags.has(word.value));
21
56
  const opts = noInstall ? undefined : { optional: true };
22
57
  const dependency = isBinary ? toBinary(specifier, opts) : toDependency(specifier, opts);
@@ -1,5 +1,5 @@
1
1
  import parseArgs from '../../util/parse-args.js';
2
- import { toEntry } from '../../util/input.js';
2
+ import { toDeferResolveEntry } from '../../util/input.js';
3
3
  import { isAbsolute, join } from '../../util/path.js';
4
4
  import { _resolveSync } from '../../util/resolve.js';
5
5
  import { toCommandBinary } from '../util.js';
@@ -39,7 +39,7 @@ export const resolve = (_binary, words, options) => {
39
39
  if (!script || manifest.scriptNames.has(script))
40
40
  return [binary];
41
41
  const resolved = _resolveSync(isAbsolute(script) ? script : join(cwd, script), cwd);
42
- return resolved ? [binary, toEntry(resolved)] : [binary];
42
+ return resolved ? [binary, toDeferResolveEntry(resolved, { optional: true })] : [binary];
43
43
  }
44
44
  if (command && (commands.has(command) || manifest.scriptNames.has(command)))
45
45
  return [binary];
@@ -0,0 +1,2 @@
1
+ import type { BinaryResolver } from '../../types/config.ts';
2
+ export declare const resolve: BinaryResolver;
@@ -0,0 +1,52 @@
1
+ import parseArgs from '../../util/parse-args.js';
2
+ import { toAbsolute } from '../../util/path.js';
3
+ import { toCommandBinary } from '../util.js';
4
+ const parseOptions = {
5
+ isStorePositions: true,
6
+ string: ['filter', 'resume-from'],
7
+ boolean: [
8
+ 'fail-if-no-match',
9
+ 'parallel',
10
+ 'recursive',
11
+ 'report-summary',
12
+ 'reverse',
13
+ 'shell-mode',
14
+ 'transitive',
15
+ 'workspace-root',
16
+ ],
17
+ alias: { filter: 'F', recursive: 'r', 'shell-mode': 'c', transitive: 't', 'workspace-root': 'w' },
18
+ };
19
+ const parseLeadingChdir = (words) => {
20
+ const first = words[0]?.value;
21
+ if (first === '-C')
22
+ return [words[1]?.value, 2];
23
+ if (first?.startsWith('-C')) {
24
+ const dir = first[2] === '=' ? first.slice(3) : first.slice(2);
25
+ if (dir)
26
+ return [dir, 1];
27
+ }
28
+ return [undefined, 0];
29
+ };
30
+ export const resolve = (_binary, _words, options) => {
31
+ const binary = toCommandBinary(_binary, options);
32
+ const [C, consumed] = parseLeadingChdir(_words);
33
+ const words = _words.slice(consumed);
34
+ const parsed = parseArgs(words, parseOptions);
35
+ const [command] = parsed._;
36
+ if (command !== 'exec')
37
+ return [binary];
38
+ const [execIndex, commandIndex] = parsed.positionalIndices;
39
+ if (commandIndex === undefined)
40
+ return [binary];
41
+ const execOptions = parseArgs(words.slice(execIndex + 1, commandIndex), parseOptions);
42
+ if (execOptions.filter)
43
+ return [binary];
44
+ const dir = execOptions['workspace-root'] ? options.rootCwd : C ? toAbsolute(C, options.cwd) : undefined;
45
+ const rest = words.slice(commandIndex);
46
+ const script = rest.map(word => (execOptions['shell-mode'] ? word.value : word.text)).join(' ');
47
+ const inputs = options.fromArgs([script], dir ? { cwd: dir } : {});
48
+ if (dir)
49
+ for (const input of inputs)
50
+ input.dir ??= dir;
51
+ return [binary, ...inputs];
52
+ };
@@ -1,4 +1,5 @@
1
1
  import { getUrlSpecifier, isScopedPackage, isTildePackage, splitSpec } from './shared.js';
2
+ import { hasUrlScheme } from '../util/url.js';
2
3
  const dependencies = ['sass', 'sass-embedded', 'node-sass'];
3
4
  const dependencyMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|\/\/[^\r\n]*(?:[\r\n]|$)|@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]|url\(\s*(?:["']([^"'\r\n]*)["']|([^'")\s]+))\s*\)/g;
4
5
  const candidates = (specifier) => {
@@ -29,7 +30,7 @@ export const compiler = text => {
29
30
  continue;
30
31
  }
31
32
  let spec = match[2];
32
- if (!spec || spec.startsWith('sass:'))
33
+ if (!spec || spec.startsWith('//') || hasUrlScheme(spec))
33
34
  continue;
34
35
  let isBare = Boolean(match[1]) || isScopedPackage(spec);
35
36
  if (isTildePackage(spec)) {
package/dist/constants.js CHANGED
@@ -22,18 +22,24 @@ export const DT_SCOPE = '@types';
22
22
  export const PROTOCOL_VIRTUAL = 'virtual:';
23
23
  export const PROTOCOL_CLOUDFLARE = 'cloudflare:';
24
24
  export const IGNORED_GLOBAL_BINARIES = new Set([
25
+ 'alias',
25
26
  'amplify',
26
27
  'aws',
27
28
  'az',
28
29
  'base64',
29
30
  'basename',
30
31
  'bash',
32
+ 'bg',
33
+ 'bind',
34
+ 'break',
35
+ 'builtin',
31
36
  'bun',
32
37
  'bundle',
33
38
  'bunx',
34
39
  'cargo',
35
40
  'cat',
36
41
  'cd',
42
+ 'chgrp',
37
43
  'chmod',
38
44
  'chown',
39
45
  'cksum',
@@ -41,16 +47,20 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
41
47
  'clear',
42
48
  'cmd',
43
49
  'cmd.exe',
50
+ 'cmp',
44
51
  'code',
45
52
  'code-insiders',
46
53
  'codesign',
47
54
  'comm',
48
55
  'command',
56
+ 'continue',
49
57
  'corepack',
50
58
  'cp',
51
59
  'curl',
52
60
  'cut',
53
61
  'date',
62
+ 'dd',
63
+ 'declare',
54
64
  'defaults',
55
65
  'deno',
56
66
  'devtunnel',
@@ -59,8 +69,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
59
69
  'dirname',
60
70
  'docker',
61
71
  'dotnet',
72
+ 'du',
62
73
  'echo',
63
74
  'env',
75
+ 'eval',
64
76
  'exec',
65
77
  'exit',
66
78
  'expand',
@@ -68,28 +80,37 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
68
80
  'expr',
69
81
  'factor',
70
82
  'false',
83
+ 'fg',
71
84
  'find',
72
85
  'fuser',
73
86
  'gem',
74
87
  'getconf',
88
+ 'getopts',
75
89
  'gh',
76
90
  'git',
77
91
  'grep',
78
92
  'groups',
93
+ 'gunzip',
79
94
  'gzip',
95
+ 'hash',
80
96
  'head',
81
97
  'hg',
98
+ 'hostname',
82
99
  'id',
100
+ 'jobs',
83
101
  'join',
84
102
  'kill',
103
+ 'killall',
85
104
  'launchctl',
86
105
  'ln',
106
+ 'local',
87
107
  'logname',
88
108
  'ls',
89
109
  'lsof',
90
110
  'md5sum',
91
111
  'mkdir',
92
112
  'mknod',
113
+ 'mktemp',
93
114
  'mv',
94
115
  'nc',
95
116
  'nice',
@@ -104,6 +125,8 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
104
125
  'open',
105
126
  'osascript',
106
127
  'paste',
128
+ 'pgrep',
129
+ 'pkill',
107
130
  'pnpm',
108
131
  'pnpx',
109
132
  'powershell',
@@ -118,6 +141,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
118
141
  'python3',
119
142
  'raft',
120
143
  'railway',
144
+ 'read',
145
+ 'readlink',
146
+ 'realpath',
147
+ 'return',
121
148
  'rm',
122
149
  'rmdir',
123
150
  'rsync',
@@ -129,6 +156,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
129
156
  'sh',
130
157
  'sha1sum',
131
158
  'sha512sum',
159
+ 'shift',
132
160
  'shred',
133
161
  'shuf',
134
162
  'sleep',
@@ -143,6 +171,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
143
171
  'sysctl',
144
172
  'systemctl',
145
173
  'tac',
174
+ 'tail',
146
175
  'tar',
147
176
  'taskkill',
148
177
  'tee',
@@ -157,10 +186,16 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
157
186
  'true',
158
187
  'tsort',
159
188
  'tty',
189
+ 'type',
190
+ 'ulimit',
191
+ 'umask',
192
+ 'unalias',
160
193
  'uname',
161
194
  'unexpand',
162
195
  'uniq',
196
+ 'unset',
163
197
  'unzip',
198
+ 'wait',
164
199
  'wc',
165
200
  'which',
166
201
  'who',
@@ -1,5 +1,5 @@
1
1
  import { compact } from '../../util/array.js';
2
- import { toDeferResolve } from '../../util/input.js';
2
+ import { toConfig, toDeferResolve } from '../../util/input.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { api, resolveName } from './helpers.js';
5
5
  const title = 'Babel';
@@ -27,12 +27,17 @@ export const getDependenciesFromConfig = (config) => {
27
27
  ...overrides,
28
28
  ]);
29
29
  };
30
+ const getExtendedConfigs = (config) => [
31
+ ...(config.extends ? [toConfig('babel', config.extends)] : []),
32
+ ...Object.values(config.env ?? {}).flatMap(getExtendedConfigs),
33
+ ...(config.overrides ?? []).flatMap(getExtendedConfigs),
34
+ ];
30
35
  const resolveConfig = async (config) => {
31
36
  if (typeof config === 'function')
32
37
  config = config(api);
33
38
  if (!config)
34
39
  return [];
35
- return getDependenciesFromConfig(config);
40
+ return [...getExtendedConfigs(config), ...getDependenciesFromConfig(config)];
36
41
  };
37
42
  const plugin = {
38
43
  title,
@@ -2,6 +2,7 @@ import type { api } from './helpers.ts';
2
2
  type BabelConfigFn = (options: typeof api) => BabelConfigObj;
3
3
  export type BabelConfigObj = {
4
4
  configFile?: string;
5
+ extends?: string;
5
6
  plugins?: (string | [string, unknown])[];
6
7
  presets?: (string | [string, unknown])[];
7
8
  env?: Record<string, BabelConfigObj>;
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Gatsby';
4
4
  const enablers = ['gatsby', 'gatsby-cli'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
6
+ const config = ['gatsby-{config,node}.{js,mjs,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,mjs,jsx,ts,tsx}'];
7
7
  const production = [
8
8
  'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
9
9
  'src/api/**/*.{js,ts}',
@@ -8,34 +8,31 @@ const title = 'React Router';
8
8
  const enablers = ['@react-router/dev'];
9
9
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
10
10
  const viteConfig = typeof vite.config === 'function' ? [] : (vite.config ?? []);
11
- const config = ['react-router.config.{js,ts}', ...viteConfig];
11
+ const entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'mts'];
12
+ const entryExtsGlob = `{${entryExts.join(',')}}`;
13
+ const config = [`react-router.config.${entryExtsGlob}`, ...viteConfig];
12
14
  const resolveConfig = async (localConfig, options) => {
13
15
  const { configFileDir } = options;
14
16
  const appDirectory = localConfig.appDirectory ?? 'app';
15
17
  const appDir = toAbsolute(appDirectory, configFileDir);
16
18
  globalThis.__reactRouterAppDirectory = appDir;
17
19
  let routeConfig = [];
18
- const routesPathTs = join(appDir, 'routes.ts');
19
- const routesPathJs = join(appDir, 'routes.js');
20
- if (existsSync(routesPathTs)) {
21
- routeConfig = await load(routesPathTs);
22
- }
23
- else if (existsSync(routesPathJs)) {
24
- routeConfig = await load(routesPathJs);
25
- }
20
+ const routesPath = entryExts.map(ext => join(appDir, `routes.${ext}`)).find(existsSync);
21
+ if (routesPath)
22
+ routeConfig = await load(routesPath);
26
23
  const mapRoute = (route) => {
27
24
  return [toAbsolute(route.file, appDir), ...(route.children ? route.children.flatMap(mapRoute) : [])];
28
25
  };
29
26
  const routes = routeConfig.flatMap(mapRoute);
30
27
  const resolved = [
31
- toEntry(join(appDir, 'routes.{js,ts}')),
32
- toProductionEntry(join(appDir, 'root.{jsx,tsx}')),
33
- toProductionEntry(join(appDir, 'entry.{client,server}.{js,jsx,ts,tsx}')),
28
+ toEntry(join(appDir, `routes.${entryExtsGlob}`)),
29
+ toProductionEntry(join(appDir, `root.${entryExtsGlob}`)),
30
+ toProductionEntry(join(appDir, `entry.{client,server}.${entryExtsGlob}`)),
34
31
  ...routes.map(id => toProductionEntry(id)),
35
32
  ];
36
33
  const serverEntries = await _glob({
37
34
  cwd: appDir,
38
- patterns: ['entry.server.{js,ts,jsx,tsx}'],
35
+ patterns: [`entry.server.${entryExtsGlob}`],
39
36
  });
40
37
  if (serverEntries.length === 0) {
41
38
  resolved.push(toProductionDependency('@react-router/node'));
@@ -6,11 +6,17 @@ import { getBabelInputs } from '../vite/helpers.js';
6
6
  const title = 'Storybook';
7
7
  const enablers = [/^@storybook\//, '@nrwl/storybook'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
- const config = ['.{storybook,rnstorybook}/{main,test-runner}.{js,ts,mts}'];
9
+ const config = [
10
+ '.{storybook,rnstorybook}/main.{js,jsx,ts,tsx,mjs,mts,cjs,cts}',
11
+ '.{storybook,rnstorybook}/test-runner.{js,ts,mts}',
12
+ ];
10
13
  const stories = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
11
- const restEntry = ['.{storybook,rnstorybook}/{manager,preview,index,vitest.setup}.{js,jsx,ts,tsx}'];
14
+ const restEntry = [
15
+ '.{storybook,rnstorybook}/{manager,preview}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}',
16
+ '.{storybook,rnstorybook}/{index,vitest.setup}.{js,jsx,ts,tsx}',
17
+ ];
12
18
  const entry = [...restEntry, ...stories];
13
- const project = ['.{storybook,rnstorybook}/**/*.{js,jsx,ts,tsx,mts}'];
19
+ const project = ['.{storybook,rnstorybook}/**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts}'];
14
20
  const resolveConfig = async (localConfig, options) => {
15
21
  const { cwd, configFileDir } = options;
16
22
  const strs = typeof localConfig?.stories === 'function' ? await localConfig.stories(stories) : localConfig?.stories;
@@ -1,4 +1,4 @@
1
- import { toDeferResolve } from '../../util/input.js';
1
+ import { toConfig, toDeferResolve } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  import { toCosmiconfig } from '../../util/plugin-config.js';
4
4
  const title = 'Stylelint';
@@ -10,7 +10,7 @@ const resolveConfig = async (config, options) => {
10
10
  const extend = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
11
11
  for (const id of extend) {
12
12
  if (typeof id === 'string')
13
- inputs.push(toDeferResolve(id));
13
+ inputs.push(toDeferResolve(id), toConfig('stylelint', id));
14
14
  else
15
15
  for (const x of await resolveConfig(id, options))
16
16
  inputs.push(x);
@@ -1,13 +1,16 @@
1
+ import { toIgnore } from '../../util/input.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
2
3
  import { toUnconfig } from '../../util/plugin-config.js';
3
4
  const title = 'UnoCSS';
4
5
  const enablers = ['unocss'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const entry = [...toUnconfig('uno.config'), ...toUnconfig('unocss.config')];
8
+ const resolve = () => [toIgnore('uno.css', 'dependencies')];
7
9
  const plugin = {
8
10
  title,
9
11
  enablers,
10
12
  isEnabled,
11
13
  entry,
14
+ resolve,
12
15
  };
13
16
  export default plugin;
@@ -20,6 +20,12 @@ const mocks = ['**/__mocks__/**/*.?(c|m)[jt]s?(x)'];
20
20
  const testEntry = ['**/*.{bench,test,test-d,spec,spec-d}.?(c|m)[jt]s?(x)'];
21
21
  const entry = [...testEntry, ...mocks];
22
22
  const benchmark = ['**/*.bench.?(c|m)[jt]s?(x)'];
23
+ const builtInCoverageProviders = new Set(['v8', 'istanbul', 'c8']);
24
+ const getCoverageInputs = (provider, customProviderModule, dir) => builtInCoverageProviders.has(provider)
25
+ ? [toDependency(`@vitest/coverage-${provider}`)]
26
+ : customProviderModule
27
+ ? [{ ...toDeferResolve(customProviderModule), dir }]
28
+ : [];
23
29
  const isProjectConfig = (project) => typeof project === 'object' && !(project instanceof Promise);
24
30
  const findConfigDependencies = (localConfig, options, vitestRoot) => {
25
31
  const testConfig = localConfig.test;
@@ -31,7 +37,9 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
31
37
  ? { ...toDeferResolve(specifier), dir: vitestRoot }
32
38
  : toDependency(specifier));
33
39
  const hasCoverage = testConfig.coverage && (testConfig.coverage.enabled !== false || testConfig.coverage.provider);
34
- const coverage = hasCoverage ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
40
+ const coverage = hasCoverage
41
+ ? getCoverageInputs(testConfig.coverage?.provider ?? 'v8', testConfig.coverage?.customProviderModule, vitestRoot)
42
+ : [];
35
43
  const setupFiles = [testConfig.setupFiles ?? []]
36
44
  .flat()
37
45
  .map(specifier => ({ ...toDeferResolve(specifier), dir: vitestRoot }));
@@ -59,7 +67,7 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
59
67
  return [
60
68
  ...environments,
61
69
  ...reporters,
62
- ...coverage.map(id => toDependency(id)),
70
+ ...coverage,
63
71
  ...setupFiles,
64
72
  ...snapshotSerializers,
65
73
  ...globalSetup,
@@ -231,12 +239,14 @@ export const resolveConfig = async (localConfig, options) => {
231
239
  };
232
240
  const args = {
233
241
  config: true,
234
- resolveInputs: (parsed) => {
242
+ alias: { root: ['r'] },
243
+ resolveInputs: (parsed, { cwd }) => {
235
244
  const inputs = [];
236
245
  if (parsed['ui'])
237
246
  inputs.push(toDependency('@vitest/ui', { optional: true }));
238
247
  if (typeof parsed['coverage'] === 'object' && parsed['coverage'].provider) {
239
- inputs.push(toDependency(`@vitest/coverage-${parsed['coverage'].provider}`));
248
+ const { provider, customProviderModule } = parsed['coverage'];
249
+ inputs.push(...getCoverageInputs(provider, customProviderModule, toAbsolute(parsed['root'] ?? '.', cwd)));
240
250
  }
241
251
  else if (parsed['coverage']) {
242
252
  inputs.push(toDependency('@vitest/coverage-v8', { optional: true }));
@@ -16,6 +16,7 @@ interface VitestConfig {
16
16
  coverage?: {
17
17
  enabled?: boolean;
18
18
  provider: string;
19
+ customProviderModule?: string;
19
20
  };
20
21
  root?: string;
21
22
  dir?: string;
@@ -1,4 +1,4 @@
1
- export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\n --include Include provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved,catalog,catalogReferences\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --cycles Shortcut for --include cycles (circular dependencies)\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print total running time (zero overhead, no instrumentation)\n --trace Show trace output\n --trace-dependency [name] Show files that import the named dependency\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, catalogReferences, cycles\n(2) Fixable issue types: dependencies, exports, types, files, catalog\n(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions, sarif\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip --workspace @myorg/* --workspace '!@myorg/legacy'\n$ knip --workspace './apps/*' --workspace '@shared/utils'\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --reporter symbols --reporter json --output-file json=knip.json\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
1
+ export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\n --include Include provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved,catalog,catalogReferences\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --cycles Shortcut for --include cycles (circular dependencies)\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\n --preprocessor Preprocess the results before providing them to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print total running time (zero overhead, no instrumentation)\n --trace Show trace output\n --trace-dependency [name] Show files that import the named dependency\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, catalogReferences, cycles\n(2) Fixable issue types: dependencies, exports, types, files, catalog\n(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions, sarif\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip --workspace @myorg/* --workspace '!@myorg/legacy'\n$ knip --workspace './apps/*' --workspace '@shared/utils'\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --reporter symbols --reporter json --output-file json=knip.json\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
2
2
  export type ParsedCLIArgs = ReturnType<typeof parseCLIArgs>;
3
3
  export declare const parseNumericOption: (value: string | undefined, option: string) => number | undefined;
4
4
  export default function parseCLIArgs(): {
@@ -40,7 +40,7 @@ Fix
40
40
  -F, --format Format modified files after --fix using the local formatter
41
41
 
42
42
  Output
43
- --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated
43
+ --preprocessor Preprocess the results before providing them to the reporter(s), can be repeated
44
44
  --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)
45
45
  --reporter Select reporter (default: symbols), can be repeated (3)
46
46
  --reporter-options Pass extra options to the reporter (as JSON string, see example)
package/dist/util/jiti.js CHANGED
@@ -9,6 +9,7 @@ const options = {
9
9
  },
10
10
  tsconfigPaths: true,
11
11
  jsx: true,
12
+ extensions: ['.js', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts', '.mtsx', '.ctsx', '.jsx'],
12
13
  };
13
14
  const createLoader = (options) => createJiti(process.cwd(), options);
14
15
  export const jiti = createLoader(options);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.44.1";
1
+ export declare const version = "6.44.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.44.1';
1
+ export const version = '6.44.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.44.1",
3
+ "version": "6.44.2",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -84,7 +84,7 @@
84
84
  "formatly": "^0.11.4",
85
85
  "get-tsconfig": "4.14.3",
86
86
  "jiti": "^2.7.0",
87
- "oxc-parser": "^0.155.0",
87
+ "oxc-parser": "^0.156.0",
88
88
  "oxc-resolver": "11.24.2",
89
89
  "picomatch": "^4.0.7",
90
90
  "smol-toml": "^1.9.0",
@@ -96,13 +96,13 @@
96
96
  },
97
97
  "devDependencies": {
98
98
  "@jest/types": "^30.5.1",
99
- "@types/bun": "^1.4.3",
99
+ "@types/bun": "^1.4.4",
100
100
  "@types/picomatch": "^4.0.3",
101
101
  "codeclimate-types": "^0.3.1",
102
102
  "prettier": "^3.9.10",
103
103
  "tsx": "^4.23.15",
104
104
  "typescript": "7.0.2",
105
- "webpack": "^5.112.0"
105
+ "webpack": "^5.112.2"
106
106
  },
107
107
  "engines": {
108
108
  "node": "^20.19.0 || >=22.12.0"