{"action":"created","issue":{"url":"https://api.github.com/repos/prettier/prettier/issues/3068","repository_url":"https://api.github.com/repos/prettier/prettier","labels_url":"https://api.github.com/repos/prettier/prettier/issues/3068/labels{/name}","comments_url":"https://api.github.com/repos/prettier/prettier/issues/3068/comments","events_url":"https://api.github.com/repos/prettier/prettier/issues/3068/events","html_url":"https://github.com/prettier/prettier/issues/3068","id":266850838,"number":3068,"title":"[JS,TS] Range formatting ObjectExpression throws","user":{"login":"CiGit","id":1453420,"avatar_url":"https://avatars1.githubusercontent.com/u/1453420?v=4","gravatar_id":"","url":"https://api.github.com/users/CiGit","html_url":"https://github.com/CiGit","followers_url":"https://api.github.com/users/CiGit/followers","following_url":"https://api.github.com/users/CiGit/following{/other_user}","gists_url":"https://api.github.com/users/CiGit/gists{/gist_id}","starred_url":"https://api.github.com/users/CiGit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CiGit/subscriptions","organizations_url":"https://api.github.com/users/CiGit/orgs","repos_url":"https://api.github.com/users/CiGit/repos","events_url":"https://api.github.com/users/CiGit/events{/privacy}","received_events_url":"https://api.github.com/users/CiGit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-19T13:53:50Z","updated_at":"2017-10-19T15:37:40Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Trying to format an ObjectExpression -- with at least 2 props -- throws. \r\n\r\n**Prettier master**\r\n\r\n**Input:**\r\n```sh\r\necho \"const y = {a:1,b:2}\" |  prettier --range-start 12 --range-end 14\r\n```\r\n\r\n**Output:**\r\n```sh\r\n[error] stdin: SyntaxError: Unexpected token, expected ; (1:7)\r\n[error] > 1 | {a:1,b:2}\r\n[error]     |       ^\r\n```\r\n\r\n**Expected behavior:**\r\nShouldn't throw and format the object as an object.\r\nNote: if they were only 1 prop in the object it wouldn't throw but it would be considered as a `LabeledStatement`\r\n```js\r\nconst y = {\r\n     a: 1 ; // It would work with no-semi \r\n}\r\n```\r\nOther issue which seems highly related:\r\n```sh\r\n> echo \"const y = [1]\" |  prettier --range-start 11 --range-end 12\r\nconst y = [1;]\r\n```"},"comment":{"url":"https://api.github.com/repos/prettier/prettier/issues/comments/337947479","html_url":"https://github.com/prettier/prettier/issues/3068#issuecomment-337947479","issue_url":"https://api.github.com/repos/prettier/prettier/issues/3068","id":337947479,"user":{"login":"suchipi","id":1341513,"avatar_url":"https://avatars0.githubusercontent.com/u/1341513?v=4","gravatar_id":"","url":"https://api.github.com/users/suchipi","html_url":"https://github.com/suchipi","followers_url":"https://api.github.com/users/suchipi/followers","following_url":"https://api.github.com/users/suchipi/following{/other_user}","gists_url":"https://api.github.com/users/suchipi/gists{/gist_id}","starred_url":"https://api.github.com/users/suchipi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suchipi/subscriptions","organizations_url":"https://api.github.com/users/suchipi/orgs","repos_url":"https://api.github.com/users/suchipi/repos","events_url":"https://api.github.com/users/suchipi/events{/privacy}","received_events_url":"https://api.github.com/users/suchipi/received_events","type":"User","site_admin":false},"created_at":"2017-10-19T15:37:40Z","updated_at":"2017-10-19T15:37:40Z","author_association":"COLLABORATOR","body":"Maybe the proper thing to do is change prettier to parse the entire input stream, then find which AST nodes are within with the selected range, and format them (using the nodes as parsed in the whole program). However, this would break formatting selected js within a markdown or vue file."}}
{"actor":{"display_login":"suchipi"}}