Do not put parens for single argument with end of line comment (#1518)

Fixes #1517
master
Christopher Chedeau 2017-05-05 21:44:42 -07:00 committed by GitHub
parent 3d964b18bb
commit c63e21b52b
3 changed files with 15 additions and 1 deletions

View File

@ -2763,7 +2763,7 @@ function canPrintParamsWithoutParens(node) {
!node.rest &&
node.params[0].type === "Identifier" &&
!node.params[0].typeAnnotation &&
!node.params[0].comments &&
!hasBlockComments(node.params[0]) &&
!node.params[0].optional &&
!node.predicate &&
!node.returnType
@ -4089,6 +4089,13 @@ function hasDanglingComments(node) {
node.comments.some(comment => !comment.leading && !comment.trailing);
}
function hasBlockComments(node) {
return node.comments &&
node.comments.some(comment =>
comment.type === "Block" || comment.type === "CommentBlock"
);
}
function removeLines(doc) {
// Force this doc into flat mode by statically converting all
// lines into spaces (or soft lines into nothing). Hard lines

View File

@ -235,11 +235,15 @@ function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
KEYPAD_NUMBERS.map(num => ( // Buttons 0-9
<div />
));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
KEYPAD_NUMBERS.map(num => <div />); // Buttons 0-9
`;

View File

@ -2,3 +2,6 @@ function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
KEYPAD_NUMBERS.map(num => ( // Buttons 0-9
<div />
));