fix(linter): avoid applying object-level docs to nested object methods in require-param#19231
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. |
There was a problem hiding this comment.
Pull request overview
Fixes jsdoc/require-param false-positives where a JSDoc attached to an object assignment/initializer was incorrectly treated as applying to functions nested inside the object literal (e.g., object methods), addressing #19139.
Changes:
- Stop JSDoc lookup when walking up the AST at
ObjectExpressionto prevent object-level JSDoc from “leaking” into nested object methods. - Add a regression test for a typed object literal (
ShikiTransformer) with an undocumented method that should no longer triggerrequire-param. - Add a test + snapshot coverage for a method that does have its own JSDoc but is missing
@param(expected to warn).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_linter/src/utils/jsdoc.rs | Adjusts nearest-JSDoc resolution to avoid applying object-level docs to nested object-literal functions. |
| crates/oxc_linter/src/rules/jsdoc/require_param.rs | Adds regression coverage for the reported scenario and a related failing case. |
| crates/oxc_linter/src/snapshots/jsdoc_require_param.snap | Updates snapshot output to include the new failing diagnostic case. |
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
9bafa76 to
b4b9469
Compare
b4b9469 to
2d0fb96
Compare
2d0fb96 to
79c82cc
Compare
…s in require-param (oxc-project#19231) fixes oxc-project#19139
# Oxlint ### 🚀 Features - ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138) (Boshen) - 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (#19275) (camc314) - a204eda linter: Implement fixer for unicorn/no-typeof-undefined (#19274) (camc314) - ab46d9c linter: Implement typescript/class-literal-property-style (#19252) (Vincent R) - 1a61f58 linter: Implement typescript/no-invalid-void-type (#19242) (Vincent R) ### 🐛 Bug Fixes - 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (#19292) (overlookmotel) - 05bc855 linter/import: Count unique module sources in max-dependencies (#19270) (camc314) - 8566b44 linter: Check for preceeding token in math trunc fixer (#19277) (camc314) - f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives with type-only edges (#19267) (camc314) - d4937e7 linter: Recognize module-scoped callback refs as stable in exhaustive-deps (#19220) (Sreetam Das) - 140c9bd linter: Detect fallthrough from `default` when it is not the last case (#19261) (Boshen) - 740a009 linter: Accept digits after 'use' in hook names (#19254) (Sreetam Das) - 31b562f linter: Update `import/no-named-as-default` to allow named import if equivalent to the default import (#19100) (connorshea) - 79c82cc linter: Avoid applying object-level docs to nested object methods in require-param (#19231) (camc314) ### ⚡ Performance - 5670291 linter/class-literal-property-style: Avoid unneeded string allocations (#19262) (camc314) # Oxfmt ### 🚀 Features - ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138) (Boshen) ### 🐛 Bug Fixes - 1957908 formatter: Avoid unnecessary parentheses for string literal in labeled statement (#19272) (Dunqing) Co-authored-by: camc314 <[email protected]>
…s in require-param (oxc-project#19231) fixes oxc-project#19139
# Oxlint ### 🚀 Features - ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138) (Boshen) - 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (oxc-project#19275) (camc314) - a204eda linter: Implement fixer for unicorn/no-typeof-undefined (oxc-project#19274) (camc314) - ab46d9c linter: Implement typescript/class-literal-property-style (oxc-project#19252) (Vincent R) - 1a61f58 linter: Implement typescript/no-invalid-void-type (oxc-project#19242) (Vincent R) ### 🐛 Bug Fixes - 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (oxc-project#19292) (overlookmotel) - 05bc855 linter/import: Count unique module sources in max-dependencies (oxc-project#19270) (camc314) - 8566b44 linter: Check for preceeding token in math trunc fixer (oxc-project#19277) (camc314) - f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives with type-only edges (oxc-project#19267) (camc314) - d4937e7 linter: Recognize module-scoped callback refs as stable in exhaustive-deps (oxc-project#19220) (Sreetam Das) - 140c9bd linter: Detect fallthrough from `default` when it is not the last case (oxc-project#19261) (Boshen) - 740a009 linter: Accept digits after 'use' in hook names (oxc-project#19254) (Sreetam Das) - 31b562f linter: Update `import/no-named-as-default` to allow named import if equivalent to the default import (oxc-project#19100) (connorshea) - 79c82cc linter: Avoid applying object-level docs to nested object methods in require-param (oxc-project#19231) (camc314) ### ⚡ Performance - 5670291 linter/class-literal-property-style: Avoid unneeded string allocations (oxc-project#19262) (camc314) # Oxfmt ### 🚀 Features - ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138) (Boshen) ### 🐛 Bug Fixes - 1957908 formatter: Avoid unnecessary parentheses for string literal in labeled statement (oxc-project#19272) (Dunqing) Co-authored-by: camc314 <[email protected]>

fixes #19139