Handle comments in assignments before template literals (#4580)

Closes #4560
master
Lucas Duailibe 2018-05-28 11:08:18 -03:00 committed by Lucas Azzola
parent d0fd41a10e
commit b8ded70848
3 changed files with 63 additions and 2 deletions

View File

@ -696,10 +696,13 @@ function handleVariableDeclaratorComments(
) {
if (
enclosingNode &&
enclosingNode.type === "VariableDeclarator" &&
(enclosingNode.type === "VariableDeclarator" ||
enclosingNode.type === "AssignmentExpression") &&
followingNode &&
(followingNode.type === "ObjectExpression" ||
followingNode.type === "ArrayExpression")
followingNode.type === "ArrayExpression" ||
followingNode.type === "TemplateLiteral" ||
followingNode.type === "TaggedTemplateExpression")
) {
addLeadingComment(followingNode, comment);
return true;

View File

@ -1757,6 +1757,24 @@ let obj = [
// Comment
'val'
]
let obj = // Comment
\`val\`;
let obj = // Comment
\`
val
val
\`;
let obj = // Comment
tag\`val\`;
let obj = // Comment
tag\`
val
val
\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let obj =
// Comment
@ -1798,4 +1816,26 @@ let obj = [
"val"
];
let obj =
// Comment
\`val\`;
let obj =
// Comment
\`
val
val
\`;
let obj =
// Comment
tag\`val\`;
let obj =
// Comment
tag\`
val
val
\`;
`;

View File

@ -35,3 +35,21 @@ let obj = [
// Comment
'val'
]
let obj = // Comment
`val`;
let obj = // Comment
`
val
val
`;
let obj = // Comment
tag`val`;
let obj = // Comment
tag`
val
val
`;