-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Bug]: With comments: false, babel inserts an extra newline before the => of an arrow function #15161
Copy link
Copy link
Closed
Labels
area: commentsi: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator
Description
💻
- Would you like to work on a fix?
How are you using Babel?
@babel/cli
Input code
var test = (/* placeholder */) => {
/* Unused */
}Configuration file name
babel.config.json
Configuration
{
"sourceType": "script",
"presets": ["@babel/preset-env"],
"comments": false
}Browserslist is set to ["defaults"].
Current and expected behavior
With comments: false, the following output is produced:
var test = (
)
=> {
};which is not valid code. With comments: true, the following output is produced:
var test = ( /* placeholder */
) => {
/* Unused */
};which is valid. With @babel/generator version 7.20.2 and comments: false, the following output is produced:
var test = (
) => {
};which is valid, so this looks like a regression in version 7.20.3 (from #15135?).
Environment
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@babel/cli: ^7.19.3 => 7.19.3
@babel/core: ^7.20.2 => 7.20.2
@babel/generator: ^7.20.3 => 7.20.3
@babel/parser: ^7.20.3 => 7.20.3
@babel/preset-env: ^7.20.2 => 7.20.2
Possible solution
No response
Additional context
Maybe #15160 will also fix this, but there seems to be a gap in testing with comments: false.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: commentsi: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator