Skip to content

fix: respect 'use no memo' directive in react-compiler-no-manual-memoization rule - #1750

Merged
aidenybai merged 3 commits into
mainfrom
cursor/triage-1749-e0d2
Sep 5, 2026
Merged

fix: respect 'use no memo' directive in react-compiler-no-manual-memoization rule#1750
aidenybai merged 3 commits into
mainfrom
cursor/triage-1749-e0d2

Conversation

@skoshx

@skoshx skoshx commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Why

React Compiler skips functions or modules with an opt-out directive. The rule still reported their manual memoization as redundant.

Before: manual memoization under "use no memo" could produce a warning.
After: function and module opt-outs preserve manual memoization while normal compiled code still reports it.

What changed

  • Support "use no memo" and the "use no forget" alias.
  • Support module and function directive prologues.
  • Resolve local component identifiers passed to memo.
  • Keep warnings for non-prologue strings and nested functions without an opt-out.
  • Add focused regression tests, a fuzz corpus case, and a patch changeset.

Local RDE did not run because its checkout contains unrelated user changes. Daytona parity did not run because DAYTONA_API_KEY is not available in this environment.

Test plan

  • 65 focused rule tests passed.
  • Strict fuzz passed with 500 iterations.
  • Full test suite passed.
  • Lint, typecheck, format, build, and JSON smoke checks passed.
  • Hosted CI passed.

Fixes #1749

cursoragent and others added 2 commits September 2, 2026 12:57
…ization rule

When a component has the 'use no memo' directive, React Compiler skips
optimization for that component, so manual memoization (useMemo,
useCallback, memo) is still needed.

This change adds support for detecting the 'use no memo' directive and
suppresses the react-compiler-no-manual-memoization rule in those cases.

- Add hasUseNoMemoDirective utility function
- Update rule to check for directive in enclosing function (useMemo/useCallback)
- Update rule to check for directive in wrapped component (memo)
- Add comprehensive tests including regression tests

Fixes #1749

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1750
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1750
npm i https://pkg.pr.new/react-doctor@1750

commit: 845ddff

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at 845ddff in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

@aidenybai
aidenybai marked this pull request as ready for review September 5, 2026 09:02
@aidenybai
aidenybai merged commit 576d756 into main Sep 5, 2026
28 checks passed
@aidenybai
aidenybai deleted the cursor/triage-1749-e0d2 branch September 5, 2026 21:22
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.

Feature Request: Respect the "use no memo" directive

3 participants