Skip to content

linter: eslint-plugin-unicorn(no-invalid-fetch-options) rule missed the actual method variable in nested readonly object #16686

@ryoppippi

Description

@ryoppippi

What version of Oxlint are you using?

1.32.0

What command did you run?

pnpm oxlint --type-aware --max-warnings=0 --type-check

What does your .oxlintrc.json config file look like?

{
	"$schema": "./node_modules/oxlint/configuration_schema.json",
	// Enable TypeScript, Unicorn, and Oxc plugins
	"plugins": ["unicorn"],
	// Ignore patterns
	"ignorePatterns": ["dist", "node_modules"],
}

What happened?

{
	const method = 'POST' as const;
	await fetch(`some-url`, { method, body: '' }); // no error
}

{
	const options = {
		method: 'POST',
	} as const;

	await fetch(`some-url`, { method: options.method, body: '' }); // error happens
}
  ⚠ eslint-plugin-unicorn(no-invalid-fetch-options): "body" is not allowed when method is "GET"
    ╭─[index.ts:13:52]
 12 │
 13 │     await fetch(`some-url`, { method: options.method, body: '' });
    ·                                                       ────
 14 │ }
    ╰────

Metadata

Metadata

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions