fix(react-compiler): clarify incompatible-library remediation (keep the rule)#951
Merged
Conversation
The react-hooks-js/incompatible-library rule from React Compiler is overly aggressive and flags well-designed, battle-tested libraries like @tanstack/react-virtual, @tanstack/react-table, and similar TanStack libraries. These libraries are specifically designed to work with React and don't present the compatibility issues the rule is trying to catch. The current remediation guidance can push users away from mature virtualization/data libraries toward fragile, handwritten implementations. This change removes react-hooks-js/incompatible-library from EXTERNAL_RULES, preventing it from being enabled in the oxlint config. Closes #950 Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
commit: |
…p the rule Instead of disabling react-hooks-js/incompatible-library, keep the rule (its compiler bail-out reason is informative) and replace the generic "rewrite the flagged code" action — which read as "reimplement the library" and steered users off mature libraries like @tanstack/react-virtual (#950) — with one that names the real fix: it's a library limitation, not a bug; memoize values you pass into other memoized components, or disable the rule if it's noise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ine-disable Tighten the remediation per the writing guidelines and point at the inline suppression: "It's how the library works, not a bug in your code. Memoize values you pass from it into other memoized components, or suppress it with `// react-doctor-disable-next-line react-hooks-js/incompatible-library`." Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reworked from the original "disable the rule" approach (per maintainer decision) to keep
react-hooks-js/incompatible-libraryactive but fix its misleading remediation copy.The rule fires when the React Compiler can't memoize through a third-party hook (e.g.
@tanstack/react-virtual'suseVirtualizer) — the reporter's pain (#950) was the generic action "Rewrite the flagged code so the compiler can optimize it", which reads as "reimplement the library locally" and steers users off mature libraries.The compiler's own bail-out reason is informative, so the rule stays on; only the action changes (in
core/src/runners/oxlint/parse-output.ts) to: it's a limitation of the library, not a bug in your code — memoize any of its values you pass into other memoized components, or disable the rule if it's noise.Changes
incompatible-libraryinEXTERNAL_RULES(reverts the disable).parse-output.ts+ areact-compiler-bailout-message.test.tscase.Closes #950
Note
Low Risk
User-facing diagnostic text only in oxlint output parsing; no runtime behavior, security, or data-path changes.
Overview
Fixes misleading guidance for
react-hooks-js/incompatible-librarywhen oxlint/React Compiler flags third-party hooks (e.g. TanStack Virtual) that the compiler cannot memoize through.The rule stays enabled; only the user-facing action changes. Instead of the generic "Rewrite the flagged code so the compiler can optimize it", diagnostics now explain that the limitation is expected library behavior, suggest memoizing values passed into other memoized components, and document
react-doctor-disable-next-linefor noise.buildReactCompilerMessageaccepts a per-rule action; other compiler bail-outs still use the rewrite copy.Adds a changeset (patch
@react-doctor/core) and a unit test asserting the new copy and absence of the old rewrite wording.Reviewed by Cursor Bugbot for commit 6b50e3f. Bugbot is set up for automated code reviews on this repo. Configure here.