Skip to content

Commit

Permalink
Fix format of comment in paren of call expression in arrow expression (
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyho112 authored and azz committed Nov 28, 2017
1 parent 172d34e commit a02e3b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ function handleCommentInEmptyParens(text, enclosingNode, comment) {
enclosingNode &&
(((enclosingNode.type === "FunctionDeclaration" ||
enclosingNode.type === "FunctionExpression" ||
enclosingNode.type === "ArrowFunctionExpression" ||
(enclosingNode.type === "ArrowFunctionExpression" &&
(enclosingNode.body.type !== "CallExpression" ||
enclosingNode.body.arguments.length === 0)) ||
enclosingNode.type === "ClassMethod" ||
enclosingNode.type === "ObjectMethod") &&
enclosingNode.params.length === 0) ||
Expand Down
6 changes: 6 additions & 0 deletions tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ f(/* ... */);
f(a, /* ... */);
f(a, /* ... */ b);
f(/* ... */ a, b);
let f = () => import(a /* ... */);
let f = () => doThing(a, /* ... */ b);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let f = (/* ... */) => {};
(function(/* ... */) {})(/* ... */);
Expand Down Expand Up @@ -72,4 +75,7 @@ f(a /* ... */);
f(a, /* ... */ b);
f(/* ... */ a, b);
let f = () => import(a /* ... */);
let f = () => doThing(a, /* ... */ b);
`;
3 changes: 3 additions & 0 deletions tests/empty_paren_comment/empty_paren_comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ f(/* ... */);
f(a, /* ... */);
f(a, /* ... */ b);
f(/* ... */ a, b);

let f = () => import(a /* ... */);
let f = () => doThing(a, /* ... */ b);

0 comments on commit a02e3b3

Please sign in to comment.