Skip to content

Commit

Permalink
fix(graphql_formatter): don't add new line in block comments in CLRF …
Browse files Browse the repository at this point in the history
…files (#4527)
  • Loading branch information
vohoanglong0107 authored Nov 18, 2024
1 parent 4721b6c commit 352556a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

### Formatter

- Fix [#4413](https://github.com/biomejs/biome/issues/4413), where the GraphQL formatter adds a new line at the start of block comments on Windows. Contributed by @vohoanglong0107

### Bug fixes

- Fix [#4121](https://github.com/biomejs/biome/issues/4326), don't ident a CSS selector when has leading comments. Contributed by @fireairforce
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl FormatNodeRule<GraphqlStringValue> for FormatGraphqlStringValue {
// But leading whitespace is significant in block strings to calculate the indentation level
// SAFETY:
// We check that the string starts with triple quotes and the parser guarantees that ends with triple quotes.
let trimmed_content = raw_content.trim_start_matches('\n').trim_end();
let trimmed_content = raw_content.trim_start_matches(['\n', '\r']).trim_end();

// Find the minimum indentation level of non-empty lines
let min_indent = trimmed_content
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type SomeTime {
"""
Here is a string
"""
id: ID!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: graphql/newline_clrf.graphql
---
# Input

```graphql
type SomeTime {
"""
Here is a string
"""
id: ID!
}
```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Bracket spacing: true
Quote style: Double Quotes
-----

```graphql
type SomeTime {
"""
Here is a string
"""
id: ID!
}
```

0 comments on commit 352556a

Please sign in to comment.