message: Reorder checkDependencies code for better locality
  Move the loop that prepares the `versions` data structure right above
  where it is used.
diff: @@ -26,6 +26,20 @@ function printHighlight(msg) {
  print(`${BOLD}${YELLOW}${msg}${RESET}`);
  }
  +let unhoistedCount = 0;
  +otherPackages.forEach(pkg => {
  + if (pkg.devDependencies) {
  + unhoistedCount++;
  + const message = `Package ${pkg.name} has devDependencies which should be ` +
  + 'hoisted into the top-level package.json:';
  + printHighlight(message);
  + Object.keys(pkg.devDependencies).forEach(devDependency => {
  + print(` ${devDependency}`);
  + });
  + print('');
  + }
  +});
  +
  const versions = {};
  [mainPackage, ...otherPackages].forEach(pkg => {
  const dependencies = pkg.dependencies;
  @@ -43,20 +57,6 @@ const versions = {};
  }
  });
  -let unhoistedCount = 0;
  -otherPackages.forEach(pkg => {
  - if (pkg.devDependencies) {
  - unhoistedCount++;
  - const message = `Package ${pkg.name} has devDependencies which should be ` +
  - 'hoisted into the top-level package.json:';
  - printHighlight(message);
  - Object.keys(pkg.devDependencies).forEach(devDependency => {
  - print(` ${devDependency}`);
  - });
  - print('');
  - }
  -});
  -
  let conflictCount = 0;
  Object.keys(versions).forEach(pkg => {
  versionRanges = Object.keys(versions[pkg]);
  