Skip to content

fix: align react static property placement with upstream - #2070

Merged
fansenze merged 1 commit into
mainfrom
codex/fix-react-static-property-placement-20260905
Sep 5, 2026
Merged

fix: align react static property placement with upstream#2070
fansenze merged 1 commit into
mainfrom
codex/fix-react-static-property-placement-20260905

Conversation

@fansenze

@fansenze fansenze commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix react/static-property-placement component detection to match ESLint. For example, Box.C = {} must take precedence over an earlier React class initializer when checking Box.C.propTypes. Component lookup now preserves upstream reference order, exact source spelling, nested property paths, repeated declarations, and TypeScript wrapper boundaries.

Reuse rslint's reference index, binding model, class-member helpers, and React pragma utility. Refine the existing JSDoc component helper with tsgo's comment scanner and parser so declaration ownership, adjacent comments, exported expressions, object methods, and tag syntax match upstream. Add regressions for the rule and its shared helper's sort-comp consumer, plus JavaScript/JSX integration and disable-comment coverage.

Validation:

  • Executed eslint-plugin-react 7.37.5 with ESLint 9.39.5 and @typescript-eslint/parser 8.69.0. All 2,824 differential cases agree, including the upstream release's source cases expanded across placement settings, message IDs, message text, and diagnostic ranges.
  • Added 22 rule regressions and 31 shared-helper examples checked in both JavaScript and TypeScript parser modes.
  • Targeted Go tests and race checks passed for reactutil, static_property_placement, and sort_comp.
  • Built @rslint/core and passed the two affected JS integration suites.
  • pnpm run check-spell and pnpm run format:check passed.
  • Go lint passed with --new-from-merge-base=origin/main, restricted to the three affected Go packages.

Local Go benchmark results (median of five 300 ms runs, 100 components per input, parsing/binding excluded):

Scenario Before After Time change
No watched members 16.83 µs 13.53 µs -19.6%
Invalid class fields 76.34 µs 38.44 µs -49.6%
Invalid external assignments (Box.C) 85.14 µs 131.93 µs +54.9%
Allowed class fields 17.94 µs 13.27 µs -26.0%
Allowed external assignments 48.06 µs 21.82 µs -54.6%

The external-assignment case includes building an uncached reference index and validating the first matching reference, which the previous declaration-first return skipped. Retain that work for correctness. Cached diagnostics and early placement checks reduce allocations elsewhere; invalid class fields drop from 1,514 to 322 allocations per input. Benchmark and profiling source files are not included.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@fansenze
fansenze merged commit 5886871 into main Sep 5, 2026
14 checks passed
@fansenze
fansenze deleted the codex/fix-react-static-property-placement-20260905 branch September 5, 2026 07:39
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.

1 participant