Skip to content

[Code Quality] Fix require-fetch-try-catch false negative for member-chained fetch calls #48004

Closed as not planned

Description

@github-actions

Description

The require-fetch-try-catch ESLint rule in eslint-factory/src/index.ts has a false negative: isAwaitFetchCall only matches an awaited CallExpression whose callee is the bare fetch Identifier. Any member-expression chain (await fetch(url).then(...), await fetch(url).catch(...), await fetch(url).json()) has a MemberExpression callee and is silently ignored.

This means bare .then() chains with no rejection handler escape detection and could crash on network TypeError.

Grounded example: validate_secrets.cjs:65,85 — await fetch(...).catch(rethrowAbortError) escapes the rule.

Suggested Changes

  • Update isAwaitFetchCall to recognize member-expression chains on fetch as fetch calls
  • Recognize terminal .catch(...) or 2-arg .then(onFulfilled, onRejected) as satisfying the try-catch requirement (do not flag these as violations)
  • Add test cases for:
    • await fetch(url).then(r => r.json()) inside try — expected: valid
    • await fetch(url).catch(handler) — expected: valid (rejection handled)
    • await fetch(url).then(r => r.json()) without try — expected: invalid (error)

Files Affected

  • eslint-factory/src/index.ts (require-fetch-try-catch rule, isAwaitFetchCall helper)
  • eslint-factory/src/tests/ (add test cases for chained fetch pattern)

Success Criteria

  • Member-chained fetch calls are detected by the rule
  • .catch(handler) and 2-arg .then() are treated as rejection-handled
  • All existing test cases pass
  • ESLint factory tests pass

Priority

Medium — closes a real false-negative gap that lets unsafe fetch chains slip through linting

Source

Extracted from [eslint-refiner] ESLint Refiner — Daily Report 2026-07-25

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 58.9 AIC · ⌖ 5.58 AIC · ⊞ 7.1K · ◷

  • expires on Jul 26, 2026, 5:14 AM UTC-08:00

Activity

  1. github-actions commented on Jul 26, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-07-26T13:14:35.013Z.

    Closed by Workflow

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions