Put parenthesis after return when jsx is prettier-ignored (#2665)

This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-08-24 19:29:05 -07:00
1 parent 0ee74a8d25
commit 0d38136115
3 files changed
+38 -8

No files matched your search

+14 -8
View File
@@ -65,21 +65,27 @@ function getPrintFunction(options) {
function hasIgnoreComment(path) {
const node = path.getValue();
return hasNodeIgnoreComment(node) || hasJsxIgnoreComment(path);
}
function hasNodeIgnoreComment(node) {
return (
node &&
((node.comments &&
node.comments.length > 0 &&
node.comments.some(
comment => comment.value.trim() === "prettier-ignore"
)) ||
hasJsxIgnoreComment(path))
node.comments &&
node.comments.length > 0 &&
node.comments.some(comment => comment.value.trim() === "prettier-ignore")
);
}
function hasJsxIgnoreComment(path) {
const node = path.getValue();
const parent = path.getParentNode();
if (!parent || node.type !== "JSXElement" || parent.type !== "JSXElement") {
if (
!parent ||
!node ||
node.type !== "JSXElement" ||
parent.type !== "JSXElement"
) {
return false;
}
@@ -4385,7 +4391,7 @@ function hasTrailingComment(node) {
function hasLeadingOwnLineComment(text, node) {
if (node.type === "JSXElement") {
return false;
return hasNodeIgnoreComment(node);
}
const res =
@@ -48,6 +48,14 @@ push(
<td> :)
</td>,
);
function f() {
return (
// prettier-ignore
/* $FlowFixMe(>=0.53.0) */
<JSX />
);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// this should remain as-is
<div>
@@ -93,4 +101,12 @@ push(
</td>
);
function f() {
return (
// prettier-ignore
/* $FlowFixMe(>=0.53.0) */
<JSX />
);
}
`;
+8
View File
@@ -45,3 +45,11 @@ push(
<td> :)
</td>,
);
function f() {
return (
// prettier-ignore
/* $FlowFixMe(>=0.53.0) */
<JSX />
);
}