Handle comments in assignments before template literals (#4580)

Closes #4560
This commit is contained in:
Lucas Duailibe authored and Lucas Azzola committed 2018-05-29 00:08:18 +10:00
1 parent d0fd41a10e
commit b8ded70848
3 files changed
+63 -2

No files matched your search

+5 -2
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;
@@ -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
\`;
`;
+18
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
`;