Skip to content

fix/eslint plugin react hooks typescript#718

Open
everettbu wants to merge 2 commits intomainfrom
fix/eslint-plugin-react-hooks-typescript
Open

fix/eslint plugin react hooks typescript#718
everettbu wants to merge 2 commits intomainfrom
fix/eslint-plugin-react-hooks-typescript

Conversation

@everettbu
Copy link
Copy Markdown

Mirror of facebook/react#36051
Original author: MorikawaSouma


  • fix(compiler): preserve HTML entities in JSX text by correctly detecting non-empty lines
  • fix(eslint-plugin-react-hooks): fix TypeScript types for flat config

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR contains two targeted fixes mirrored from facebook/react#36051:

  • Compiler: Preserve HTML entities in JSX text — Fixes trimJsxText in BuildHIR.ts to use .trim().length > 0 instead of a regex /[^ \t]/ for detecting non-empty lines. The old regex was not correctly identifying lines containing only certain whitespace characters, which could cause lastNonEmptyLine to be tracked incorrectly, leading to HTML entities being stripped. A test fixture (jsx-html-entity.js) validates the fix.
  • ESLint plugin: Fix TypeScript types for flat config — Corrects the ReactHooksFlatConfig type which previously had plugins: {react: any} (wrong key and any type) to plugins: {'react-hooks': typeof plugin}. Also restructures the code to inline configs into the plugin object and use a self-referential assignment pattern, improving type safety and eliminating Object.assign.

Confidence Score: 5/5

  • This PR is safe to merge — both changes are minimal, correct bug fixes with no risk of regressions.
  • Both changes are small, targeted fixes for clear bugs (incorrect regex for whitespace detection and wrong TypeScript type key/value). The compiler fix has a corresponding test fixture validating correctness. The ESLint plugin fix corrects an obvious type error (reactreact-hooks, anytypeof plugin) and the restructuring is a straightforward refactor that preserves runtime behavior.
  • No files require special attention.

Important Files Changed

Filename Overview
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts Replaces regex /[^ \t]/ with .trim().length > 0 for detecting non-empty lines in JSX text trimming, correctly handling HTML entities and edge-case whitespace. Minimal, correct fix.
packages/eslint-plugin-react-hooks/src/index.ts Fixes TypeScript types for flat config: corrects ReactHooksFlatConfig.plugins key from react to react-hooks, types it as typeof plugin instead of any, and restructures to inline configs into the plugin object using the standard self-referential pattern.

Last reviewed commit: 44c7c5c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants