Versions

require-yield

Require generator functions to contain yield

Recommended

Using the recommended config from @eslint/js in a configuration file enables this rule

Rule Details

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

Examples

Examples of incorrect code for this rule:

Open in Playground
/*eslint require-yield: "error"*/

function* foo() {
  return 10;
}

Examples of correct code for this rule:

Open in Playground
/*eslint require-yield: "error"*/

function* foo() {
  yield 5;
  return 10;
}

function bar() {
  return 10;
}

// This rule does not warn on empty generator functions.
function* baz() { }

When Not To Use It

If you don’t want to notify generator functions that have no yield expression, then it’s safe to disable this rule.

Version

This rule was introduced in ESLint v1.0.0-rc-1.

Resources

Change Language
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy