require-yield
JavaScript / TypeScriptsuspiciousno fixdefault: errorjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports a generator (function*, a generator method, async function*) that has statements but no yield. An empty generator is not reported.
Why it matters
Section titled “Why it matters”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 *.
Example
Section titled “Example”...function* p() {}function* q() { r(); }function* s() { yield 1; }var t = { *u() { v(); } };class L { *w() { x(); } async *y() { z(); } }Configuration
Section titled “Configuration”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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | require-yield |
full |