Skip to content

Commit 7e2871b

Browse files
committed
JS: Propagate React components through recompose HOCs
1 parent 173be0c commit 7e2871b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

javascript/ql/src/semmle/javascript/frameworks/ComposedFunctions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module FunctionCompositionCall {
8888
RightToLeft() {
8989
this = DataFlow::moduleImport(["compose-function"]).getACall()
9090
or
91-
this = DataFlow::moduleMember(["redux", "ramda", "@reduxjs/toolkit"], "compose").getACall()
91+
this = DataFlow::moduleMember(["redux", "ramda", "@reduxjs/toolkit", "recompose"], "compose").getACall()
9292
or
9393
this = LodashUnderscore::member("flowRight").getACall()
9494
}

javascript/ql/src/semmle/javascript/frameworks/React.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ private DataFlow::SourceNode higherOrderComponentBuilder() {
777777
or
778778
result = DataFlow::moduleMember("redux-form", "reduxForm").getACall()
779779
or
780+
result = DataFlow::moduleMember("recompose", _).getACall()
781+
or
780782
result = reactRouterDom().getAPropertyRead("withRouter")
781783
or
782784
exists(FunctionCompositionCall compose |

javascript/ql/test/library-tests/frameworks/ReactJS/higherOrderComponent.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { compose } from 'redux';
44
import styled from 'styled-components';
55
import unknownFunction from 'somewhere';
66
import { hot } from 'react-hot-loader';
7+
import { withState } from 'recompose';
78

89
import { MyComponent } from './exportedComponent';
910

@@ -22,4 +23,6 @@ const withConnect = connect(mapStateToProps, mapDispatchToProps);
2223

2324
const ConnectedComponent = compose(withConnect, unknownFunction)(StyledComponent);
2425

25-
export default hot(module)(memo(ConnectedComponent));
26+
const ConnectedComponent2 = withState('counter', 'setCounter', 0)(ConnectedComponent);
27+
28+
export default hot(module)(memo(ConnectedComponent2));

0 commit comments

Comments
 (0)