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?
Open the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | JavaScript | Prettier, and select the On code reformat checkbox.
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With