-
Notifications
You must be signed in to change notification settings - Fork 73
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
Improve removal of parentheses around expressions #609
Comments
The first example is definitely a bug
Yup, this is something I've always wanted to do. IIRC, The main reason I didn't do it yet is because of the incredibly common Looks like parentheses removal could be improved in some of the cases you've shown - I'd probably say it's a separate enhancement compared to the initial bug, but I'll take a look at this, thanks! |
The bug where the parentheses highlighting precedence were removed has been fixed I do want to improve the parentheses removal, and start adding in new parentheses too. The reason right now that parentheses are not being removed in the samples you showed is because the internal expressions are binary expressions. For simplicity, I don't touch them right now, but I do want to improve this. Will convert this issue into a feature request about this |
Thanks so much! |
Currently stylua removes many redundant parens, and in one specific case it's triggering a luau analysis warning.
Ex:
Changes to:
This triggers the linter:
ComparisonPrecedence: not X == Y is equivalent to (not X) == Y; consider using X ~= Y, or add parentheses to silence
I noticed that a number of cases where redundant parens aren't removed, maybe this use case should be added? Should Stylua add parens to clarify the operator precedence?
Here are some cases I noticed where parens aren't removed:
Another example from Prettier, it adds parens to show operator precedence between and/or:
Interested to hear your thoughts!
The text was updated successfully, but these errors were encountered: