I code in React and I always use arrow functions. When I use a single parameter in JS function, I like to leave it without parantheses. I always use arrow functions But I use Prettier frequently, and it wraps all my parameters in paranteheses automatically. Is there any way to make Prettier leave the parameter unwrapped?
CodePudding user response:
The option you're looking for is "Arrow Function Parentheses". Go to your Prettier config (e.g. in .prettierrc
file) and add this key:
"arrowParens": "avoid"
Example of what this option does:
// Before formatting
const foo = (x) => 10;
const bar = (x, y) => 20;
// After formatting
const foo = x => 10;
const bar = (x, y) => 20;
Read more: How to add custom Prettier config