-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(json_formatter): handle comments in empty arrays/objects (#1323)
- Loading branch information
1 parent
d12e99c
commit 5f9610b
Showing
5 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
crates/biome_json_formatter/tests/specs/json/comments/empty_with_comments.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"object-block": { /* here's a block comment */}, | ||
"object-line": { // here's a line comment | ||
}, | ||
"object-ownline": { | ||
/* here's a block comment */ | ||
// and a line comment | ||
}, | ||
"array-block": [ /* here's a block comment */], | ||
"array-line": [ // here's a line comment | ||
], | ||
"array-ownline": [ | ||
/* here's a block comment */ | ||
// and a line comment | ||
] | ||
} |
66 changes: 66 additions & 0 deletions
66
crates/biome_json_formatter/tests/specs/json/comments/empty_with_comments.json.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: json/comments/empty_with_comments.json | ||
--- | ||
|
||
# Input | ||
|
||
```json | ||
{ | ||
"object-block": { /* here's a block comment */}, | ||
"object-line": { // here's a line comment | ||
}, | ||
"object-ownline": { | ||
/* here's a block comment */ | ||
// and a line comment | ||
}, | ||
"array-block": [ /* here's a block comment */], | ||
"array-line": [ // here's a line comment | ||
], | ||
"array-ownline": [ | ||
/* here's a block comment */ | ||
// and a line comment | ||
] | ||
} | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
----- | ||
|
||
```json | ||
{ | ||
"object-block": { | ||
/* here's a block comment */ | ||
}, | ||
"object-line": { | ||
// here's a line comment | ||
}, | ||
"object-ownline": { | ||
/* here's a block comment */ | ||
// and a line comment | ||
}, | ||
"array-block": [ | ||
/* here's a block comment */ | ||
], | ||
"array-line": [ | ||
// here's a line comment | ||
], | ||
"array-ownline": [ | ||
/* here's a block comment */ | ||
// and a line comment | ||
] | ||
} | ||
``` | ||
|
||
|