Bugfix/ Leave Dangle Comments in NewExpression (#5017)

```js
new Thing(/* comment */)
```

now stays the same instead of being formatted into

```js
new Thing /* comment */()
```
master
Felix Wu 2018-08-27 03:23:14 +02:00 committed by Ika
parent 58d34bb844
commit 8779937a07
3 changed files with 8 additions and 1 deletions

View File

@ -479,7 +479,8 @@ function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
enclosingNode.type === "ClassMethod" ||
enclosingNode.type === "ObjectMethod") &&
enclosingNode.params.length === 0) ||
(enclosingNode.type === "CallExpression" &&
((enclosingNode.type === "CallExpression" ||
enclosingNode.type === "NewExpression") &&
enclosingNode.arguments.length === 0))
) {
addDanglingComment(enclosingNode, comment);

View File

@ -190,6 +190,8 @@ var x = [/* dangling */];
function x() {
/* dangling */
}
new Thing(/* dangling */);
Thing(/* dangling */);
declare class Foo extends Qux<string> {/* dangling */}
export /* dangling */{};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -205,6 +207,8 @@ var x = [
function x() {
/* dangling */
}
new Thing(/* dangling */);
Thing(/* dangling */);
declare class Foo extends Qux<string> {
/* dangling */
}

View File

@ -6,5 +6,7 @@ var x = [/* dangling */];
function x() {
/* dangling */
}
new Thing(/* dangling */);
Thing(/* dangling */);
declare class Foo extends Qux<string> {/* dangling */}
export /* dangling */{};