Skip to content

eslint-factory: no-unsafe-catch-error-property guard is whole-block, causing branch-order false negatives #42189

Closed as not planned

Description

@github-actions

Summary

The rule treats a single getErrorMessage(err) or err instanceof Error anywhere in a catch block as suppressing every unsafe access in that block (hasGuard is per-frame, order-independent — see CallExpression/BinaryExpression handlers in eslint-factory/src/rules/no-unsafe-catch-error-property.ts:72-92). A guard in one branch wrongly suppresses an unguarded access executed in a sibling/earlier branch.

Example missed today

try { f(); } catch (err) {
  if (cond) { return getErrorMessage(err); }
  core.setFailed(err.message); // unsafe, but suppressed by the guard above
}

Acceptance criteria

  • Suppress an access only when a guard dominates it (lexically precedes in same/enclosing block), not when any guard exists.
  • Add invalid test: guard in one branch, unsafe access in another → still flagged.
  • Add valid test: guard then access in same straight-line block → not flagged.
  • No regression on existing nested-try and instanceof-ternary cases.

Generated by 🤖 ESLint Refiner · 156.2 AIC · ⌖ 11 AIC · ⊞ 4.7K · ◷

  • expires on Jul 5, 2026, 10:55 PM UTC-08:00

Activity

  1. added
    cookie
    on Jun 29, 2026
  2. github-actions commented on Jun 29, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I have identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · 2.32 AIC · ⌖ 9.01 AIC · ⊞ 3.6K · ◷

  3. added a commit that references this issue on Jun 29, 2026
    b82c4a6
  4. github-actions commented on Jul 6, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-07-06T06:55:02.667Z.

    Closed by Workflow

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

Metadata

Metadata

Labels

cookieeslint

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions