Skip to content

Commit

Permalink
fix(linter): block in eslint/no_cond_assign (#4721)
Browse files Browse the repository at this point in the history
fix: #4687
  • Loading branch information
heygsc committed Aug 7, 2024
1 parent 33f1312 commit 6273994
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_cond_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl Rule for NoCondAssign {
}
AstKind::Function(_)
| AstKind::ArrowFunctionExpression(_)
| AstKind::Program(_) => break,
| AstKind::Program(_)
| AstKind::BlockStatement(_) => break,
_ => {}
}
}
Expand Down Expand Up @@ -159,6 +160,11 @@ fn test() {
("switch (foo) { case a = b: bar(); }", Some(serde_json::json!(["except-parens"]))),
("switch (foo) { case a = b: bar(); }", Some(serde_json::json!(["always"]))),
("switch (foo) { case baz + (a = b): bar(); }", Some(serde_json::json!(["always"]))),
// not in condition
("if (obj.key) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
("for (;;) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
("while (obj.key) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
("do { (obj.key=false) } while (obj.key)", Some(serde_json::json!(["always"]))),
];

let fail = vec![
Expand Down

0 comments on commit 6273994

Please sign in to comment.