From dc52a7192347cd975dbf7d1838068260fda3f9e3 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Fri, 17 Mar 2017 11:01:17 -0700 Subject: [PATCH] Inline class expressions for bracket-less arrow functions (#1023) I could go either way but it doesn't seem a big deal to inline them. I don't expect it to be very common anyway Fixes #990 --- src/printer.js | 3 ++- tests/arrows/__snapshots__/jsfmt.spec.js.snap | 21 ++++++++++++++++++- tests/arrows/call.js | 11 +++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/printer.js b/src/printer.js index 5a0d22b3..d2adf083 100644 --- a/src/printer.js +++ b/src/printer.js @@ -338,7 +338,8 @@ function genericPrintNoParens(path, options, print) { n.body.type === "JSXElement" || n.body.type === "BlockStatement" || n.body.type === "TaggedTemplateExpression" || - n.body.type === "TemplateElement" + n.body.type === "TemplateElement" || + n.body.type === "ClassExpression" ) { return group(collapsed); } diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index fa959434..98559667 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -140,7 +140,17 @@ function render() { /> ); -}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} + +jest.mock( + '../SearchSource', + () => class { + findMatchingTests(pattern) { + return {paths: []}; + } + }, +); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Seq(typeDef.interface.groups).forEach(group => Seq(group.members).forEach((member, memberName) => markdownDoc(member.doc, { @@ -209,6 +219,15 @@ function render() { ); } + +jest.mock( + \\"../SearchSource\\", + () => class { + findMatchingTests(pattern) { + return { paths: [] }; + } + } +); " `; diff --git a/tests/arrows/call.js b/tests/arrows/call.js index 99383312..3b2b5e2c 100644 --- a/tests/arrows/call.js +++ b/tests/arrows/call.js @@ -64,4 +64,13 @@ function render() { /> ); -} \ No newline at end of file +} + +jest.mock( + '../SearchSource', + () => class { + findMatchingTests(pattern) { + return {paths: []}; + } + }, +);