forked from prettier/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow formatting ranges of JSON (prettier#2298)
* Add test for prettier#2297 * Add JSON types to isSourceElement() See prettier#2297 * Avoid expanding format range when possible This fixes prettier#2297 * Move JSON range test into tests/range_json This is so that the AST_COMPARE=1 tests don't try to parse JSON with Flow. * Check parser in isSourceElement() Otherwise JSON formatting would format weird things inside of JS. See prettier#2298 (comment) * Use arrow functions instead of .bind() See prettier#2298 (comment) * Add test of range-formatting JSON identifier See https://github.com/prettier/prettier/pull/2298/files#r124410750 * Allow range-formatting JSON identifier See https://github.com/prettier/prettier/pull/2298/files#r124410750 * Fix lint
- Loading branch information
1 parent
5f063ab
commit b47c0b4
Showing
5 changed files
with
38 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`identifier.json 1`] = ` | ||
{"a":1, "b":2} | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
{"a":1, "b":2} | ||
`; | ||
|
||
exports[`issue2297.json 1`] = ` | ||
{"a":1, "b":2} | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
{"a":1, "b":2} | ||
`; |
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 @@ | ||
{<<<PRETTIER_RANGE_START>>>"a"<<<PRETTIER_RANGE_END>>>:1, "b":2} |
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 @@ | ||
{"a":<<<PRETTIER_RANGE_START>>>1<<<PRETTIER_RANGE_END>>>, "b":2} |
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 @@ | ||
run_spec(__dirname, { parser: "json" }); |