From 007cfd9179c0ec920c96160a7c2697f728be4b61 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 19 Apr 2017 11:59:23 -0700 Subject: [PATCH] Fix duplicate comments in classes (#1349) Turns out, you can't blindly print this node. We need a deeper fix but let's revert this fix for now. Fixes #1348 --- src/printer.js | 6 +----- .../__snapshots__/jsfmt.spec.js.snap | 18 ++++++++++++++++++ tests/empty_paren_comment/class.js | 7 +++++++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/empty_paren_comment/class.js diff --git a/src/printer.js b/src/printer.js index 0b81c235..57a22aa5 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2119,11 +2119,7 @@ function printMethod(path, options, print) { group( concat([ path.call(function(valuePath) { - return comments.printComments( - path, - p => printFunctionParams(valuePath, print, options), - options - ) + return printFunctionParams(valuePath, print, options); }, "value"), path.call(p => printReturnType(p, print), "value") ]) diff --git a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap index 0640e849..cad8d3e1 100644 --- a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`class.js 1`] = ` +class x { + /** + * Set of default settings to be applied to model fetch calls in DAO layer. + */ + static get defaultSettings() { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class x { + /** + * Set of default settings to be applied to model fetch calls in DAO layer. + */ + static get defaultSettings() {} +} + +`; + exports[`empty_paren_comment.js 1`] = ` let f = (/* ... */) => {} (function (/* ... */) {})(/* ... */) diff --git a/tests/empty_paren_comment/class.js b/tests/empty_paren_comment/class.js new file mode 100644 index 00000000..30306114 --- /dev/null +++ b/tests/empty_paren_comment/class.js @@ -0,0 +1,7 @@ +class x { + /** + * Set of default settings to be applied to model fetch calls in DAO layer. + */ + static get defaultSettings() { + } +}