A generator function contains no yield, so it produces no values

tx0/ts:generator-without-yieldrecommendedwarningbug

What it finds

function* ids() { return [1, 2, 3]; }: a generator that never yields produces an iterator with no values. What it returns goes to the value of the final result, which for-of and spreading ignore. Either yield was left out or the * is unintended.

Generators with an empty body, which some interfaces need as a placeholder, are left alone.

From the rule's source, generator_without_yield.rs.

Example from the rule's tests
function* ids() {tx0 reports: this generator never yields  return [1, 2, 3];}function* real() {  yield 1;}function* placeholder() {}class Tree {  *walk() {tx0 reports: this generator never yields    const inner = function* () {      yield 1;    };    return inner;  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:generator-without-yield" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:generator-without-yield] reason="..."

tx0 explain tx0/ts:generator-without-yield shows the same in the terminal. Found a false positive? Report it.