Skip to content

Autofix removes valid JSX boolean shorthand props (autoFocus) #18151

@blowery

Description

@blowery

Summary

When running oxlint with --fix, valid JSX boolean shorthand props like autoFocus are being removed from elements. This breaks functionality as the prop is simply deleted with no replacement.

Reproduction

// Original code - input receives focus on mount
<input
  aria-label="Search"
  autoComplete="off"
  autoFocus
  className={style.input}
/>

// After autofix - autoFocus prop is deleted
<input
  aria-label="Search"
  autoComplete="off"
  className={style.input}
/>

Impact

  • Tests that verify element.toHaveFocus() fail
  • User experience degrades as inputs no longer auto-focus

Files affected

In our codebase, 13 files had autoFocus props removed:

  • Search forms
  • Login/password forms
  • Modal dialogs
  • Text editors

Expected behavior

Valid JSX boolean shorthand props should not be removed by autofix. autoFocus is equivalent to autoFocus={true} and is a standard HTML/React attribute.

Unknown

I was unable to determine which specific rule's autofix caused this deletion. The prop was simply removed with no diagnostic message indicating why.

Workaround

Manually restore the props after autofix, or identify and disable the offending rule.

Environment

  • oxlint version: latest (via npm)
  • React codebase with TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions