docs: function normalizeOptions(config) {
    var alias = config.alias || "foreign";
    var type = config.type;
  
    //
    if ((0, _typeof3.default)(config.options) !== "object" || Array.isArray(config.options)) {
      throw new TypeError("Invalid options type for " + alias);
    }
  
    //
    var options = (0, _assign2.default)({}, config.options);
  
    if (type !== "arguments") {
      if (options.filename !== undefined) {
        throw new Error(alias + ".filename is only allowed as a root argument");
      }
  
      if (options.babelrc !== undefined) {
        throw new Error(alias + ".babelrc is only allowed as a root argument");
      }
    }
  
    if (type === "preset") {
      if (options.only !== undefined) {
        throw new Error(alias + ".only is not supported in a preset");
      }
      if (options.ignore !== undefined) {
        throw new Error(alias + ".ignore is not supported in a preset");
      }
      if (options.extends !== undefined) {
        throw new Error(alias + ".extends is not supported in a preset");
      }
      if (options.env !== undefined) {
        throw new Error(alias + ".env is not supported in a preset");
      }
    }
  
    if (options.sourceMap !== undefined) {
      if (options.sourceMaps !== undefined) {
        throw new Error("Both " + alias + ".sourceMap and .sourceMaps have been set");
      }
  
      options.sourceMaps = options.sourceMap;
      delete options.sourceMap;
    }
  
    for (var key in options) {
      // check for an unknown option
      if (!optionNames.has(key)) {
        if (_removed2.default[key]) {
          throw new ReferenceError("Using removed Babel 5 option: " + alias + "." + key + " - " + _removed2.default[key].message);
        } else {
          // eslint-disable-next-line max-len
          var unknownOptErr = "Unknown option: " + alias + "." + key + ". Check out http://babeljs.io/docs/usage/options/ for more information about options.";
  
          throw new ReferenceError(unknownOptErr);
        }
      }
    }
  
    if (options.parserOpts && typeof options.parserOpts.parser === "string") {
      options.parserOpts = (0, _assign2.default)({}, options.parserOpts);
      options.parserOpts.parser = (0, _files.loadParser)(options.parserOpts.parser, config.dirname).value;
    }
  
    if (options.generatorOpts && typeof options.generatorOpts.generator === "string") {
      options.generatorOpts = (0, _assign2.default)({}, options.generatorOpts);
      options.generatorOpts.generator = (0, _files.loadGenerator)(options.generatorOpts.generator, config.dirname).value;
    }
  
    delete options.passPerPreset;
    delete options.plugins;
    delete options.presets;
  
    return options;
  }