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

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 18, 2022
1 parent 4361da2 commit 83cd5ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,12 @@ impl Rule for UseKeyWithClickEvents {

match node {
JsxAnyElement::JsxOpeningElement(element) => {
let on_click_attribute = 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()
|| element.has_trailing_spread_prop(on_click_attribute)
{
return None;
}
element.name().ok()?.as_jsx_name()?;
let on_click_attribute = element.find_attribute_by_name("onClick").ok()??;
if element.has_trailing_spread_prop(on_click_attribute) {
return None;
}

for attribute in element.attributes().into_iter() {
if let JsxAnyAttribute::JsxAttribute(attribute) = attribute {
Expand All @@ -96,17 +92,14 @@ impl Rule for UseKeyWithClickEvents {
Some(())
}
JsxAnyElement::JsxSelfClosingElement(element) => {
let on_click_attribute = 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()
|| element.has_trailing_spread_prop(on_click_attribute)
{
return None;
}

if element.has_trailing_spread_prop(on_click_attribute) {
return None;
}

for attr in element.attributes().into_iter() {
for attribute in element.attributes().into_iter() {
if let JsxAnyAttribute::JsxAttribute(attribute) = attribute {
let name = attribute
.name()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ impl Rule for UseKeyWithMouseEvents {
fn run(ctx: &RuleContext<Self>) -> Self::Signals {
let node = ctx.query();

if node.is_custom_component().is_none() || node.has_valid_focus_attributes().is_none() {
return Some(UseKeyWithMouseEventsState::MissingOnFocus);
}
if node.is_custom_component().is_some() {
if node.has_valid_focus_attributes().is_none() {
return Some(UseKeyWithMouseEventsState::MissingOnFocus);
}

if node.has_valid_blur_attributes().is_none() {
return Some(UseKeyWithMouseEventsState::MissingOnBlur);
if node.has_valid_blur_attributes().is_none() {
return Some(UseKeyWithMouseEventsState::MissingOnBlur);
}
}

None
Expand Down

0 comments on commit 83cd5ee

Please sign in to comment.