{"action":"created","issue":{"url":"https://api.github.com/repos/mooz/js2-mode/issues/389","repository_url":"https://api.github.com/repos/mooz/js2-mode","labels_url":"https://api.github.com/repos/mooz/js2-mode/issues/389/labels{/name}","comments_url":"https://api.github.com/repos/mooz/js2-mode/issues/389/comments","events_url":"https://api.github.com/repos/mooz/js2-mode/issues/389/events","html_url":"https://github.com/mooz/js2-mode/issues/389","id":187670174,"number":389,"title":"JSX indentation after fat-arrow attribute","user":{"login":"felipeochoa","id":2739312,"avatar_url":"https://avatars.githubusercontent.com/u/2739312?v=3","gravatar_id":"","url":"https://api.github.com/users/felipeochoa","html_url":"https://github.com/felipeochoa","followers_url":"https://api.github.com/users/felipeochoa/followers","following_url":"https://api.github.com/users/felipeochoa/following{/other_user}","gists_url":"https://api.github.com/users/felipeochoa/gists{/gist_id}","starred_url":"https://api.github.com/users/felipeochoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felipeochoa/subscriptions","organizations_url":"https://api.github.com/users/felipeochoa/orgs","repos_url":"https://api.github.com/users/felipeochoa/repos","events_url":"https://api.github.com/users/felipeochoa/events{/privacy}","received_events_url":"https://api.github.com/users/felipeochoa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-07T10:06:47Z","updated_at":"2016-11-07T17:52:10Z","closed_at":null,"body":"I just submitted a bug about this to bug-gnu-emacs@gnu.org, but there's a `js2`-specific piece to it. From the main bug report:\r\n\r\n> When indenting JSX code using js2- or js-mode, the indentation function gets confused when there's a fat arrow function in a JSX prop. Compare the way the following two code blocks are auto-indented:\r\n> \r\n> ```jsx\r\n> const Component = props => ( // Incorrect indentation\r\n>     <FatArrow a={e => c}\r\n>       b={123}>\r\n>     </FatArrow>\r\n> );\r\n> ```\r\n> \r\n> ```jsx\r\n> const Component = props => ( // Correct indentation\r\n>     <NoFatArrow a={123}\r\n>                 b={123}>\r\n>     </NoFatArrow>\r\n> );\r\n> ```\r\n\r\nOne possible fix is to propertize the `>` in the fat arrow as punctuation, which would let `sgml` determine the correct end of the tag. Though there is an issue to resolve in `js-mode` allowing the use of `parse-sexp-lookup-properties` in the indentation logic delegated to `sgml`, if that is resolved, the following patch to `js2-parse-function-internal` would fix this issue:\r\n\r\n```diff\r\n@@ -8323,6 +8323,8 @@ Last token scanned is the close-curly for the function body.\"\r\n           js2-loop-and-switch-set)\r\n       (js2-parse-function-params function-type fn-node pos)\r\n-      (when (eq function-type 'FUNCTION_ARROW)\r\n-        (js2-must-match js2-ARROW \"msg.bad.arrow.args\"))\r\n+      (and (eq function-type 'FUNCTION_ARROW)\r\n+           (js2-must-match js2-ARROW \"msg.bad.arrow.args\")\r\n+           (js2-record-text-property (1- (js2-current-token-end)) (js2-current-token-end) 'syntax-table\r\n+                                     (string-to-syntax \".\")))\r\n       (if (and (>= js2-language-version 180)\r\n                (/= (js2-peek-token) js2-LC))\r\n```\r\n\r\nIf the upstream fix happens and you like this approach, happy to submit a PR for this + tests."},"comment":{"url":"https://api.github.com/repos/mooz/js2-mode/issues/comments/258909057","html_url":"https://github.com/mooz/js2-mode/issues/389#issuecomment-258909057","issue_url":"https://api.github.com/repos/mooz/js2-mode/issues/389","id":258909057,"user":{"login":"felipeochoa","id":2739312,"avatar_url":"https://avatars.githubusercontent.com/u/2739312?v=3","gravatar_id":"","url":"https://api.github.com/users/felipeochoa","html_url":"https://github.com/felipeochoa","followers_url":"https://api.github.com/users/felipeochoa/followers","following_url":"https://api.github.com/users/felipeochoa/following{/other_user}","gists_url":"https://api.github.com/users/felipeochoa/gists{/gist_id}","starred_url":"https://api.github.com/users/felipeochoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felipeochoa/subscriptions","organizations_url":"https://api.github.com/users/felipeochoa/orgs","repos_url":"https://api.github.com/users/felipeochoa/repos","events_url":"https://api.github.com/users/felipeochoa/events{/privacy}","received_events_url":"https://api.github.com/users/felipeochoa/received_events","type":"User","site_admin":false},"created_at":"2016-11-07T17:52:09Z","updated_at":"2016-11-07T17:52:09Z","body":"Yes -- it's only when calling out to the sgml indent function. I suppose that means we could make the propertizing conditional on being in JSX mode"}}
{"actor":{"display_login":"felipeochoa"}}