fix(jsdoc): prevent outer JSDoc from applying to nested functions#19219
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
There was a problem hiding this comment.
Pull request overview
Fixes the JSDoc linter behavior where an outer function’s JSDoc could incorrectly be applied to nested function/arrow expressions (e.g., callbacks inside an exported function expression), causing false-positive require-param / require-returns diagnostics.
Changes:
- Update JSDoc lookup to stop when walking from a function into an enclosing (different) function/arrow node, preventing outer-to-inner JSDoc “leakage”.
- Add regression test cases for
require-returnsandrequire-paramcovering nested arrow functions inside a JSDoc-documented outer function.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/oxc_linter/src/utils/jsdoc.rs |
Prevents traversing past an enclosing function/arrow when searching for the “nearest” JSDoc node. |
crates/oxc_linter/src/rules/jsdoc/require_returns.rs |
Adds a passing test ensuring nested functions don’t inherit the outer function’s JSDoc for returns checks. |
crates/oxc_linter/src/rules/jsdoc/require_param.rs |
Adds a passing test ensuring nested functions don’t inherit the outer function’s JSDoc for param checks. |
22aa520 to
3ea8f08
Compare
Merging this PR will not alter performance
Comparing Footnotes
|

Fixes #19139