knip 5.36.1 → 5.36.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.
@@ -7,7 +7,7 @@ import { debugLogArray, debugLogObject } from './util/debug.js';
7
7
  import { _glob, hasNoProductionSuffix, hasProductionSuffix, negate, prependDirToPattern } from './util/glob.js';
8
8
  import { isConfigPattern, toDebugString, toEntry } from './util/input.js';
9
9
  import { getKeysByValue } from './util/object.js';
10
- import { basename, dirname, join } from './util/path.js';
10
+ import { basename, dirname, extname, join } from './util/path.js';
11
11
  import { getFinalEntryPaths, loadConfigForPlugin } from './util/plugin.js';
12
12
  const nullConfig = { config: null, entry: null, project: null };
13
13
  const initEnabledPluginsMap = () => Object.keys(Plugins).reduce((enabled, pluginName) => ({ ...enabled, [pluginName]: false }), {});
@@ -183,7 +183,8 @@ export class WorkspaceWorker {
183
183
  if (!configFiles.has(pluginName))
184
184
  configFiles.set(pluginName, new Set());
185
185
  configFiles.get(pluginName)?.add(configFilePath);
186
- addInput(toEntry(dependency.specifier), dependency.containingFilePath);
186
+ if (extname(dependency.specifier) !== '.json')
187
+ addInput(toEntry(dependency.specifier), dependency.containingFilePath);
187
188
  }
188
189
  };
189
190
  for (const input of [...inputsFromManifest, ...productionInputsFromManifest]) {
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ export const main = async (unresolvedConfiguration) => {
51
51
  const isReportTypes = report.types || report.nsTypes || report.enumMembers;
52
52
  const isReportClassMembers = report.classMembers;
53
53
  const isSkipLibs = !(isIncludeLibs || isReportClassMembers);
54
+ const isShowConfigHints = !workspace && !isProduction && !isHideConfigHints;
54
55
  const collector = new IssueCollector({ cwd, rules, filters });
55
56
  const allConfigFilePaths = new Set();
56
57
  const enabledPluginsStore = new Map();
@@ -491,15 +492,17 @@ export const main = async (unresolvedConfiguration) => {
491
492
  for (const issue of optionalPeerDependencyIssues)
492
493
  collector.addIssue(issue);
493
494
  deputy.removeIgnoredIssues(collector.getIssues());
494
- if (!workspace && !isProduction && !isHideConfigHints) {
495
+ if (isShowConfigHints) {
495
496
  const configurationHints = deputy.getConfigurationHints();
496
497
  for (const hint of configurationHints)
497
498
  collector.addConfigurationHint(hint);
498
499
  }
499
500
  }
500
- const unusedIgnoredWorkspaces = chief.getUnusedIgnoredWorkspaces();
501
- for (const identifier of unusedIgnoredWorkspaces) {
502
- collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
501
+ if (isShowConfigHints) {
502
+ const unusedIgnoredWorkspaces = chief.getUnusedIgnoredWorkspaces();
503
+ for (const identifier of unusedIgnoredWorkspaces) {
504
+ collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
505
+ }
503
506
  }
504
507
  };
505
508
  await collectUnusedExports();
@@ -41,6 +41,7 @@ const resolveDependencies = async (config, options) => {
41
41
  }
42
42
  }
43
43
  const runner = config.runner ? [config.runner] : [];
44
+ const runtime = config.runtime && config.runtime !== 'jest-circus' ? [config.runtime] : [];
44
45
  const environments = config.testEnvironment === 'jsdom' ? ['jest-environment-jsdom'] : [];
45
46
  const resolvers = config.resolver ? [config.resolver] : [];
46
47
  const reporters = config.reporters
@@ -67,6 +68,7 @@ const resolveDependencies = async (config, options) => {
67
68
  ...presets,
68
69
  ...projects,
69
70
  ...runner,
71
+ ...runtime,
70
72
  ...environments,
71
73
  ...resolvers,
72
74
  ...reporters,
@@ -5,14 +5,17 @@ import { fromBinary, isBinary, isConfigPattern, isDeferResolveEntry, isDependenc
5
5
  import { getPackageNameFromSpecifier } from './modules.js';
6
6
  import { dirname, isAbsolute, isInternal, join } from './path.js';
7
7
  import { _resolveSync } from './resolve.js';
8
+ const getWorkspaceFor = (input, chief, workspace) => (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) ||
9
+ (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) ||
10
+ workspace;
8
11
  export const getReferencedInputsHandler = (collector, deputy, chief, isGitIgnored) => (input, workspace) => {
9
12
  const { specifier, containingFilePath } = input;
10
13
  if (!containingFilePath || IGNORED_RUNTIME_DEPENDENCIES.has(specifier))
11
14
  return;
12
15
  if (isBinary(input)) {
13
16
  const binaryName = fromBinary(input);
14
- const ws = (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) || workspace;
15
- const isHandled = deputy.maybeAddReferencedBinary(ws, binaryName);
17
+ const inputWorkspace = getWorkspaceFor(input, chief, workspace);
18
+ const isHandled = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName);
16
19
  if (isHandled)
17
20
  return;
18
21
  collector.addIssue({
@@ -27,16 +30,16 @@ export const getReferencedInputsHandler = (collector, deputy, chief, isGitIgnore
27
30
  const packageName = getPackageNameFromSpecifier(specifier);
28
31
  if (packageName) {
29
32
  const isWorkspace = chief.workspacesByPkgName.has(packageName);
30
- const specifierWorkspace = chief.findWorkspaceByFilePath(containingFilePath) ?? workspace;
31
- if (specifierWorkspace) {
32
- const isHandled = deputy.maybeAddReferencedExternalDependency(specifierWorkspace, packageName);
33
+ const inputWorkspace = getWorkspaceFor(input, chief, workspace);
34
+ if (inputWorkspace) {
35
+ const isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName);
33
36
  if (isWorkspace || isDependency(input)) {
34
37
  if (!isHandled) {
35
38
  if ((deputy.isProduction && input.production) || !deputy.isProduction) {
36
39
  collector.addIssue({
37
40
  type: 'unlisted',
38
41
  filePath: containingFilePath,
39
- workspace: specifierWorkspace.name,
42
+ workspace: inputWorkspace.name,
40
43
  symbol: packageName ?? specifier,
41
44
  specifier,
42
45
  });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.36.1";
1
+ export declare const version = "5.36.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.36.1';
1
+ export const version = '5.36.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.36.1",
3
+ "version": "5.36.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": {