Skip to content

TypeScript · architecture

no-raw-fetch-outside-clients

eslint:no-raw-fetch-outside-clients

Disallow calling the global `fetch` outside the client layer; route outbound HTTP through a client module that owns retry, timeout and status handling.

Default
error
Fix
none
Languages
typescript

Why

Scattered fetch calls bypass shared transport policy and are harder to stub and observe consistently.

Fix

Move the request into a client module and call that abstraction from application code.

Before / after

Executed by this rule’s unit tests.

Before

Do not call global fetch here

src/routes/handler.ts · focus
const response = await fetch('/api/invoices');

After

Use a client abstraction

src/routes/handler.ts · focus
const response = await billingClient.getInvoice(id);

Limits

  • Tests, client-layer paths, constructed handoffs, and pre-signed URL transfers are excluded.

Message IDs

rawFetch

Options

{
  "additionalProperties": false,
  "properties": {
    "allow": {
      "description": "Regular-expression sources matched against the filename. Replaces the defaults.",
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "type": "object"
}