Skip to content

Commit

Permalink
feat(jsx-a11y/linter) add fixer for scope (#5310)
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Aug 29, 2024
1 parent e5ead86 commit bb995f6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/oxc_linter/src/rules/jsx_a11y/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ declare_oxc_lint!(
/// ```
Scope,
correctness,
pending
fix
);

impl Rule for Scope {
Expand Down Expand Up @@ -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)
});
}
}

Expand Down Expand Up @@ -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();
}

0 comments on commit bb995f6

Please sign in to comment.