Skip to content

Commit

Permalink
feat(linter/jsx-a11y): add fixer for aria-unsupported-elements
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Aug 13, 2024
1 parent 0cdd414 commit 88f9c47
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ declare_oxc_lint! {
/// ```
///
AriaUnsupportedElements,
correctness
correctness,
fix
}

#[derive(Debug, Default, Clone)]
Expand All @@ -56,7 +57,10 @@ impl Rule for AriaUnsupportedElements {
};
let attr_name = get_jsx_attribute_name(&attr.name).to_lowercase();
if INVALID_ATTRIBUTES.contains(&attr_name) {
ctx.diagnostic(aria_unsupported_elements_diagnostic(attr.span, &attr_name));
ctx.diagnostic_with_fix(
aria_unsupported_elements_diagnostic(attr.span, &attr_name),
|fixer| fixer.delete(&attr.span),
);
}
}
}
Expand Down Expand Up @@ -416,7 +420,16 @@ fn test() {
(r#"<track aria-hidden aria-role="none" {...props} />"#, None),
];

let fix = vec![
(r"<col role {...props} />", r"<col {...props} />"),
(
r#"<meta aria-hidden aria-role="none" {...props} />"#,
r#"<meta aria-role="none" {...props} />"#,
),
];

Tester::new(AriaUnsupportedElements::NAME, pass, fail)
.with_jsx_a11y_plugin(true)
.expect_fix(fix)
.test_and_snapshot();
}

0 comments on commit 88f9c47

Please sign in to comment.