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:
- 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
- Similar: In multiline `if()` conditions, I want a linebreak before the closing brace
- 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?
请先登录再写评论。
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
Thanks for the quick feedback and clarification, Elena!
For reference: I've added that feature request here: https://youtrack.jetbrains.com/issue/WEB-49342