knip 5.24.3 → 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.
@@ -32,7 +32,7 @@ export declare class WorkspaceWorker {
32
32
  isStrict: boolean;
33
33
  rootIgnore: Configuration['ignore'];
34
34
  negatedWorkspacePatterns: string[];
35
- enabledPluginsMap: Record<"astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo", boolean>;
35
+ enabledPluginsMap: Record<"angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie", boolean>;
36
36
  enabledPlugins: PluginName[];
37
37
  enabledPluginsInAncestors: string[];
38
38
  cache: CacheConsultant<CacheItem>;
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
52
52
  entryFilePatterns: Set<string>;
53
53
  productionEntryFilePatterns: Set<string>;
54
54
  referencedDependencies: ReferencedDependencies;
55
- enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo")[];
55
+ enabledPlugins: ("angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie")[];
56
56
  }>;
57
57
  onDispose(): void;
58
58
  }
@@ -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 globalSetup = (config.globalSetup ? [config.globalSetup] : []).map(toEntryPattern);
64
- const globalTeardown = (config.globalTeardown ? [config.globalTeardown] : []).map(toEntryPattern);
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 { isAbsolute, join, relative } from '#p/util/path.js';
2
- import { hasDependency, tryResolve } from '#p/util/plugin.js';
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(v => resolveEntry(options, rootDir, v));
36
- const globalSetup = [testConfig.globalSetup ?? []].flat().map(v => resolveEntry(options, rootDir, v));
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, rootDir, specifier));
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
  }
@@ -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;
@@ -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.3";
1
+ export declare const version = "5.24.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.24.3';
1
+ export const version = '5.24.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.24.3",
3
+ "version": "5.24.4",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {