Skip to content

Commit

Permalink
Fix arrow function parenthesis with comments in flow (#1339)
Browse files Browse the repository at this point in the history
`leadingComment` and `trailingComment` are babylon-specific, we should use `comments` which is what prettier adds.

Fixes #1335
  • Loading branch information
vjeux committed Apr 19, 2017
1 parent 938f0e3 commit 042e603
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/printer.js
Expand Up @@ -2353,8 +2353,7 @@ function canPrintParamsWithoutParens(node) {
!node.rest &&
node.params[0].type === "Identifier" &&
!node.params[0].typeAnnotation &&
!node.params[0].leadingComments &&
!node.params[0].trailingComments &&
!node.params[0].comments &&
!node.params[0].optional &&
!node.predicate &&
!node.returnType
Expand Down
2 changes: 2 additions & 0 deletions tests/comments/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -234,10 +234,12 @@ exports[`function-declaration.js 1`] = `
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
`;
Expand Down
1 change: 1 addition & 0 deletions tests/comments/function-declaration.js
@@ -1,3 +1,4 @@
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});

0 comments on commit 042e603

Please sign in to comment.