Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

require-yield

Require generator functions to contain yield

A generator that never yields produces no values, so a for...of loop over it ends right away. Either the yield is missing or the * is a mistake.

A generator with an empty body isn't reported. A yield in a nested generator doesn't count for the outer one.

This rule is on by default.

Configure

On by default as a warning. To turn it off:

bunfig.toml
[lint.rules]
"require-yield" = "off" # or "error"

Examples

Reported:

function* ids() {
  return nextId();
}

Not reported:

function* ids() {
  while (true) {
    yield nextId();
  }
}

function* nothing() {}