-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSX indentation after fat-arrow attribute #389
Comments
Does the problem occur only in conjunction with JSX? |
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 |
With const Component = props => ( // Incorrect indentation
<FatArrow a={e => c}
b={123}>
</FatArrow>
);
const Component = props => ( // Correct indentation
<NoFatArrow a={123}
b={123}>
</NoFatArrow>
); |
Oh I see what you mean. I think |
|
Sorry have been super busy, but looking at this now with fresh eyes, I think I see we were talking past each other. Here's my assessment of the situation:
Fixing the whole thing requires going to If you are in vanilla |
Okay, but when does the second example indent correctly for you? Like I said,
For posterity, it's http://debbugs.gnu.org/24896.
Or on being inside an JSX literal, maybe? |
Ah! A different bug. I'd tried the example without the comment in const Component = props => ( // Correct indentation
<NoFatArrow a={123}
b={123}>
</NoFatArrow>
); |
Yup, I'm hitting this issue too, I think. When I'm doing a render() {
const messages = this.state.messages.map(
message => <Message key={message.id}
text={message.text}
mine={message.mine} />
);
return messages;
} I'd ideally expect something like: render() {
const messages = this.state.messages.map(
message => <Message key={message.id}
text={message.text}
mine={message.mine} />
);
return messages;
} It's even odder when I try to leave the argument to the arrow function in the line above: render() {
const messages = this.state.messages.map(message =>
<Message key={message.timestamp}
text={message.text}
mine={message.mine} />
);
return messages;
} For this second case, I'd hope to get: render() {
const messages = this.state.messages.map(message =>
<Message key={message.timestamp}
text={message.text}
mine={message.mine} />
);
return messages;
} (I get such results if I wrap the return expression in parentheses) |
Is this the same issue as reported here (and determined to be upstream)? If so I won't open another... |
Same topic but different issue. There are a handful of indentation issues around, but I don't think this one has come up yet. I'd file it against |
@felipeochoa ok, I just sent an email about this to bug-gnu-emacs@gnu.org (at least how I understood you're supposed to report bugs related to js-mode). We'll see what they have to say about this… |
@metakermit any response/update from the mailing list? Did you find out if it was indeed the right place to submit js-mode bugs? |
@aikeru seems it was the right place, though I think it's not resolved yet. My bug report is visible here which someone merged to this bug which is still open from what I see. (having a hard time following the format of that issue tracking system 😄 ) |
Can you guys try this branch out and see if it's fixed? I think I've effectively by-passed @felipeochoa fix that's still pending to be merged into Emacs's js-mode. If you don't want to wait, I think my fix is pretty good for now. |
I'm having this issue as well I tried a few things but none of them solve the problem completely. Fat arrow without parenthesis: return reviewers.map((reviewer, i) =>
<ReviewerTileContainer
key={`${reviewer.user}-${i}`}
className="col-md-4 col-xs-12"
>
<ReviewerTile reviewer={reviewer} />
</ReviewerTileContainer>
) Fat arrow with parenthesis: return reviewers.map((reviewer, i) =>(
<ReviewerTileContainer
key={`${reviewer.user}-${i}`}
className="col-md-4 col-xs-12"
>
<ReviewerTile reviewer={reviewer} />
</ReviewerTileContainer>
)
) The second one is closer to what I'm expecting but the last parenthesis is trying to match the indentation of the matching parenthesis. Map function in new line: return reviewers.map(
(reviewer, i) =>(
<ReviewerTileContainer
key={`${reviewer.user}-${i}`}
className="col-md-4 col-xs-12"
>
<ReviewerTile reviewer={reviewer} />
</ReviewerTileContainer>
)
) On this last one I managed to get the correct indentation(except for the closing Is there any fix for this? |
As a temporary fix, you can use use-package-quelpa to pin |
@wyuenho Yes! I'm sorry -- I meant to do it over the weekend, but couldn't find the time. Unfortunately not sure if this week will be any better. Might have to wait until next week |
Haha no worries, it took me 2 weeks to write up those branches, I wouldn't blame you if it takes you longer to review them. |
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:One possible fix is to propertize the
>
in the fat arrow as punctuation, which would letsgml
determine the correct end of the tag. Though there is an issue to resolve injs-mode
allowing the use ofparse-sexp-lookup-properties
in the indentation logic delegated tosgml
, if that is resolved, the following patch tojs2-parse-function-internal
would fix this issue:If the upstream fix happens and you like this approach, happy to submit a PR for this + tests.
The text was updated successfully, but these errors were encountered: