Skip to content

Commit 6c03cb7

Browse files
committed
Fix lint errors for src/
1 parent a79715d commit 6c03cb7

File tree

7 files changed

+124
-124
lines changed

7 files changed

+124
-124
lines changed

src/components/Provider.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
import { Component, PropTypes, Children } from 'react';
2-
import storeShape from '../utils/storeShape';
1+
import { Component, PropTypes, Children } from 'react'
2+
import storeShape from '../utils/storeShape'
33

4-
let didWarnAboutReceivingStore = false;
4+
let didWarnAboutReceivingStore = false
55
function warnAboutReceivingStore() {
66
if (didWarnAboutReceivingStore) {
7-
return;
7+
return
88
}
99

10-
didWarnAboutReceivingStore = true;
10+
didWarnAboutReceivingStore = true
1111
console.error( // eslint-disable-line no-console
1212
'<Provider> does not support changing `store` on the fly. ' +
1313
'It is most likely that you see this error because you updated to ' +
1414
'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' +
1515
'automatically. See https://github.com/rackt/react-redux/releases/' +
1616
'tag/v2.0.0 for the migration instructions.'
17-
);
17+
)
1818
}
1919

2020
export default class Provider extends Component {
2121
getChildContext() {
22-
return { store: this.store };
22+
return { store: this.store }
2323
}
2424

2525
constructor(props, context) {
26-
super(props, context);
27-
this.store = props.store;
26+
super(props, context)
27+
this.store = props.store
2828
}
2929

3030
componentWillReceiveProps(nextProps) {
31-
const { store } = this;
32-
const { store: nextStore } = nextProps;
31+
const { store } = this
32+
const { store: nextStore } = nextProps
3333

3434
if (store !== nextStore) {
35-
warnAboutReceivingStore();
35+
warnAboutReceivingStore()
3636
}
3737
}
3838

3939
render() {
40-
let { children } = this.props;
41-
return Children.only(children);
40+
let { children } = this.props
41+
return Children.only(children)
4242
}
4343
}
4444

4545
Provider.propTypes = {
4646
store: storeShape.isRequired,
4747
children: PropTypes.element.isRequired
48-
};
48+
}
4949
Provider.childContextTypes = {
5050
store: storeShape.isRequired
51-
};
51+
}

src/components/connect.js

+89-89
Original file line numberDiff line numberDiff line change
@@ -1,238 +1,238 @@
1-
import React, { Component } from 'react';
2-
import storeShape from '../utils/storeShape';
3-
import shallowEqual from '../utils/shallowEqual';
4-
import isPlainObject from '../utils/isPlainObject';
5-
import wrapActionCreators from '../utils/wrapActionCreators';
6-
import hoistStatics from 'hoist-non-react-statics';
7-
import invariant from 'invariant';
8-
9-
const defaultMapStateToProps = () => ({});
10-
const defaultMapDispatchToProps = dispatch => ({ dispatch });
1+
import React, { Component } from 'react'
2+
import storeShape from '../utils/storeShape'
3+
import shallowEqual from '../utils/shallowEqual'
4+
import isPlainObject from '../utils/isPlainObject'
5+
import wrapActionCreators from '../utils/wrapActionCreators'
6+
import hoistStatics from 'hoist-non-react-statics'
7+
import invariant from 'invariant'
8+
9+
const defaultMapStateToProps = () => ({})
10+
const defaultMapDispatchToProps = dispatch => ({ dispatch })
1111
const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
1212
...parentProps,
1313
...stateProps,
1414
...dispatchProps
15-
});
15+
})
1616

1717
function getDisplayName(WrappedComponent) {
18-
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
18+
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
1919
}
2020

2121
// Helps track hot reloading.
22-
let nextVersion = 0;
22+
let nextVersion = 0
2323

2424
export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
25-
const shouldSubscribe = Boolean(mapStateToProps);
26-
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
25+
const shouldSubscribe = Boolean(mapStateToProps)
26+
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps
2727
const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ?
2828
wrapActionCreators(mapDispatchToProps) :
29-
mapDispatchToProps || defaultMapDispatchToProps;
30-
const finalMergeProps = mergeProps || defaultMergeProps;
31-
const shouldUpdateStateProps = finalMapStateToProps.length > 1;
32-
const shouldUpdateDispatchProps = finalMapDispatchToProps.length > 1;
33-
const { pure = true, withRef = false } = options;
29+
mapDispatchToProps || defaultMapDispatchToProps
30+
const finalMergeProps = mergeProps || defaultMergeProps
31+
const shouldUpdateStateProps = finalMapStateToProps.length > 1
32+
const shouldUpdateDispatchProps = finalMapDispatchToProps.length > 1
33+
const { pure = true, withRef = false } = options
3434

3535
// Helps track hot reloading.
36-
const version = nextVersion++;
36+
const version = nextVersion++
3737

3838
function computeStateProps(store, props) {
39-
const state = store.getState();
39+
const state = store.getState()
4040
const stateProps = shouldUpdateStateProps ?
4141
finalMapStateToProps(state, props) :
42-
finalMapStateToProps(state);
42+
finalMapStateToProps(state)
4343

4444
invariant(
4545
isPlainObject(stateProps),
4646
'`mapStateToProps` must return an object. Instead received %s.',
4747
stateProps
48-
);
49-
return stateProps;
48+
)
49+
return stateProps
5050
}
5151

5252
function computeDispatchProps(store, props) {
53-
const { dispatch } = store;
53+
const { dispatch } = store
5454
const dispatchProps = shouldUpdateDispatchProps ?
5555
finalMapDispatchToProps(dispatch, props) :
56-
finalMapDispatchToProps(dispatch);
56+
finalMapDispatchToProps(dispatch)
5757

5858
invariant(
5959
isPlainObject(dispatchProps),
6060
'`mapDispatchToProps` must return an object. Instead received %s.',
6161
dispatchProps
62-
);
63-
return dispatchProps;
62+
)
63+
return dispatchProps
6464
}
6565

6666
function computeNextState(stateProps, dispatchProps, parentProps) {
67-
const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps);
67+
const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps)
6868
invariant(
6969
isPlainObject(mergedProps),
7070
'`mergeProps` must return an object. Instead received %s.',
7171
mergedProps
72-
);
73-
return mergedProps;
72+
)
73+
return mergedProps
7474
}
7575

7676
return function wrapWithConnect(WrappedComponent) {
7777
class Connect extends Component {
7878
shouldComponentUpdate(nextProps, nextState) {
7979
if (!pure) {
80-
this.updateStateProps(nextProps);
81-
this.updateDispatchProps(nextProps);
82-
this.updateState(nextProps);
83-
return true;
80+
this.updateStateProps(nextProps)
81+
this.updateDispatchProps(nextProps)
82+
this.updateState(nextProps)
83+
return true
8484
}
8585

86-
const storeChanged = nextState.storeState !== this.state.storeState;
87-
const propsChanged = !shallowEqual(nextProps, this.props);
88-
let mapStateProducedChange = false;
89-
let dispatchPropsChanged = false;
86+
const storeChanged = nextState.storeState !== this.state.storeState
87+
const propsChanged = !shallowEqual(nextProps, this.props)
88+
let mapStateProducedChange = false
89+
let dispatchPropsChanged = false
9090

9191
if (storeChanged || (propsChanged && shouldUpdateStateProps)) {
92-
mapStateProducedChange = this.updateStateProps(nextProps);
92+
mapStateProducedChange = this.updateStateProps(nextProps)
9393
}
9494

9595
if (propsChanged && shouldUpdateDispatchProps) {
96-
dispatchPropsChanged = this.updateDispatchProps(nextProps);
96+
dispatchPropsChanged = this.updateDispatchProps(nextProps)
9797
}
9898

9999
if (propsChanged || mapStateProducedChange || dispatchPropsChanged) {
100-
this.updateState(nextProps);
101-
return true;
100+
this.updateState(nextProps)
101+
return true
102102
}
103103

104-
return false;
104+
return false
105105
}
106106

107107
constructor(props, context) {
108-
super(props, context);
109-
this.version = version;
110-
this.store = props.store || context.store;
108+
super(props, context)
109+
this.version = version
110+
this.store = props.store || context.store
111111

112112
invariant(this.store,
113113
`Could not find "store" in either the context or ` +
114114
`props of "${this.constructor.displayName}". ` +
115115
`Either wrap the root component in a <Provider>, ` +
116116
`or explicitly pass "store" as a prop to "${this.constructor.displayName}".`
117-
);
117+
)
118118

119-
this.stateProps = computeStateProps(this.store, props);
120-
this.dispatchProps = computeDispatchProps(this.store, props);
121-
this.state = { storeState: null };
122-
this.updateState();
119+
this.stateProps = computeStateProps(this.store, props)
120+
this.dispatchProps = computeDispatchProps(this.store, props)
121+
this.state = { storeState: null }
122+
this.updateState()
123123
}
124124

125125
computeNextState(props = this.props) {
126126
return computeNextState(
127127
this.stateProps,
128128
this.dispatchProps,
129129
props
130-
);
130+
)
131131
}
132132

133133
updateStateProps(props = this.props) {
134-
const nextStateProps = computeStateProps(this.store, props);
134+
const nextStateProps = computeStateProps(this.store, props)
135135
if (shallowEqual(nextStateProps, this.stateProps)) {
136-
return false;
136+
return false
137137
}
138138

139-
this.stateProps = nextStateProps;
140-
return true;
139+
this.stateProps = nextStateProps
140+
return true
141141
}
142142

143143
updateDispatchProps(props = this.props) {
144-
const nextDispatchProps = computeDispatchProps(this.store, props);
144+
const nextDispatchProps = computeDispatchProps(this.store, props)
145145
if (shallowEqual(nextDispatchProps, this.dispatchProps)) {
146-
return false;
146+
return false
147147
}
148148

149-
this.dispatchProps = nextDispatchProps;
150-
return true;
149+
this.dispatchProps = nextDispatchProps
150+
return true
151151
}
152152

153153
updateState(props = this.props) {
154-
this.nextState = this.computeNextState(props);
154+
this.nextState = this.computeNextState(props)
155155
}
156156

157157
isSubscribed() {
158-
return typeof this.unsubscribe === 'function';
158+
return typeof this.unsubscribe === 'function'
159159
}
160160

161161
trySubscribe() {
162162
if (shouldSubscribe && !this.unsubscribe) {
163-
this.unsubscribe = this.store.subscribe(::this.handleChange);
164-
this.handleChange();
163+
this.unsubscribe = this.store.subscribe(::this.handleChange)
164+
this.handleChange()
165165
}
166166
}
167167

168168
tryUnsubscribe() {
169169
if (this.unsubscribe) {
170-
this.unsubscribe();
171-
this.unsubscribe = null;
170+
this.unsubscribe()
171+
this.unsubscribe = null
172172
}
173173
}
174174

175175
componentDidMount() {
176-
this.trySubscribe();
176+
this.trySubscribe()
177177
}
178178

179179
componentWillUnmount() {
180-
this.tryUnsubscribe();
180+
this.tryUnsubscribe()
181181
}
182182

183183
handleChange() {
184184
if (!this.unsubscribe) {
185-
return;
185+
return
186186
}
187187

188188
this.setState({
189189
storeState: this.store.getState()
190-
});
190+
})
191191
}
192192

193193
getWrappedInstance() {
194194
invariant(withRef,
195195
`To access the wrapped instance, you need to specify ` +
196196
`{ withRef: true } as the fourth argument of the connect() call.`
197-
);
197+
)
198198

199-
return this.refs.wrappedInstance;
199+
return this.refs.wrappedInstance
200200
}
201201

202202
render() {
203-
const ref = withRef ? 'wrappedInstance' : null;
203+
const ref = withRef ? 'wrappedInstance' : null
204204
return (
205205
<WrappedComponent {...this.nextState} ref={ref} />
206-
);
206+
)
207207
}
208208
}
209209

210-
Connect.displayName = `Connect(${getDisplayName(WrappedComponent)})`;
211-
Connect.WrappedComponent = WrappedComponent;
210+
Connect.displayName = `Connect(${getDisplayName(WrappedComponent)})`
211+
Connect.WrappedComponent = WrappedComponent
212212
Connect.contextTypes = {
213213
store: storeShape
214-
};
214+
}
215215
Connect.propTypes = {
216216
store: storeShape
217-
};
217+
}
218218

219219
if (process.env.NODE_ENV !== 'production') {
220220
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
221221
if (this.version === version) {
222-
return;
222+
return
223223
}
224224

225225
// We are hot reloading!
226-
this.version = version;
226+
this.version = version
227227

228228
// Update the state and bindings.
229-
this.trySubscribe();
230-
this.updateStateProps();
231-
this.updateDispatchProps();
232-
this.updateState();
233-
};
229+
this.trySubscribe()
230+
this.updateStateProps()
231+
this.updateDispatchProps()
232+
this.updateState()
233+
}
234234
}
235235

236-
return hoistStatics(Connect, WrappedComponent);
237-
};
236+
return hoistStatics(Connect, WrappedComponent)
237+
}
238238
}

0 commit comments

Comments
 (0)