Skip to content

Latest commit

ย 

History

History
48 lines (35 loc) ยท 1.13 KB

File metadata and controls

48 lines (35 loc) ยท 1.13 KB

no-invalid-fetch-options

๐Ÿ“ Disallow invalid options in fetch() and new Request().

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

fetch() throws a TypeError when the method is GET or HEAD and a body is provided.

Examples

// โŒ
const response = await fetch('/', {body: 'foo=bar'});
// โŒ
const request = new Request('/', {body: 'foo=bar'});
// โœ…
const response = await fetch('/', {method: 'HEAD'});
// โœ…
const request = new Request('/', {method: 'HEAD'});
// โŒ
const response = await fetch('/', {method: 'GET', body: 'foo=bar'});

// โœ…
const response = await fetch('/', {method: 'POST', body: 'foo=bar'});
// โŒ
const request = new Request('/', {method: 'GET', body: 'foo=bar'});

// โœ…
const request = new Request('/', {method: 'POST', body: 'foo=bar'});
โšก