fix(rome_js_analyze): additional check for `noNegationElse`
MODIFY
crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs
crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs
@@ -139,8 +139,8 @@ fn is_negation(node: &JsAnyExpression) -> Option<bool> {
match (expr.operator().ok(), expr.argument().ok()) {
(
Some(JsUnaryOperator::LogicalNot),
- Some(JsAnyExpression::JsUnaryExpression(_)),
- ) => Some(false),
+ Some(JsAnyExpression::JsUnaryExpression(inner_unary)),
+ ) => Some(inner_unary.operator().ok()? != JsUnaryOperator::LogicalNot),
_ => Some(true),
}
}

MODIFY
crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js
crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js
-// valid
+// invalid
function f() {
return !!specs.variables ? specs.variables(props) : {};
}
+// valid
+!-a ? b : c
\ No newline at end of file

fix(rome_js_analyze): additional check for `noNegationElse` (#3517)