WebStorm code style - Function definition - Keep one-liner if body empty

Plop!

When creating dummy functions, with an empty body, I would like them to look like that:

start : function() {},
pause : function() {},


However, WebStorm reformats them this way:

start : function() {
},
pause : function() {
},


It is fine for every other case, but I don't like it when the functions have an empty body.
Is there any way to configure WebStorm in accordance with this wanted behavior?

Thanks again.

5 comments
Comment actions Permalink

Code Style/JavaScript/Wrapping and Braces, Keep when reformatting/Simple methods in one line

4
Comment actions Permalink

@Elena

I would like to keep only empty functions in one line, not simple functions.

function xyz() {}
function xyz(abc) {
return abc + 1;
}

 

It also doesn't apply to classes:

export class AppRoutingModule {
}
0
Comment actions Permalink

for classes, please try "Keep when reformatting > Simple blocks in one line"

If you need a separate option for functions with empty body, please feel free to create a request in youtrack, https://youtrack.jetbrains.com/issues/WEB

0
Comment actions Permalink

@Elena

Thanks for the tip, but it only works if the class is not being exported.

export class AppRoutingModule {
}

class AppRoutingModule {}
0

Please sign in to leave a comment.