Skip to content

Latest commit

Β 

History

History
60 lines (42 loc) Β· 1.31 KB

File metadata and controls

60 lines (42 loc) Β· 1.31 KB

no-unnecessary-fetch-options

πŸ“ Disallow unnecessary options in fetch() and new Request().

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

Redundant fetch() and Request options make the request harder to scan.

The rule removes options that are equivalent to omission. Some RequestInit defaults are only equivalent when the input is known not to be an existing Request, because omitted options inherit from the input request.

Examples

// ❌
await fetch('/', {});

// βœ…
await fetch('/');
// ❌
await fetch('/', {method: 'GET'});

// βœ…
await fetch('/');
// ❌
await fetch('/', {credentials: 'same-origin'});

// βœ…
await fetch('/');
// ❌
await fetch(url, {signal: undefined});

// βœ…
await fetch(url);
// ❌
new Request(url, {body: null});

// βœ…
new Request(url);
// βœ…
await fetch(request, {method: 'GET'});