feat(jsx-a11y/linter) add fixer for scope (#5310)

This commit is contained in:
camc314 2024-08-29 00:51:00 +00:00
parent e5ead86d43
commit bb995f6361

View file

@ -41,7 +41,7 @@ declare_oxc_lint!(
/// ```
Scope,
correctness,
pending
fix
);
impl Rule for Scope {
@ -74,7 +74,9 @@ impl Rule for Scope {
return;
}
ctx.diagnostic(scope_diagnostic(scope_attribute.span));
ctx.diagnostic_with_fix(scope_diagnostic(scope_attribute.span), |fixer| {
fixer.delete_range(scope_attribute.span)
});
}
}
@ -107,5 +109,13 @@ fn test() {
let fail =
vec![(r"<div scope />", None, None), (r"<Foo scope='bar' />;", None, Some(settings()))];
Tester::new(Scope::NAME, pass, fail).with_jsx_a11y_plugin(true).test_and_snapshot();
let fix = vec![
(r"<div scope />", r"<div />", None),
(r"<h1 scope='bar' />;", r"<h1 />;", Some(settings())),
];
Tester::new(Scope::NAME, pass, fail)
.expect_fix(fix)
.with_jsx_a11y_plugin(true)
.test_and_snapshot();
}