ReSharper 2021.1 Help

Context Actions for JavaScript

ReSharper provides the following context actions for JavaScript:

NameDescription
Add bracesAdds braces around if/else/for/do/while/with statement body
Add JsDoc commentsAdd JsDoc comments
Add 'use strict'Adds 'use strict'
Add XML Comment ReferenceAdd XML comment reference to the file where the referenced symbol is declared
Add xml-doc commentsAdd xml-doc comments
Compute constant valueComputes value of the current expression and replace it (e.g. 1 + 1 replaced by 2)
Convert bin to dec (ES6)Converts numeric literal from binary to decimal form
Convert concatenation to template stringConverts string and arguments concatenation to template string
Convert 'if' statement to ternary expressionWorks on 'if' statement that returns value or performs assignment inside each branch. It converts the statement to a ternary expression ('x ? a : b')
Convert 'if' to 'switch'If the same expression is checked against several values for strict equality, 'if' statement may be converted to 'switch'
Convert object literal get-accessor to simple propertyConverts ECMAScript 5 get-accessor to simple property
Convert object literal property to accessors pair with backing fieldConverts object literal property to ECMAScript 5 accessors pair with backing field
Convert object literal property to get-accessorConverts object literal property to ECMAScript 5 get-accessor
Convert oct to dec (ES6)Converts numeric literal from binary to decimal form
Convert property assignment in constructors to accessor property definition with backing fieldConverts property assignment in constructors to accessor property definition via Object.defineProperty() call
Convert property assignment in constructors to data property definitionConverts property assignment in constructors to data property definition via Object.defineProperty() call
Convert property assignment in constructors to get-accessor property definitionConverts property assignment in constructors to get-accessor property definition via Object.defineProperty() call
Convert ternary expression to 'if' statementConverts ternary expression whose value is returned or assigned to an 'if' statement
Convert to bin (ES6)Converts numeric literal from decimal to binary form
Convert to decConverts numeric literal from hexadecimal to decimal form
Convert to decConverts numeric literal from octal to decimal form
Convert to hexConverts numeric literal from decimal to hexadecimal form
Convert to octConverts numeric literal from decimal to octal form
Converts expression lambda to block lambda with returnConverts expression lambda to block lambda with return
Converts single-return block lambda to expressionConverts single-return block lambda to expression lambda
Create From UsageCreates property, function, local variable or parameter from usage
For more information, see Generate Code from Usage.
Flip an operator argumentsFlips left and right arguments for selected operator e.g. null == x to x == null.
Flip relational expressionFlips the current relational expression e.g. x > 1 to x < 1.
Introduce variable from expression statementIntroduces variable from expression statement
Invert 'if' statementInverts guard condition of an 'if' statement and swaps the branches' code accordingly
Invert ternary conditionInverts condition and swaps branches of a ternary expression
Join local variable declaration and assignmentWorks on an assignment to a variable that was declared without initializer. Moves the declaration to the current point and merges it with the assignment.
Join string literalsConcatenates two string literals into one
Merge nested 'if' statementsMerges two nested 'if' statements to a single 'if' statement that checks conjunction of the original conditions.
Merge two 'if' statementsMerges 'if' statement with nested 'if' statement in else branch with equal body to a single 'if' statement that checks disjunction of the original conditions.
Negate logical expressionNegates logical expression
Remove bracesRemoves unnecessary braces around one or more statements in the code
Remove redundant parenthesisRemoves parenthesis in case they are redundant
Replace logical expression with equal expressionReplace logical expression with equal expression
Replace single-quoted string literal with double-quotedReplace single-quoted string literal with double-quoted and vice versa
Reverse assignment statementReverses source and destination parts of an assignment statement.
Split 'if' with '&&'-condition into nested 'if'-statementsWorks on an 'if' statement, whose value is a conjunction ('&&') of two simpler conditions. It converts the 'if' statement into two nested 'if' statements.
Split 'if' with '||'-condition into two 'if'-statementsWorks on an 'if' statement, whose condition is a disjunction ('||') of two simpler conditions. It converts the 'if' statement into two 'if' statements with equal bodies.
Split into separate declarationsWorks on variable declaration or lexical declaration statement that declares multiple variables. It splits such statement into multiple statements each declaring a single variable.
Split 'return' statement of boolean value to 'if' statementWorks on a 'return' statement, whose value is of boolean type. It converts the 'return' statement into an 'if' statement with two 'return' statements, returning 'true' and 'false' values.
Split 'return' with '&&'-condition into guarding 'if' and 'return'Works on a 'return' statement, whose condition is a conjunction ('&&') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'.
Split 'return' with '||'-condition into assignment to temporary variable, 'if'-statement and 'return'Works on a 'return' statement, whose value is a disjunction ('||') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'.
Split variable declaration and assignmentMoves variable initializer from declaration statement to separate assignment statement.
Last modified: 08 March 2021