close

no-invalid-fetch-options

Unreleased

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-invalid-fetch-options': 'error',
    },
  },
]);

Rule Details

Disallows request bodies in fetch() and new Request() calls whose method is GET or HEAD. The Fetch Standard throws a TypeError for these combinations.

Examples of incorrect code for this rule:

fetch('/', { body: 'foo=bar' });

new Request('/', { method: 'HEAD', body: 'foo=bar' });

Examples of correct code for this rule:

fetch('/', { method: 'POST', body: 'foo=bar' });

new Request('/', { method: 'HEAD' });

Original Documentation