Skip to content
← Back to rules

eslint/require-yield 正确性

This rule is turned on by default.

作用

该规则会为不包含 yield 关键字的生成器函数生成警告。

为什么这不好?

这可能是一个错误。

示例

以下是此规则的错误代码示例:

javascript
function* foo() {
  return 10;
}

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "require-yield": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "require-yield": "error",
  },
});
bash
oxlint --deny require-yield

版本

此规则于 v0.0.4 中添加。

参考资料