Skip to content

blobReadingMethods

Prefer direct Blob reading methods over wrapping in Response for simpler code.

✅ This rule is included in the node stylistic and stylisticStrict presets.

Direct Blob methods are simpler and more direct than wrapping the Blob in a Response object. The Response wrapper adds unnecessary complexity when the Blob already provides the needed methods.

const
const text: string
text
= await new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
(
const blob: Blob
blob
).
Body.text(): Promise<string>
text
();
const
const arrayBuffer: ArrayBuffer
arrayBuffer
= await new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
(
const blob: Blob
blob
).
Body.arrayBuffer(): Promise<ArrayBuffer>
arrayBuffer
();
const
const bytes: Uint8Array<ArrayBuffer>
bytes
= await new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
(
const blob: Blob
blob
).
Body.bytes(): Promise<Uint8Array<ArrayBuffer>>
bytes
();

This rule is not configurable.

If you need to use Response-specific functionality while reading the Blob data, you might choose not to enable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.