规则名 | 规则类型 | 关联规则 | |
---|---|---|---|
require-yield |
suggestion |
|
This rule generates warnings for generator functions that do not have the yield
keyword.
此规则的 错误 代码实例:
/*eslint require-yield: "error"*/
/*eslint-env es6*/
function* foo() {
return 10;
}
此规则的 正确 代码实例:
::: correct
/*eslint require-yield: "error"*/
/*eslint-env es6*/
function* foo() {
yield 5;
return 10;
}
function foo() {
return 10;
}
// This rule does not warn on empty generator functions.
function* foo() { }
If you don't want to notify generator functions that have no yield
expression, then it's safe to disable this rule.