Skip to content

eslint-factory: broaden no-unsafe-catch-error-property to flag .status, .cause, .name#42239

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/eslint-factory-broaden-no-unsafe-catch
Draft

eslint-factory: broaden no-unsafe-catch-error-property to flag .status, .cause, .name#42239
Copilot wants to merge 2 commits into
mainfrom
copilot/eslint-factory-broaden-no-unsafe-catch

Conversation

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

no-unsafe-catch-error-property (and its promise variant) only flagged .message, .stack, .code on unguarded caught error variables — missing .status accesses like if (err.status === 404) that are common in HTTP error handling.

Changes

  • Broadened UNSAFE_PROPERTIES in both no-unsafe-catch-error-property and no-unsafe-promise-catch-error-property to include status, cause, and name
  • Added typeof err === 'object' as an accepted guard (strict === only; alongside existing instanceof Error and getErrorMessage guards) — real call sites that check typeof err === 'object' before reading .status are no longer false positives
  • New RuleTester cases for all three new properties (invalid without guard) and typeof guard variants (valid)
// Now flagged:
try { ... } catch (err) { if (err.status === 404) { } }
//                              ^^^^^^^^^^

// Still suppressed — typeof guard recognized:
try { ... } catch (err) { if (typeof err === 'object') { doSomething(err.status); } }

…e/name with typeof guard

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add check for additional properties in no-unsafe-catch-error-property eslint-factory: broaden no-unsafe-catch-error-property to flag .status, .cause, .name Jun 29, 2026
Copilot AI requested a review from pelikhan June 29, 2026 12:31
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.

2 participants