-
Notifications
You must be signed in to change notification settings - Fork 76
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
Assignment: hang at equal token before expanding RHS #292
Comments
Current prettier output of equivalent JS, which supports the idea of breaking multiple assignment at the assignment operator (the underlying heuristic may be something else, though): const { musicId, musicTime, responseTick, responseOffset } =
remotes.Server.GetSpectatorInfo.InvokeServer(player, sendTick); |
Out of curiosity what happens if you have like 20 variables being assigned, does it do something like my 3rd example? |
I would (personally) argue that your 3rd example is more confusing than the second, since in the second it is easier to see all the variables that are being assigned on one line, then the expression(s) assigning them on the other. My intention is to implement the 2nd format (once I've got some spare time) I imagine for an extremely large number of variables, prettier would format it to expand the "table"-like syntax for the variable destructuring, with each variable on its own line. (This is just a guess though, can't test rn, would recommend having a quick look at the prettier playground to see the actual result). This isn't something we do yet, but could be a possibility |
I was looking back at testing this, and it seems that prettier's heuristics have changed, and it is now formatted differently - strange I implemented a change in #342 which adds this in, but it seems to have some impact on the other test cases - I'm not sure which version is better in the failing tests |
That is interesting. When I use your prettier link above and add another parameter, it hangs at the assignment: it looks like it does work “backward”, figuring out what needs to be hung based on the token group |
Currently I have a function that gets formatted into this:
In this situation I believe that this:
Or maybe even this: (This cuts down on variables per a line which maybe is be easier to read)
Looks better.
The text was updated successfully, but these errors were encountered: