Code Style help: How to format multiline JS

I'm really struggling with the JS code style settings. I think that I've tried all settings but could not identify the code style options for the following rules:

  1.  In multiline `if()` conditions, I want a linebreak after the opening brace; right now, I have the first term of the condition in the same line as the brace
  2. Similar: In multiline `if()` conditions, I want a linebreak before the closing brace
  3. In multiline function calls, I want the same style (newline after opening brace and before closing brace)

Here is a sample code snippet after PHP Storm formatted it:

if (animation_entry.style
&& animation_entry.repeat
&& animation_entry.duration
&& animation_entry.delay
&& animation_entry.speed_curve) {
false !== ord && _do_process(true,
ord,
some_other_var
);
}

And this is how I want it to look like:

if (  // ← newline after opening brace
animation_entry.style
&& animation_entry.repeat
&& animation_entry.duration
&& animation_entry.delay
&& animation_entry.speed_curve // ← newline before closing brace
) {
false !== ord && _do_process( // ← newline after opening brace
true,
ord,
some_other_var
);
}

 

Can anyone point me to the correct Code Style options for this?

0
2 comments

There are no options to add new lines after/before parentheses; please feel free to file a feature request for adding them to youtrack, https://youtrack.jetbrains.com/issues/WEB

For function calls, you have to enable Function call arguments > New line after '(' and Place ')' on new line in Settings | Editor | Code Style | JavaScript | Wrapping and Braces

1

Thanks for the quick feedback and clarification, Elena!

For reference: I've added that feature request here: https://youtrack.jetbrains.com/issue/WEB-49342

0

Please sign in to leave a comment.