ReSharper 2017.2 Help

JavaScript - Braces Layout

Braces layout

Empty braces formatting

Property names:

[resharper_]js_empty_block_style, [resharper_]empty_block_style

Possible values:

  • together_same_line: Together on the same line
  • together: Place braces together
  • multiline: On different lines

Examples:

Before formatting After formatting, together_same_line
function·func(par1, ·par2)·{}
function·func(par1, ····par2)·{}
Before formatting After formatting, together
function·func(par1, ·par2)·{}
function·func(par1, ····par2)·{}
Before formatting After formatting, multiline
function·func(par1, ·par2)·{}
function·func(par1, ····par2)·{ }

Function

Property names:

[resharper_]js_function_braces, [resharper_]js_brace_style, [resharper_]function_braces, [resharper_]brace_style

Possible values:

  • next_line_shifted: At next line indented (Whitesmiths style)
  • next_line_shifted_2: At next line indented 2 (GNU style)
  • next_line: At next line (BSD style)
  • end_of_line: At end of line (K&R style)
  • end_of_line_no_space: At end of line (no space)

Examples:

next_line_shifted
function·foo() ····{ ····bar(); ····}
next_line_shifted_2
function·foo() ····{ ········bar(); ····}
next_line
function·foo() { ····bar(); }
end_of_line
function·foo()·{ ····bar(); }
end_of_line_no_space
function·foo(){ ····bar(); }

Functions passed as parameters to other function calls

Property names:

[resharper_]js_function_in_invocation_braces, [resharper_]js_brace_style, [resharper_]function_in_invocation_braces, [resharper_]brace_style

Possible values:

  • next_line_shifted: At next line indented (Whitesmiths style)
  • next_line_shifted_2: At next line indented 2 (GNU style)
  • next_line: At next line (BSD style)
  • end_of_line: At end of line (K&R style)
  • end_of_line_no_space: At end of line (no space)

Examples:

next_line_shifted
bar(function·foo() ····{ ····bar(); ····});
next_line_shifted_2
bar(function·foo() ····{ ········bar(); ····});
next_line
bar(function·foo() { ····bar(); });
end_of_line
bar(function·foo()·{ ····bar(); });
end_of_line_no_space
bar(function·foo(){ ····bar(); });

Control statements

Property names:

[resharper_]js_control_statements_braces, [resharper_]js_brace_style, [resharper_]control_statements_braces, [resharper_]brace_style

Possible values:

  • next_line_shifted: At next line indented (Whitesmiths style)
  • next_line_shifted_2: At next line indented 2 (GNU style)
  • next_line: At next line (BSD style)
  • end_of_line: At end of line (K&R style)
  • end_of_line_no_space: At end of line (no space)

Examples:

next_line_shifted
while·(cond) ····{ ····Action(); ····}; do ····{ ····Action(); ····}·while·(cond);
next_line_shifted_2
while·(cond) ····{ ········Action(); ····}; do ····{ ········Action(); ····}·while·(cond);
next_line
while·(cond) { ····Action(); }; do { ····Action(); }·while·(cond);
end_of_line
while·(cond)·{ ····Action(); }; do·{ ····Action(); }·while·(cond);
end_of_line_no_space
while·(cond){ ····Action(); }; do{ ····Action(); }·while·(cond);

Indent parenthesis, brackets and expression braces

Property names:

[resharper_]js_indent_pars, [resharper_]indent_pars

Possible values:

  • outside_and_inside: Parenthesis 1x, inside 2x (GNU style)
  • none: No indent
  • inside: Inside parenthesis (BSD/K&R style)
  • outside: Parenthesis and inside equally (Whitesmiths style)

Examples:

outside_and_inside
a·= ····{ ········1, ········2, ········3 ····}; b·= ····( ········1·+·2 ····)
none
a·= { 1, 2, 3 }; b·= ( 1·+·2 )
inside
a·= { ····1, ····2, ····3 }; b·= ( ····1·+·2 )
outside
a·= ····{ ····1, ····2, ····3 ····}; b·= ····( ····1·+·2 ····)

Force braces

Braces in statements

Property names:

[resharper_]js_force_control_statements_braces, [resharper_]force_control_statements_braces

Possible values:

  • always_add: Add braces
  • only_for_multiline: Use braces for multiline
  • do_not_change: Do not change
  • always_remove: Remove braces

Examples:

Before formatting After formatting, always_add
if·(condition)·{ ··foo(); } else ··while·(condition) ····foo();
if·(condition)·{ ····foo(); }·else·{ ····while·(condition)·{ ········foo();}}
Before formatting After formatting, only_for_multiline
if·(condition)·{ ··foo(); } else ··while·(condition) ····foo();
if·(condition)·foo(); else·{ ····while·(condition) ········foo();}
Before formatting After formatting, do_not_change
if·(condition)·{ ··foo(); } else ··while·(condition) ····foo();
if·(condition)·{ ····foo(); }·else ····while·(condition) ········foo();
Before formatting After formatting, always_remove
if·(condition)·{ ··foo(); } else ··while·(condition) ····foo();
if·(condition)·foo(); else ····while·(condition) ········foo();

Case statement

Indent "case" from "switch"

Property names:

[resharper_]js_indent_switch_labels, [resharper_]indent_switch_labels

Possible values:

true | false

Examples:

true
switch·(expression)·{ ····case·0: ········break; }
false
switch·(expression)·{ case·0: ····break; }
Last modified: 11 December 2017