Skip to content

require-yield

Reports a generator (function*, a generator method, async function*) that has statements but no yield. An empty generator is not reported.

A generator that never yields produces no values: iterating it runs the body once and ends at once. That is the mistake of a function* that was meant to be a normal function, or of a yield that was left out.

To fix, add the yield, or drop the *.

Reported
...
function* p() {}
function* q() { r(); }
function* s() { yield 1; }
var t = { *u() { v(); } };
class L { *w() { x(); } async *y() { z(); } }
js:
lint:
rules:
require-yield: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line require-yield in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint require-yield full