Skip to content

Don't convert line comments containing */ to block comments#15135

Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom
liuxingbaoyu:fix-15132
Nov 7, 2022
Merged

Don't convert line comments containing */ to block comments#15135
nicolo-ribaudo merged 1 commit intobabel:mainfrom
liuxingbaoyu:fix-15132

Conversation

@liuxingbaoyu
Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu commented Nov 5, 2022

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

regression: #15118

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator area: comments i: regression labels Nov 5, 2022
this.token("(");
this._parameters(node.params, node);
this.token(")");
this._noLineTerminator = true;
Copy link
Copy Markdown
Member Author

@liuxingbaoyu liuxingbaoyu Nov 5, 2022

Choose a reason for hiding this comment

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

This is the fix, can you confirm it? I'm not sure about the purpose here.
@nicolo-ribaudo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In arrow functions, ) cannot be followed by a newline.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably it doesn't matter because inner comments in arrow functions would already be printer earlier.

Comment on lines -907 to +914
if (this._noLineTerminator && HAS_NEWLINE.test(comment.value)) {
const noLineTerminator = this._noLineTerminator;

if (
noLineTerminator &&
(HAS_NEWLINE.test(comment.value) ||
HAS_BlOCK_COMMENT_END.test(comment.value))
) {
Copy link
Copy Markdown
Member Author

@liuxingbaoyu liuxingbaoyu Nov 5, 2022

Choose a reason for hiding this comment

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

Here is the fix for the root cause, see the test.

@babel-bot
Copy link
Copy Markdown
Collaborator

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

@nicolo-ribaudo nicolo-ribaudo changed the title fix: Generate invalid comments Don't convert line comments containing */ to block comments Nov 7, 2022
@nicolo-ribaudo nicolo-ribaudo merged commit 9b8fbcd into babel:main Nov 7, 2022
@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 Feb 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: comments i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to use pako in create-react-app 5 with latest babel v7.20.x

3 participants