Skip to content

Conversation

@huangtiandi1999
Copy link
Contributor

Part of fix issue: #10439

The auto-fix feature removed the comments in this case.

if (a) { return 1 } else { /** comments */ return 2 }

@graphite-app
Copy link
Contributor

graphite-app bot commented Apr 18, 2025

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.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Apr 18, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 18, 2025

CodSpeed Instrumentation Performance Report

Merging #10494 will not alter performance

Comparing huangtiandi1999:fix/linter/no-else-return (078a35f) with main (0ab2cb4)

Summary

✅ 36 untouched benchmarks

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

This does not look efficient. Can you try to use the span of BlockStatement?

@huangtiandi1999
Copy link
Contributor Author

This does not look efficient. Can you try to use the span of BlockStatement?

do you mean modified like this?

- ctx.comments().iter().find()
+ ctx.comments_range(block.span.start..block.span.end).find()

@Dunqing
Copy link
Member

Dunqing commented Apr 18, 2025

This does not look efficient. Can you try to use the span of BlockStatement?

do you mean modified like this?

- ctx.comments().iter().find()
+ ctx.comments_range(block.span.start..block.span.end).find()

Sorry that I did not explain clearly. I mean that you don't even need to access comments, return span of BlockStatement is enough because that BlockStatement always contains comments. Note that BlockStatement's span contains { and }, you need to exclude them.

@huangtiandi1999
Copy link
Contributor Author

Hi @Dunqing
I have updated the replacement_span to use the span of BlockStatement and adjusted the related auto-fix test cases. Could you please review the changes when you have a moment?

@huangtiandi1999 huangtiandi1999 requested a review from Dunqing April 21, 2025 09:55
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Great! Now the code looks clearer and simpler. One thing I guess we can make it better, can you take a look?

@huangtiandi1999 huangtiandi1999 requested a review from Dunqing April 21, 2025 12:55
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Looks good to me, we can polish the fixer code later if needed

@Dunqing Dunqing merged commit 020d8f8 into oxc-project:main Apr 21, 2025
25 checks passed
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.

2 participants