Skip to content

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.

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.

Examples

Before — flagged Do not call global fetch here
src/routes/handler.ts
const response = await fetch("/api/invoices");
After — preferred Use a client abstraction
src/routes/handler.ts
const response = await billingClient.getInvoice(id);

Options

{
"additionalProperties": false,
"properties": {
"allow": {
"description": "Regular-expression sources matched against the filename. Replaces the defaults.",
"items": { "type": "string" },
"type": "array"
},
"basePath": {
"pattern": "^/(?!$)(?!.*[?#])(?!(?:.*/)?\\.\\.?(?:/|$))(?:[^/]+/)*[^/]+$",
"type": "string"
}
},
"type": "object"
}