Code Inspections in JavaScript
In JavaScript, ReSharper 2021.2 provides two kinds of code inspections: 4 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, and so on (you cannot configure or disable any of these inspections), and 113 proprietary code inspections, any of which you can disable or change its severity level.
These code inspections help you detect code issues in design time in all open files, and additionally they allow you to find code issues in specific scope.
Configurable JavaScript inspections are listed below, grouped by their categories.
Common Practices and Code Improvements (3 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability.
Inspection | |
---|---|
Join local variable declaration and assignment | |
Statement termination doesn't match code style | |
Use of future reserved word |
Constraints Violations (1 inspection)
This category includes code inspections, mostly with the warning severity level, which detect violations related to symbol attributes, including ReSharper's code annotations, and other similar issues.
Inspection | |
---|---|
|
Language Usage Opportunities (9 inspections)
This category includes code inspections, mostly with the suggestion severity level, which notify you when more advanced language constructs can be used. These inspections detect syntax of outdated language versions and suggest using features from more modern language versions. For most of the supported languages, language version can be detected automatically or set manually.
Inspection | |
---|---|
A series of undefined-checks for properties can be replaced with destructuring | |
Intermediate local variable is redundant and can be safely inlined | |
Intermediate local variable is redundant because it can be replaced with a destructuring swap expression | |
Local variable can be safely moved to inner block | |
String concatenation can be converted to a template string | |
Subsequent indexers can be replaced by a destructuring declaration or assignment | |
Subsequent indexers in object literal fields can be simplified with destructuring | |
'var' variable can be made 'let' variable | |
Variable can be made constant |
Potential Code Quality Issues (68 inspections)
This category includes inspections that detect critical issues (code smells), mostly with Error or Warning level. This category also includes inspections that ensure localization assistance.
Inspection | |
---|---|
'?:' expression has identical true and false branches | |
A trailing element of an array is elided | |
Assignment to a variable inside a conditional statement | |
Assignment to an implicitly declared global variable | |
Assignment to constant | |
Cannot resolve symbol | |
Closure on a variable modified in loop of outer scope | |
Comma is expected in object literal | |
Comma is not valid here | |
Comparison of 'typeof' expression with incorrect value | |
Condition is always constant | |
Constructor call is not used or possibly used for side-effects | |
Declaration hides another declaration from an outer scope | |
Duplicate property declaration | |
Duplicate switch label | |
ECMAScript 2015 feature usage when in ES 5 or lower | |
ECMAScript 2016 feature usage when in ES 2015 or lower | |
Error in XML doc comment reference | |
Experimental feature usage when language level set to stable | |
Expression is always constant | |
Expression is expected after 'throw' statement | |
Extending prototype of native object | |
Heuristically unreachable code | |
Illegal syntax in XML code comment | |
'import' keyword is not allowed here. | |
Inconsistent function returns | |
Invalid JSON syntax | |
Invocation of non-function expression | |
Invoked expression is not a function value | |
JSON validation failed | |
Lexical declaration can only be declared inside a block. | |
Local function is redefined later | |
L-value expected error | |
Misuse of 'this' qualifier in inner function | |
Multiple declarations in 'for in' error | |
Non-assigned constant | |
Non-parenthesized object destructuring assignment cannot be used in an expression statement | |
Not all code paths return a value | |
Object property declaration is expected | |
Overwriting prototype of native object | |
Parameter name 'arguments' clashes with pre-defined JS function-scope variable | |
Parameter value is not used | |
Path for reference comment not found | |
Possible mistake: ambiguous lambda block and object literal | |
Property getter cannot have parameters | |
Property setter must have a single parameter | |
Qualifier can be 'null' or 'undefined' | |
Qualifier is 'null' or 'undefined' | |
Redeclaration of let/const | |
Return statement with a value in the global scope | |
Similar expressions comparison | |
Statement is possibly incorrectly broken by a newline | |
'super' must be called before accessing 'this' in the constructor of a derived class. | |
Suspicious expression statement | |
There is no .hasOwnProperty() check in a body of 'for in' loop. This will cause an enumeration of prototype properties | |
Trailing redundant comma in object properties list may be error | |
Triple-slash directives are only valid at the top of the file | |
Usage of possibly unassigned local variable | |
Usage of unassigned local variable | |
Use 'break' or 'continue' outside of loop body | |
Use of expression after break or continue | |
Use of implicitly declared global variable | |
Use of possibly unassigned property or global variable | |
Use of 'this' in global context | |
Using of 'arguments.caller' and 'arguments.callee' | |
Using of coerced equality (using of coerced equality operator with 'null' or 'undefined') | |
Using of coerced equality (using of coerced equality operator) | |
Variable is used before it is declared |
Redundancies in Code (4 inspections)
Code inspections in this category look for redundancies and dead code, which affect code readability and style, and could be safely removed. Some code redundancies cannot be fixed automatically, and quick-fixes for them are performed in the interactive mode, requiring the user input. But the majority of the redundancies can be fixed without user interaction, using either fix in scope or code cleanup.
Inspection | |
---|---|
Assigned value is never used | |
Redundant block | |
Redundant empty finally block | |
Unreachable code |
Redundancies in Symbol Declarations (11 inspections)
This category includes code inspections, mostly with the warning severity level, which detect empty and unused symbol declarations.
Inspection | |
---|---|
Assignment of a local variable to itself is redundant | |
Duplicate local declaration | |
Redundant 'else' block | |
Redundant local class name | |
Redundant local function name | |
Type is never used (non-private accessibility) | |
Type member is never used (non-private accessibility) | |
Unused local variable / function / class | |
Unused parameter | |
Unused parameter of inherited member | |
Unused property or function |
Spelling issues (3 inspections)
These inspections detect typos in various contexts.
Inspection | |
---|---|
| |
| |
|
Strict mode violations (9 inspections)
Inspection | |
---|---|
Calling 'delete' on non-qualified identifier in 'strict mode' | |
Duplicate parameter declaration in 'strict mode' | |
Duplicate property declaration in 'strict mode' | |
Octal literals and escape sequences using in 'strict mode' | |
Using of 'arguments.caller' and 'arguments.callee' in 'strict mode' | |
Using of 'eval'/'arguments' name in 'strict mode' | |
Using of future reserved keywords in 'strict mode' | |
Using of undeclared global variable | |
Using of 'with' statements in 'strict mode' |
Syntax Style (5 inspections)
Inspections in this category detect violations of code syntax styles. In contrast to most of other code inspections, these inspections can either detect the same code construct as a code issue or not depending on the corresponding code style rule configured on the page of ReSharper options (Alt+R, O). You can also fix issues that these inspection detect using code cleanup.
Inspection | |
---|---|
Function is used before it is declared | |
Function is used outside of scope which it is declared | |
Non-compliant quotes around string literal | |
Variable is used in inner scope before it is declared | |
Variable is used outside of scope which it is declared |