ReSharper 2017.2 Help

JavaScript - Line Breaks

Blank lines

Max blank lines in code

Property names:

[resharper_]js_keep_blank_lines_in_code, [resharper_]keep_blank_lines_in_code

Possible values:

an integer

Examples:

Before formatting After formatting, value: 0
function·foo()·{ ··bar(); ··bas(); }
function·foo()·{ ··bar(); ··bas(); }
Before formatting After formatting, value: 1
function·foo()·{ ··bar(); ··bas(); }
function·foo()·{ ··bar(); ··bas(); }
Before formatting After formatting, value: 2
function·foo()·{ ··bar(); ··bas(); }
function·foo()·{ ··bar(); ··bas(); }

Max blank lines between declarations

Property names:

[resharper_]js_keep_blank_lines_between_declarations, [resharper_]keep_blank_lines_between_declarations

Possible values:

an integer

Examples:

Before formatting After formatting, value: 0
class·Foo·{ constructor()·{ ·//·constructor·code } Method()·{ ·//·method·code } }
class·Foo·{ ··constructor()·{ ····//·constructor·code ··} ··Method()·{ ····//·method·code ··} }
Before formatting After formatting, value: 1
class·Foo·{ constructor()·{ ·//·constructor·code } Method()·{ ·//·method·code } }
class·Foo·{ ··constructor()·{ ····//·constructor·code ··} ··Method()·{ ····//·method·code ··} }
Before formatting After formatting, value: 2
class·Foo·{ constructor()·{ ·//·constructor·code } Method()·{ ·//·method·code } }
class·Foo·{ ··constructor()·{ ····//·constructor·code ··} ··Method()·{ ····//·method·code ··} }

Min blank lines around functions

Property names:

[resharper_]js_min_blank_lines_around_functions, [resharper_]min_blank_lines_around_functions

Possible values:

an integer

Examples:

Before formatting After formatting, value: 0
function·foo()·{ } function·bar()·{ }
function·foo()·{ } function·bar()·{ }
Before formatting After formatting, value: 1
function·foo()·{ } function·bar()·{ }
function·foo()·{ } function·bar()·{ }
Before formatting After formatting, value: 2
function·foo()·{ } function·bar()·{ }
function·foo()·{ } function·bar()·{ }

Line breaks

Simple embedded statement

Property names:

[resharper_]js_simple_embedded_statement_style, [resharper_]simple_embedded_statement_style

Possible values:

  • line_break: Force line breaks
  • on_single_line: Force put on single line
  • do_not_change: Do not change

Examples:

Before formatting After formatting, line_break
if·(conditionDoSomething(); if·(condition) ··DoSomething();
if·(condition) ··DoSomething(); if·(condition) ··DoSomething();
Before formatting After formatting, on_single_line
if·(conditionDoSomething(); if·(condition) ··DoSomething();
if·(conditionDoSomething(); if·(conditionDoSomething();
Before formatting After formatting, do_not_change
if·(conditionDoSomething(); if·(condition) ··DoSomething();
if·(conditionDoSomething(); if·(condition) ··DoSomething();

Single-statement function

Property names:

[resharper_]js_single_statement_function_style, [resharper_]single_statement_function_style

Possible values:

  • line_break: Force line breaks
  • on_single_line: Force put on single line
  • do_not_change: Do not change

Examples:

Before formatting After formatting, line_break
foo(function(){document.writeln();}); foo(function(){ ··document.writeln(); }); foo(function(){document.writeln(); });
foo(function()·{ ··document.writeln(); }); foo(function()·{ ··document.writeln(); }); foo(function()·{ ··document.writeln(); });
Before formatting After formatting, on_single_line
foo(function(){document.writeln();}); foo(function(){ ··document.writeln(); }); foo(function(){document.writeln(); });
foo(function()·document.writeln();·}); foo(function()·document.writeln();·}); foo(function()·document.writeln();·});
Before formatting After formatting, do_not_change
foo(function(){document.writeln();}); foo(function(){ ··document.writeln(); }); foo(function(){document.writeln(); });
foo(function()·document.writeln();·}); foo(function()·{ ··document.writeln(); }); foo(function()·{ ··document.writeln(); });

Special "else if" treatment

Property names:

[resharper_]js_special_else_if_treatment, [resharper_]special_else_if_treatment

Possible values:

true | false

Examples:

true
if·(condition{ ··foo(); else·if·(condition{ }
false
if·(condition{ ··foo(); else ··if·(condition{ ··}

Wrapping and chopping

Right margin (columns)

Property names:

js_max_line_length, max_line_length

Possible values:

an integer

Prefer wrap before comma

Property names:

[resharper_]js_wrap_before_comma, [resharper_]wrap_before_comma

Possible values:

true | false

Examples:

Before formatting After formatting, true
method(par1par2par3par4par5par6par7par8par9par10);
method(par1 ··par2 ··par3 ··par4 ··par5 ··par6 ··par7 ··par8 ··par9 ··par10);
Before formatting After formatting, false
method(par1par2par3par4par5par6par7par8par9par10);
method(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);

Wrap chained method calls

Property names:

[resharper_]js_wrap_chained_method_calls, [resharper_]wrap_chained_method_calls

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
obj.m().m().m(); obj.method().method().method().method().method().method().method();
obj.m() ··.m() ··.m(); obj.method() ··.method() ··.method() ··.method() ··.method() ··.method() ··.method();
Before formatting After formatting, chop_if_long
obj.m().m().m(); obj.method().method().method().method().method().method().method();
obj.m().m().m(); obj.method() ··.method() ··.method() ··.method() ··.method() ··.method() ··.method();
Before formatting After formatting, wrap_if_long
obj.m().m().m(); obj.method().method().method().method().method().method().method();
obj.m().m().m(); obj.method().method().method() ··.method().method().method() ··.method();

Prefer wrap before "."

Property names:

[resharper_]js_wrap_before_dot, [resharper_]wrap_before_dot

Possible values:

true | false

Examples:

Before formatting After formatting, true
obj.method().method().method().method().method().method().method();
obj.method().method().method() ··.method().method().method() ··.method();
Before formatting After formatting, false
obj.method().method().method().method().method().method().method();
obj.method().method(). ··method().method().method(). ··method().method();

Wrap chained binary expressions

Property names:

[resharper_]js_wrap_chained_binary_expressions, [resharper_]wrap_chained_binary_expressions

Possible values:

  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_if_long
var·a1·a2·a3·a4; var·arg1·arg2·arg3·arg4·arg5·arg6·arg7·arg8;
var·a1·a2·a3·a4; var·arg1·+ ··arg2·+ ··arg3·+ ··arg4·+ ··arg5·+ ··arg6·+ ··arg7·+ ··arg8;
Before formatting After formatting, wrap_if_long
var·a1·a2·a3·a4; var·arg1·arg2·arg3·arg4·arg5·arg6·arg7·arg8;
var·a1·a2·a3·a4; var·arg1·arg2·arg3·+ ··arg4·arg5·arg6·arg7·+ ··arg8;

Prefer wrap before operator in binary expression

Property names:

[resharper_]js_wrap_before_binary_opsign, [resharper_]wrap_before_binary_opsign

Possible values:

true | false

Examples:

Before formatting After formatting, true
var·arg1·arg2·arg3·arg4·arg5·arg6·arg7·arg8;
var·arg1 ··arg2 ··arg3 ··arg4 ··arg5 ··arg6 ··arg7 ··arg8;
Before formatting After formatting, false
var·arg1·arg2·arg3·arg4·arg5·arg6·arg7·arg8;
var·arg1·+ ··arg2·+ ··arg3·+ ··arg4·+ ··arg5·+ ··arg6·+ ··arg7·+ ··arg8;

Wrap invocation arguments

Property names:

[resharper_]js_wrap_arguments_style, [resharper_]wrap_arguments_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
m(a,b,c,d); method(par1par2par3par4par5par6par7par8par9par10);
m(a, ··b, ··c, ··d); method(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);
Before formatting After formatting, chop_if_long
m(a,b,c,d); method(par1par2par3par4par5par6par7par8par9par10);
m(abcd); method(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);
Before formatting After formatting, wrap_if_long
m(a,b,c,d); method(par1par2par3par4par5par6par7par8par9par10);
m(abcd); method(par1par2par3par4, ··par5par6par7par8, ··par9par10);

Prefer wrap before "(" in invocation

Property names:

[resharper_]js_wrap_before_invocation_lpar, [resharper_]wrap_before_invocation_lpar

Possible values:

true | false

Examples:

Before formatting After formatting, true
method(par1par2par3par4par5par6par7par8par9par10);
method (par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);
Before formatting After formatting, false
method(par1par2par3par4par5par6par7par8par9par10);
method(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);

Prefer wrap after "(" in invocation

Property names:

[resharper_]js_wrap_after_invocation_lpar, [resharper_]wrap_after_invocation_lpar

Possible values:

true | false

Examples:

Before formatting After formatting, true
method(par1par2par3par4par5par6par7par8par9par10);
method( ··par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);
Before formatting After formatting, false
method(par1par2par3par4par5par6par7par8par9par10);
method(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8, ··par9, ··par10);

Wrap formal parameters

Property names:

[resharper_]js_wrap_parameters_style, [resharper_]wrap_parameters_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
function·f(a,b,c{} function·meth(par1par2par3par4par5par6par7par8{}
function·f(a, ··b, ··c{ } function·meth(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }
Before formatting After formatting, chop_if_long
function·f(a,b,c{} function·meth(par1par2par3par4par5par6par7par8{}
function·f(abc{} function·meth(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }
Before formatting After formatting, wrap_if_long
function·f(a,b,c{} function·meth(par1par2par3par4par5par6par7par8{}
function·f(abc{} function·meth(par1par2, ··par3par4par5par6, ··par7par8{ }

Prefer wrap before "(" in declaration

Property names:

[resharper_]js_wrap_before_declaration_lpar, [resharper_]wrap_before_declaration_lpar

Possible values:

true | false

Examples:

Before formatting After formatting, true
function·meth(par1par2par3par4par5par6par7par8{}
function·meth (par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }
Before formatting After formatting, false
function·meth(par1par2par3par4par5par6par7par8{}
function·meth(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }

Prefer wrap after "(" in declaration

Property names:

[resharper_]js_wrap_after_declaration_lpar, [resharper_]wrap_after_declaration_lpar

Possible values:

true | false

Examples:

Before formatting After formatting, true
function·meth(par1par2par3par4par5par6par7par8{}
function·meth( ··par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }
Before formatting After formatting, false
function·meth(par1par2par3par4par5par6par7par8{}
function·meth(par1, ··par2, ··par3, ··par4, ··par5, ··par6, ··par7, ··par8{ }

Wrap object literals

Property names:

[resharper_]js_wrap_object_literals, [resharper_]wrap_object_literals

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
var·a1b1}; var·field1nullfield2nullfield3nullfield4null·};
var·{ ··a1, ··b1 }; var·{ ··field1null, ··field2null, ··field3null, ··field4null };
Before formatting After formatting, chop_if_long
var·a1b1}; var·field1nullfield2nullfield3nullfield4null·};
var·a1b}; var·{ ··field1null, ··field2null, ··field3null, ··field4null };
Before formatting After formatting, wrap_if_long
var·a1b1}; var·field1nullfield2nullfield3nullfield4null·};
var·a1b}; var·field1null, ··field2nullfield3null, ··field4null·};

Wrap array literals

Property names:

[resharper_]js_wrap_array_literals, [resharper_]wrap_array_literals

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
var·[1,2,3,4]; var·[elem1elem2elem3elem4elem5elem6elem7elem8elem9];
var·[ ··1234 ]; var·[ ··elem1elem2elem3elem4, ··elem5elem6elem7elem8, ··elem9 ];
Before formatting After formatting, chop_if_long
var·[1,2,3,4]; var·[elem1elem2elem3elem4elem5elem6elem7elem8elem9];
var·[1234]; var·[ ··elem1elem2elem3elem4, ··elem5elem6elem7elem8, ··elem9 ];
Before formatting After formatting, wrap_if_long
var·[1,2,3,4]; var·[elem1elem2elem3elem4elem5elem6elem7elem8elem9];
var·[1234]; var·[elem1elem2elem3, ··elem4elem5elem6elem7, ··elem8elem9];

Wrap "for" statement header

Property names:

[resharper_]js_wrap_for_stmt_header_style, [resharper_]wrap_for_stmt_header_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
for·(15++); for·(myVar·0myVar·5myVar·++);
for·(1; ··5; ··++); for·(myVar·0; ··myVar·5; ··myVar·++);
Before formatting After formatting, chop_if_long
for·(15++); for·(myVar·0myVar·5myVar·++);
for·(15++); for·(myVar·0; ··myVar·5; ··myVar·++);
Before formatting After formatting, wrap_if_long
for·(15++); for·(myVar·0myVar·5myVar·++);
for·(15++); for·(myVar·0myVar·5; ··myVar·++);

Wrap ternary expression

Property names:

[resharper_]js_wrap_ternary_expr_style, [resharper_]wrap_ternary_expr_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
var·c; var·myObj·===·null·myObj.getValue()·null;
var·a ··b ··c; var·myObj·===·null ··myObj.getValue() ··null;
Before formatting After formatting, chop_if_long
var·c; var·myObj·===·null·myObj.getValue()·null;
var·c; var·myObj·===·null ··myObj.getValue() ··null;
Before formatting After formatting, wrap_if_long
var·c; var·myObj·===·null·myObj.getValue()·null;
var·c; var·myObj·===·null ··myObj.getValue()·null;

Prefer wrap before "?" and ":" in ternary expressions

Property names:

[resharper_]js_wrap_before_ternary_opsigns, [resharper_]wrap_before_ternary_opsigns

Possible values:

true | false

Examples:

Before formatting After formatting, true
var·myObj·===·null·myObj.getValue()·null;
var·myObj·===·null ··myObj.getValue() ··null;
Before formatting After formatting, false
var·myObj·===·null·myObj.getValue()·null;
var·myObj·===·null·? ··myObj.getValue()·: ··null;

Wrap multiple declaration

Property names:

[resharper_]js_wrap_multiple_declaration_style, [resharper_]wrap_multiple_declaration_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

Before formatting After formatting, chop_always
var·abc; var·left·100top·100width·calcWidth(),·height·calcHeight();
var·a, ··b, ··c; var·left·100, ··top·100, ··width·calcWidth(), ··height·calcHeight();
Before formatting After formatting, chop_if_long
var·abc; var·left·100top·100width·calcWidth(),·height·calcHeight();
var·abc; var·left·100, ··top·100, ··width·calcWidth(), ··height·calcHeight();
Before formatting After formatting, wrap_if_long
var·abc; var·left·100top·100width·calcWidth(),·height·calcHeight();
var·abc; var·left·100top·100, ··width·calcWidth(), ··height·calcHeight();

Place on a new line

Place "else" on a new line

Property names:

[resharper_]js_new_line_before_else, [resharper_]new_line_before_else

Possible values:

true | false

Examples:

true
if·(condition{ ··foo(); } else·{ ··foo(); }
false
if·(condition{ ··foo(); else·{ ··foo(); }

Place "while" on a new line

Property names:

[resharper_]js_new_line_before_while, [resharper_]new_line_before_while

Possible values:

true | false

Examples:

true
do·{ ··foo(); } while·(condition);
false
do·{ ··foo(); while·(condition);

Place "catch" on a new line

Property names:

[resharper_]js_new_line_before_catch, [resharper_]new_line_before_catch

Possible values:

true | false

Examples:

true
try·{ ··foo(); } catch·(e{ ··foo(); finally·{ }
false
try·{ ··foo(); catch·(e{ ··foo(); finally·{ }

Place "finally" on a new line

Property names:

[resharper_]js_new_line_before_finally, [resharper_]new_line_before_finally

Possible values:

true | false

Examples:

true
try·{ ··foo(); catch·(e{ ··foo(); } finally·{ }
false
try·{ ··foo(); catch·(e{ ··foo(); finally·{ }

Place template literal arguments on a new line

Property names:

[resharper_]js_place_template_args_on_new_line, [resharper_]place_template_args_on_new_line

Possible values:

true | false

Examples:

true
var·`a${ ··b ··},·b${ ··a ··}`;
false
var·`a${b},·b${a}`;
Last modified: 20 October 2017