fix(javascript): skip .connect() method when composing fun (#5739)
parent
a8d423b18c
commit
94eab666c4
|
@ -3852,12 +3852,18 @@ const functionCompositionFunctionNames = new Set([
|
|||
"connect", // Redux
|
||||
"createSelector" // Reselect
|
||||
]);
|
||||
const ordinaryMethodNames = new Set([
|
||||
"connect" // GObject, MongoDB
|
||||
]);
|
||||
|
||||
function isFunctionCompositionFunction(node) {
|
||||
switch (node.type) {
|
||||
case "OptionalMemberExpression":
|
||||
case "MemberExpression": {
|
||||
return isFunctionCompositionFunction(node.property);
|
||||
return (
|
||||
isFunctionCompositionFunction(node.property) &&
|
||||
!ordinaryMethodNames.has(node.property.name)
|
||||
);
|
||||
}
|
||||
case "Identifier": {
|
||||
return functionCompositionFunctionNames.has(node.name);
|
||||
|
|
|
@ -115,6 +115,34 @@ this.subscriptions.add(
|
|||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`gobject_connect.js 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow", "babel", "typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
button.connect(
|
||||
"clicked",
|
||||
() => doSomething()
|
||||
);
|
||||
app.connect(
|
||||
"activate",
|
||||
async () => {
|
||||
await data.load();
|
||||
win.show_all();
|
||||
}
|
||||
);
|
||||
|
||||
=====================================output=====================================
|
||||
button.connect("clicked", () => doSomething());
|
||||
app.connect("activate", async () => {
|
||||
await data.load();
|
||||
win.show_all();
|
||||
});
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`lodash_flow.js 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow", "babel", "typescript"]
|
||||
|
@ -215,6 +243,29 @@ foo(6);
|
|||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`mongo_connect.js 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow", "babel", "typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
MongoClient.connect(
|
||||
"mongodb://localhost:27017/posts",
|
||||
(err, db) => {
|
||||
assert.equal(null, err);
|
||||
db.close();
|
||||
}
|
||||
);
|
||||
|
||||
=====================================output=====================================
|
||||
MongoClient.connect("mongodb://localhost:27017/posts", (err, db) => {
|
||||
assert.equal(null, err);
|
||||
db.close();
|
||||
});
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`ramda_compose.js 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow", "babel", "typescript"]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
button.connect(
|
||||
"clicked",
|
||||
() => doSomething()
|
||||
);
|
||||
app.connect(
|
||||
"activate",
|
||||
async () => {
|
||||
await data.load();
|
||||
win.show_all();
|
||||
}
|
||||
);
|
|
@ -0,0 +1,7 @@
|
|||
MongoClient.connect(
|
||||
"mongodb://localhost:27017/posts",
|
||||
(err, db) => {
|
||||
assert.equal(null, err);
|
||||
db.close();
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue