From bb995f6361cf9873f7bbe8c328810c3f127b4a75 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Thu, 29 Aug 2024 00:51:00 +0000 Subject: [PATCH] feat(jsx-a11y/linter) add fixer for `scope` (#5310) --- crates/oxc_linter/src/rules/jsx_a11y/scope.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/oxc_linter/src/rules/jsx_a11y/scope.rs b/crates/oxc_linter/src/rules/jsx_a11y/scope.rs index 20cda7a0a9d02..07fcd1579852c 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/scope.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/scope.rs @@ -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"
", None, None), (r";", None, Some(settings()))]; - Tester::new(Scope::NAME, pass, fail).with_jsx_a11y_plugin(true).test_and_snapshot(); + let fix = vec![ + (r"
", r"
", None), + (r"

;", r"

;", Some(settings())), + ]; + + Tester::new(Scope::NAME, pass, fail) + .expect_fix(fix) + .with_jsx_a11y_plugin(true) + .test_and_snapshot(); }