Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically print inner comments #15080

Merged
merged 1 commit into from Oct 28, 2022

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Oct 26, 2022

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR updates @babel/generator to automatically print .innerComments whenever there are two contiguous "raw" tokens (i.e. not nested nodes). By doing so, we reduce the risk of accidentally forgetting to print inner comments.

@nicolo-ribaudo nicolo-ribaudo added PR: Internal 🏠 A type of pull request used for our changelog categories pkg: generator labels Oct 26, 2022
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53256/

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

Great!

Comment on lines 8 to 9
/* D */ default /* E */class /* F */{/* G */} /* H */ No newline at end of file
/* D */ default /* E */class /* F */{/* G */} /* H */
Copy link
Member

Choose a reason for hiding this comment

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

Great change.

/* 0 */import /* 1 */ module /* 2 */from /* 3 */ from /* 4 */"./module.wasm" /* 5 */;
Copy link
Member

Choose a reason for hiding this comment

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

There is an inconsistency in the spaces here, but there have been similar ones in the past, and ignoring them should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I tried to fix some of them, but they have different causes and I couldn't figure out how ti fix all of them 😅

/*1*/for /* 2 */ /*3*/ await ( /*4*/using /*5*/fo /*6*/ of /*7*/of /*8*/) /*9*/;
Copy link
Member

Choose a reason for hiding this comment

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

The original behavior is better for me, but I don't mind the new one.

@@ -1,3 +1,3 @@
class C {
async [/* 2 */foo /* 3 */] /* 1 */ /* 4 */ /* 5 */() {}
async /* 1 */ /* 4 */ /* 5 */ [/* 2 */foo /* 3 */]() {}
Copy link
Member

Choose a reason for hiding this comment

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

The original behavior is better for me, but I don't mind the new one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the problem is that there is no "correct" answer: due to how we mix inner comments, two of 1/4/5 will be in the wrong place.

@nicolo-ribaudo nicolo-ribaudo merged commit bea7a43 into babel:main Oct 28, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the auto-innercomments branch October 28, 2022 15:21
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants