Skip to content

Conversation

@petermuessig
Copy link
Member

No description provided.

@petermuessig petermuessig requested a review from Copilot May 13, 2025 07:36
Copy link

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

This PR fixes the wrapping behavior in noWrapBeforeImport mode so that the first import is correctly processed when there is no code before it.

  • Adjusts the conditional logic in visitor.js to handle the first import and its preceding node more explicitly.
  • Adds a check in wrapper.js to set the reachedFirstImport flag when no node is marked with lastBeforeWrapping.
  • Updates tests and snapshots to validate the updated wrapping behavior.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

File Description
packages/plugin/src/modules/visitor.js Revised conditional logic for marking the previous sibling when applicable.
packages/plugin/src/modules/helpers/wrapper.js Introduced logic to set reachedFirstImport based on lastBeforeWrapping presence.
packages/plugin/test/fixtures/... Added/updated tests and snapshots to cover the new import wrapping behavior.
Comments suppressed due to low confidence (1)

packages/plugin/src/modules/helpers/wrapper.js:96

  • Ensure that the variable 'reachedFirstImport' is declared in the appropriate scope before being assigned; currently, the diff does not show its declaration, which could lead to a runtime ReferenceError.
if (!fullBody.find((item) => item.lastBeforeWrapping)) {

Comment on lines +207 to +208
// for the first element there is a special case as we can't mark the previous one
// therefore we do not mark anything to make clear that there's nothing to exclude
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider clarifying in the comment that when path.key equals 0 no marking takes place because there is no valid previous node, to improve maintainability and ease of understanding of this special case.

Suggested change
// for the first element there is a special case as we can't mark the previous one
// therefore we do not mark anything to make clear that there's nothing to exclude
// For the first element, there is a special case: when path.key === 0, we can't mark the previous node
// because there is no valid previous node. Therefore, we do not mark anything to make clear that there's nothing to exclude.

Copilot uses AI. Check for mistakes.
@petermuessig petermuessig merged commit d80c070 into main May 13, 2025
6 checks passed
@petermuessig petermuessig deleted the fix/noWrapBeforeImport branch May 13, 2025 07:39
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.

2 participants