Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/promote-rules-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 28, 2022
2 parents 74c69b9 + a9db0f0 commit 0139d44
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
13 changes: 12 additions & 1 deletion crates/rome_js_analyze/src/analyzers/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down
16 changes: 14 additions & 2 deletions crates/rome_js_analyze/src/semantic_analyzers/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// valid
// invalid
function f() {
return !!specs.variables ? specs.variables(props) : {};
}
}
// valid
!-a ? b : c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,33 @@ expression: issue_3141.js
---
# Input
```js
// valid
// invalid
function f() {
return !!specs.variables ? specs.variables(props) : {};
}
// valid
!-a ? b : c
```

# Diagnostics
```
issue_3141.js:6:1 lint/style/noNegationElse FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Invert blocks when performing a negation test.
4 │ }
5 │ // valid
> 6 │ !-a ? b : c
│ ^^^^^^^^^^^
i Suggested fix: Exchange alternate and consequent of the node
4 4 │ }
5 5 │ // valid
6 │ - !-a·?·b·:·c
6 │ + -a·?·c·:·b
```


0 comments on commit 0139d44

Please sign in to comment.