Skip to content

Commit 1849851

Browse files
committed
Run prettier on existing code.
1 parent 73e3a16 commit 1849851

14 files changed

+142
-150
lines changed

src/components/connectAdvanced.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export default function connectAdvanced(
8686
invariant(
8787
isValidElementType(WrappedComponent),
8888
`You must pass a component to the function returned by ` +
89-
`${methodName}. Instead received ${JSON.stringify(WrappedComponent)}`
90-
);
89+
`${methodName}. Instead received ${JSON.stringify(WrappedComponent)}`
90+
)
9191
}
9292

9393
const wrappedComponentName =

src/connect/connect.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ function match(arg, factories, name) {
2929
}
3030

3131
return (dispatch, options) => {
32-
throw new Error(`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`)
32+
throw new Error(
33+
`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${
34+
options.wrappedComponentName
35+
}.`
36+
)
3337
}
3438
}
3539

36-
function strictEqual(a, b) { return a === b }
40+
function strictEqual(a, b) {
41+
return a === b
42+
}
3743

3844
// createConnect with default args builds the 'official' connect behavior. Calling it with
3945
// different options opens up some testing and extensibility scenarios
@@ -57,15 +63,23 @@ export function createConnect({
5763
...extraOptions
5864
} = {}
5965
) {
60-
const initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps')
61-
const initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps')
66+
const initMapStateToProps = match(
67+
mapStateToProps,
68+
mapStateToPropsFactories,
69+
'mapStateToProps'
70+
)
71+
const initMapDispatchToProps = match(
72+
mapDispatchToProps,
73+
mapDispatchToPropsFactories,
74+
'mapDispatchToProps'
75+
)
6276
const initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps')
6377

6478
return connectHOC(selectorFactory, {
6579
// used in error messages
6680
methodName: 'connect',
6781

68-
// used to compute Connect's displayName from the wrapped component's displayName.
82+
// used to compute Connect's displayName from the wrapped component's displayName.
6983
getDisplayName: name => `Connect(${name})`,
7084

7185
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes

src/connect/mapDispatchToProps.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ import { bindActionCreators } from 'redux'
22
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
33

44
export function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
5-
return (typeof mapDispatchToProps === 'function')
5+
return typeof mapDispatchToProps === 'function'
66
? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps')
77
: undefined
88
}
99

1010
export function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
11-
return (!mapDispatchToProps)
11+
return !mapDispatchToProps
1212
? wrapMapToPropsConstant(dispatch => ({ dispatch }))
1313
: undefined
1414
}
1515

1616
export function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
17-
return (mapDispatchToProps && typeof mapDispatchToProps === 'object')
18-
? wrapMapToPropsConstant(dispatch => bindActionCreators(mapDispatchToProps, dispatch))
17+
return mapDispatchToProps && typeof mapDispatchToProps === 'object'
18+
? wrapMapToPropsConstant(dispatch =>
19+
bindActionCreators(mapDispatchToProps, dispatch)
20+
)
1921
: undefined
2022
}
2123

src/connect/mapStateToProps.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
22

33
export function whenMapStateToPropsIsFunction(mapStateToProps) {
4-
return (typeof mapStateToProps === 'function')
4+
return typeof mapStateToProps === 'function'
55
? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps')
66
: undefined
77
}
88

99
export function whenMapStateToPropsIsMissing(mapStateToProps) {
10-
return (!mapStateToProps)
11-
? wrapMapToPropsConstant(() => ({}))
12-
: undefined
10+
return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : undefined
1311
}
1412

15-
export default [
16-
whenMapStateToPropsIsFunction,
17-
whenMapStateToPropsIsMissing
18-
]
13+
export default [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]

src/connect/mergeProps.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export function defaultMergeProps(stateProps, dispatchProps, ownProps) {
66

77
export function wrapMergePropsFunc(mergeProps) {
88
return function initMergePropsProxy(
9-
dispatch, { displayName, pure, areMergedPropsEqual }
9+
dispatch,
10+
{ displayName, pure, areMergedPropsEqual }
1011
) {
1112
let hasRunOnce = false
1213
let mergedProps
@@ -17,7 +18,6 @@ export function wrapMergePropsFunc(mergeProps) {
1718
if (hasRunOnce) {
1819
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps))
1920
mergedProps = nextMergedProps
20-
2121
} else {
2222
hasRunOnce = true
2323
mergedProps = nextMergedProps
@@ -32,18 +32,13 @@ export function wrapMergePropsFunc(mergeProps) {
3232
}
3333

3434
export function whenMergePropsIsFunction(mergeProps) {
35-
return (typeof mergeProps === 'function')
35+
return typeof mergeProps === 'function'
3636
? wrapMergePropsFunc(mergeProps)
3737
: undefined
3838
}
3939

4040
export function whenMergePropsIsOmitted(mergeProps) {
41-
return (!mergeProps)
42-
? () => defaultMergeProps
43-
: undefined
41+
return !mergeProps ? () => defaultMergeProps : undefined
4442
}
4543

46-
export default [
47-
whenMergePropsIsFunction,
48-
whenMergePropsIsOmitted
49-
]
44+
export default [whenMergePropsIsFunction, whenMergePropsIsOmitted]

src/connect/selectorFactory.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,21 @@ export function pureFinalPropsSelectorFactory(
9797
// props have not changed. If false, the selector will always return a new
9898
// object and shouldComponentUpdate will always return true.
9999

100-
export default function finalPropsSelectorFactory(dispatch, {
101-
initMapStateToProps,
102-
initMapDispatchToProps,
103-
initMergeProps,
104-
...options
105-
}) {
100+
export default function finalPropsSelectorFactory(
101+
dispatch,
102+
{ initMapStateToProps, initMapDispatchToProps, initMergeProps, ...options }
103+
) {
106104
const mapStateToProps = initMapStateToProps(dispatch, options)
107105
const mapDispatchToProps = initMapDispatchToProps(dispatch, options)
108106
const mergeProps = initMergeProps(dispatch, options)
109107

110108
if (process.env.NODE_ENV !== 'production') {
111-
verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName)
109+
verifySubselectors(
110+
mapStateToProps,
111+
mapDispatchToProps,
112+
mergeProps,
113+
options.displayName
114+
)
112115
}
113116

114117
const selectorFactory = options.pure

src/connect/verifySubselectors.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import warning from '../utils/warning'
33
function verify(selector, methodName, displayName) {
44
if (!selector) {
55
throw new Error(`Unexpected value for ${methodName} in ${displayName}.`)
6-
7-
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
6+
} else if (
7+
methodName === 'mapStateToProps' ||
8+
methodName === 'mapDispatchToProps'
9+
) {
810
if (!selector.hasOwnProperty('dependsOnOwnProps')) {
911
warning(
1012
`The selector for ${methodName} of ${displayName} did not specify a value for dependsOnOwnProps.`
@@ -13,7 +15,12 @@ function verify(selector, methodName, displayName) {
1315
}
1416
}
1517

16-
export default function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
18+
export default function verifySubselectors(
19+
mapStateToProps,
20+
mapDispatchToProps,
21+
mergeProps,
22+
displayName
23+
) {
1724
verify(mapStateToProps, 'mapStateToProps', displayName)
1825
verify(mapDispatchToProps, 'mapDispatchToProps', displayName)
1926
verify(mergeProps, 'mergeProps', displayName)

src/connect/wrapMapToProps.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,40 @@ export function wrapMapToPropsConstant(getConstant) {
44
return function initConstantSelector(dispatch, options) {
55
const constant = getConstant(dispatch, options)
66

7-
function constantSelector() { return constant }
8-
constantSelector.dependsOnOwnProps = false
7+
function constantSelector() {
8+
return constant
9+
}
10+
constantSelector.dependsOnOwnProps = false
911
return constantSelector
1012
}
1113
}
1214

1315
// dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
1416
// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
1517
// whether mapToProps needs to be invoked when props have changed.
16-
//
18+
//
1719
// A length of one signals that mapToProps does not depend on props from the parent component.
1820
// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
1921
// therefore not reporting its length accurately..
2022
export function getDependsOnOwnProps(mapToProps) {
21-
return (mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined)
23+
return mapToProps.dependsOnOwnProps !== null &&
24+
mapToProps.dependsOnOwnProps !== undefined
2225
? Boolean(mapToProps.dependsOnOwnProps)
2326
: mapToProps.length !== 1
2427
}
2528

2629
// Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
2730
// this function wraps mapToProps in a proxy function which does several things:
28-
//
31+
//
2932
// * Detects whether the mapToProps function being called depends on props, which
3033
// is used by selectorFactory to decide if it should reinvoke on props changes.
31-
//
34+
//
3235
// * On first call, handles mapToProps if returns another function, and treats that
3336
// new function as the true mapToProps for subsequent calls.
34-
//
37+
//
3538
// * On first call, verifies the first result is a plain object, in order to warn
3639
// the developer that their mapToProps function is not returning a valid result.
37-
//
40+
//
3841
export function wrapMapToPropsFunc(mapToProps, methodName) {
3942
return function initProxySelector(dispatch, { displayName }) {
4043
const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
@@ -46,7 +49,10 @@ export function wrapMapToPropsFunc(mapToProps, methodName) {
4649
// allow detectFactoryAndVerify to get ownProps
4750
proxy.dependsOnOwnProps = true
4851

49-
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
52+
proxy.mapToProps = function detectFactoryAndVerify(
53+
stateOrDispatch,
54+
ownProps
55+
) {
5056
proxy.mapToProps = mapToProps
5157
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps)
5258
let props = proxy(stateOrDispatch, ownProps)
@@ -57,7 +63,7 @@ export function wrapMapToPropsFunc(mapToProps, methodName) {
5763
props = proxy(stateOrDispatch, ownProps)
5864
}
5965

60-
if (process.env.NODE_ENV !== 'production')
66+
if (process.env.NODE_ENV !== 'production')
6167
verifyPlainObject(props, displayName, methodName)
6268

6369
return props

src/utils/shallowEqual.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ function is(x, y) {
1111
export default function shallowEqual(objA, objB) {
1212
if (is(objA, objB)) return true
1313

14-
if (typeof objA !== 'object' || objA === null ||
15-
typeof objB !== 'object' || objB === null) {
14+
if (
15+
typeof objA !== 'object' ||
16+
objA === null ||
17+
typeof objB !== 'object' ||
18+
objB === null
19+
) {
1620
return false
1721
}
1822

@@ -22,8 +26,7 @@ export default function shallowEqual(objA, objB) {
2226
if (keysA.length !== keysB.length) return false
2327

2428
for (let i = 0; i < keysA.length; i++) {
25-
if (!hasOwn.call(objB, keysA[i]) ||
26-
!is(objA[keysA[i]], objB[keysA[i]])) {
29+
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
2730
return false
2831
}
2932
}

test/babel-transformer.jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ const path = require('path')
22
const { createTransformer } = require('babel-jest')
33

44
module.exports = createTransformer({
5-
configFile: path.resolve(__dirname, '../.babelrc.js'),
5+
configFile: path.resolve(__dirname, '../.babelrc.js')
66
})

test/install-test-deps.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint no-console: 0 */
2-
'use strict';
2+
'use strict'
33

4-
const { readdirSync, existsSync, copyFile, mkdirSync } = require('fs');
5-
const rimraf = require('rimraf');
6-
const { join } = require('path');
7-
const spawn = require("cross-spawn");
4+
const { readdirSync, existsSync, copyFile, mkdirSync } = require('fs')
5+
const rimraf = require('rimraf')
6+
const { join } = require('path')
7+
const spawn = require('cross-spawn')
88
const reactVersion = process.env.REACT || '16.6'
99

1010
readdirSync(join(__dirname, 'react')).forEach(version => {
@@ -16,16 +16,16 @@ readdirSync(join(__dirname, 'react')).forEach(version => {
1616
const srcs = [
1717
join(__dirname, '..', 'src', 'components'),
1818
join(__dirname, '..', 'src', 'connect'),
19-
join(__dirname, '..', 'src', 'utils'),
19+
join(__dirname, '..', 'src', 'utils')
2020
]
2121
const dest = [
2222
join(__dirname, 'react', version, 'test', 'components'),
23-
join(__dirname, 'react', version, 'test', 'utils'),
23+
join(__dirname, 'react', version, 'test', 'utils')
2424
]
2525
const srcDest = [
2626
join(__dirname, 'react', version, 'src', 'components'),
2727
join(__dirname, 'react', version, 'src', 'connect'),
28-
join(__dirname, 'react', version, 'src', 'utils'),
28+
join(__dirname, 'react', version, 'src', 'utils')
2929
]
3030

3131
if (!existsSync(join(__dirname, 'react', version, 'test'))) {
@@ -66,24 +66,32 @@ readdirSync(join(__dirname, 'react')).forEach(version => {
6666
if (e) console.log(e)
6767
})
6868
})
69-
copyFile(join(__dirname, '..', 'src', 'index.js'), join(__dirname, 'react', version, 'src', 'index.js'), e => {
70-
if (e) console.log(e)
71-
})
69+
copyFile(
70+
join(__dirname, '..', 'src', 'index.js'),
71+
join(__dirname, 'react', version, 'src', 'index.js'),
72+
e => {
73+
if (e) console.log(e)
74+
}
75+
)
7276
})
73-
const cwd = join(__dirname, 'react', version);
74-
if (existsSync(join(__dirname, 'react', version, 'node_modules', 'react', 'package.json'))) {
75-
console.log(`Skipping React version ${version} ... (already installed)`);
77+
const cwd = join(__dirname, 'react', version)
78+
if (
79+
existsSync(
80+
join(__dirname, 'react', version, 'node_modules', 'react', 'package.json')
81+
)
82+
) {
83+
console.log(`Skipping React version ${version} ... (already installed)`)
7684
return
7785
}
7886

79-
console.log(`Installing React version ${version}...`);
87+
console.log(`Installing React version ${version}...`)
8088

8189
const installTask = spawn.sync('npm', ['install'], {
8290
cwd,
83-
stdio: 'inherit',
84-
});
91+
stdio: 'inherit'
92+
})
8593

8694
if (installTask.status > 0) {
87-
process.exit(installTask.status);
95+
process.exit(installTask.status)
8896
}
89-
});
97+
})

0 commit comments

Comments
 (0)