From 5671f32c077306d9ae8f6a47d5f6f1b59a5a4ccf Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 23 May 2017 17:13:40 -0700 Subject: [PATCH] Handle comments at the beginning of ClassProperty value (#1692) We didn't call the helper that handles this use case --- src/printer.js | 10 +++++++++- .../__snapshots__/jsfmt.spec.js.snap | 16 ++++++++++++++++ tests/class_comment/comments.js | 8 ++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/printer.js b/src/printer.js index 2651414fe..b48ff6178 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1631,7 +1631,15 @@ function genericPrintNoParens(path, options, print, args) { parts.push(": ", path.call(print, "typeAnnotation")); } if (n.value) { - parts.push(" = ", path.call(print, "value")); + parts.push( + " =", + printAssignmentRight( + n.value, + path.call(print, "value"), + false, // canBreak + options + ) + ); } parts.push(semi); diff --git a/tests/class_comment/__snapshots__/jsfmt.spec.js.snap b/tests/class_comment/__snapshots__/jsfmt.spec.js.snap index d3f57b761..e1965e6dd 100644 --- a/tests/class_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_comment/__snapshots__/jsfmt.spec.js.snap @@ -33,6 +33,14 @@ class x { // do nothing } } + +class X { + TEMPLATE = + // tab index is needed so we can focus, which is needed for keyboard events + '
' + + '
' + + '
'; +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // comment 1 // comment 2 @@ -69,4 +77,12 @@ class x { } } +class X { + TEMPLATE = + // tab index is needed so we can focus, which is needed for keyboard events + '
' + + '
' + + "
"; +} + `; diff --git a/tests/class_comment/comments.js b/tests/class_comment/comments.js index dbe3f0f2e..659a3f4a7 100644 --- a/tests/class_comment/comments.js +++ b/tests/class_comment/comments.js @@ -30,3 +30,11 @@ class x { // do nothing } } + +class X { + TEMPLATE = + // tab index is needed so we can focus, which is needed for keyboard events + '
' + + '
' + + '
'; +}