deno.com

require-yield

NOTE: this rule is part of the recommended rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["recommended"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["require-yield"],
      "exclude": ["require-yield"]
    }
  }
}

Disallows generator functions that have no yield.

JavaScript provides generator functions expressed as function*, where we can pause and later resume the function execution at the middle points. At these points we use the yield keyword. In other words, it makes no sense at all to create generator functions that contain no yield keyword, since such functions could be written as normal functions.

Invalid:

function* f1() {
  return "f1";
}

Valid:

function* f1() {
  yield "f1";
}

// generator function with empty body is allowed
function* f2() {}

function f3() {
  return "f3";
}

Did you find what you needed?

Privacy policy