Skip to content

[error-boundaries] Extend JSX detection to variable assignments inside try blocks #1760

@Rel1cx

Description

@Rel1cx

Background

Per error-boundaries.spec.diff.md, the current error-boundaries rule only inspects ReturnStatement nodes for JSX inside try blocks, missing intermediate variable assignments.

React Compiler's ValidateNoJSXInTryStatement flags any JsxExpression / JsxFragment instruction.

Current behavior

function Component() {
  try {
    const el = <div />; // ❌ currently missed
    return el;
  } catch {}
}

Expected behavior

When traversing TryStatement, also detect JSX expressions inside VariableDeclarator, AssignmentExpression, and similar nodes.

References

  • Diff report: plugins/eslint-plugin-react-x/src/rules/error-boundaries/error-boundaries.spec.diff.md (§2.1 / §7)
  • SPEC: ValidateNoJSXInTryStatement

Priority

P0 — low implementation cost (extend existing visitor), high alignment benefit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerReact Compiler SPEC alignmentpriority: criticalRegression or crash; fix immediatelystatus: triageNeeds initial review / classificationtype: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions