Skip to content

Commit b705408

Browse files
authored
fix: remove needless parens in key value prop value (#766)
1 parent 2c75919 commit b705408

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/generation/generate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,7 @@ fn should_skip_paren_expr<'a>(node: &'a ParenExpr<'a>, context: &Context<'a>) ->
29162916
| NodeKind::JSXExprContainer
29172917
| NodeKind::UpdateExpr
29182918
| NodeKind::ComputedPropName
2919+
| NodeKind::KeyValueProp
29192920
) {
29202921
return true;
29212922
}

tests/specs/expressions/ObjectProperty/ObjectProperty_All.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,25 @@ function test() {
2929
},
3030
};
3131
}
32+
33+
== should remove needless parens ==
34+
const obj = {
35+
prop: ({ a, b } = obj)
36+
}
37+
38+
const obj = {
39+
prop , // test
40+
prop2 : (2),
41+
prop3 : (foo()),
42+
};
43+
44+
[expect]
45+
const obj = {
46+
prop: ({ a, b } = obj),
47+
};
48+
49+
const obj = {
50+
prop, // test
51+
prop2: 2,
52+
prop3: foo(),
53+
};

0 commit comments

Comments
 (0)