jsdoc/require-yields Correctness
它的作用
要求记录 yields。 如果存在多个 @yields 标签,也会报告。
为什么这不好?
该规则旨在防止在需要 @yields 标签时遗漏它们。
示例
此规则的错误代码示例:
javascript
function* quux(foo) {
yield foo;
}
/**
* @yields {undefined}
* @yields {void}
*/
function* quux(foo) {}此规则的正确代码示例:
javascript
/** * @yields Foo */
function* quux(foo) {
yield foo;
}配置
此规则接受一个具有以下属性的配置对象:
exemptedBy
type: string[]
default: ["inheritdoc"]
带有这些标签的函数将被此 lint 规则豁免。
forceRequireYields
type: boolean
default: false
当为 true 时,所有生成器函数都必须有 @yields 标签,即使它们不产出值或主体为空。
withGeneratorTag
type: boolean
default: false
当为 true 时,在存在 @generator 标签时要求提供 @yields。
如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsdoc"],
"rules": {
"jsdoc/require-yields": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsdoc"],
rules: {
"jsdoc/require-yields": "error",
},
});bash
oxlint --deny jsdoc/require-yields --jsdoc-plugin版本
此规则于 v0.3.2 中添加。
