fix(rome_js_formatter): make empty line after hashbang optional
MODIFY
crates/rome_js_formatter/src/utils/mod.rs
crates/rome_js_formatter/src/utils/mod.rs
@@ -124,7 +124,15 @@ impl<'a> FormatInterpreterToken<'a> {
impl Format<JsFormatContext> for FormatInterpreterToken<'_> {
fn fmt(&self, f: &mut JsFormatter) -> FormatResult<()> {
if let Some(interpreter) = self.token {
- write!(f, [interpreter.format(), empty_line()])
+ write!(f, [interpreter.format()])?;
+
+ match interpreter
+ .next_token()
+ .map_or(0, |next_token| get_lines_before_token(&next_token))
+ {
+ 0 | 1 => write!(f, [hard_line_break()]),
+ _ => write!(f, [empty_line()]),
+ }
} else {
Ok(())
}

MODIFY
crates/rome_js_formatter/tests/specs/js/module/interpreter.js.snap
crates/rome_js_formatter/tests/specs/js/module/interpreter.js.snap
@@ -29,7 +29,6 @@ Trailing comma: All
```js
#!/usr/bin/env node
-
console.log(1);
console.log(1);

ADD
crates/rome_js_formatter/tests/specs/js/module/interpreter_with_empty_line.js
+#!/usr/bin/env node
+
+
+console.log(1)
\ No newline at end of file

ADD
crates/rome_js_formatter/tests/specs/js/module/interpreter_with_empty_line.js.snap
+---
+source: crates/rome_js_formatter/tests/spec_test.rs
+expression: interpreter_with_empty_line.js
+---
+
+# Input
+
+```js
+#!/usr/bin/env node
+
+
+console.log(1)
+```
+
+
+=============================
+
+# Outputs
+
+## Output 1
+
+-----
+Indent style: Tab
+Line width: 80
+Quote style: Double Quotes
+Quote properties: As needed
+Trailing comma: All
+-----
+
+```js
+#!/usr/bin/env node
+
+console.log(1);
+```
+
+

MODIFY
crates/rome_js_formatter/tests/specs/js/module/script.js.snap
crates/rome_js_formatter/tests/specs/js/module/script.js.snap
@@ -30,7 +30,6 @@ Trailing comma: All
```js
#!/usr/bin/env node
-
"use strict";
"use asm";
var express = require("express");

MODIFY
crates/rome_js_formatter/tests/specs/js/script/script.js.snap
crates/rome_js_formatter/tests/specs/js/script/script.js.snap
@@ -30,7 +30,6 @@ Trailing comma: All
```js
#!/usr/bin/env node
-
"use strict";
"use asm";
var express = require("express");

fix(rome_js_formatter): make empty line after hashbang optional (#3552)