@@ -29,11 +29,12 @@ ruleTester.run('mapStateToProps-no-store', rule, {
29
29
});
30
30
` ,
31
31
'export default function observeStore(store) {return store;}' ,
32
- 'export default connect(() => {})(Alert)' ,
33
- 'export default connect(null, null)(Alert)' ,
34
- 'connect((state) => ({isActive: state.isActive}), null)(App)' ,
35
- 'connect(null, null)(App)' ,
36
- `connect(
32
+ `import { connect } from 'react-redux'; export default connect(() => {})(Alert)` ,
33
+ `import { connect } from 'react-redux'; export default connect(null, null)(Alert)` ,
34
+ `import { connect } from 'react-redux'; connect((state) => ({isActive: state.isActive}), null)(App)` ,
35
+ `import { connect } from 'react-redux'; connect(null, null)(App)` ,
36
+ `import { connect } from 'react-redux';
37
+ connect(
37
38
(state) => {
38
39
return {
39
40
isActive: state.isActive
@@ -42,7 +43,8 @@ ruleTester.run('mapStateToProps-no-store', rule, {
42
43
null
43
44
)(App)
44
45
` ,
45
- `connect(function(state){
46
+ `import { connect } from 'react-redux';
47
+ connect(function(state){
46
48
return {
47
49
isActive: state.isActive
48
50
}
@@ -58,14 +60,15 @@ ruleTester.run('mapStateToProps-no-store', rule, {
58
60
}` ,
59
61
'const mapStateToProps = (state, ownProps) => {}' ,
60
62
'const mapStateToProps = (state) => {isActive: state.isActive}' ,
61
- `const mapStateToProps = (state, ownProps) => {};
63
+ `import { connect } from 'react-redux';
64
+ const mapStateToProps = (state, ownProps) => {};
62
65
connect(mapStateToProps, null)(Alert);` ,
63
66
`const mapStateToProps = ({ header }) => ({
64
67
isLoggedIn: header.user && header.user.isLoggedIn,
65
68
}); ` ,
66
69
'const mapStateToProps = ({header}, ownProps) => {header};' ,
67
- ' connect(({header}, ownProps) => {header})(App);' ,
68
- ' connect(({header}, {ownProp1}) => {header, ownProp1})(App);' ,
70
+ `import { connect } from 'react-redux'; connect(({header}, ownProps) => {header})(App);` ,
71
+ `import { connect } from 'react-redux'; connect(({header}, {ownProp1}) => {header, ownProp1})(App);` ,
69
72
] ,
70
73
invalid : [ {
71
74
code : 'const mapStateToProps = (state) => state' ,
@@ -93,7 +96,8 @@ ruleTester.run('mapStateToProps-no-store', rule, {
93
96
} ,
94
97
] ,
95
98
} , {
96
- code : `export default connect(
99
+ code : `import { connect } from 'react-redux';
100
+ export default connect(
97
101
(state) => {
98
102
return {
99
103
state: state
@@ -111,14 +115,15 @@ ruleTester.run('mapStateToProps-no-store', rule, {
111
115
} ,
112
116
] ,
113
117
} , {
114
- code : ' connect((state) => state, null)(App)' ,
118
+ code : `import { connect } from 'react-redux'; connect((state) => state, null)(App)` ,
115
119
errors : [
116
120
{
117
121
message : 'mapStateToProps should not return complete store object' ,
118
122
} ,
119
123
] ,
120
124
} , {
121
- code : `const mapStateToProps = (state, ownProps) => state;
125
+ code : `import { connect } from 'react-redux';
126
+ const mapStateToProps = (state, ownProps) => state;
122
127
connect(mapStateToProps, null)(Alert);` ,
123
128
errors : [
124
129
{
@@ -133,7 +138,7 @@ ruleTester.run('mapStateToProps-no-store', rule, {
133
138
} ,
134
139
] ,
135
140
} , {
136
- code : ' connect((state) => ({...state}), null)(App)' ,
141
+ code : `import { connect } from 'react-redux'; connect((state) => ({...state}), null)(App)` ,
137
142
errors : [
138
143
{
139
144
message : 'mapStateToProps should not return complete store object' ,
0 commit comments