require-yield (Rules) – Eslint 中文开发手册 - Break易站

[
  •   Eslint 中文开发手册

    require-yield (Rules) - Eslint 中文开发手册

    "extends": "eslint:recommended"配置文件中的属性启用此规则。

    规则细节

    此规则会为没有yield关键字的生成器函数生成警告。

    示例

    此规则的错误代码示例:

    /*eslint require-yield: "error"*/
    /*eslint-env es6*/
    
    function* foo() {
      return 10;
    }

    此规则的正确代码示例:

    /*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() { }

    何时不使用它

    如果您不想通知没有yield表达式的生成器函数,那么禁用此规则是安全的。

    相关规则

    require-awaitVersion此规则在ESLint 1.0.0-rc-1.Resources中引入规则来源文档来源

  •   Eslint 中文开发手册
    ]
    转载请保留页面地址:https://www.breakyizhan.com/javascript/34562.html

    posted on 2020-07-13 20:25  MrAit  阅读(249)  评论(0)    收藏  举报

    导航