Skip to content

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

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

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!eslint

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions