From 57050ab16ac2a5c001138595b0a59f760bff0d1d Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:17:09 +0000 Subject: [PATCH] refactor(linter): shorten code in `jsx_a11y/aria_activedescendant_has_tabindex` rule (#5340) Shorten code which was introduced in #5223. --- .../aria_activedescendant_has_tabindex.rs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs index 15ef149c09c02..507810698fbc4 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs @@ -82,22 +82,12 @@ impl Rule for AriaActivedescendantHasTabindex { return; } - match &jsx_opening_el.name { - JSXElementName::Identifier(identifier) => { - ctx.diagnostic(aria_activedescendant_has_tabindex_diagnostic( - identifier.span, - identifier.name.as_str(), - )); - } - - JSXElementName::IdentifierReference(identifier_reference) => { - ctx.diagnostic(aria_activedescendant_has_tabindex_diagnostic( - identifier_reference.span, - identifier_reference.name.as_str(), - )); - } - _ => {} - } + let (name, span) = match &jsx_opening_el.name { + JSXElementName::Identifier(id) => (id.name.as_str(), id.span), + JSXElementName::IdentifierReference(id) => (id.name.as_str(), id.span), + _ => return, + }; + ctx.diagnostic(aria_activedescendant_has_tabindex_diagnostic(span, name)); } }