Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto formatting ES6 destructuring assignment in IntelliJ/WebStorm

I'm utilizing the airbnb eslint rules for linting my ES6 code. One of the rules forces object-curly-spacing.

An example of the rule, using destructuring assignment in a function, is as follows:

Bad:

function({a, b}) {

}

Good:

function({ a, b }) {

}

I would really like Intellij/WebStorm to automatically insert these spaces when I reformat code, however, none of the Codestyle settings seem to affect destructuring. The closest codestyle setting I could find is Object Literal Braces but it has no effect.

Shy of turning off this rule, is there any additional setting, plugin, etc that would automatically insert spaces before and after around destructuring assignments?

like image 302
dustin.schultz Avatar asked Feb 23 '16 16:02

dustin.schultz


People also ask

How do you prettify codes in Webstorm?

Open the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | JavaScript | Prettier, and select the On code reformat checkbox.

What is Destructuring assignment in ES6?

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

How do you indent code on Webstorm?

While in the editor, select the necessary code fragment and press Ctrl+Alt+I . If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.


1 Answers

As mentioned in the comments this option exist in later versions of webstorm/intellij. I was having a hard time finding them so here is a picture of where to find them:

enter image description here

like image 73
Zaptree Avatar answered Sep 19 '22 16:09

Zaptree