knip 2.23.0 → 2.24.0

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,6 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Vite";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
- export declare const ENTRY_FILE_PATTERNS: string[];
5
+ export declare const CONFIG_FILE_PATTERNS: string[];
6
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,5 +1,12 @@
1
- import { hasDependency } from '../../util/plugin.js';
1
+ import { timerify } from '../../util/Performance.js';
2
+ import { hasDependency, load } from '../../util/plugin.js';
3
+ import { findVitestDeps } from '../vitest/index.js';
2
4
  export const NAME = 'Vite';
3
5
  export const ENABLERS = ['vite'];
4
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- export const ENTRY_FILE_PATTERNS = ['vite.config.{js,ts}'];
7
+ export const CONFIG_FILE_PATTERNS = ['vite.config.{js,ts}'];
8
+ const findViteDependencies = async (configFilePath) => {
9
+ const config = await load(configFilePath);
10
+ return findVitestDeps(config);
11
+ };
12
+ export const findDependencies = timerify(findViteDependencies);
@@ -0,0 +1,4 @@
1
+ import type { VitestConfig } from '../vitest/types.js';
2
+ export interface ViteConfig extends VitestConfig {
3
+ plugins: unknown[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,9 @@
1
+ import type { VitestConfig } from './types.js';
1
2
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
3
  export declare const NAME = "Vitest";
3
4
  export declare const ENABLERS: string[];
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const ENTRY_FILE_PATTERNS: string[];
7
+ export declare const ENTRY_FILE_PATTERNS: never[];
8
+ export declare const findVitestDeps: (config: VitestConfig) => any[];
7
9
  export declare const findDependencies: GenericPluginCallback;
@@ -6,9 +6,8 @@ export const NAME = 'Vitest';
6
6
  export const ENABLERS = ['vitest'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = ['vitest.config.ts'];
9
- export const ENTRY_FILE_PATTERNS = ['vite.config.ts'];
10
- const findVitestDependencies = async (configFilePath) => {
11
- const config = await load(configFilePath);
9
+ export const ENTRY_FILE_PATTERNS = [];
10
+ export const findVitestDeps = (config) => {
12
11
  if (!config || !config.test)
13
12
  return [];
14
13
  const cfg = config.test;
@@ -19,4 +18,8 @@ const findVitestDependencies = async (configFilePath) => {
19
18
  const globalSetup = cfg.globalSetup ? [cfg.globalSetup].flat() : [];
20
19
  return compact([...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup]);
21
20
  };
21
+ const findVitestDependencies = async (configFilePath) => {
22
+ const config = await load(configFilePath);
23
+ return findVitestDeps(config);
24
+ };
22
25
  export const findDependencies = timerify(findVitestDependencies);
@@ -1,4 +1,4 @@
1
- export type VitestConfig = {
1
+ export interface VitestConfig {
2
2
  test: {
3
3
  coverage?: {
4
4
  provider: string;
@@ -8,4 +8,4 @@ export type VitestConfig = {
8
8
  reporters?: (string | unknown)[];
9
9
  setupFiles?: string | string[];
10
10
  };
11
- };
11
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.23.0";
1
+ export declare const version = "2.24.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.23.0';
1
+ export const version = '2.24.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
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",