xsburg / vscode-javascript-booster

Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster
159 stars 13 forks source link

Arrow function style #10

Closed sabrehagen closed 5 years ago

sabrehagen commented 6 years ago

When executing Add braces to arrow function statement on

const example = (args) => args;

it yields

const example = args => {
  return args;
};

How can I configure the plugin to also apply Wrap parameter with () in the same operation to produce

const example = (args) => {
  return args;
};

with only one code action?

xsburg commented 6 years ago

Hi,

Good question. When manipulating the code, the extension tries to preserve the existing formatting but it isn't possible in some cases. For these situations, default formatting options are applied, which is basically what happens in the case that you mention.

These default formatting options are hardcoded now but could be easily exposed via extension settings. I'll publish an updated version soon and it will fix the problem. You'll just have to set arrowParensAlways: true to adjust the behavior.

Also, I would recommend using Prettier to preserve code style automatically. When configured to format on save, such formatting issues become barely noticable imo.

Cheers!

xsburg commented 5 years ago

Fixed with the option javascriptBooster.formattingOptions in v0.11.0.