{"size": 1301, "ext": "js", "max_stars_repo_path": "codemods/babel-plugin-codemod-object-assign-to-object-spread/lib/index.js", "max_stars_repo_name": "GerHobbelt/babel", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "codemods/babel-plugin-codemod-object-assign-to-object-spread/lib/index.js", "max_issues_repo_name": "GerHobbelt/babel", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "codemods/babel-plugin-codemod-object-assign-to-object-spread/lib/index.js", "max_forks_repo_name": "GerHobbelt/babel", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6545454545, "max_line_length": 101, "alphanum_fraction": 0.5833973866}
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

function _babelPluginSyntaxObjectRestSpread() {
  const data = _interopRequireDefault(require("@gerhobbelt/babel-plugin-syntax-object-rest-spread"));

  _babelPluginSyntaxObjectRestSpread = function () {
    return data;
  };

  return data;
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _default({
  types: t
}) {
  return {
    inherits: _babelPluginSyntaxObjectRestSpread().default,
    visitor: {
      CallExpression(path) {
        if (!path.get("callee").matchesPattern("Object.assign")) return;
        const args = path.get("arguments");
        if (args.length === 0) return;
        const [objPath] = args;
        if (!objPath.isObjectExpression()) return;
        const obj = objPath.node;
        const {
          properties
        } = obj;

        for (let i = 1; i < args.length; i++) {
          const arg = args[i];
          const {
            node
          } = arg;

          if (arg.isObjectExpression()) {
            properties.push(...node.properties);
          } else {
            properties.push(t.spreadElement(node));
          }
        }

        path.replaceWith(obj);
      }

    }
  };
}