useYield (since v12.0.0)
Require generator functions to contain yield
.
This rule generates warnings for generator functions that do not have the yield
keyword.
Source: require-await.
Examples
Invalid
function* foo() {
return 10;
}
nursery/useYield.js:1:1 lint/nursery/useYield ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This generator function doesn't contain yield.
> 1 │ function* foo() {
│ ^^^^^^^^^^^^^^^^^
> 2 │ return 10;
> 3 │ }
│ ^
4 │
Valid
function* foo() {
yield 5;
return 10;
}
function foo() {
return 10;
}
// This rule does not warn on empty generator functions.
function* foo() { }