function parseFileContentToJSON(pathToRcFile, contents) {
  // Check if file path ends in .js
  if (JS_FILE_EXTENSION_REGEX.test(pathToRcFile)) {
    return require(pathToRcFile);
  }

  // Check if file path ends in .yaml or .yml
  if (YAML_FILE_EXTENSION_REGEX.test(pathToRcFile)) {
    // Parse yaml content to JSON
    return yaml.safeLoad(contents);
  }

  // Fallback to JSON parsing
  return JSON.parse(contents);
}
Parse file content to JSON.
@param {string} pathToRcFile
@param {string} contents
@return {LHCI.LighthouseRc}