Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 1.78 KB

README.md

File metadata and controls

85 lines (59 loc) · 1.78 KB

@putout/plugin-generators NPM version

The function* declaration creates a binding of a new generator function to a given name. A generator function can be exited and later re-entered, with its context (variable bindings) saved across re-entrances.

(c) MDN

🐊Putout plugin improves Generator-related code.

Install

npm i @putout/plugin-generators -D

Rules

Config

{
    "rules": {
        "generators/add-missing-star": "on",
        "generators/convert-multiple-to-generator": "on"
    }
}

add-missing-star

The function* declaration creates a binding of a new generator function to a given name.

(c) MDN

❌ Example of incorrect code

function hello() {
    yield;
    'world';
}

function func2() {
    yield * func1();
}

✅ Example of correct code

function* hello() {
    yield 'world';
}

function* func2() {
    yield* func1();
}

convert-multiply-to-generator

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const a = 5 * function hello() {};

✅ Example of correct code

const a = 5;

function* hello() {}

License

MIT