JS Arrow Functions Parentheses
Hi.
Is there an option to remove parentheses if there's only one parameter name in an arrow function when I reformat code?
(singleParam) => { statements }
Reformatted
singleParam => { statements }
Thank you.
Please sign in to leave a comment.
There is
Remove unnecessary parenthesesquick fix, available on Alt+Enter:Thanks!
Is there any way to add that into the codestyle formatter, to have it perform that option on the whole file?
You can:
Fix all 'unnecessary parentheses' problems in fileto fix all parentheses in fileCleanup codeto fix this and all similar 'safe' problemsJust wanted to share the solution to my problem as well.
I'm using Prettier for reformatting with a custom keymap (Shift + Cmd + P) and it added an unnecessary parentheses on every format.
Setting Prettier config property arrowParens to "avoid" removes the unnecessary parentheses, like this:
"arrowParens": "avoid"
Prettier documentation here