Preserve comment position for last arg or method (#1025)

In #856, it handled a bunch of cases but missed class methods

Fixes #905
master
Christopher Chedeau 2017-03-17 11:00:01 -07:00 committed by James Long
parent 35547993d4
commit 16ed595086
3 changed files with 37 additions and 1 deletions

View File

@ -519,7 +519,8 @@ function handleLastFunctionArgComments(
precedingNode.type === "Identifier" &&
enclosingNode &&
(enclosingNode.type === "ArrowFunctionExpression" ||
enclosingNode.type === "FunctionExpression") &&
enclosingNode.type === "FunctionExpression" ||
enclosingNode.type === "ClassMethod") &&
followingNode &&
followingNode.type !== "Identifier"
) {

View File

@ -1246,6 +1246,13 @@ f = function(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {};
class X {
f(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type f = (
currentRequest: { a: number }
@ -1266,6 +1273,13 @@ f = function(
currentRequest: { a: number }
// TODO this is a very very very very long comment that makes it go > 80 columns
) {};
class X {
f(
currentRequest: { a: number }
// TODO this is a very very very very long comment that makes it go > 80 columns
) {}
}
"
`;
@ -1289,6 +1303,13 @@ f = function(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {};
class X {
f(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type f = (
currentRequest: { a: number }
@ -1309,6 +1330,13 @@ f = function(
currentRequest: { a: number }
// TODO this is a very very very very long comment that makes it go > 80 columns
) {};
class X {
f(
currentRequest: { a: number }
// TODO this is a very very very very long comment that makes it go > 80 columns
) {}
}
"
`;

View File

@ -17,3 +17,10 @@ f = function(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {};
class X {
f(
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) {}
}