Skip to content

Fix comment attach in ForXStatement#18099

Merged
fisker merged 8 commits intoprettier:mainfrom
fisker:for-comment
Oct 19, 2025
Merged

Fix comment attach in ForXStatement#18099
fisker merged 8 commits intoprettier:mainfrom
fisker:for-comment

Conversation

@fisker
Copy link
Copy Markdown
Member

@fisker fisker commented Oct 18, 2025

Description

This part was introduced in #901
But when the comment is before a meaningful ForXStatement.body, should be excluded.

Fixes #9812
Closes #9829

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Oct 18, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/prettier/prettier/@prettier/plugin-hermes@18099.tgz
yarn add https://pkg.pr.new/prettier/prettier/@prettier/plugin-oxc@18099.tgz
yarn add https://pkg.pr.new/prettier/prettier@18099.tgz

commit: 2bd7a9b

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 18, 2025

Deploy Preview for prettier ready!

Name Link
🔨 Latest commit 2bd7a9b
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/68f2f739d7865800080f0686
😎 Deploy Preview https://deploy-preview-18099--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@fisker
Copy link
Copy Markdown
Member Author

fisker commented Oct 18, 2025

Didn't notice #9829, will take a deeper look

@fisker
Copy link
Copy Markdown
Member Author

fisker commented Oct 18, 2025

Ha, this is the solution proposed in #9829 (comment)

@fisker
Copy link
Copy Markdown
Member Author

fisker commented Oct 18, 2025

For the EmptyStatement case, I'm going to allow attach to it in some places, since we have ancestors information in canAttachComment now #18055

@fisker fisker marked this pull request as ready for review October 18, 2025 02:15
@fisker fisker added this to the 3.7 milestone Oct 18, 2025
@fisker fisker merged commit 561d62a into prettier:main Oct 19, 2025
35 checks passed
@fisker fisker deleted the for-comment branch October 19, 2025 10:49
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.

@ts-expect-error comment is being shifted so it breaks

1 participant