diff --git a/src/printer.js b/src/printer.js index 0bba17879..e87b08a37 100644 --- a/src/printer.js +++ b/src/printer.js @@ -522,7 +522,7 @@ function genericPrintNoParens(path, options, print) { parts.push( indent( options.tabWidth, - concat([ line, print(childPath), ";", line ]) + concat([ hardline, print(childPath), ";", hardline ]) ) ); }, diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index a1221a5a1..eabfb3c56 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -1,3 +1,17 @@ +exports[`test directives.js 1`] = ` +"\"use strict\"; + +function fn() { + \"use strict\"; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +\"use strict\"; + +function fn() { + \"use strict\"; +}" +`; + exports[`test optional-type-name.js 1`] = ` "type Foo = (any) => string diff --git a/tests/prettier/directives.js b/tests/prettier/directives.js new file mode 100644 index 000000000..777ed217c --- /dev/null +++ b/tests/prettier/directives.js @@ -0,0 +1,5 @@ +"use strict"; + +function fn() { + "use strict"; +}