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'});