{"action":"created","comment":{"url":"https://api.github.com/repos/reactjs/react-codemod/pulls/comments/43466733","id":43466733,"diff_hunk":"@@ -0,0 +1,95 @@\n+module.exports = function(file, api) {\n+  const j = api.jscodeshift;\n+  const root = j(file.source);\n+\n+  const convertObjectExpressionToJSXAttributes = (objectExpression) => {\n+    if (!objectExpression.properties) {\n+      return [];\n+    }\n+\n+    const attributes = objectExpression.properties.map((property) => {\n+\n+      if (property.type === 'SpreadProperty') {\n+        return j.jsxSpreadAttribute(property.argument);\n+      }  else if (property.type === 'Property') {\n+        const propertyValueType = property.value.type;\n+\n+        let value;\n+        if (propertyValueType === 'Literal') {\n+          value = j.literal(property.value.value);\n+        } else if (propertyValueType === 'MemberExpression') {\n+          value = j.jsxExpressionContainer(property.value);\n+        }\n+\n+        return j.jsxAttribute(\n+          j.jsxIdentifier(property.key.name),\n+          value\n+        );\n+      }\n+    });\n+\n+    return attributes;\n+  };\n+\n+  const convertNodeToJSX = (node) => {\n+    if (!node.value || node.value.type !== 'CallExpression') {\n+      return undefined;\n+    }\n+\n+    const args = node.value.arguments;","path":"transforms/create-element-to-jsx.js","position":39,"original_position":39,"commit_id":"b5f84d30b593805f15f251c6d79571c1db2ce3d2","original_commit_id":"11b4bd813247bbbe3424935b9d643eae47522a5b","user":{"login":"cpojer","id":13352,"avatar_url":"https://avatars.githubusercontent.com/u/13352?v=3","gravatar_id":"","url":"https://api.github.com/users/cpojer","html_url":"https://github.com/cpojer","followers_url":"https://api.github.com/users/cpojer/followers","following_url":"https://api.github.com/users/cpojer/following{/other_user}","gists_url":"https://api.github.com/users/cpojer/gists{/gist_id}","starred_url":"https://api.github.com/users/cpojer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpojer/subscriptions","organizations_url":"https://api.github.com/users/cpojer/orgs","repos_url":"https://api.github.com/users/cpojer/repos","events_url":"https://api.github.com/users/cpojer/events{/privacy}","received_events_url":"https://api.github.com/users/cpojer/received_events","type":"User","site_admin":false},"body":"`const {arguments: args} = node.value;` if you wanna go nuts.","created_at":"2015-10-30T02:28:27Z","updated_at":"2015-10-30T02:28:27Z","html_url":"https://github.com/reactjs/react-codemod/pull/9#discussion_r43466733","pull_request_url":"https://api.github.com/repos/reactjs/react-codemod/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/comments/43466733"},"html":{"href":"https://github.com/reactjs/react-codemod/pull/9#discussion_r43466733"},"pull_request":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/reactjs/react-codemod/pulls/9","id":49164722,"html_url":"https://github.com/reactjs/react-codemod/pull/9","diff_url":"https://github.com/reactjs/react-codemod/pull/9.diff","patch_url":"https://github.com/reactjs/react-codemod/pull/9.patch","issue_url":"https://api.github.com/repos/reactjs/react-codemod/issues/9","number":9,"state":"open","locked":false,"title":"Adding a codemod for transforming createElement function calls to JSX","user":{"login":"TheSavior","id":249164,"avatar_url":"https://avatars.githubusercontent.com/u/249164?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSavior","html_url":"https://github.com/TheSavior","followers_url":"https://api.github.com/users/TheSavior/followers","following_url":"https://api.github.com/users/TheSavior/following{/other_user}","gists_url":"https://api.github.com/users/TheSavior/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSavior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSavior/subscriptions","organizations_url":"https://api.github.com/users/TheSavior/orgs","repos_url":"https://api.github.com/users/TheSavior/repos","events_url":"https://api.github.com/users/TheSavior/events{/privacy}","received_events_url":"https://api.github.com/users/TheSavior/received_events","type":"User","site_admin":false},"body":"Transforms\r\n```\r\nvar a = React.createElement(\r\n  Foo,\r\n  null,\r\n  React.createElement(\"div\", { foo: \"bar\" }),\r\n  React.createElement(\r\n    \"span\",\r\n    null,\r\n    \"blah\"\r\n  )\r\n);\r\n```\r\n\r\nto\r\n```\r\nvar a = <Foo><div foo=\"bar\"></div><span>blah</span></Foo>;\r\n```\r\n\r\nThis codemod is useful for people who start out without using JSX and want to convert their codebase to JSX later.","created_at":"2015-10-29T16:31:11Z","updated_at":"2015-10-30T02:28:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"511995145f66f63ddc8fff30e82558cb7fdbbed6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/reactjs/react-codemod/pulls/9/commits","review_comments_url":"https://api.github.com/repos/reactjs/react-codemod/pulls/9/comments","review_comment_url":"https://api.github.com/repos/reactjs/react-codemod/pulls/comments{/number}","comments_url":"https://api.github.com/repos/reactjs/react-codemod/issues/9/comments","statuses_url":"https://api.github.com/repos/reactjs/react-codemod/statuses/b5f84d30b593805f15f251c6d79571c1db2ce3d2","head":{"label":"TheSavior:createElement","ref":"createElement","sha":"b5f84d30b593805f15f251c6d79571c1db2ce3d2","user":{"login":"TheSavior","id":249164,"avatar_url":"https://avatars.githubusercontent.com/u/249164?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSavior","html_url":"https://github.com/TheSavior","followers_url":"https://api.github.com/users/TheSavior/followers","following_url":"https://api.github.com/users/TheSavior/following{/other_user}","gists_url":"https://api.github.com/users/TheSavior/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSavior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSavior/subscriptions","organizations_url":"https://api.github.com/users/TheSavior/orgs","repos_url":"https://api.github.com/users/TheSavior/repos","events_url":"https://api.github.com/users/TheSavior/events{/privacy}","received_events_url":"https://api.github.com/users/TheSavior/received_events","type":"User","site_admin":false},"repo":{"id":45195953,"name":"react-codemod","full_name":"TheSavior/react-codemod","owner":{"login":"TheSavior","id":249164,"avatar_url":"https://avatars.githubusercontent.com/u/249164?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSavior","html_url":"https://github.com/TheSavior","followers_url":"https://api.github.com/users/TheSavior/followers","following_url":"https://api.github.com/users/TheSavior/following{/other_user}","gists_url":"https://api.github.com/users/TheSavior/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSavior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSavior/subscriptions","organizations_url":"https://api.github.com/users/TheSavior/orgs","repos_url":"https://api.github.com/users/TheSavior/repos","events_url":"https://api.github.com/users/TheSavior/events{/privacy}","received_events_url":"https://api.github.com/users/TheSavior/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheSavior/react-codemod","description":"React codemod scripts","fork":true,"url":"https://api.github.com/repos/TheSavior/react-codemod","forks_url":"https://api.github.com/repos/TheSavior/react-codemod/forks","keys_url":"https://api.github.com/repos/TheSavior/react-codemod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheSavior/react-codemod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheSavior/react-codemod/teams","hooks_url":"https://api.github.com/repos/TheSavior/react-codemod/hooks","issue_events_url":"https://api.github.com/repos/TheSavior/react-codemod/issues/events{/number}","events_url":"https://api.github.com/repos/TheSavior/react-codemod/events","assignees_url":"https://api.github.com/repos/TheSavior/react-codemod/assignees{/user}","branches_url":"https://api.github.com/repos/TheSavior/react-codemod/branches{/branch}","tags_url":"https://api.github.com/repos/TheSavior/react-codemod/tags","blobs_url":"https://api.github.com/repos/TheSavior/react-codemod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheSavior/react-codemod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheSavior/react-codemod/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheSavior/react-codemod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheSavior/react-codemod/statuses/{sha}","languages_url":"https://api.github.com/repos/TheSavior/react-codemod/languages","stargazers_url":"https://api.github.com/repos/TheSavior/react-codemod/stargazers","contributors_url":"https://api.github.com/repos/TheSavior/react-codemod/contributors","subscribers_url":"https://api.github.com/repos/TheSavior/react-codemod/subscribers","subscription_url":"https://api.github.com/repos/TheSavior/react-codemod/subscription","commits_url":"https://api.github.com/repos/TheSavior/react-codemod/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheSavior/react-codemod/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheSavior/react-codemod/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheSavior/react-codemod/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheSavior/react-codemod/contents/{+path}","compare_url":"https://api.github.com/repos/TheSavior/react-codemod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheSavior/react-codemod/merges","archive_url":"https://api.github.com/repos/TheSavior/react-codemod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheSavior/react-codemod/downloads","issues_url":"https://api.github.com/repos/TheSavior/react-codemod/issues{/number}","pulls_url":"https://api.github.com/repos/TheSavior/react-codemod/pulls{/number}","milestones_url":"https://api.github.com/repos/TheSavior/react-codemod/milestones{/number}","notifications_url":"https://api.github.com/repos/TheSavior/react-codemod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheSavior/react-codemod/labels{/name}","releases_url":"https://api.github.com/repos/TheSavior/react-codemod/releases{/id}","created_at":"2015-10-29T16:29:15Z","updated_at":"2015-10-29T16:29:15Z","pushed_at":"2015-10-30T02:27:08Z","git_url":"git://github.com/TheSavior/react-codemod.git","ssh_url":"git@github.com:TheSavior/react-codemod.git","clone_url":"https://github.com/TheSavior/react-codemod.git","svn_url":"https://github.com/TheSavior/react-codemod","homepage":null,"size":262,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"reactjs:master","ref":"master","sha":"a82c8e29234e8a6d9e48adde74cd43822dcbd897","user":{"login":"reactjs","id":6412038,"avatar_url":"https://avatars.githubusercontent.com/u/6412038?v=3","gravatar_id":"","url":"https://api.github.com/users/reactjs","html_url":"https://github.com/reactjs","followers_url":"https://api.github.com/users/reactjs/followers","following_url":"https://api.github.com/users/reactjs/following{/other_user}","gists_url":"https://api.github.com/users/reactjs/gists{/gist_id}","starred_url":"https://api.github.com/users/reactjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactjs/subscriptions","organizations_url":"https://api.github.com/users/reactjs/orgs","repos_url":"https://api.github.com/users/reactjs/repos","events_url":"https://api.github.com/users/reactjs/events{/privacy}","received_events_url":"https://api.github.com/users/reactjs/received_events","type":"Organization","site_admin":false},"repo":{"id":44563064,"name":"react-codemod","full_name":"reactjs/react-codemod","owner":{"login":"reactjs","id":6412038,"avatar_url":"https://avatars.githubusercontent.com/u/6412038?v=3","gravatar_id":"","url":"https://api.github.com/users/reactjs","html_url":"https://github.com/reactjs","followers_url":"https://api.github.com/users/reactjs/followers","following_url":"https://api.github.com/users/reactjs/following{/other_user}","gists_url":"https://api.github.com/users/reactjs/gists{/gist_id}","starred_url":"https://api.github.com/users/reactjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactjs/subscriptions","organizations_url":"https://api.github.com/users/reactjs/orgs","repos_url":"https://api.github.com/users/reactjs/repos","events_url":"https://api.github.com/users/reactjs/events{/privacy}","received_events_url":"https://api.github.com/users/reactjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reactjs/react-codemod","description":"React codemod scripts","fork":false,"url":"https://api.github.com/repos/reactjs/react-codemod","forks_url":"https://api.github.com/repos/reactjs/react-codemod/forks","keys_url":"https://api.github.com/repos/reactjs/react-codemod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reactjs/react-codemod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reactjs/react-codemod/teams","hooks_url":"https://api.github.com/repos/reactjs/react-codemod/hooks","issue_events_url":"https://api.github.com/repos/reactjs/react-codemod/issues/events{/number}","events_url":"https://api.github.com/repos/reactjs/react-codemod/events","assignees_url":"https://api.github.com/repos/reactjs/react-codemod/assignees{/user}","branches_url":"https://api.github.com/repos/reactjs/react-codemod/branches{/branch}","tags_url":"https://api.github.com/repos/reactjs/react-codemod/tags","blobs_url":"https://api.github.com/repos/reactjs/react-codemod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reactjs/react-codemod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reactjs/react-codemod/git/refs{/sha}","trees_url":"https://api.github.com/repos/reactjs/react-codemod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reactjs/react-codemod/statuses/{sha}","languages_url":"https://api.github.com/repos/reactjs/react-codemod/languages","stargazers_url":"https://api.github.com/repos/reactjs/react-codemod/stargazers","contributors_url":"https://api.github.com/repos/reactjs/react-codemod/contributors","subscribers_url":"https://api.github.com/repos/reactjs/react-codemod/subscribers","subscription_url":"https://api.github.com/repos/reactjs/react-codemod/subscription","commits_url":"https://api.github.com/repos/reactjs/react-codemod/commits{/sha}","git_commits_url":"https://api.github.com/repos/reactjs/react-codemod/git/commits{/sha}","comments_url":"https://api.github.com/repos/reactjs/react-codemod/comments{/number}","issue_comment_url":"https://api.github.com/repos/reactjs/react-codemod/issues/comments{/number}","contents_url":"https://api.github.com/repos/reactjs/react-codemod/contents/{+path}","compare_url":"https://api.github.com/repos/reactjs/react-codemod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reactjs/react-codemod/merges","archive_url":"https://api.github.com/repos/reactjs/react-codemod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reactjs/react-codemod/downloads","issues_url":"https://api.github.com/repos/reactjs/react-codemod/issues{/number}","pulls_url":"https://api.github.com/repos/reactjs/react-codemod/pulls{/number}","milestones_url":"https://api.github.com/repos/reactjs/react-codemod/milestones{/number}","notifications_url":"https://api.github.com/repos/reactjs/react-codemod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reactjs/react-codemod/labels{/name}","releases_url":"https://api.github.com/repos/reactjs/react-codemod/releases{/id}","created_at":"2015-10-19T20:47:22Z","updated_at":"2015-10-29T10:07:21Z","pushed_at":"2015-10-30T02:27:08Z","git_url":"git://github.com/reactjs/react-codemod.git","ssh_url":"git@github.com:reactjs/react-codemod.git","clone_url":"https://github.com/reactjs/react-codemod.git","svn_url":"https://github.com/reactjs/react-codemod","homepage":null,"size":262,"stargazers_count":29,"watchers_count":29,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/9"},"html":{"href":"https://github.com/reactjs/react-codemod/pull/9"},"issue":{"href":"https://api.github.com/repos/reactjs/react-codemod/issues/9"},"comments":{"href":"https://api.github.com/repos/reactjs/react-codemod/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/reactjs/react-codemod/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/reactjs/react-codemod/statuses/b5f84d30b593805f15f251c6d79571c1db2ce3d2"}}}}