knip 5.30.1 → 5.30.3

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/README.md CHANGED
@@ -42,6 +42,6 @@ Special thanks to the wonderful people who have contributed to this project:
42
42
  [4]: https://discord.gg/r5uXTtbTpc
43
43
  [5]: https://github.com/webpro-nl/knip/blob/main/.github/CONTRIBUTING.md
44
44
  [6]: https://knip.dev/sponsors
45
- [7]: https://en.wiktionary.org/wiki/knip#Dutch
45
+ [7]: https://www.youtube.com/watch?v=PE7h7KvQoUI&t=9s
46
46
  [8]: https://github.com/webpro-nl/knip/graphs/contributors
47
47
  [9]: https://contrib.rocks/image?repo=webpro-nl/knip
@@ -37,7 +37,7 @@ export declare class ConfigurationChief {
37
37
  manifest?: PackageJson;
38
38
  ignoredWorkspacePatterns: string[];
39
39
  workspacePackages: Map<string, Package>;
40
- workspacePackagesByName: Map<string, Package>;
40
+ workspacePackagesByPkgName: Map<string, Package>;
41
41
  additionalWorkspaceNames: Set<string>;
42
42
  availableWorkspaceNames: string[];
43
43
  availableWorkspacePkgNames: Set<string>;
@@ -54,7 +54,7 @@ export class ConfigurationChief {
54
54
  manifest;
55
55
  ignoredWorkspacePatterns = [];
56
56
  workspacePackages = new Map();
57
- workspacePackagesByName = new Map();
57
+ workspacePackagesByPkgName = new Map();
58
58
  additionalWorkspaceNames = new Set();
59
59
  availableWorkspaceNames = [];
60
60
  availableWorkspacePkgNames = new Set();
@@ -157,7 +157,7 @@ export class ConfigurationChief {
157
157
  const workspaceNames = compact([...this.getListedWorkspaces(), ...this.additionalWorkspaceNames]);
158
158
  const [byName, byPkgName] = await mapWorkspaces(this.cwd, workspaceNames);
159
159
  this.workspacePackages = byName;
160
- this.workspacePackagesByName = byPkgName;
160
+ this.workspacePackagesByPkgName = byPkgName;
161
161
  this.addRootPackage();
162
162
  this.availableWorkspaceNames = this.getAvailableWorkspaceNames(byName.keys());
163
163
  this.availableWorkspacePkgNames = this.getAvailableWorkspacePkgNames(byPkgName.keys());
@@ -178,14 +178,14 @@ export class ConfigurationChief {
178
178
  manifest: this.manifest,
179
179
  };
180
180
  this.workspacePackages.set('.', rootPackage);
181
- this.workspacePackagesByName.set(pkgName, rootPackage);
181
+ this.workspacePackagesByPkgName.set(pkgName, rootPackage);
182
182
  }
183
183
  }
184
184
  getListedWorkspaces() {
185
185
  const workspaces = this.manifest?.workspaces
186
186
  ? Array.isArray(this.manifest.workspaces)
187
187
  ? this.manifest.workspaces
188
- : this.manifest.workspaces.packages ?? []
188
+ : (this.manifest.workspaces.packages ?? [])
189
189
  : [];
190
190
  return workspaces.map(pattern => pattern.replace(/(?<=!?)\.\//, ''));
191
191
  }
@@ -2775,9 +2775,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2775
2775
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
2776
2776
  ignoreWorkspaces?: string[] | undefined;
2777
2777
  includeEntryExports?: boolean | undefined;
2778
- compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
2779
- syncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => string> | undefined;
2780
- asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>> | undefined;
2778
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
2779
+ syncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => string> | undefined;
2780
+ asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => Promise<string>> | undefined;
2781
2781
  astro?: string | boolean | string[] | {
2782
2782
  config?: string | string[] | undefined;
2783
2783
  entry?: string | string[] | undefined;
@@ -3552,9 +3552,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3552
3552
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
3553
3553
  ignoreWorkspaces?: string[] | undefined;
3554
3554
  includeEntryExports?: boolean | undefined;
3555
- compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
3556
- syncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => string> | undefined;
3557
- asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>> | undefined;
3555
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
3556
+ syncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => string> | undefined;
3557
+ asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => Promise<string>> | undefined;
3558
3558
  astro?: string | boolean | string[] | {
3559
3559
  config?: string | string[] | undefined;
3560
3560
  entry?: string | string[] | undefined;
@@ -65,8 +65,8 @@ export class IssueFixer {
65
65
  const filePaths = new Set([...this.unusedTypeNodes.keys(), ...this.unusedExportNodes.keys()]);
66
66
  for (const filePath of filePaths) {
67
67
  const exportPositions = [
68
- ...(this.isFixUnusedTypes ? this.unusedTypeNodes.get(filePath) ?? [] : []),
69
- ...(this.isFixUnusedExports ? this.unusedExportNodes.get(filePath) ?? [] : []),
68
+ ...(this.isFixUnusedTypes ? (this.unusedTypeNodes.get(filePath) ?? []) : []),
69
+ ...(this.isFixUnusedExports ? (this.unusedExportNodes.get(filePath) ?? []) : []),
70
70
  ].sort((a, b) => b[0] - a[0]);
71
71
  if (exportPositions.length > 0) {
72
72
  const sourceFileText = exportPositions.reduce((text, [start, end]) => text.substring(0, start) + text.substring(end), await readFile(filePath, 'utf-8'));
@@ -34,7 +34,7 @@ export declare class WorkspaceWorker {
34
34
  isStrict: boolean;
35
35
  rootIgnore: Configuration['ignore'];
36
36
  negatedWorkspacePatterns: string[];
37
- enabledPluginsMap: Record<"angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "preconstruct" | "prettier" | "reactCosmos" | "releaseIt" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vike" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie", boolean>;
37
+ enabledPluginsMap: Record<"astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "preconstruct" | "prettier" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vike" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "reactCosmos" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo", boolean>;
38
38
  enabledPlugins: PluginName[];
39
39
  enabledPluginsInAncestors: string[];
40
40
  cache: CacheConsultant<CacheItem>;
@@ -55,7 +55,7 @@ export declare class WorkspaceWorker {
55
55
  entryFilePatterns: Set<string>;
56
56
  productionEntryFilePatterns: Set<string>;
57
57
  referencedDependencies: ReferencedDependencies;
58
- enabledPlugins: ("angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "preconstruct" | "prettier" | "reactCosmos" | "releaseIt" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vike" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie")[];
58
+ enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "preconstruct" | "prettier" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vike" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "reactCosmos" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo")[];
59
59
  }>;
60
60
  onDispose(): void;
61
61
  }
@@ -17,7 +17,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
17
17
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
18
18
  ignoreWorkspaces?: string[] | undefined;
19
19
  includeEntryExports?: boolean | undefined;
20
- compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
20
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
21
21
  astro?: string | boolean | string[] | {
22
22
  config?: string | string[] | undefined;
23
23
  entry?: string | string[] | undefined;
package/dist/index.js CHANGED
@@ -16,7 +16,8 @@ import { _glob, negate } from './util/glob.js';
16
16
  import { getReferencedDependencyHandler } from './util/handle-dependency.js';
17
17
  import { getHasStrictlyNsReferences, getType } from './util/has-strictly-ns-references.js';
18
18
  import { getIsIdentifierReferencedHandler } from './util/is-identifier-referenced.js';
19
- import { getEntryPathsFromManifest, getPackageNameFromModuleSpecifier } from './util/modules.js';
19
+ import { getPackageNameFromModuleSpecifier } from './util/modules.js';
20
+ import { getEntryPathsFromManifest } from './util/package-json.js';
20
21
  import { dirname, join } from './util/path.js';
21
22
  import { findMatch } from './util/regex.js';
22
23
  import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from './util/tag.js';
@@ -1,7 +1,7 @@
1
1
  import { hasDependency } from '#p/util/plugin.js';
2
2
  import { getDependenciesDeep } from './helpers.js';
3
3
  const title = 'ESLint';
4
- const enablers = ['eslint'];
4
+ const enablers = ['eslint', '@eslint/js'];
5
5
  const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, enablers) ||
6
6
  'eslint' in config ||
7
7
  Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
@@ -5,7 +5,7 @@ import { getEnvPackageName, getExternalReporters } from './helpers.js';
5
5
  const title = 'Vitest';
6
6
  const enablers = ['vitest'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
- const config = ['vitest*.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{ts,js,json}'];
8
+ const config = ['vitest*.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{js,mjs,ts,cjs,mts,cts,json}'];
9
9
  const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)'];
10
10
  const isVitestCoverageCommand = /vitest(.+)--coverage(?:\.enabled(?:=true)?)?/;
11
11
  const hasScriptWithCoverage = (scripts) => scripts
@@ -3,7 +3,7 @@ import ts from 'typescript';
3
3
  import { ALIAS_TAG, ANONYMOUS, DEFAULT_EXTENSIONS, IMPORT_STAR } from '../constants.js';
4
4
  import { timerify } from '../util/Performance.js';
5
5
  import { addNsValue, addValue, createImports } from '../util/dependency-graph.js';
6
- import { isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
6
+ import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
7
7
  import { extname, isInNodeModules } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
9
9
  import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isReferencedInExportedType, } from './ast-helpers.js';
@@ -102,7 +102,9 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
102
102
  if (module.isExternalLibraryImport) {
103
103
  if (skipTypeOnly && isTypeOnly)
104
104
  return;
105
- const sanitizedSpecifier = sanitizeSpecifier(specifier);
105
+ const sanitizedSpecifier = isInNodeModules(specifier)
106
+ ? getPackageNameFromFilePath(specifier)
107
+ : sanitizeSpecifier(specifier);
106
108
  if (!isStartsLikePackageName(sanitizedSpecifier)) {
107
109
  return;
108
110
  }
@@ -55,7 +55,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
55
55
  }
56
56
  function resolveModuleName(name, containingFile) {
57
57
  const sanitizedSpecifier = sanitizeSpecifier(name);
58
- if (isBuiltin(sanitizedSpecifier) || isInNodeModules(name))
58
+ if (isBuiltin(sanitizedSpecifier))
59
59
  return undefined;
60
60
  const resolvedFileName = resolveSync(sanitizedSpecifier, dirname(containingFile));
61
61
  if (resolvedFileName) {
@@ -39,10 +39,17 @@ export const getReferencedDependencyHandler = (collector, deputy, chief) => (spe
39
39
  symbol: specifier,
40
40
  });
41
41
  if (packageName && specifier !== packageName) {
42
- if (chief.workspacePackagesByName.get(packageName)) {
43
- const filePath = _resolveSync(specifier, dirname(containingFilePath));
44
- if (filePath)
45
- return filePath;
42
+ const specifierWorkspace = chief.workspacePackagesByPkgName.get(packageName);
43
+ if (specifierWorkspace) {
44
+ if (specifier.startsWith(packageName)) {
45
+ const dir = specifier.replace(new RegExp(`^${packageName}`), `./${specifierWorkspace.name}`);
46
+ const resolvedFilePath = _resolveSync(dir, chief.cwd);
47
+ if (resolvedFilePath)
48
+ return resolvedFilePath;
49
+ }
50
+ const resolvedFilePath = _resolveSync(specifier, dirname(containingFilePath));
51
+ if (resolvedFilePath)
52
+ return resolvedFilePath;
46
53
  collector.addIssue({
47
54
  type: 'unresolved',
48
55
  filePath: containingFilePath,
@@ -1,14 +1,7 @@
1
- import type { PackageJson } from '../types/package-json.js';
2
1
  export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => string | undefined;
3
2
  export declare const getPackageNameFromFilePath: (value: string) => string;
4
3
  export declare const isStartsLikePackageName: (specifier: string) => boolean;
5
4
  export declare const isDefinitelyTyped: (packageName: string) => boolean;
6
5
  export declare const getDefinitelyTypedFor: (packageName: string) => string;
7
6
  export declare const getPackageFromDefinitelyTyped: (typedDependency: string) => string;
8
- export declare const getEntryPathsFromManifest: (manifest: PackageJson, sharedGlobOptions: {
9
- cwd: string;
10
- dir: string;
11
- gitignore: boolean;
12
- ignore: string[];
13
- }) => Promise<string[]>;
14
7
  export declare const sanitizeSpecifier: (specifier: string) => string;
@@ -1,7 +1,5 @@
1
1
  import { isBuiltin } from 'node:module';
2
2
  import { DT_SCOPE } from '../constants.js';
3
- import { _glob } from './glob.js';
4
- import { getStringValues } from './object.js';
5
3
  import { isAbsolute, toPosix } from './path.js';
6
4
  export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
7
5
  if (!isStartsLikePackageName(moduleSpecifier))
@@ -32,28 +30,6 @@ export const getPackageFromDefinitelyTyped = (typedDependency) => {
32
30
  }
33
31
  return typedDependency;
34
32
  };
35
- export const getEntryPathsFromManifest = (manifest, sharedGlobOptions) => {
36
- const { main, bin, exports, types, typings } = manifest;
37
- const entryPaths = new Set();
38
- if (typeof main === 'string')
39
- entryPaths.add(main);
40
- if (bin) {
41
- if (typeof bin === 'string')
42
- entryPaths.add(bin);
43
- if (typeof bin === 'object')
44
- for (const id of Object.values(bin))
45
- entryPaths.add(id);
46
- }
47
- if (exports) {
48
- for (const item of getStringValues(exports))
49
- entryPaths.add(item);
50
- }
51
- if (typeof types === 'string')
52
- entryPaths.add(types);
53
- if (typeof typings === 'string')
54
- entryPaths.add(typings);
55
- return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
56
- };
57
33
  const matchDirectives = /^([?!|-]+)?([^!?:]+).*/;
58
34
  export const sanitizeSpecifier = (specifier) => {
59
35
  if (isBuiltin(specifier))
@@ -7,4 +7,10 @@ interface ExtendedPackageJson extends PackageJson {
7
7
  }
8
8
  export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
9
9
  export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
10
+ export declare const getEntryPathsFromManifest: (manifest: PackageJson, sharedGlobOptions: {
11
+ cwd: string;
12
+ dir: string;
13
+ gitignore: boolean;
14
+ ignore: string[];
15
+ }) => Promise<string[]>;
10
16
  export {};
@@ -1,4 +1,6 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
+ import { _glob } from './glob.js';
3
+ import { getStringValues } from './object.js';
2
4
  const INDENT = Symbol.for('indent');
3
5
  const NEWLINE = Symbol.for('newline');
4
6
  const DEFAULT_NEWLINE = '\n';
@@ -28,3 +30,25 @@ export const save = async (filePath, content) => {
28
30
  const fileContent = `${JSON.stringify(content, null, space)}\n`.replace(/\n/g, EOL);
29
31
  await writeFile(filePath, fileContent);
30
32
  };
33
+ export const getEntryPathsFromManifest = (manifest, sharedGlobOptions) => {
34
+ const { main, bin, exports, types, typings } = manifest;
35
+ const entryPaths = new Set();
36
+ if (typeof main === 'string')
37
+ entryPaths.add(main);
38
+ if (bin) {
39
+ if (typeof bin === 'string')
40
+ entryPaths.add(bin);
41
+ if (typeof bin === 'object')
42
+ for (const id of Object.values(bin))
43
+ entryPaths.add(id);
44
+ }
45
+ if (exports) {
46
+ for (const item of getStringValues(exports))
47
+ entryPaths.add(item);
48
+ }
49
+ if (typeof types === 'string')
50
+ entryPaths.add(types);
51
+ if (typeof typings === 'string')
52
+ entryPaths.add(typings);
53
+ return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
54
+ };
@@ -1,6 +1,6 @@
1
1
  import { basename, dirname } from './path.js';
2
- const getName2 = (parent, base) => (parent.charAt(0) === '@' ? `${parent}/${base}` : base);
3
- const getName = (dir) => (dir ? getName2(basename(dirname(dir)), basename(dir)) : undefined);
2
+ const getPkgName = (parent, base) => (parent.charAt(0) === '@' ? `${parent}/${base}` : base);
3
+ const getName = (dir) => (dir ? getPkgName(basename(dirname(dir)), basename(dir)) : undefined);
4
4
  export function getPackageName(pkg, pathname) {
5
5
  const { name } = pkg;
6
6
  return name || getName(pathname);
@@ -9,7 +9,7 @@ const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
9
9
  const matchExt = /(\.d)?\.(m|c)?(j|t)s$/;
10
10
  export const augmentWorkspace = (workspace, dir, compilerOptions) => {
11
11
  const srcDir = join(dir, 'src');
12
- workspace.srcDir = compilerOptions.rootDir ?? isDirectory(srcDir) ? srcDir : dir;
12
+ workspace.srcDir = (compilerOptions.rootDir ?? isDirectory(srcDir)) ? srcDir : dir;
13
13
  workspace.outDir = compilerOptions.outDir || workspace.srcDir;
14
14
  };
15
15
  export const getToSourcePathHandler = (chief) => {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.30.1";
1
+ export declare const version = "5.30.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.30.1';
1
+ export const version = '5.30.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.30.1",
3
+ "version": "5.30.3",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -72,7 +72,7 @@
72
72
  "picocolors": "^1.0.0",
73
73
  "picomatch": "^4.0.1",
74
74
  "pretty-ms": "^9.0.0",
75
- "smol-toml": "^1.1.4",
75
+ "smol-toml": "^1.3.0",
76
76
  "strip-json-comments": "5.0.1",
77
77
  "summary": "2.1.0",
78
78
  "zod": "^3.22.4",
@@ -85,14 +85,14 @@
85
85
  "devDependencies": {
86
86
  "@jest/types": "^29.6.3",
87
87
  "@release-it/bumper": "^6.0.1",
88
- "@types/bun": "^1.1.6",
88
+ "@types/bun": "^1.1.10",
89
89
  "@types/js-yaml": "^4.0.9",
90
90
  "@types/minimist": "^1.2.5",
91
- "@types/picomatch": "2.3.4",
91
+ "@types/picomatch": "3.0.1",
92
92
  "@types/webpack": "^5.28.5",
93
- "@wdio/types": "^8.39.0",
93
+ "@wdio/types": "^9.0.8",
94
94
  "glob": "^10.4.2",
95
- "release-it": "^17.4.1",
95
+ "release-it": "^17.6.0",
96
96
  "type-fest": "^4.20.0",
97
97
  "typescript": "^5.5.2"
98
98
  },