Skip to content

useYield (since v1.0.0)

Diagnostic Category: lint/correctness/useYield

Sources:

Require generator functions to contain yield.

This rule generates warnings for generator functions that do not have the yield keyword.

function* foo() {
return 10;
}
correctness/useYield.js:1:1 lint/correctness/useYield ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This generator function doesn't contain yield.
  
  > 1 │ function* foo() {
   ^^^^^^^^^^^^^^^^^
  > 2 │   return 10;
  > 3 │ }
   ^
    4 │ 
  
function* foo() {
yield 5;
return 10;
}
function foo() {
return 10;
}
// This rule does not warn on empty generator functions.
function* foo() { }