Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/rules/react_rules_of_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ impl Handler for RulesOfHooksHandler {
}
}
}
Node::BinExpr(_) => {
if let Some(ParentKind::Bin) = self.parent_kind.pop() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is even really needed, might be excessive paranoia.

self.maybe_decrease_cond_counter();
}
}
Node::FnDecl(_)
| Node::ArrowExpr(_)
| Node::BinExpr(_)
| Node::CondExpr(_)
| Node::VarDeclarator(_)
| Node::ForInStmt(_)
Expand Down Expand Up @@ -334,6 +338,22 @@ function doAThing() {
}
const [foo, setFoo] = useState(false);
}"#,
r#"function Foo() {
useCustomHook(val ?? 0);
useState(0);
}"#,
r#"function Foo() {
useCustomHook(val && 0);
useState(0);
}"#,
r#"function Foo() {
useCustomHook(val || 0);
useState(0);
}"#,
r#"function Foo() {
useCustomHook(val > 0);
useState(0);
}"#,
};
}

Expand Down