Skip to content
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

Convert parallel assignment (massign) expressions into multiple assignment expressions #94

Closed
kddnewton opened this issue Feb 13, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@kddnewton
Copy link
Member

Currently, when @prettier/plugin-ruby encounters an massign expression, it will always print it out as an massign. However, there are one case where we don't want to do that:

a, b, c = 1, 2, 3

This is functionally equivalent to:

a = 1
b = 2
c = 3

We should handle this inside the massign handler in src/nodes.js by checking if the number of args on the left is equal to the number of args on the right, that none of them have parens around them, and that none of them are splats. If these conditions are met, the massign expression should be converted into multiple individual assignments.

I'd be happy to pair with someone to accomplish this. It shouldn't take too long once you get the hang of how nodes are being printed.

@kddnewton kddnewton added help wanted Extra attention is needed good first issue Good for newcomers enhancement New feature or request labels Feb 13, 2019
@kddnewton kddnewton changed the title Convert parallel assignment (massign) expressions into multiple assignment expressions Convert parallel assignment (massign) expressions into multiple assignment expressions Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant