diff --git a/src/printer.js b/src/printer.js index cf35ad28d..b285df7ce 100644 --- a/src/printer.js +++ b/src/printer.js @@ -713,6 +713,11 @@ function genericPrintNoParens(path, options, print, args) { if (hasDirectives) { path.each(childPath => { parts.push(indent(concat([hardline, print(childPath), semi]))); + if ( + util.isNextLineEmpty(options.originalText, childPath.getValue()) + ) { + parts.push(hardline); + } }, "directives"); } diff --git a/tests/directives/__snapshots__/jsfmt.spec.js.snap b/tests/directives/__snapshots__/jsfmt.spec.js.snap index 342de6894..7cbb320a1 100644 --- a/tests/directives/__snapshots__/jsfmt.spec.js.snap +++ b/tests/directives/__snapshots__/jsfmt.spec.js.snap @@ -130,6 +130,26 @@ exports[`test.js 1`] = ` function fn() { "use strict"; } + +function f() { + 'ngInject'; + Object.assign(this, { $log, $uibModal }); +} + +function f() { + + 'ngInject'; + + Object.assign(this, { $log, $uibModal }); + +} + +function f() { + 'ngInject'; + + + Object.assign(this, { $log, $uibModal }); +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "use strict"; @@ -137,4 +157,21 @@ function fn() { "use strict"; } +function f() { + "ngInject"; + Object.assign(this, { $log, $uibModal }); +} + +function f() { + "ngInject"; + + Object.assign(this, { $log, $uibModal }); +} + +function f() { + "ngInject"; + + Object.assign(this, { $log, $uibModal }); +} + `; diff --git a/tests/directives/test.js b/tests/directives/test.js index 777ed217c..4019c54e5 100644 --- a/tests/directives/test.js +++ b/tests/directives/test.js @@ -3,3 +3,23 @@ function fn() { "use strict"; } + +function f() { + 'ngInject'; + Object.assign(this, { $log, $uibModal }); +} + +function f() { + + 'ngInject'; + + Object.assign(this, { $log, $uibModal }); + +} + +function f() { + 'ngInject'; + + + Object.assign(this, { $log, $uibModal }); +}