{"record":{"id":"8a65546a574d91a5","repo":"oxc-project/oxc","slug":"yields-tag-is-required-when-using-generator","errorCode":null,"errorMessage":"`@yields` tag is required when using `@generator` tag.","messagePattern":"`@yields` tag is required when using `@generator` tag\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jsdoc/require_yields.rs","lineNumber":35,"sourceCode":"        should_ignore_as_avoid, should_ignore_as_custom_skip, should_ignore_as_internal,\n        should_ignore_as_private,\n    },\n};\n\nfn missing_yields(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing JSDoc `@yields` declaration for generator function.\")\n        .with_help(\"Add `@yields` tag to the JSDoc comment.\")\n        .with_label(span)\n}\n\nfn duplicate_yields(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Duplicate `@yields` tags.\")\n        .with_help(\"Remove redundant `@yields` tag.\")\n        .with_label(span)\n}\n\nfn missing_yields_with_generator(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`@yields` tag is required when using `@generator` tag.\")\n        .with_help(\"Add `@yields` tag to the JSDoc comment.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct RequireYields(Box<RequireYieldsConfig>);\n\nimpl Deref for RequireYields {\n    type Target = RequireYieldsConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }\n}\n\n#[derive(Debug, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct RequireYieldsConfig {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/jsdoc/require_yields.rs#L17-L53","documentation":"This is the oxlint `jsdoc/require-yields` diagnostic for the `@generator` case. When the rule option `withGeneratorTag` (upstream `forceRequireGenerator`) is enabled, any JSDoc block that declares `@generator` must also declare `@yields`; otherwise the generator's output is undocumented. It is off by default and only fires when you opted in via rule config.","triggerScenarios":"Rule config sets `\"withGeneratorTag\": true` (jsdoc/require-yields) and a function's JSDoc contains a `@generator` tag but no `@yields` tag. The diagnostic is labeled on the `@generator` tag's span.","commonSituations":"Porting an ESLint config that used `require-yields` with `forceRequireGenerator: true`; doc pipelines that emit `@generator` boilerplate automatically (e.g. some typedoc templates) without a matching `@yields`.","solutions":["Add a `@yields` tag (even `@yields {void}`) next to `@generator` in the block.","Remove the redundant `@generator` tag — the `function*` syntax already conveys it.","If the coupling is unwanted, set `\"withGeneratorTag\": false` or omit the option (it defaults to false)."],"exampleFix":"// before\n/**\n * @generator\n */\nfunction* ids(start) { yield start; }\n\n// after\n/**\n * @generator\n * @yields {number} Sequential ids from `start`.\n */\nfunction* ids(start) { yield start; }","handlingStrategy":"validation","validationCode":"// Only fires when withGeneratorTag is enabled: flag @generator blocks without @yields\nconst src = require('fs').readFileSync(file, 'utf8');\nfor (const block of src.matchAll(/\\/\\*\\*[\\s\\S]*?\\*\\//g)) {\n  if (/@generator\\b/.test(block[0]) && !/@yields?\\b/.test(block[0])) console.error('require-yields (@generator) will fire');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable `withGeneratorTag` when you actually want the coupling between @generator and @yields.","Prefer deleting redundant @generator tags — `function*` is self-documenting.","Document your rule config choices in the repo so the option's origin is known."],"tags":["jsdoc","generator","documentation","lint","oxlint","config"],"backgroundTag":"jsdoc-yields-tag-missing","analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}