knip 2.19.0 → 2.19.1
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/ava/index.d.ts +1 -0
- package/dist/plugins/ava/index.js +1 -0
- package/dist/plugins/eslint/helpers.d.ts +2 -1
- package/dist/plugins/eslint/helpers.js +21 -21
- package/dist/plugins/jest/index.d.ts +1 -0
- package/dist/plugins/jest/index.js +1 -0
- package/dist/plugins/typescript/index.js +6 -4
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -3,4 +3,5 @@ export declare const NAME = "Ava";
|
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: never[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -5,6 +5,7 @@ export const NAME = 'Ava';
|
|
|
5
5
|
export const ENABLERS = ['ava'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['ava.config.{js,cjs,mjs}', 'package.json'];
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = [];
|
|
8
9
|
const findAvaDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
9
10
|
const config = configFilePath.endsWith('package.json') ? manifest.ava : await load(configFilePath);
|
|
10
11
|
const requireArgs = (config?.require ?? []).map(require => `--require ${require}`);
|
|
@@ -9,5 +9,6 @@ type GetDependenciesDeep = (configFilePath: string, dependencies: Set<string>, o
|
|
|
9
9
|
manifest: Manifest;
|
|
10
10
|
}) => Promise<Set<string>>;
|
|
11
11
|
export declare const getDependenciesDeep: GetDependenciesDeep;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const resolvePluginSpecifier: (specifier: string) => string;
|
|
13
|
+
export declare const resolveExtendSpecifier: (specifier: string) => string | undefined;
|
|
13
14
|
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
3
2
|
import { isInternal, dirname, toAbsolute } from '../../util/path.js';
|
|
4
3
|
import { load } from '../../util/plugin.js';
|
|
5
4
|
import { _resolve } from '../../util/require.js';
|
|
6
5
|
import { fallback } from './fallback.js';
|
|
7
6
|
const getDependencies = (config) => {
|
|
8
|
-
const extendsSpecifiers = config.extends ? [config.extends].flat().map(
|
|
7
|
+
const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendSpecifier) : [];
|
|
9
8
|
if (extendsSpecifiers.includes('eslint-plugin-prettier'))
|
|
10
9
|
extendsSpecifiers.push('eslint-config-prettier');
|
|
11
|
-
const plugins = config.plugins ? config.plugins.map(
|
|
10
|
+
const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
|
|
12
11
|
const parser = config.parser;
|
|
13
12
|
const extraPlugins = config.parserOptions?.babelOptions?.plugins ?? [];
|
|
14
13
|
const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
|
|
@@ -46,28 +45,29 @@ export const getDependenciesDeep = async (configFilePath, dependencies = new Set
|
|
|
46
45
|
}
|
|
47
46
|
return dependencies;
|
|
48
47
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
const isQualifiedSpecifier = (specifier) => specifier === 'eslint' ||
|
|
49
|
+
/\/eslint-(config|plugin)$/.test(specifier) ||
|
|
50
|
+
/.+eslint-(config|plugin)\//.test(specifier) ||
|
|
51
|
+
/eslint-(config|plugin)-/.test(specifier);
|
|
52
|
+
const resolveSpecifier = (namespace, rawSpecifier) => {
|
|
53
|
+
const specifier = rawSpecifier.replace(/(^plugin:|:.+$)/, '');
|
|
54
|
+
if (isQualifiedSpecifier(specifier))
|
|
55
|
+
return specifier;
|
|
56
|
+
if (!specifier.startsWith('@'))
|
|
57
|
+
return `${namespace}-${specifier}`;
|
|
58
|
+
const [scope, name, ...rest] = specifier.split('/');
|
|
59
|
+
if (rawSpecifier.startsWith('plugin:') && rest.length === 0)
|
|
60
|
+
return [scope, namespace, name].join('/');
|
|
61
|
+
return [scope, name ? `${namespace}-${name}` : namespace, ...rest].join('/');
|
|
57
62
|
};
|
|
58
|
-
const
|
|
59
|
-
export const
|
|
63
|
+
export const resolvePluginSpecifier = (specifier) => resolveSpecifier('eslint-plugin', specifier);
|
|
64
|
+
export const resolveExtendSpecifier = (specifier) => {
|
|
60
65
|
if (isInternal(specifier))
|
|
61
66
|
return;
|
|
62
|
-
if (
|
|
67
|
+
if (/^next(\/.+)?$/.test(specifier))
|
|
63
68
|
return specifier;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
return '@typescript-eslint/eslint-plugin';
|
|
67
|
-
if (noProtocolSpecifier === 'eslint')
|
|
68
|
-
return;
|
|
69
|
-
const packageName = getPackageNameFromModuleSpecifier(noProtocolSpecifier) ?? noProtocolSpecifier;
|
|
70
|
-
return resolvePackageName(specifier.startsWith('plugin:') ? 'eslint-plugin' : 'eslint-config', packageName);
|
|
69
|
+
const namespace = specifier.startsWith('plugin:') ? 'eslint-plugin' : 'eslint-config';
|
|
70
|
+
return resolveSpecifier(namespace, specifier);
|
|
71
71
|
};
|
|
72
72
|
const getDependenciesFromSettings = (settings = {}) => {
|
|
73
73
|
return compact(Object.entries(settings).flatMap(([settingKey, settings]) => {
|
|
@@ -3,4 +3,5 @@ export declare const NAME = "Jest";
|
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: never[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -5,6 +5,7 @@ export const NAME = 'Jest';
|
|
|
5
5
|
export const ENABLERS = ['jest'];
|
|
6
6
|
export const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, ENABLERS) || Boolean(manifest.name?.startsWith('jest-presets'));
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}', 'package.json'];
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = [];
|
|
8
9
|
const resolveExtensibleConfig = async (configFilePath) => {
|
|
9
10
|
const config = await load(configFilePath);
|
|
10
11
|
if (config?.preset) {
|
|
@@ -9,10 +9,12 @@ export const CONFIG_FILE_PATTERNS = ['tsconfig.json'];
|
|
|
9
9
|
const resolveExtensibleConfig = async (configFilePath) => {
|
|
10
10
|
const config = await load(configFilePath);
|
|
11
11
|
if (config?.extends) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
for (const extend of [config.extends].flat()) {
|
|
13
|
+
if (isInternal(extend)) {
|
|
14
|
+
const presetConfigPath = toAbsolute(extend, dirname(configFilePath));
|
|
15
|
+
const presetConfig = await resolveExtensibleConfig(presetConfigPath);
|
|
16
|
+
Object.assign(config, presetConfig);
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
return config;
|
|
@@ -2,6 +2,6 @@ import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types
|
|
|
2
2
|
export declare const NAME = "Vitest";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
-
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
7
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -5,8 +5,8 @@ import { getEnvPackageName, getExternalReporters } from './helpers.js';
|
|
|
5
5
|
export const NAME = 'Vitest';
|
|
6
6
|
export const ENABLERS = ['vitest'];
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
|
-
export const ENTRY_FILE_PATTERNS = ['vite.config.ts'];
|
|
9
8
|
export const CONFIG_FILE_PATTERNS = ['vitest.config.ts'];
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = ['vite.config.ts'];
|
|
10
10
|
const findVitestDependencies = async (configFilePath) => {
|
|
11
11
|
const config = await load(configFilePath);
|
|
12
12
|
if (!config || !config.test)
|
|
@@ -14,7 +14,7 @@ const findVitestDependencies = async (configFilePath) => {
|
|
|
14
14
|
const cfg = config.test;
|
|
15
15
|
const environments = cfg.environment ? [getEnvPackageName(cfg.environment)] : [];
|
|
16
16
|
const reporters = getExternalReporters(cfg.reporters);
|
|
17
|
-
const coverage = cfg.coverage ? [`@vitest/coverage-${cfg.coverage.provider ??
|
|
17
|
+
const coverage = cfg.coverage ? [`@vitest/coverage-${cfg.coverage.provider ?? 'v8'}`] : [];
|
|
18
18
|
const setupFiles = cfg.setupFiles ? [cfg.setupFiles].flat() : [];
|
|
19
19
|
const globalSetup = cfg.globalSetup ? [cfg.globalSetup].flat() : [];
|
|
20
20
|
return compact([...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup]);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.19.
|
|
1
|
+
export declare const version = "2.19.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.19.
|
|
1
|
+
export const version = '2.19.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.1",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"@npmcli/package-json": "4.0.1",
|
|
66
66
|
"@release-it/bumper": "5.1.0",
|
|
67
67
|
"@swc/cli": "0.1.62",
|
|
68
|
-
"@swc/core": "1.3.
|
|
68
|
+
"@swc/core": "1.3.75",
|
|
69
69
|
"@types/eslint": "8.44.2",
|
|
70
70
|
"@types/js-yaml": "4.0.5",
|
|
71
71
|
"@types/micromatch": "4.0.2",
|
|
72
72
|
"@types/minimist": "1.2.2",
|
|
73
|
-
"@types/node": "20.4.
|
|
73
|
+
"@types/node": "20.4.8",
|
|
74
74
|
"@types/npmcli__map-workspaces": "3.0.1",
|
|
75
75
|
"@types/webpack": "5.28.1",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
77
|
-
"@typescript-eslint/parser": "6.
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "6.3.0",
|
|
77
|
+
"@typescript-eslint/parser": "6.3.0",
|
|
78
78
|
"c8": "8.0.1",
|
|
79
79
|
"eslint": "8.46.0",
|
|
80
80
|
"eslint-import-resolver-typescript": "3.5.5",
|