chore(rome_js_analyze): better use of `Option`
MODIFY
crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs
crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs
@@ -62,8 +62,11 @@ impl Rule for UseKeyWithClickEvents {
match node {
JsxAnyElement::JsxOpeningElement(element) => {
- element.name().ok()?.as_jsx_name()?;
- element.find_attribute_by_name("onClick").ok()??;
+ if element.name().ok()?.as_jsx_name().is_none()
+ || element.find_attribute_by_name("onClick").ok()?.is_none()
+ {
+ return None;
+ }
for attr in element.attributes().into_iter() {
let name = attr
@@ -83,8 +86,11 @@ impl Rule for UseKeyWithClickEvents {
Some(())
}
JsxAnyElement::JsxSelfClosingElement(element) => {
- element.name().ok()?.as_jsx_name()?;
- element.find_attribute_by_name("onClick").ok()??;
+ if element.name().ok()?.as_jsx_name().is_none()
+ || element.find_attribute_by_name("onClick").ok()?.is_none()
+ {
+ return None;
+ }
for attr in element.attributes().into_iter() {
let name = attr

MODIFY
crates/rome_js_analyze/src/semantic_analyzers/nursery/use_key_with_mouse_events.rs
crates/rome_js_analyze/src/semantic_analyzers/nursery/use_key_with_mouse_events.rs
@@ -174,9 +174,7 @@ impl Rule for UseKeyWithMouseEvents {
fn run(ctx: &RuleContext<Self>) -> Self::Signals {
let node = ctx.query();
- node.is_custom_component()?;
-
- if node.has_spread_attribute() {
+ if node.is_custom_component().is_none() || node.has_spread_attribute() {
return None;
}

chore(rome_js_analyze): better use of `Option` (#3434)