Skip to content

fix(jsdoc): prevent outer JSDoc from applying to nested functions#19219

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/02-10-fix_jsdoc_prevent_outer_jsdoc_from_applying_to_nested_functions
Feb 10, 2026
Merged

fix(jsdoc): prevent outer JSDoc from applying to nested functions#19219
graphite-app[bot] merged 1 commit intomainfrom
c/02-10-fix_jsdoc_prevent_outer_jsdoc_from_applying_to_nested_functions

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Feb 10, 2026

Fixes #19139

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Feb 10, 2026
Copy link
Contributor Author

camc314 commented Feb 10, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@camc314 camc314 self-assigned this Feb 10, 2026
@camc314 camc314 marked this pull request as ready for review February 10, 2026 13:40
Copilot AI review requested due to automatic review settings February 10, 2026 13:40
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Feb 10, 2026
Copy link
Contributor Author

camc314 commented Feb 10, 2026

Merge activity

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-returns and require-param covering 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.

@graphite-app graphite-app bot force-pushed the c/02-10-fix_jsdoc_prevent_outer_jsdoc_from_applying_to_nested_functions branch from 22aa520 to 3ea8f08 Compare February 10, 2026 13:45
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/02-10-fix_jsdoc_prevent_outer_jsdoc_from_applying_to_nested_functions (22aa520) with main (b4f7e7f)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (1b2f354) during the generation of this report, so b4f7e7f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app bot merged commit 3ea8f08 into main Feb 10, 2026
21 checks passed
@graphite-app graphite-app bot deleted the c/02-10-fix_jsdoc_prevent_outer_jsdoc_from_applying_to_nested_functions branch February 10, 2026 13:50
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: unexpected detection with jsdoc

2 participants