knip 5.24.2 → 5.24.4
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/dist/plugins/angular/index.js +8 -0
- package/dist/plugins/jest/index.js +6 -5
- package/dist/plugins/vitest/index.js +5 -14
- package/dist/typescript/visitors/dynamic-imports/importCall.js +1 -1
- package/dist/util/plugin.d.ts +1 -1
- package/dist/util/plugin.js +11 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,14 @@ const resolveConfig = async (config, options) => {
|
|
|
23
23
|
if ('main' in opts && typeof opts.main === 'string') {
|
|
24
24
|
dependencies.add(toProductionEntryPattern(join(cwd, opts.main)));
|
|
25
25
|
}
|
|
26
|
+
if ('browser' in opts && typeof opts.browser === 'string') {
|
|
27
|
+
dependencies.add(toProductionEntryPattern(join(cwd, opts.browser)));
|
|
28
|
+
}
|
|
29
|
+
if ('ssr' in opts && opts.ssr && typeof opts.ssr === 'object') {
|
|
30
|
+
if ('entry' in opts.ssr && typeof opts.ssr.entry === 'string') {
|
|
31
|
+
dependencies.add(toProductionEntryPattern(join(cwd, opts.ssr.entry)));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, isInternal, join, toAbsolute } from '#p/util/path.js';
|
|
2
|
-
import { hasDependency, load } from '#p/util/plugin.js';
|
|
2
|
+
import { hasDependency, load, resolveEntry } from '#p/util/plugin.js';
|
|
3
3
|
import { toEntryPattern } from '#p/util/protocols.js';
|
|
4
4
|
const title = 'Jest';
|
|
5
5
|
const enablers = ['jest'];
|
|
@@ -49,8 +49,6 @@ const resolveDependencies = async (config, options) => {
|
|
|
49
49
|
.filter(reporter => !['default', 'github-actions', 'summary'].includes(reporter))
|
|
50
50
|
: [];
|
|
51
51
|
const watchPlugins = config.watchPlugins?.map(watchPlugin => (typeof watchPlugin === 'string' ? watchPlugin : watchPlugin[0])) ?? [];
|
|
52
|
-
const setupFiles = (config.setupFiles ?? []).map(toEntryPattern);
|
|
53
|
-
const setupFilesAfterEnv = (config.setupFilesAfterEnv ?? []).map(toEntryPattern);
|
|
54
52
|
const transform = config.transform
|
|
55
53
|
? Object.values(config.transform).map(transform => (typeof transform === 'string' ? transform : transform[0]))
|
|
56
54
|
: [];
|
|
@@ -60,8 +58,11 @@ const resolveDependencies = async (config, options) => {
|
|
|
60
58
|
const testResultsProcessor = config.testResultsProcessor ? [config.testResultsProcessor] : [];
|
|
61
59
|
const snapshotResolver = config.snapshotResolver ? [config.snapshotResolver] : [];
|
|
62
60
|
const testSequencer = config.testSequencer ? [config.testSequencer] : [];
|
|
63
|
-
const
|
|
64
|
-
const
|
|
61
|
+
const resolve = (specifier) => resolveEntry(options, specifier);
|
|
62
|
+
const setupFiles = (config.setupFiles ?? []).map(resolve);
|
|
63
|
+
const setupFilesAfterEnv = (config.setupFilesAfterEnv ?? []).map(resolve);
|
|
64
|
+
const globalSetup = (config.globalSetup ? [config.globalSetup] : []).map(resolve);
|
|
65
|
+
const globalTeardown = (config.globalTeardown ? [config.globalTeardown] : []).map(resolve);
|
|
65
66
|
return [
|
|
66
67
|
...presets,
|
|
67
68
|
...projects,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { hasDependency,
|
|
1
|
+
import { join } from '#p/util/path.js';
|
|
2
|
+
import { hasDependency, resolveEntry } from '#p/util/plugin.js';
|
|
3
3
|
import { toEntryPattern } from '#p/util/protocols.js';
|
|
4
4
|
import { getEnvPackageName, getExternalReporters } from './helpers.js';
|
|
5
5
|
const title = 'Vitest';
|
|
@@ -7,15 +7,6 @@ const enablers = ['vitest'];
|
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
8
|
const config = ['vitest*.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{ts,js,json}'];
|
|
9
9
|
const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)'];
|
|
10
|
-
const resolveEntry = (options, rootDir, specifier) => {
|
|
11
|
-
const { configFileDir, configFileName } = options;
|
|
12
|
-
const resolvedPath = isAbsolute(specifier)
|
|
13
|
-
? specifier
|
|
14
|
-
: tryResolve(join(configFileDir, rootDir, specifier), join(configFileDir, rootDir, configFileName));
|
|
15
|
-
if (resolvedPath)
|
|
16
|
-
return toEntryPattern(relative(configFileDir, resolvedPath));
|
|
17
|
-
return specifier;
|
|
18
|
-
};
|
|
19
10
|
const isVitestCoverageCommand = /vitest(.+)--coverage(?:\.enabled(?:=true)?)?/;
|
|
20
11
|
const hasScriptWithCoverage = (scripts) => scripts
|
|
21
12
|
? Object.values(scripts).some(script => {
|
|
@@ -32,8 +23,8 @@ const findConfigDependencies = (localConfig, options) => {
|
|
|
32
23
|
const hasCoverageEnabled = (testConfig.coverage && testConfig.coverage.enabled !== false) || hasScriptWithCoverage(manifest.scripts);
|
|
33
24
|
const coverage = hasCoverageEnabled ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
|
|
34
25
|
const rootDir = testConfig.root ?? '.';
|
|
35
|
-
const setupFiles = [testConfig.setupFiles ?? []].flat().map(
|
|
36
|
-
const globalSetup = [testConfig.globalSetup ?? []].flat().map(
|
|
26
|
+
const setupFiles = [testConfig.setupFiles ?? []].flat().map(specifier => resolveEntry(options, specifier, rootDir));
|
|
27
|
+
const globalSetup = [testConfig.globalSetup ?? []].flat().map(specifier => resolveEntry(options, specifier, rootDir));
|
|
37
28
|
return [...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup];
|
|
38
29
|
};
|
|
39
30
|
const getConfigs = async (localConfig) => {
|
|
@@ -79,7 +70,7 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
79
70
|
dependencies.add(dependency);
|
|
80
71
|
const entry = cfg.build?.lib?.entry ?? [];
|
|
81
72
|
const rootDir = cfg.test?.root ?? '.';
|
|
82
|
-
const deps = (typeof entry === 'string' ? [entry] : Object.values(entry)).map(specifier => resolveEntry(options,
|
|
73
|
+
const deps = (typeof entry === 'string' ? [entry] : Object.values(entry)).map(specifier => resolveEntry(options, specifier, rootDir));
|
|
83
74
|
for (const dependency of deps)
|
|
84
75
|
dependencies.add(dependency);
|
|
85
76
|
}
|
|
@@ -30,7 +30,7 @@ export default visit(() => true, node => {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
else if (ts.isObjectBindingPattern(arg.name)) {
|
|
33
|
+
else if (arg && ts.isObjectBindingPattern(arg.name)) {
|
|
34
34
|
return arg.name.elements.map(element => {
|
|
35
35
|
const identifier = (element.propertyName ?? element.name).getText();
|
|
36
36
|
const alias = element.propertyName ? element.name.getText() : undefined;
|
package/dist/util/plugin.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
2
2
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
3
|
export { _load as load } from './loader.js';
|
|
4
|
-
export { _tryResolve as tryResolve } from './require.js';
|
|
5
4
|
import type { RawPluginConfiguration } from '../types/config.js';
|
|
6
5
|
import type { Plugin, PluginOptions } from '../types/plugins.js';
|
|
7
6
|
export declare const toCamelCase: (name: string) => string;
|
|
@@ -37,3 +36,4 @@ export declare const toUnconfig: (moduleName: string, options?: {
|
|
|
37
36
|
configFilesAllExtensions?: boolean;
|
|
38
37
|
additionalExtensions?: string[];
|
|
39
38
|
}) => string[];
|
|
39
|
+
export declare const resolveEntry: (options: PluginOptions, specifier: string, rootDir?: string) => string;
|
package/dist/util/plugin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
2
2
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
3
|
export { _load as load } from './loader.js';
|
|
4
|
-
export { _tryResolve as tryResolve } from './require.js';
|
|
5
4
|
import { arrayify } from './array.js';
|
|
6
5
|
import { _load as load } from './loader.js';
|
|
7
6
|
import { get } from './object.js';
|
|
8
|
-
import { basename } from './path.js';
|
|
7
|
+
import { basename, isAbsolute, join, relative } from './path.js';
|
|
9
8
|
import { toEntryPattern, toProductionEntryPattern } from './protocols.js';
|
|
9
|
+
import { _tryResolve as tryResolve } from './require.js';
|
|
10
10
|
export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
|
|
11
11
|
export const hasDependency = (dependencies, values) => values.some(value => {
|
|
12
12
|
if (typeof value === 'string') {
|
|
@@ -89,3 +89,12 @@ export const toUnconfig = toConfigMap(['json', 'ts', 'mts', 'cts', 'js', 'mjs',
|
|
|
89
89
|
rcSuffix: '',
|
|
90
90
|
configFiles: false,
|
|
91
91
|
});
|
|
92
|
+
export const resolveEntry = (options, specifier, rootDir = '.') => {
|
|
93
|
+
const { configFileDir, configFileName } = options;
|
|
94
|
+
const resolvedPath = isAbsolute(specifier)
|
|
95
|
+
? specifier
|
|
96
|
+
: tryResolve(join(configFileDir, rootDir, specifier), join(configFileDir, rootDir, configFileName));
|
|
97
|
+
if (resolvedPath)
|
|
98
|
+
return toEntryPattern(relative(configFileDir, resolvedPath));
|
|
99
|
+
return specifier;
|
|
100
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.24.
|
|
1
|
+
export declare const version = "5.24.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.24.
|
|
1
|
+
export const version = '5.24.4';
|