+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

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

Merged
merged 5 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/rome_js_formatter/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Trailing comma: All

```js
#!/usr/bin/env node

console.log(1);

console.log(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node


console.log(1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
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);
```


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Trailing comma: All

```js
#!/usr/bin/env node

"use strict";
"use asm";
var express = require("express");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Trailing comma: All

```js
#!/usr/bin/env node

"use strict";
"use asm";
var express = require("express");
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载