Code Inspections in JavaScript
In JavaScript, ReSharper 2016.3 provides 106 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 in the following categories:
- Code Style (5 inspections)
- Common Practices and Code Improvements (3 inspections)
- Constraints Violations (1 inspection)
- Language Usage Opportunities (9 inspections)
- Potential Code Quality Issues (65 inspections)
- Redundancies in Code (4 inspections)
- Redundancies in Symbol Declarations (10 inspections)
- Strict mode violations (9 inspections)
Code Style (5 inspections)
Inspections in this category detect violations of code style rules. In contrast to the rest of 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 in the pages of ReSharper options. You can also fix issues that these inspection detect, using code cleanup. For more information, see Code Style and Cleanup.Inspection | Default Severity |
---|---|
Function is used before it is declared | Disabled |
Function is used outside of scope which it is declared | Warning |
Non-compliant quotes around string literal | Hint |
Variable is used in inner scope before it is declared | Warning |
Variable is used outside of scope which it is declared | Warning |
Common Practices and Code Improvements (3 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability.Inspection | Default Severity |
---|---|
Join local variable declaration and assignment | Suggestion |
Statement is not terminated with semicolon | Warning |
Use of future reserved word | Warning |
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 | Default Severity |
---|---|
Inconsistent Naming | Warning |
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 | Default Severity |
---|---|
A serie of undefined-checks for properties may be replaced by a destructuring | Hint |
Intermediate local variable is redundant and may be safely inlined | Hint |
Intermediate local variable is redundant because it may be replaced with a destructuring swap expression | Hint |
Local variable can be safely moved to inner block | Hint |
String concatenation may be converted to template string | Hint |
Subsequent indexers in object literal fields may be simplified using a destructuring | Hint |
Subsequent indexers may be replaced by a destructuring declaration or assignment | Hint |
'var' variable can be made 'let' variable | Hint |
Variable can be made constant | Hint |
Potential Code Quality Issues (65 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 | Default Severity |
---|---|
'?:' expression has identical true and false branches | Warning |
A trailing element of an array is elided | Warning |
Assignment to a variable inside a conditional statement | Warning |
Assignment to an implicitly declared global variable | Warning |
Assignment to constant | Error |
Cannot resolve symbol | Warning |
Closure on a variable modified in loop of outer scope | Warning |
Comma is not valid here | Error |
Comparison of 'typeof' expression with incorrect value | Warning |
Condition is always constant | Warning |
Constructor call is not used or possibly used for side-effects | Warning |
Declaration hides another declaration from an outer scope | Hint |
Duplicate property declaration | Warning |
Duplicate switch label | Warning |
ECMAScript 2015 feature usage when in ES 5 or lower | Error |
ECMAScript 2016 feature usage when in ES 2015 or lower | Error |
Error in Xml doc comment reference | Error |
Experimental feature usage when language level set to stable | Error |
Expression is always constant | Warning |
Expression is expected after 'throw' statement | Error |
Extending prototype of native object | Warning |
Heuristically unreachable code | Warning |
Illegal syntax in XML code comment | Warning |
Inconsistent function returns | Warning |
Invalid JSON syntax | Error |
Invocation of non-function expression | Warning |
Invoked expression is not a function value | Warning |
JSON validation failed | Error |
Lexical declaration can only be declared inside a block. | Error |
Local function is redefined later | Warning |
L-value expected error | Error |
Misuse of 'this' qualifier in inner function | Warning |
Multiple declarations in 'for in' error | Error |
Non-assigned constant | Error |
Non-parenthesized object destructuring assignment cannot be used in an expression statement | Error |
Not all code paths return a value | Warning |
Object property declaration is expected | Error |
Overwriting prototype of native object | Warning |
Parameter name 'arguments' clashes with pre-defined JS function-scope variable | Warning |
Parameter value is not used | Warning |
Path for reference comment not found | Error |
Possible mistake: ambiguous lambda block and object literal | Warning |
Property getter cannot have parameters | Error |
Property setter must have a single parameter | Error |
Qualifier can be 'null' or 'undefined' | Warning |
Qualifier is 'null' or 'undefined' | Warning |
Redeclaration of let/const | Error |
Return statement with a value in the global scope | Warning |
Similar expressions comparison | Warning |
Statement is possibly incorrectly broken by a newline | Warning |
'super' must be called before accessing 'this' in the constructor of a derived class. | Error |
Suspicious expression statement | Warning |
There is no .hasOwnProperty() check in a body of 'for in' loop. This will cause an enumeration of prototype properties | Warning |
Trailing redundant comma in object properties list may be error | Warning |
Usage of possibly unassigned local variable | Warning |
Usage of unassigned local variable | Warning |
Use 'break' or 'continue' outside of loop body | Warning |
Use of expression after break or continue | Error |
Use of implicitly declared global variable | Warning |
Use of possibly unassigned property or global variable | Hint |
Use of 'this' in global context | Warning |
Using of 'arguments.caller' and 'arguments.callee' | Warning |
Using of coerced equality (using of coerced equality operator with 'null' or 'undefined') | Disabled |
Using of coerced equality (using of coerced equality operator) | Warning |
Variable is used before it is declared | Warning |
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 | Default Severity |
---|---|
Assigned value is never used | Warning |
Redundant block | Warning |
Redundant empty finally block | Warning |
Unreachable code | Warning |
Redundancies in Symbol Declarations (10 inspections)
This category includes code inspections, mostly with the warning severity level, which detect empty and unused symbol declarations.Inspection | Default Severity |
---|---|
Assignment of a local variable to itself is redundant | Warning |
Duplicate local declaration | Warning |
Redundant 'else' block | Warning |
Redundant local class name | Hint |
Redundant local function name | Hint |
Type or member is never used (non-private accessibility) | Suggestion |
Unused local variable / function / class | Warning |
Unused parameter | Warning |
Unused parameter of inherited member | Hint |
Unused property or function | Warning |
Strict mode violations (9 inspections)
Inspection | Default Severity |
---|---|
Calling 'delete' on non-qualified identifier in 'strict mode' | Error |
Duplicate parameter declaration in 'strict mode' | Error |
Duplicate property declaration in 'strict mode' | Error |
Octal literals and escape sequences using in 'strict mode' | Error |
Using of 'arguments.caller' and 'arguments.callee' in 'strict mode' | Error |
Using of 'eval'/'arguments' name in 'strict mode' | Error |
Using of future reserved keywords in 'strict mode' | Error |
Using of undeclared global variable | Warning |
Using of 'with' statements in 'strict mode' | Error |
Last modified: 12 October 2017