# 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.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

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

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

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
function* ids() {
  return nextId();
}
```

Not reported:

{/* good */}
```js
function* ids() {
  while (true) {
    yield nextId();
  }
}

function* nothing() {}
```
