-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rome_json_parser): support allowTrailingCommas option (#326)
- Loading branch information
Showing
45 changed files
with
658 additions
and
58 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
45 changes: 45 additions & 0 deletions
45
...iome_cli/tests/snapshots/main_commands_format/format_json_when_allow_trailing_commas.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,45 @@ | ||
--- | ||
source: crates/biome_cli/tests/snap_test.rs | ||
expression: content | ||
--- | ||
## `biome.json` | ||
|
||
```json | ||
{ | ||
"json": { | ||
"parser": { "allowTrailingCommas": true } | ||
} | ||
} | ||
``` | ||
|
||
## `file.json` | ||
|
||
```json | ||
{ | ||
"array": [ | ||
1, | ||
], | ||
} | ||
``` | ||
|
||
# Emitted Messages | ||
|
||
```block | ||
file.json format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
i Formatter would have printed the following content: | ||
3 3 │ 1, | ||
4 4 │ ], | ||
5 │ - } | ||
5 │ + } | ||
6 │ + | ||
``` | ||
|
||
```block | ||
Compared 1 file(s) in <TIME> | ||
``` | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
crates/biome_json_parser/tests/json_test_suite/allow_trailing_commas/err/null.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 @@ | ||
null, |
69 changes: 69 additions & 0 deletions
69
crates/biome_json_parser/tests/json_test_suite/allow_trailing_commas/err/null.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,69 @@ | ||
--- | ||
source: crates/biome_json_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
|
||
## Input | ||
|
||
```json | ||
null, | ||
``` | ||
|
||
|
||
## AST | ||
|
||
``` | ||
JsonRoot { | ||
value: JsonArrayValue { | ||
l_brack_token: missing (required), | ||
elements: JsonArrayElementList [ | ||
JsonNullValue { | ||
value_token: NULL_KW@0..4 "null" [] [], | ||
}, | ||
missing separator, | ||
JsonBogusValue { | ||
items: [ | ||
COMMA@4..5 "," [] [], | ||
], | ||
}, | ||
], | ||
r_brack_token: missing (required), | ||
}, | ||
eof_token: EOF@5..6 "" [Newline("\n")] [], | ||
} | ||
``` | ||
|
||
## CST | ||
|
||
``` | ||
0: [email protected] | ||
0: [email protected] | ||
0: (empty) | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "null" [] [] | ||
1: (empty) | ||
2: [email protected] | ||
0: [email protected] "," [] [] | ||
2: (empty) | ||
1: [email protected] "" [Newline("\n")] [] | ||
``` | ||
|
||
## Diagnostics | ||
|
||
``` | ||
null.json:1:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× End of file expected | ||
> 1 │ null, | ||
│ ^ | ||
2 │ | ||
i Use an array for a sequence of values: `[1, 2]` | ||
``` | ||
|
||
|
1 change: 1 addition & 0 deletions
1
crates/biome_json_parser/tests/json_test_suite/allow_trailing_commas/err/object.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 @@ | ||
{}, |
Oops, something went wrong.