Skip to content

Conversation

Copy link

Copilot AI commented Oct 28, 2025

  • Add test case demonstrating the issue where root0.bar is missing between root0.foo and root0.bar.baz
  • Fix the ordering logic in findExpectedIndex to use flattened roots correctly
  • Update test case with bad example (FooBar foo) to match current behavior
  • Verify all tests pass (3008 passing)
  • Verify lint passes

Summary

Fixed the issue where intermediate destructured properties were being inserted in the wrong order. The problem was in the findExpectedIndex function in src/rules/requireParam.js.

The Issue

When documenting function quux ({ foo, bar: { baz }}) with:

/**
 * @param root0
 * @param root0.foo
 * @param root0.bar.baz
 */

The missing root0.bar was being inserted after root0.bar.baz instead of before it.

The Fix

Changed findExpectedIndex to use the flattened parameter list correctly:

  • Previously: Used functionParameterNames.slice(indexAtFunctionParams) which used the unflattened structure
  • Now: Uses flattenedRoots.slice(indexAtFunctionParams + 1) which uses the correct flattened order
  • Added proper prefix handling since flattened roots don't include the "root0" prefix but JSDoc tags do

The fix now correctly inserts root0.bar between root0.foo and root0.bar.baz.

Original prompt

This section details on the original issue you should resolve

<issue_title>Destructuring improvements/fixes</issue_title>
<issue_description>A couple issues on the new destructuring support:

  • Where a root and grandchildren are present but not children, the fixing order is off.
  • As per checkDestructured property to disable destructured checks #532 (review) , we'd like to have clearer messages for reporting destructuring issues. To do this, we need to have a proper function for stringifying a destructured parameter object.
  • Report the proper line numbers

I put the issues together since for implementation, I think it will be easiest to refactor getFunctionParameterNames to handle both cases (perhaps avoiding flattening--need to investigate).


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
</issue_description>

<agent_instructions>Fix just the issue "Where a root and grandchildren are present but not children, the fixing order is off." For example:

/**
           * @param root0
           * @param root0.foo
           * @param root0.bar.baz
           */
          function quux ({ foo, bar: { baz }}) {

          }

...the plain root0.bar is missing.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@brettz9

This comment was marked as outdated.

brettz9

This comment was marked as outdated.

@brettz9 brettz9 dismissed their stale review October 28, 2025 22:14

Wondering if it is holding up Copilot

@brettz9
Copy link
Collaborator

brettz9 commented Oct 28, 2025

Copilot, please try again. Your work stopped during the process.

@brettz9 brettz9 closed this Oct 29, 2025
@brettz9 brettz9 deleted the copilot/fix-destructuring-issues-again branch October 29, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Destructuring improvements/fixes

2 participants