fix object literal checks in isSimpleCallArgument (#7403)

This commit is contained in:
Georgii Dolzhykov authored and GitHub committed 2020-01-21 17:55:43 +02:00
1 parent e8009fa102
commit 8efa29ca0c
3 files changed
+58 -3

No files matched your search

+1 -3
View File
@@ -926,9 +926,7 @@ function isSimpleCallArgument(node, depth) {
}
if (node.type === "ObjectExpression") {
return node.properties.every(
p =>
p.shorthand ||
(isSimpleCallArgument(p.key, depth) && isChildSimple(p.value))
p => !p.computed && (p.shorthand || (p.value && isChildSimple(p.value)))
);
}
if (node.type === "ArrayExpression") {
@@ -1176,6 +1176,48 @@ wrapper
================================================================================
`;
exports[`object-literal.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
of("test")
.pipe(throwIfEmpty())
.subscribe({
error(err) {
thrown = err;
}
});
of("test")
.pipe(throwIfEmpty())
.subscribe({
get foo() {
bar();
}
});
=====================================output=====================================
of("test")
.pipe(throwIfEmpty())
.subscribe({
error(err) {
thrown = err;
},
});
of("test")
.pipe(throwIfEmpty())
.subscribe({
get foo() {
bar();
},
});
================================================================================
`;
exports[`short-names.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
+15
View File
@@ -0,0 +1,15 @@
of("test")
.pipe(throwIfEmpty())
.subscribe({
error(err) {
thrown = err;
}
});
of("test")
.pipe(throwIfEmpty())
.subscribe({
get foo() {
bar();
}
});