{"action":"created","issue":{"url":"https://api.github.com/repos/millermedeiros/esformatter/issues/472","repository_url":"https://api.github.com/repos/millermedeiros/esformatter","labels_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/472/labels{/name}","comments_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/472/comments","events_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/472/events","html_url":"https://github.com/millermedeiros/esformatter/issues/472","id":190896765,"number":472,"title":"esformatter-jsx Throwing Unexpected Character Error","user":{"login":"loganknecht","id":1308524,"avatar_url":"https://avatars.githubusercontent.com/u/1308524?v=3","gravatar_id":"","url":"https://api.github.com/users/loganknecht","html_url":"https://github.com/loganknecht","followers_url":"https://api.github.com/users/loganknecht/followers","following_url":"https://api.github.com/users/loganknecht/following{/other_user}","gists_url":"https://api.github.com/users/loganknecht/gists{/gist_id}","starred_url":"https://api.github.com/users/loganknecht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loganknecht/subscriptions","organizations_url":"https://api.github.com/users/loganknecht/orgs","repos_url":"https://api.github.com/users/loganknecht/repos","events_url":"https://api.github.com/users/loganknecht/events{/privacy}","received_events_url":"https://api.github.com/users/loganknecht/received_events","type":"User","site_admin":false},"labels":[{"id":21436123,"url":"https://api.github.com/repos/millermedeiros/esformatter/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-22T03:12:12Z","updated_at":"2016-12-28T23:10:07Z","closed_at":"2016-12-22T18:18:18Z","body":"Hi all! I love the tool, and its goal.\r\n\r\nWas playing around with it, and I keep getting an error thrown at me for some files.\r\n\r\nI have this bit of code\r\n# app.js\r\n```\r\n\"use strict\";\r\n\r\n// Third-Party Libraries\r\nimport React from \"react\";\r\nimport {browserHistory, Router, Route, Link, withRouter} from \"react-router\";\r\n// Custom Libraries\r\nimport AboutPage from \"./aboutPage\";\r\nimport Header from \"./header\";\r\nimport Reports from \"./reports\";\r\n\r\nimport ReportStore from \"../stores/reportsStore\";\r\nimport UserStore from \"../stores/userStore\";\r\nimport ValidationStore from \"../stores/validationStore\";\r\n\r\nclass AppRoot extends React.Component {\r\n    constructor(props) {\r\n        super(props);\r\n\r\n        this.state = {\r\n            authenticated: UserStore.authenticated(),\r\n            userData: UserStore.getUserData()\r\n        };\r\n\r\n        this._onUserChange = this._onUserChange.bind(this);\r\n    }\r\n\r\n    _onUserChange() {\r\n        this.setState({userData: UserStore.getUserData()});\r\n    }\r\n\r\n    render() {\r\n        return (\r\n            <div>\r\n              <div className=\"page-header\">\r\n                <h1><small>Welcome to Your Doom!</small></h1>\r\n              </div>\r\n              <Header data={ this.state.userData }></Header>\r\n              { this.props.children }\r\n            </div>\r\n            );\r\n    }\r\n}\r\n\r\nexport default AppRoot\r\n```\r\n\r\nThat when I save it tries to format and says:\r\n\r\n# stacktrace\r\n```\r\nError (1):Error: stdin:37:50 Unexpected token, expected }\r\nSyntaxError: Unexpected token, expected } (37:50)\r\n    at Parser.pp$5.raise (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:4215:13)\r\n    at Parser.pp.unexpected (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:1599:8)\r\n    at Parser.pp.expect (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:1587:33)\r\n    at Parser.pp$8.jsxParseExpressionContainer (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6190:8)\r\n    at Parser.pp$8.jsxParseAttributeValue (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6140:19)\r\n    at Parser.pp$8.jsxParseAttribute (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6205:42)\r\n    at Parser.pp$8.jsxParseOpeningElementAt (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6216:31)\r\n    at Parser.pp$8.jsxParseElementAt (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6238:29)\r\n    at Parser.pp$8.jsxParseElementAt (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6251:30)\r\n    at Parser.pp$8.jsxParseElement (/usr/local/lib/node_modules/esformatter-jsx/node_modules/babylon/lib/index.js:6293:15)\r\n```\r\n\r\nMy esformatter config is set up like so:\r\n# esformatter config\r\n```\r\n{\r\n    \"preset\": \"default\",\r\n    \"plugins\": [\r\n        \"esformatter-collapse-objects\",\r\n        \"esformatter-jsx\",\r\n        \"esformatter-literal-notation\",\r\n        \"esformatter-parseint\",\r\n        \"esformatter-quote-props\",\r\n        \"esformatter-quotes\",\r\n        \"esformatter-remove-trailing-commas\",\r\n        \"esformatter-semicolons\", // This breaks js by adding semi-colons in the incorrect location\r\n        \"esformatter-spaced-lined-comment\",\r\n        \"esformatter-var-each\"\r\n    ],\r\n    \"collapseObjects\": {\r\n        \"ObjectExpression\": {\r\n            \"maxLineLength\": 79,\r\n            \"maxKeys\": 1\r\n        }\r\n    },\r\n    \"indent\" : {\r\n        \"value\": \"    \",\r\n        \"AlignComments\": false\r\n    },\r\n    \"jsx\": {\r\n        \"alignWithFirstAttribute\": false,     // do not align attributes with the first tag \r\n        \"attrsOnSameLineAsTag\": true,         // move each attribute to its own line \r\n        \"closingTagOnNewLine\": false,         // default false. if true attributes on multiple lines will close the tag on a new line \r\n        \"firstAttributeOnSameLine\": true,     // keep the first attribute in the same line as the tag \r\n        \"formatJSX\": true,                    //Duh! that's the default \r\n        \"formatJSXExpressions\": true,         // default true, if false jsxExpressions won't be recursively formatted \r\n        \"htmlOptions\": {\r\n            // put here the options for js-beautify.html \r\n            \"brace_style\": \"collapse\",\r\n            \"indent_char\": \" \",\r\n            \"indent_size\": 4,\r\n            \"max_preserve_newlines\": 2,\r\n            \"preserve_newlines\": true\r\n            //wrap_line_length: 250 \r\n        },\r\n        \"JSXExpressionsSingleLine\": true,     // default true, if false the JSXExpressions might span several lines \r\n        \"maxAttrsOnTag\": 3,                   // if lower or equal than 3 attributes, they will be kept on a single line \r\n        \"removeSpaceBeforeClosingJSX\": false, // default false. if true <React.Something /> => <React.Something/> \r\n        \"spaceInJSXExpressionContainers\": \" \" // default to one space. Make it empty if you don't like spaces between JSXExpressionContainers \r\n    },\r\n    \"quotes\": {\r\n        \"type\": \"double\"\r\n    },\r\n    \"whiteSpace\": {\r\n        \"before\": {\r\n            \"ObjectExpressionClosingBrace\": 0,\r\n            \"ModuleSpecifierClosingBrace\": 0,\r\n            \"PropertyName\": 1\r\n        },\r\n        \"after\": {\r\n            \"ObjectExpressionOpeningBrace\": 0,\r\n            \"ModuleSpecifierOpeningBrace\": 0\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe error for this is that on line 37 and 38 of app.js the esformatter-semicolons plug-in is adding semi-colons there, which makes sense.\r\n\r\nHowever, then the esformater-jsx tries to format this and crashes saying the semi-colons on those lines are invalid. I'm not sure which plug-in is necessarily correct. I just know it's causing it to crash.\r\n\r\nThe easiest solution for me in the mean-time has been to disable the `esformatter-semicolons` plug-in. Which is a shame, because I really do appreciate that functionality.\r\n\r\nKeen to hear your thoughts on this!"},"comment":{"url":"https://api.github.com/repos/millermedeiros/esformatter/issues/comments/269556188","html_url":"https://github.com/millermedeiros/esformatter/issues/472#issuecomment-269556188","issue_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/472","id":269556188,"user":{"login":"ujwal-setlur","id":5835869,"avatar_url":"https://avatars.githubusercontent.com/u/5835869?v=3","gravatar_id":"","url":"https://api.github.com/users/ujwal-setlur","html_url":"https://github.com/ujwal-setlur","followers_url":"https://api.github.com/users/ujwal-setlur/followers","following_url":"https://api.github.com/users/ujwal-setlur/following{/other_user}","gists_url":"https://api.github.com/users/ujwal-setlur/gists{/gist_id}","starred_url":"https://api.github.com/users/ujwal-setlur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ujwal-setlur/subscriptions","organizations_url":"https://api.github.com/users/ujwal-setlur/orgs","repos_url":"https://api.github.com/users/ujwal-setlur/repos","events_url":"https://api.github.com/users/ujwal-setlur/events{/privacy}","received_events_url":"https://api.github.com/users/ujwal-setlur/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T23:10:07Z","updated_at":"2016-12-28T23:10:07Z","body":"I have added a simple test case showing the problem in https://github.com/bulyshko/esformatter-semicolons/issues/8"}}
{"actor":{"display_login":"ujwal-setlur"}}