From bfe31617620229bd1b77ae199601b05e24726e1e Mon Sep 17 00:00:00 2001 From: Alessandro Di Felice Date: Sun, 30 Apr 2017 19:49:31 -0500 Subject: [PATCH] Break class expression returned by arrow call (#1464) --- src/printer.js | 1 - .../__snapshots__/jsfmt.spec.js.snap | 20 +++++++++++++++++++ tests/arrow-call/arrow_call.js | 5 +++++ tests/arrows/__snapshots__/jsfmt.spec.js.snap | 9 +++++---- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/printer.js b/src/printer.js index 1800441e1..a90b62f24 100644 --- a/src/printer.js +++ b/src/printer.js @@ -376,7 +376,6 @@ function genericPrintNoParens(path, options, print, args) { n.body.type === "BlockStatement" || n.body.type === "TaggedTemplateExpression" || n.body.type === "TemplateElement" || - n.body.type === "ClassExpression" || n.body.type === "ArrowFunctionExpression" ) { return group(collapsed); diff --git a/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap b/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap index 692a38453..0597d87a7 100644 --- a/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap @@ -38,6 +38,11 @@ func( veryLooooooooooooooooooooooooongName => veryLoooooooooooooooongName.something() ); + +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter) @@ -83,6 +88,11 @@ func( veryLoooooooooooooooongName.something() ); +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; + `; exports[`arrow_call.js 2`] = ` @@ -123,6 +133,11 @@ func( veryLooooooooooooooooooooooooongName => veryLoooooooooooooooongName.something() ); + +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter), @@ -168,4 +183,9 @@ func( veryLoooooooooooooooongName.something(), ); +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; + `; diff --git a/tests/arrow-call/arrow_call.js b/tests/arrow-call/arrow_call.js index c0f585101..cb73bf52f 100644 --- a/tests/arrow-call/arrow_call.js +++ b/tests/arrow-call/arrow_call.js @@ -35,3 +35,8 @@ func( veryLooooooooooooooooooooooooongName => veryLoooooooooooooooongName.something() ); + +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index 823e4548d..1c5b41267 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -229,11 +229,12 @@ function render() { jest.mock( "../SearchSource", - () => class { - findMatchingTests(pattern) { - return { paths: [] }; + () => + class { + findMatchingTests(pattern) { + return { paths: [] }; + } } - } ); `;