From effc4112f611cf417aa618894f893cad61130e1d Mon Sep 17 00:00:00 2001 From: Ben Lowery <14350+blowery@users.noreply.github.com> Date: Sat, 17 Jan 2026 19:08:16 -0500 Subject: [PATCH] fix(linter/jsx-a11y): change `no-autofocus` autofix to suggestion The autofix for `jsx-a11y/no-autofocus` automatically removes `autoFocus` attributes from JSX elements. This is dangerous because: 1. It silently changes application behavior (removes auto-focus functionality) 2. It can cause test failures and user experience regressions 3. The ESLint equivalent rule does NOT have an autofix Changed from `fix` to `suggestion` so users must explicitly opt-in with `--fix-suggestions` to apply this transformation. Closes #18151 --- crates/oxc_linter/src/rules/jsx_a11y/no_autofocus.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxc_linter/src/rules/jsx_a11y/no_autofocus.rs b/crates/oxc_linter/src/rules/jsx_a11y/no_autofocus.rs index 22f97e9385c7b..129583b7314a4 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/no_autofocus.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/no_autofocus.rs @@ -56,7 +56,7 @@ declare_oxc_lint!( NoAutofocus, jsx_a11y, correctness, - fix, + suggestion, config = NoAutofocus, ); @@ -81,7 +81,7 @@ impl Rule for NoAutofocus { if HTML_TAG.contains(element_type.as_ref()) && let JSXAttributeItem::Attribute(attr) = autofocus { - ctx.diagnostic_with_fix(no_autofocus_diagnostic(attr.span), |fixer| { + ctx.diagnostic_with_suggestion(no_autofocus_diagnostic(attr.span), |fixer| { fixer.delete(&attr.span) }); } @@ -89,7 +89,7 @@ impl Rule for NoAutofocus { } if let JSXAttributeItem::Attribute(attr) = autofocus { - ctx.diagnostic_with_fix(no_autofocus_diagnostic(attr.span), |fixer| { + ctx.diagnostic_with_suggestion(no_autofocus_diagnostic(attr.span), |fixer| { fixer.delete(&attr.span) }); }