1.0.0 β’ Published 1 year ago
@putout/plugin-generators v1.0.0
@putout/plugin-generators 
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
1.0.0
1 year ago