<commit_before>import * as fs from "fs";

/**
 * Typing for the fields of package.json we care about
 */
export interface PackageJson {
  readonly main: string;
}

export interface ReadPackageJson {
  (file: string): PackageJson | undefined;
}

/**
 * @param  packageJsonPath Path to package.json
 * @param  loadPackageJson Function that reads and parses package.json.
 * @param  fileExists Function that checks for existance of a file.
 * @returns string
 */
export function readPackage(
  packageJsonPath: string,
  // tslint:disable-next-line:no-any
  loadPackageJson: ReadPackageJson = loadJsonFromDisk,
  fileExists: (path: string) => boolean = fs.existsSync
): PackageJson | undefined {
  return (
    (packageJsonPath.match(/package\.json$/) &&
      fileExists(packageJsonPath) &&
      loadPackageJson(packageJsonPath)) ||
    undefined
  );
}

function loadJsonFromDisk(file: string): PackageJson {
  // tslint:disable-next-line:no-require-imports
  const packageJson = require(file);

  return packageJson;
}<commit_msg>Remove lint override<commit_after>import * as fs from "fs";

/**
 * Typing for the fields of package.json we care about
 */
export interface PackageJson {
  readonly main: string;
}

export interface ReadPackageJson {
  (file: string): PackageJson | undefined;
}

/**
 * @param  packageJsonPath Path to package.json
 * @param  loadPackageJson Function that reads and parses package.json.
 * @param  fileExists Function that checks for existance of a file.
 * @returns string
 */
export function readPackage(
  packageJsonPath: string,
  loadPackageJson: ReadPackageJson = loadJsonFromDisk,
  fileExists: (path: string) => boolean = fs.existsSync
): PackageJson | undefined {
  return (
    (packageJsonPath.match(/package\.json$/) &&
      fileExists(packageJsonPath) &&
      loadPackageJson(packageJsonPath)) ||
    undefined
  );
}

function loadJsonFromDisk(file: string): PackageJson {
  // tslint:disable-next-line:no-require-imports
  const packageJson = require(file);

  return packageJson;
}
{'fraction_non_alphanumeric': 0.10580708661417323, 'fraction_numerical': 0.0, 'mean_word_length': 4.239690721649485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5862300', 'n_tokens_mistral': 590, 'n_tokens_neox': 584, 'n_words': 167}