-
Notifications
You must be signed in to change notification settings - Fork 350
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
Parenthesis on return statement has been removed #705
Comments
I think this is because the printer doesn't understand |
I was incorrect about that being the cause. |
Sorry, no, I was correct. But recast is correct that you don't need parens here. It just isn't respecting the fact that the source had parens, which it should. The reason it doesn't understand that there were parens is as I stated. If you're able to pass the I'm also going to put up a PR that fixes this outright. |
Actually I don't know quite how that will be possible. But since jscodeshift uses |
|
And I test it using jscodeshift |
When you say they don't work, what do you mean? How did you test them? If you can provide me enough info to reproduce a failure you're seeing I'll fix it. |
@bigggge I've released |
@conartist6 I push my test project and you can check it. |
@bigggge is there something for me to do? I ran the code and it seems to indicate that it is passing, but you'd have known that without me... |
When you run |
@bigggge I tested again and it appears to be working perfectly. What did happen is that when my IDE has format on save turned on prettier stripped the extra parens when I saved the file. Once I stopped that happening there were no more problems. |
Oh interesting, but it does seem to lose the parens around return when your codeshift transform actually makes a change |
I'm still not entirely sure what I'm seeing. I made a version of this test case in the recast test suite to cut out jscodeshift involvement and it works fine -- no parens are lost. I tried to replicate that result with jscodeshift by using the exact same babel parser ( function a() {
let a = ( 1 + color.black );
return (a + color.black);
}
// became
function a() {
let a = ( 1 + color.white );
return a + color.white;
} So this is pretty odd. It stopped throwing away the parens on the first line, but still lost the ones around the return expression. I've got to head to work now, but I'd say this means two things: you should use |
Reproduce example using jscodeshift:
https://astexplorer.net/#/gist/177972c375c147cd128f46354af81057/ae5a5014fa96340436dd3c68ff5063767dea8f4a
A simple demo without JSX
https://astexplorer.net/#/gist/ee27a86037e45714a0e4acaa57eca5c2/1a769021f57b29d21b3de0d8b59b44236decbcff
to
I just want to change
color.black
tocolor.white
, but parens has been removed.The text was updated successfully, but these errors were encountered: