-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve formatting for do expression (#10693)
- Loading branch information
1 parent
07ae013
commit 0cdc62e
Showing
4 changed files
with
175 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#### Improve formatting for do expression (#10693 by @sosukesuzuki) | ||
|
||
<!-- prettier-ignore --> | ||
```js | ||
// Input | ||
expect(do { | ||
var bar = "foo"; | ||
bar; | ||
}).toBe("foo"); | ||
|
||
// Prettier stable | ||
expect( | ||
do { | ||
var bar = "foo"; | ||
bar; | ||
} | ||
).toBe("foo"); | ||
|
||
// Prettier main | ||
expect(do { | ||
var bar = "foo"; | ||
bar; | ||
}).toBe("foo"); | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// from https://github.com/babel/babel/pull/13122/ | ||
expect( | ||
do { | ||
var bar = "foo"; | ||
if (!bar) throw new Error( | ||
"unreachable" | ||
) | ||
bar; | ||
} | ||
).toBe("foo"); | ||
expect(bar).toBe("foo"); | ||
|
||
var x = do { | ||
var bar = "foo"; | ||
if (!bar) throw new Error( | ||
"unreachable" | ||
) | ||
bar; | ||
}; | ||
|
||
expect( | ||
do { | ||
var bar = "foo"; | ||
bar; | ||
} | ||
).toBe("foo"); | ||
expect(bar).toBe("foo"); | ||
|
||
var x = do { | ||
var bar = "foo"; | ||
bar; | ||
}; | ||
|
||
expect( | ||
() => do { | ||
() => { | ||
var bar = "foo"; | ||
}; | ||
bar; | ||
} | ||
).toThrow(ReferenceError); |