+ !(
+ (n.name && n.name.comments && n.name.comments.length) ||
+ (n.attributes[0].comments && n.attributes[0].comments.length)
+ )
) {
return group(
concat([
@@ -1785,10 +1798,21 @@ function genericPrintNoParens(path, options, print, args) {
const bracketSameLine =
options.jsxBracketSameLine &&
+ // We should print the bracket in a new line for the following cases:
+ //
+ //
!(
- n.name &&
- ((n.name.trailingComments && n.name.trailingComments.length) ||
- (n.name.comments && n.name.comments.length))
+ (n.name &&
+ !(n.attributes && n.attributes.length) &&
+ n.name.comments &&
+ n.name.comments.length) ||
+ (n.attributes &&
+ n.attributes.length &&
+ hasTrailingComment(util.getLast(n.attributes)))
);
return group(
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 13707fb3e..ba1df1f9c 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -844,6 +844,24 @@ onClick={() => {}}>
{foo}
;
+
+ {foo}
+
;
+
+
+ {foo}
+
;
+
+
+ {children}
+
;
{}
@@ -929,6 +947,25 @@ onClick={() => {}}>
{foo}
;
+
+ {foo}
+
;
+
+
+ {foo}
+
;
+
+
+ {children}
+
;
+
{}
diff --git a/tests/comments/jsx.js b/tests/comments/jsx.js
index bff243611..d184e1f10 100644
--- a/tests/comments/jsx.js
+++ b/tests/comments/jsx.js
@@ -95,6 +95,24 @@ onClick={() => {}}>
{foo}