Skip to content

no-detached-global-fetch

Keep the ambient global fetch receiver-safe when storing or explicitly rebinding it.

Why

Calling a raw ambient fetch through a class or object property supplies that object as this; receiver-sensitive hosts can reject that invocation only after deployment.

Fix

Store a forwarding wrapper such as (input, init) => fetch(input, init), or bind the callable to a compatible global or undefined receiver before storing it.

Examples

Before — flagged Do not store raw ambient fetch as an object method
src/client.ts
class Client {
readonly request = fetch;
}
After — preferred Store a receiver-safe forwarding wrapper
src/client.ts
class Client {
readonly request = (input: RequestInfo | URL, init?: RequestInit) =>
fetch(input, init);
}