{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1585","labels_url":"https://api.github.com/repos/babel/babel/issues/1585/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1585/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1585/events","html_url":"https://github.com/babel/babel/issues/1585","id":78683553,"number":1585,"title":"retainLines option doesn't collapse JSXElements properly","user":{"login":"kevinb7","id":1044413,"avatar_url":"https://avatars.githubusercontent.com/u/1044413?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinb7","html_url":"https://github.com/kevinb7","followers_url":"https://api.github.com/users/kevinb7/followers","following_url":"https://api.github.com/users/kevinb7/following{/other_user}","gists_url":"https://api.github.com/users/kevinb7/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinb7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinb7/subscriptions","organizations_url":"https://api.github.com/users/kevinb7/orgs","repos_url":"https://api.github.com/users/kevinb7/repos","events_url":"https://api.github.com/users/kevinb7/events{/privacy}","received_events_url":"https://api.github.com/users/kevinb7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-20T20:27:12Z","updated_at":"2015-05-20T22:50:01Z","closed_at":null,"body":"Input code:\r\n```\r\nvar React = require(\"react\");\r\nvar $_ = require(\"i18n.js\").$_;\r\nvar $i18nDoNotTranslate = require(\"i18n.js\").$i18nDoNotTranslate;\r\n\r\nfunction hello_world() {\r\n    return \"hello, world!\";\r\n}\r\n\r\nfunction goodbye_world() {\r\n    return \"goodbye, world\";\r\n}\r\n\r\nvar TestComponent = React.createClass({\r\n    render: function() {\r\n        var maybe = Math.random() > 0.5;\r\n\r\n        return <div>\r\n            <$_ textbox={<input type=\"text\"/>}>some text</$_>\r\n            <$i18nDoNotTranslate>other text\r\n                more other text</$i18nDoNotTranslate>\r\n            <$i18nDoNotTranslate>\r\n                {\"```if (x < 0) {\\n    return;\\n}```\"}</$i18nDoNotTranslate>\r\n            <$_>before { maybe ? hello_world() : goodbye_world() } after</$_>\r\n            <$_></$_>\r\n        </div>;\r\n    }\r\n});\r\n\r\nmodule.exports = TestComponent;\r\n```\r\n\r\njstransform output:\r\n```\r\nvar React = require(\"react\");\r\nvar $_ = require(\"i18n.js\").$_;\r\nvar $i18nDoNotTranslate = require(\"i18n.js\").$i18nDoNotTranslate;\r\n\r\nfunction hello_world() {\r\n    return \"hello, world!\";\r\n}\r\n\r\nfunction goodbye_world() {\r\n    return \"goodbye, world\";\r\n}\r\n\r\nvar TestComponent = React.createClass({displayName: 'TestComponent',\r\n    render: function() {\r\n        var maybe = Math.random() > 0.5;\r\n\r\n        return React.createElement(\"div\", null, \r\n            React.createElement($_, {textbox: React.createElement(\"input\", {type: \"text\"})}, \"some text\"), \r\n            React.createElement($i18nDoNotTranslate, null, \"other text\" + ' ' +\r\n                \"more other text\"), \r\n            React.createElement($i18nDoNotTranslate, null, \r\n                \"```if (x < 0) {\\n    return;\\n}```\"), \r\n            React.createElement($_, null, \"before \",  maybe ? hello_world() : goodbye_world(), \" after\"), \r\n            React.createElement($_, null)\r\n        );\r\n    }\r\n});\r\n\r\nmodule.exports = TestComponent;\r\n```\r\n\r\nbabel output:\r\n```\r\nvar React = require(\"react\");\r\nvar $_ = require(\"i18n.js\").$_;\r\nvar $i18nDoNotTranslate = require(\"i18n.js\").$i18nDoNotTranslate;\r\n\r\nfunction hello_world() {\r\n    return \"hello, world!\";}\r\n\r\n\r\nfunction goodbye_world() {\r\n    return \"goodbye, world\";}\r\n\r\n\r\nvar TestComponent = React.createClass({ displayName: \"TestComponent\", \r\n    render: function () {\r\n        var maybe = Math.random() > 0.5;\r\n\r\n        return React.createElement(\"div\",\r\n            null,\r\n            React.createElement($_,\r\n                { textbox: React.createElement(\"input\", { type: \"text\" }) },\r\n                \"some text\"),\r\n            React.createElement($i18nDoNotTranslate,\r\n                null,\r\n                \"other text more other text\"),\r\n            React.createElement($i18nDoNotTranslate,\r\n                null,\r\n                \"```if (x < 0) {\\n    return;\\n}```\"),\r\n            React.createElement($_,\r\n                null,\r\n                \"before \",\r\n                maybe ? hello_world() : goodbye_world(),\r\n                \" after\"),\r\n            React.createElement($_, null));} });module.exports = TestComponent;\r\n```\r\n\r\ncode used to compile w/ babel:\r\n```\r\nvar output_code = babel.transform(code, { \r\n    retainLines: true, \r\n    whitelist: whitelist_with_react \r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/104065508","html_url":"https://github.com/babel/babel/issues/1585#issuecomment-104065508","issue_url":"https://api.github.com/repos/babel/babel/issues/1585","id":104065508,"user":{"login":"kevinb7","id":1044413,"avatar_url":"https://avatars.githubusercontent.com/u/1044413?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinb7","html_url":"https://github.com/kevinb7","followers_url":"https://api.github.com/users/kevinb7/followers","following_url":"https://api.github.com/users/kevinb7/following{/other_user}","gists_url":"https://api.github.com/users/kevinb7/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinb7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinb7/subscriptions","organizations_url":"https://api.github.com/users/kevinb7/orgs","repos_url":"https://api.github.com/users/kevinb7/repos","events_url":"https://api.github.com/users/kevinb7/events{/privacy}","received_events_url":"https://api.github.com/users/kevinb7/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T22:50:01Z","updated_at":"2015-05-20T22:50:01Z","body":"I've narrowed down what the issue is.  ```JSXElement.exit(node)``` in build-react-transformer.js is setting ```_prettyCall``` on the call expression node to ```true``` which forces ```CallExpression(node, print)``` in generators/expression.js to adding in new lines.\r\n\r\nIn order to fix this I've updated ```CallExpression(node,print)``` to look like this:\r\n```\r\nfunction CallExpression(node, print, parent, format) {\r\n  print(node.callee);\r\n\r\n  this.push(\"(\");\r\n\r\n  var separator = \",\";\r\n\r\n  if (node._prettyCall && !format.retainLines) {\r\n    separator += \"\\n\";\r\n    this.newline();\r\n    this.indent();\r\n  } else {\r\n    separator += \" \";\r\n  }\r\n\r\n  print.list(node.arguments, { separator: separator });\r\n\r\n  if (node._prettyCall && !format.retainLines) {\r\n    this.newline();\r\n    this.dedent();\r\n  }\r\n\r\n  this.push(\")\");\r\n}\r\n```\r\n\r\nThe callsite in ```index.js``` ended up looking like this:\r\n```\r\nthis[node.type](node, this.buildPrint(node), parent, this.format);\r\n```\r\n\r\nI'll submit a PR for this later today."}}