diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 80501f066..cba8c4ea3 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -3425,27 +3425,11 @@ const functionCompositionFunctionNames = new Set([ "connect" // Redux ]); -function isThisExpression(node) { - switch (node.type) { - case "OptionalMemberExpression": - case "MemberExpression": { - return isThisExpression(node.object); - } - case "ThisExpression": - case "Super": { - return true; - } - } -} - function isFunctionCompositionFunction(node) { switch (node.type) { case "OptionalMemberExpression": case "MemberExpression": { - return ( - !isThisExpression(node.object) && - isFunctionCompositionFunction(node.property) - ); + return isFunctionCompositionFunction(node.property); } case "Identifier": { return functionCompositionFunctionNames.has(node.name); diff --git a/tests/functional_composition/__snapshots__/jsfmt.spec.js.snap b/tests/functional_composition/__snapshots__/jsfmt.spec.js.snap index a4a84a264..728b36e05 100644 --- a/tests/functional_composition/__snapshots__/jsfmt.spec.js.snap +++ b/tests/functional_composition/__snapshots__/jsfmt.spec.js.snap @@ -2,43 +2,49 @@ exports[`functional_compose.js - flow-verify 1`] = ` compose( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); somelib.compose( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); composeFlipped( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); somelib.composeFlipped( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); // no regression (#4602) const hasValue = hasOwnProperty(a, b); -// filter out ThisExpression this.compose(sortBy(x => x), flatten); this.a.b.c.compose(sortBy(x => x), flatten); someObj.someMethod(this.field.compose(a, b)); -// filter out Super class A extends B { compose() { super.compose(sortBy(x => x), flatten); } } + +this.subscriptions.add( + this.componentUpdates + .pipe(startWith(this.props), distinctUntilChanged(isEqual)) + .subscribe(props => { + + }) + ) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compose( sortBy(x => x), @@ -67,18 +73,39 @@ somelib.composeFlipped( // no regression (#4602) const hasValue = hasOwnProperty(a, b); -// filter out ThisExpression -this.compose(sortBy(x => x), flatten); -this.a.b.c.compose(sortBy(x => x), flatten); -someObj.someMethod(this.field.compose(a, b)); +this.compose( + sortBy(x => x), + flatten +); +this.a.b.c.compose( + sortBy(x => x), + flatten +); +someObj.someMethod( + this.field.compose( + a, + b + ) +); -// filter out Super class A extends B { compose() { - super.compose(sortBy(x => x), flatten); + super.compose( + sortBy(x => x), + flatten + ); } } +this.subscriptions.add( + this.componentUpdates + .pipe( + startWith(this.props), + distinctUntilChanged(isEqual) + ) + .subscribe(props => {}) +); + `; exports[`lodash_flow.js - flow-verify 1`] = ` diff --git a/tests/functional_composition/functional_compose.js b/tests/functional_composition/functional_compose.js index 0e3e28a95..f92641497 100644 --- a/tests/functional_composition/functional_compose.js +++ b/tests/functional_composition/functional_compose.js @@ -1,38 +1,44 @@ compose( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); somelib.compose( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); composeFlipped( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); somelib.composeFlipped( - sortBy(x => x), - flatten, + sortBy(x => x), + flatten, map(x => [x, x*2]) ); // no regression (#4602) const hasValue = hasOwnProperty(a, b); -// filter out ThisExpression this.compose(sortBy(x => x), flatten); this.a.b.c.compose(sortBy(x => x), flatten); someObj.someMethod(this.field.compose(a, b)); -// filter out Super class A extends B { compose() { super.compose(sortBy(x => x), flatten); } } + +this.subscriptions.add( + this.componentUpdates + .pipe(startWith(this.props), distinctUntilChanged(isEqual)) + .subscribe(props => { + + }) + )