Skip to content

Commit 6273994

Browse files
authored
fix(linter): block in eslint/no_cond_assign (#4721)
fix: #4687
1 parent 33f1312 commit 6273994

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/oxc_linter/src/rules/eslint/no_cond_assign.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ impl Rule for NoCondAssign {
7777
}
7878
AstKind::Function(_)
7979
| AstKind::ArrowFunctionExpression(_)
80-
| AstKind::Program(_) => break,
80+
| AstKind::Program(_)
81+
| AstKind::BlockStatement(_) => break,
8182
_ => {}
8283
}
8384
}
@@ -159,6 +160,11 @@ fn test() {
159160
("switch (foo) { case a = b: bar(); }", Some(serde_json::json!(["except-parens"]))),
160161
("switch (foo) { case a = b: bar(); }", Some(serde_json::json!(["always"]))),
161162
("switch (foo) { case baz + (a = b): bar(); }", Some(serde_json::json!(["always"]))),
163+
// not in condition
164+
("if (obj.key) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
165+
("for (;;) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
166+
("while (obj.key) { (obj.key=false) }", Some(serde_json::json!(["always"]))),
167+
("do { (obj.key=false) } while (obj.key)", Some(serde_json::json!(["always"]))),
162168
];
163169

164170
let fail = vec![

0 commit comments

Comments
 (0)