checkForMatchCompatibility = (
  /** @type {PathFromSystemRoot} */ referencePath,
  /** @type {PathFromSystemRoot} */ targetPath,
) => {
  const referencePkg = InputDataService.getPackageJson(referencePath);
  const targetPkg = InputDataService.getPackageJson(targetPath);

  const allTargetDeps = [
    ...Object.entries(targetPkg?.devDependencies || {}),
    ...Object.entries(targetPkg?.dependencies || {}),
  ];

  const importEntry = allTargetDeps.find(([name]) => referencePkg?.name === name);
  if (!importEntry) {
    return { compatible: false, reason: 'no-dependency' };
  }
  if (referencePkg?.version && !semver.satisfies(referencePkg.version, importEntry[1])) {
    return { compatible: false, reason: 'no-matched-version' };
  }
  return { compatible: true };
}
Before running the analyzer, we need two conditions for a 'compatible match':
- 1. referenceProject is imported by targetProject at all
- 2. referenceProject and targetProject have compatible major versions
@typedef {(referencePath:PathFromSystemRoot,targetPath:PathFromSystemRoot) => {compatible:boolean; reason?:string}} CheckForMatchCompatibilityFn
@type {CheckForMatchCompatibilityFn}