This commit is contained in:
1 parent
2ff156136f
commit
dc46155962
3 files changed
+24
-4
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#### Add parens when yielding jsx ([#9011](https://github.com/prettier/prettier/pull/9011) by [@fisker](https://github.com/fisker))
|
||||
|
||||
In `v2.0.0` we [removed the parens when yielding jsx](https://prettier.io/blog/2020/03/21/2.0.0.html#remove-unnecessary-parens-when-yielding-jsx-7367httpsgithubcomprettierprettierpull7367-by-cola119httpsgithubcomcola119), this works for most parsers, but ESLint throws when parsing it, [related issue](https://github.com/acornjs/acorn-jsx/issues/82).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
function* f() {
|
||||
yield <div>generator</div>
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
function* f() {
|
||||
yield <div>generator</div>
|
||||
}
|
||||
|
||||
// Prettier master
|
||||
function* f() {
|
||||
yield (<div>generator</div>);
|
||||
}
|
||||
```
|
||||
@@ -730,8 +730,7 @@ function needsParens(path, options) {
|
||||
parent.type !== "ReturnStatement" &&
|
||||
parent.type !== "ThrowStatement" &&
|
||||
parent.type !== "TypeCastExpression" &&
|
||||
parent.type !== "VariableDeclarator" &&
|
||||
parent.type !== "YieldExpression")
|
||||
parent.type !== "VariableDeclarator")
|
||||
);
|
||||
case "TypeAnnotation":
|
||||
return (
|
||||
|
||||
@@ -87,8 +87,8 @@ function* f() {
|
||||
|
||||
=====================================output=====================================
|
||||
function* f() {
|
||||
yield <div>generator</div>;
|
||||
yield <div>generator</div>;
|
||||
yield (<div>generator</div>);
|
||||
yield (<div>generator</div>);
|
||||
yield (
|
||||
<div>
|
||||
<p>generator</p>
|
||||
|
||||
Reference in new issue
Block a user