ReSharper 2026.3 Help

JavaScript 中的代码检查

在 JavaScript 中,ReSharper 2026.3 提供两种代码检查:4 项 检测错误的检查 ,例如语法错误、未解析的符号、编译器错误等(这些检查无法配置或禁用),以及 117 项 专有代码检查 ,您可以 禁用 或更改其 严重性级别。
These code inspections help you detect code issues at design time in all open files, and additionally they allow you to find code issues in specific scope.

可配置的 JavaScript 检查列在下方,并按其 类别 分组。

常见实践和代码改进(3 项检查)

此类别分组的检查主要查找中等严重性的问题,这些问题主要影响代码的可读性。

检查
ID
EditorConfig 属性

默认严重性

合并局部变量声明和赋值
JoinDeclarationAndInitializerJs
resharper_join_declaration_and_initializer_js_highlighting

建议

语句终止符与代码风格设置不匹配
StatementTermination
resharper_statement_termination_highlighting

警告

使用未来保留字
UsingOfReservedWord
resharper_using_of_reserved_word_highlighting

警告

约束违规(1 项检查)

此类别包括代码检查,主要具有 警告 严重性级别,用于检测与符号属性相关的违规行为,包括 ReSharper 的代码注解 和其他类似问题。

检查
ID
EditorConfig 属性

默认严重性

命名不一致
InconsistentNaming
resharper_inconsistent_naming_highlighting

警告

语法问题(4 项检查)

此类别中的检查报告字符串字面量和文档注释中的 语法问题。

检查
ID
EditorConfig 属性

默认严重性

注释中的语法错误
GrammarMistakeInComment
resharper_grammar_mistake_in_comment_highlighting

建议

标记属性值中的语法错误
GrammarMistakeInMarkupAttribute
resharper_grammar_mistake_in_markup_attribute_highlighting

建议

标记文本中的语法错误
GrammarMistakeInMarkupText
resharper_grammar_mistake_in_markup_text_highlighting

建议

字符串字面量中的语法错误
GrammarMistakeInStringLiteral
resharper_grammar_mistake_in_string_literal_highlighting

已禁用

语言使用机会(9 项检查)

此类别包括代码检查,主要具有 建议严重性级别,当可以使用更高级的语言结构时会通知您。 这些检查检测过时语言版本的语法,并建议使用更现代语言版本的功能。 对于大多数支持的语言,语言版本 可以自动检测或手动设置。

检查
ID
EditorConfig 属性

默认严重性

可以用解构替换一系列属性的未定义检查
ReplaceUndefinedCheckingSeriesWithObjectDestructuring
resharper_replace_undefined_checking_series_with_object_destructuring_highlighting

提示

中间局部变量是多余的,可以安全地内联
RedundantIntermediateVariable
resharper_redundant_intermediate_variable_highlighting

提示

中间局部变量是多余的,因为可以用解构交换表达式替换
ReplaceWithDestructuringSwap
resharper_replace_with_destructuring_swap_highlighting

提示

局部变量可以安全地移动到内部块
VariableCanBeMovedToInnerBlock
resharper_variable_can_be_moved_to_inner_block_highlighting

提示

字符串拼接可以转换为模板字符串
StringConcatenationToTemplateString
resharper_string_concatenation_to_template_string_highlighting

提示

后续索引器可以用解构声明或赋值替换
ReplaceIndicingWithArrayDestructuring
resharper_replace_indicing_with_array_destructuring_highlighting

提示

对象字面量字段中的后续索引器可以通过解构简化
ReplaceIndicingWithShortHandPropertiesAfterDestructuring
resharper_replace_indicing_with_short_hand_properties_after_destructuring_highlighting

提示

'var' 变量可以改为 'let' 变量
VariableCanBeMadeLet
resharper_variable_can_be_made_let_highlighting

提示

变量可以改为常量
VariableCanBeMadeConst
resharper_variable_can_be_made_const_highlighting

提示

潜在的代码质量问题(68 项检查)

此类别包括检测关键问题(代码异味)的检查,主要具有 错误 或 警告 级别。 此类别还包括 确保本地化支持的检查。

检查
ID
EditorConfig 属性

默认严重性

'?:' 表达式的 true 和 false 分支相同
ConditionalTernaryEqualBranch
resharper_conditional_ternary_equal_branch_highlighting

警告

数组的尾部元素被省略
ElidedTrailingElement
resharper_elided_trailing_element_highlighting

警告

在条件语句中对变量赋值
AssignmentInConditionExpression
resharper_assignment_in_condition_expression_highlighting

警告

对隐式声明的全局变量赋值
AssignToImplicitGlobalInFunctionScope
resharper_assign_to_implicit_global_in_function_scope_highlighting

警告

对常量赋值
AssignToConstant
resharper_assign_to_constant_highlighting

错误

无法解析符号
NotResolved
resharper_not_resolved_highlighting

警告

闭包引用了外部作用域中在循环中修改的变量
ClosureOnModifiedVariable
resharper_closure_on_modified_variable_highlighting

警告

对象字面量中缺少逗号
ObjectLiteralsAreNotCommaFree
resharper_object_literals_are_not_comma_free_highlighting

错误

此处逗号无效
CommaNotValidHere
resharper_comma_not_valid_here_highlighting

错误

'typeof' 表达式与不正确的值进行比较
IncorrectOperandInTypeOfComparison
resharper_incorrect_operand_in_type_of_comparison_highlighting

警告

条件始终为常量
ConditionIsAlwaysConst
resharper_condition_is_always_const_highlighting

警告

构造函数调用未使用或可能用于副作用
ConstructorCallNotUsed
resharper_constructor_call_not_used_highlighting

警告

声明隐藏了外部作用域的另一个声明
DeclarationHides
resharper_declaration_hides_highlighting

提示

重复的属性声明
DuplicatingPropertyDeclaration
resharper_duplicating_property_declaration_highlighting

警告

重复的 switch 标签
DuplicatingSwitchLabel
resharper_duplicating_switch_label_highlighting

警告

在 ES 5 或更低版本中使用 ECMAScript 2015 功能
Es6Feature
resharper_es6_feature_highlighting

错误

在 ES 2015 或更低版本中使用 ECMAScript 2016 功能
Es7Feature
resharper_es7_feature_highlighting

错误

XML 文档注释引用中的错误
ErrorInXmlDocReference
resharper_error_in_xml_doc_reference_highlighting

错误

在语言级别设置为稳定时使用实验性功能
ExperimentalFeature
resharper_experimental_feature_highlighting

错误

表达式始终为常量
ExpressionIsAlwaysConst
resharper_expression_is_always_const_highlighting

警告

'throw' 语句后需要表达式
ThrowMustBeFollowedByExpression
resharper_throw_must_be_followed_by_expression_highlighting

错误

扩展原生对象的原型
NativeTypePrototypeExtending
resharper_native_type_prototype_extending_highlighting

警告

启发式不可达代码
HeuristicallyUnreachableCode
resharper_heuristically_unreachable_code_highlighting

警告

XML 代码注释中的非法语法
XmlDocCommentSyntaxProblem
resharper_xml_doc_comment_syntax_problem_highlighting

警告

此处不允许使用 'import' 关键字
ImportKeywordNotWithInvocation
resharper_import_keyword_not_with_invocation_highlighting

错误

函数返回值不一致
InconsistentFunctionReturns
resharper_inconsistent_function_returns_highlighting

警告

无效的 JSON 语法
InvalidJsonSyntax
resharper_invalid_json_syntax_highlighting

错误

调用非函数表达式
InvocationOfNonFunction
resharper_invocation_of_non_function_highlighting

警告

调用的表达式不是函数值
InvokedExpressionMaybeNonFunction
resharper_invoked_expression_maybe_non_function_highlighting

警告

JSON 验证失败
JsonValidationFailed
resharper_json_validation_failed_highlighting

错误

词法声明只能在块内声明
LexicalDeclarationNeedsBlock
resharper_lexical_declaration_needs_block_highlighting

错误

局部函数在后续被重新定义
LocalFunctionRedefinedLater
resharper_local_function_redefined_later_highlighting

警告

需要左值错误
LValueIsExpected
resharper_l_value_is_expected_highlighting

错误

在内部函数中误用 'this' 限定符
MisuseOfOwnerFunctionThis
resharper_misuse_of_owner_function_this_highlighting

警告

'for in' 中的多重声明错误
MultipleDeclarationsInForeach
resharper_multiple_declarations_in_foreach_highlighting

错误

未赋值的常量
NonAssignedConstant
resharper_non_assigned_constant_highlighting

错误

非括号的对象解构赋值不能用于表达式语句
ObjectDestructuringWithoutParentheses
resharper_object_destructuring_without_parentheses_highlighting

错误

并非所有代码路径都返回值
NotAllPathsReturnValue
resharper_not_all_paths_return_value_highlighting

警告

需要对象属性声明
EmptyObjectPropertyDeclaration
resharper_empty_object_property_declaration_highlighting

错误

覆盖原生对象的原型
NativeTypePrototypeOverwriting
resharper_native_type_prototype_overwriting_highlighting

警告

参数名称 'arguments' 与预定义的 JS 函数作用域变量冲突
FunctionParameterNamedArguments
resharper_function_parameter_named_arguments_highlighting

警告

参数值未被使用
ParameterValueIsNotUsed
resharper_parameter_value_is_not_used_highlighting

警告

未找到引用注释的路径
JsPathNotFound
resharper_js_path_not_found_highlighting

错误

可能的错误:模糊的 lambda 块和对象字面量
SuspiciousLambdaBlock
resharper_suspicious_lambda_block_highlighting

警告

属性 getter 不能有参数
PropertyGetterCannotHaveParameters
resharper_property_getter_cannot_have_parameters_highlighting

错误

属性 setter 必须有一个参数
PropertySetterMustHaveSingleParameter
resharper_property_setter_must_have_single_parameter_highlighting

错误

限定符可以是 'null' 或 'undefined'
QualifiedExpressionMaybeNull
resharper_qualified_expression_maybe_null_highlighting

警告

限定符是 'null' 或 'undefined'
QualifiedExpressionIsNull
resharper_qualified_expression_is_null_highlighting

警告

重复声明 let/const
BlockScopeRedeclaration
resharper_block_scope_redeclaration_highlighting

错误

全局作用域中的 return 语句带有值
ReturnFromGlobalScopetWithValue
resharper_return_from_global_scopet_with_value_highlighting

警告

相似表达式比较
SimilarExpressionsComparison
resharper_similar_expressions_comparison_highlighting

警告

语句可能被错误地通过换行符中断
PossiblyIncorrectlyBrokenStatement
resharper_possibly_incorrectly_broken_statement_highlighting

警告

在派生类的构造函数中访问 'this' 之前必须调用 'super'
SuperCallProhibitsThis
resharper_super_call_prohibits_this_highlighting

错误

可疑的表达式语句
WrongExpressionStatement
resharper_wrong_expression_statement_highlighting

警告

在 'for in' 循环体中没有 .hasOwnProperty() 检查。 这将导致枚举原型属性。
MissingHasOwnPropertyInForeach
resharper_missing_has_own_property_in_foreach_highlighting

警告

对象属性列表中的尾随冗余逗号可能导致错误
UnsafeCommaInObjectPropertiesList
resharper_unsafe_comma_in_object_properties_list_highlighting

警告

三斜线指令仅在文件顶部有效
IncorrectTripleSlashLocation
resharper_incorrect_triple_slash_location_highlighting

警告

可能未赋值的局部变量的使用
UsageOfPossiblyUnassignedValue
resharper_usage_of_possibly_unassigned_value_highlighting

警告

未赋值的局部变量的使用
UsageOfDefinitelyUnassignedValue
resharper_usage_of_definitely_unassigned_value_highlighting

警告

在循环体外使用 'break' 或 'continue'
JumpMustBeInLoop
resharper_jump_must_be_in_loop_highlighting

警告

在 'break' 或 'continue' 之后使用表达式
LabelOrSemicolonExpected
resharper_label_or_semicolon_expected_highlighting

错误

使用隐式声明的全局变量
UseOfImplicitGlobalInFunctionScope
resharper_use_of_implicit_global_in_function_scope_highlighting

警告

可能未赋值的属性或全局变量的使用
PossiblyUnassignedProperty
resharper_possibly_unassigned_property_highlighting

提示

在全局上下文中使用 'this'
ThisInGlobalContext
resharper_this_in_global_context_highlighting

警告

使用 'arguments.caller' 和 'arguments.callee'
CallerCalleeUsing
resharper_caller_callee_using_highlighting

警告

使用强制相等(使用与 'null' 或 'undefined' 的强制相等运算符)
CoercedEqualsUsingWithNullUndefined
resharper_coerced_equals_using_with_null_undefined_highlighting

已禁用

使用强制相等(使用强制相等运算符)
CoercedEqualsUsing
resharper_coerced_equals_using_highlighting

警告

变量在声明之前被使用
VariableUsedBeforeDeclared
resharper_variable_used_before_declared_highlighting

警告

代码中的冗余(4 项检查)

此类别中的代码检查会查找冗余和无用代码,这些代码会影响代码的可读性和风格,并且可以安全地移除。 某些代码冗余无法自动修复,其快速修复需要在交互模式下完成,需用户输入。 但大多数冗余可以在无需用户交互的情况下修复,使用 范围内修复 或 代码清理。

检查
ID
EditorConfig 属性

默认严重性

赋值的值从未被使用
AssignedValueIsNeverUsed
resharper_assigned_value_is_never_used_highlighting

警告

冗余块
RedundantBlock
resharper_redundant_block_highlighting

警告

冗余的空 finally 块
RedundantEmptyFinallyBlock
resharper_redundant_empty_finally_block_highlighting

警告

不可达代码
JsUnreachableCode
resharper_js_unreachable_code_highlighting

警告

符号声明中的冗余(11 项检查)

此类别包括代码检查,主要为 警告严重性级别,用于检测空的和未使用的符号声明。

检查
ID
EditorConfig 属性

默认严重性

局部变量赋值给自身是多余的
SameVariableAssignment
resharper_same_variable_assignment_highlighting

警告

重复的局部声明
DuplicatingLocalDeclaration
resharper_duplicating_local_declaration_highlighting

警告

冗余的 'else' 块
RedundantElseBlock
resharper_redundant_else_block_highlighting

警告

冗余的局部类名
RedundantLocalClassName
resharper_redundant_local_class_name_highlighting

提示

冗余的局部函数名
RedundantLocalFunctionName
resharper_redundant_local_function_name_highlighting

提示

类型从未使用(非私有可访问性)
UnusedType.Global
resharper_unused_type_global_highlighting

建议

类型成员从未使用(非私有可访问性)
UnusedMember.Global
resharper_unused_member_global_highlighting

建议

未使用的局部变量 / 函数 / 类
UnusedLocals
resharper_unused_locals_highlighting

警告

未使用的参数
UnusedParameter
resharper_unused_parameter_highlighting

警告

继承成员的未使用参数
UnusedInheritedParameter
resharper_unused_inherited_parameter_highlighting

提示

未使用的属性或函数
UnusedProperty
resharper_unused_property_highlighting

警告

拼写问题(3 项检查)

这些检查 检测各种上下文中的拼写错误。

检查
ID
EditorConfig 属性

默认严重性

注释中的拼写错误
CommentTypo
resharper_comment_typo_highlighting

建议

标识符中的拼写错误
IdentifierTypo
resharper_identifier_typo_highlighting

建议

字符串字面量中的拼写错误
StringLiteralTypo
resharper_string_literal_typo_highlighting

建议

严格模式违规(9 项检查)

检查
ID
EditorConfig 属性

默认严重性

在 'strict mode' 中对非限定标识符调用 'delete'
DeletingNonQualifiedReference
resharper_deleting_non_qualified_reference_highlighting

错误

在 'strict mode' 中重复的参数声明
DuplicatingParameterDeclarationError
resharper_duplicating_parameter_declaration_error_highlighting

错误

在 'strict mode' 中重复的属性声明
DuplicatingPropertyDeclarationError
resharper_duplicating_property_declaration_error_highlighting

错误

在 'strict mode' 中使用八进制字面量和转义序列
OctalLiteralsNotAllowedError
resharper_octal_literals_not_allowed_error_highlighting

错误

在 'strict mode' 中使用 'arguments.caller' 和 'arguments.callee'
CallerCalleeUsingError
resharper_caller_callee_using_error_highlighting

错误

在 'strict mode' 中使用 'eval'/'arguments' 名称
EvalArgumentsNameError
resharper_eval_arguments_name_error_highlighting

错误

在 'strict mode' 中使用未来保留关键字
UsingOfReservedWordError
resharper_using_of_reserved_word_error_highlighting

错误

使用未声明的全局变量
UndeclaredGlobalVariableUsing
resharper_undeclared_global_variable_using_highlighting

警告

在 'strict mode' 中使用 'with' 语句
WithStatementUsingError
resharper_with_statement_using_error_highlighting

错误

语法风格(5 项检查)

此类别中的检查检测 代码语法样式的违规。 与大多数代码检查不同,这些检查是否将相同的代码结构检测为代码问题取决于在 ReSharper 选项 的 代码编辑 | JavaScript | 语法样式 页面上配置的相应代码风格规则 Alt+R, O 。 您还可以使用 代码清理修复这些检查检测到的问题。

检查
ID
EditorConfig 属性

默认严重性

函数在声明之前被使用
FunctionsUsedBeforeDeclared
resharper_functions_used_before_declared_highlighting

已禁用

函数在声明范围之外被使用
FunctionUsedOutOfScope
resharper_function_used_out_of_scope_highlighting

警告

字符串字面量周围的引号不符合规范
StringLiteralWrongQuotes
resharper_string_literal_wrong_quotes_highlighting

提示

变量在内部作用域中声明之前被使用
VariableUsedInInnerScopeBeforeDeclared
resharper_variable_used_in_inner_scope_before_declared_highlighting

警告

变量在声明范围之外被使用
VariableUsedOutOfScope
resharper_variable_used_out_of_scope_highlighting

警告

2026年 11月 6日