Skip to content

[use-memo] Add validateNoVoidUseMemo option to allow disabling Rule 4 and 5 #1763

@Rel1cx

Description

@Rel1cx

Background

Per use-memo.spec.diff.md, React Compiler's ValidateUseMemo.ts provides a validateNoVoidUseMemo toggle that enables Rule 4 (must return a value) and Rule 5 (result must be used) only when turned on.

The current ESLint rule enforces both unconditionally.

Current behavior

// Always reported, even when the developer intentionally doesn't need the return value
useMemo(() => {
  doSideEffect();
}, []); // ❌ resultMustBeUsed

Expected behavior

Add a validateNoVoidUseMemo option to the rule schema (default true for backward compatibility, or false to match the SPEC default) so users can opt out of Rule 4 and Rule 5.

References

  • Diff report: plugins/eslint-plugin-react-x/src/rules/use-memo/use-memo.spec.diff.md (§2.4 / §2.5 / §4)
  • SPEC: ValidateUseMemo.ts

Priority

P1 — medium implementation cost, aligns SPEC configurability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerReact Compiler SPEC alignmentpriority: highMajor impact; schedule next releasestatus: triageNeeds initial review / classificationtype: featureNew feature or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions