Skip to content

fix(react): align jsx-key with upstream - #2161

Merged
fansenze merged 1 commit into
mainfrom
fix/react-jsx-key-parity
Sep 16, 2026
Merged

fansenze merged 1 commit into
mainfrom
fix/react-jsx-key-parity

Conversation

@elecmonkey

Copy link
Copy Markdown
Member

Motivation

react/jsx-key currently misses key diagnostics for parenthesized JSX elements in arrays because the TypeScript AST preserves parentheses that ESTree omits.

The rule also ignores file-level @jsx pragmas when recognizing Children.toArray calls and constructing fragment diagnostics. This can produce false positives for custom JSX runtimes and recommend the wrong fragment name.

Changes

  • Unwrap parenthesized array elements before checking missing keys, duplicate keys, and key placement relative to spreads.
  • Honor file-level @jsx pragmas when recognizing Children.toArray calls and constructing fragment diagnostics.
  • Keep the fragment name independently controlled by settings.react.fragment, matching upstream behavior.
  • Split upstream and rslint-specific Go coverage and migrate all 57 canonical cases from eslint-plugin-react@7.37.5.
  • Add regression coverage for parenthesized elements, pragma precedence, diagnostic locations, and combined options.

@elecmonkey
elecmonkey marked this pull request as ready for review September 14, 2026 09:36
@fansenze
fansenze merged commit cdec320 into main Sep 16, 2026
37 of 41 checks passed
@fansenze
fansenze deleted the fix/react-jsx-key-parity branch September 16, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants