Skip to content

Commit

Permalink
Inline do expressions inside of JSX (#3607)
Browse files Browse the repository at this point in the history
Fixes #3602
  • Loading branch information
vjeux authored and duailibe committed Dec 29, 2017
1 parent cfb8987 commit 7eca801
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/language-js/printer-estree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,7 @@ function printPathNoParens(path, options, print, args) {
n.expression.type === "JSXEmptyExpression" ||
n.expression.type === "TemplateLiteral" ||
n.expression.type === "TaggedTemplateExpression" ||
n.expression.type === "DoExpression" ||
(isJSXNode(parent) &&
(n.expression.type === "ConditionalExpression" ||
isBinaryish(n.expression))));
Expand Down
16 changes: 16 additions & 0 deletions tests/jsx-do/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`do.js 1`] = `
<div>
{do {
1
}}
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div>
{do {
1;
}}
</div>;
`;
5 changes: 5 additions & 0 deletions tests/jsx-do/do.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
{do {
1
}}
</div>
1 change: 1 addition & 0 deletions tests/jsx-do/jsfmt.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run_spec(__dirname, ["babylon"]);

0 comments on commit 7eca801

Please sign in to comment.