JavaScript - Braces Layout
Braces Layout
Empty braces formatting
Property names:
[resharper_]js_empty_block_style
, [resharper_]empty_block_style
Possible values:
-
multiline
: On different lines -
together
: Place braces together -
together_same_line
: Together on the same line
Examples:
Before formatting | After formatting, multiline |
---|
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, together_same_line |
---|
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:
-
end_of_line
: At end of line (K&R style) -
end_of_line_no_space
: At end of line (no space) -
next_line
: At next line (BSD style) -
next_line_shifted
: At next line indented (Whitesmiths style) -
next_line_shifted_2
: At next line indented 2 (GNU style)
Examples:
end_of_line |
---|
function·foo()·{
····bar();
} |
end_of_line_no_space |
---|
function·foo(){
····bar();
} |
next_line |
---|
function·foo()
{
····bar();
} |
next_line_shifted |
---|
function·foo()
····{
····bar();
····} |
next_line_shifted_2 |
---|
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:
-
end_of_line
: At end of line (K&R style) -
end_of_line_no_space
: At end of line (no space) -
next_line
: At next line (BSD style) -
next_line_shifted
: At next line indented (Whitesmiths style) -
next_line_shifted_2
: At next line indented 2 (GNU style)
Examples:
end_of_line |
---|
bar(function·foo()·{
····bar();
}); |
end_of_line_no_space |
---|
bar(function·foo(){
····bar();
}); |
next_line |
---|
bar(function·foo()
{
····bar();
}); |
next_line_shifted |
---|
bar(function·foo()
····{
····bar();
····}); |
next_line_shifted_2 |
---|
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:
-
end_of_line
: At end of line (K&R style) -
end_of_line_no_space
: At end of line (no space) -
next_line
: At next line (BSD style) -
next_line_shifted
: At next line indented (Whitesmiths style) -
next_line_shifted_2
: At next line indented 2 (GNU style)
Examples:
end_of_line |
---|
while·(cond)·{
····Action();
};
do·{
····Action();
}·while·(cond); |
end_of_line_no_space |
---|
while·(cond){
····Action();
};
do{
····Action();
}·while·(cond); |
next_line |
---|
while·(cond)
{
····Action();
};
do
{
····Action();
}·while·(cond); |
next_line_shifted |
---|
while·(cond)
····{
····Action();
····};
do
····{
····Action();
····}·while·(cond); |
next_line_shifted_2 |
---|
while·(cond)
····{
········Action();
····};
do
····{
········Action();
····}·while·(cond); |
Indent parenthesis, brackets and expression braces
Property names:
[resharper_]js_indent_pars
, [resharper_]indent_pars
Possible values:
-
inside
: Inside parenthesis (BSD/K&R style) -
outside
: Parenthesis and inside equally (Whitesmiths style) -
outside_and_inside
: Parenthesis 1x, inside 2x (GNU style) -
none
: No indent
Examples:
inside |
---|
a·=
{
····1,
····2,
····3
};
b·=
(
····1·+·2
) |
outside |
---|
a·=
····{
····1,
····2,
····3
····};
b·=
····(
····1·+·2
····) |
outside_and_inside |
---|
a·=
····{
········1,
········2,
········3
····};
b·=
····(
········1·+·2
····) |
none |
---|
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:
-
do_not_change
: Do not change -
always_remove
: Remove braces -
always_add
: Add braces -
only_for_multiline
: Use braces for multiline
Examples:
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(); |
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();} |
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: 20 August 2018