Skip to content

Commit 78cdeac

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/react-redux into withTypes
2 parents 7cf1383 + 4b63c88 commit 78cdeac

39 files changed

+1901
-1261
lines changed

.eslintrc

-69
This file was deleted.

.eslintrc.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/eslint-recommended",
9+
"plugin:import/recommended",
10+
"plugin:react/recommended",
11+
"plugin:@typescript-eslint/recommended"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"ecmaFeatures": { "jsx": true },
16+
"ecmaVersion": 2015,
17+
"project": true,
18+
"sourceType": "module"
19+
},
20+
"plugins": ["@typescript-eslint", "import", "react"],
21+
"rules": {
22+
"valid-jsdoc": [2]
23+
},
24+
"settings": {
25+
"import/ignore": ["react-native"],
26+
"import/resolver": { "node": { "extensions": [".js", ".ts", ".tsx"] } },
27+
"react": { "version": "detect" }
28+
},
29+
"overrides": [
30+
{
31+
"files": ["**/*.{ts,tsx,cts}"],
32+
"extends": [
33+
"eslint:recommended",
34+
"plugin:import/recommended",
35+
"plugin:react/recommended",
36+
"plugin:@typescript-eslint/recommended"
37+
],
38+
"rules": {
39+
"@typescript-eslint/ban-ts-comment": [0],
40+
"@typescript-eslint/no-redeclare": [2],
41+
"@typescript-eslint/no-explicit-any": [0],
42+
"@typescript-eslint/no-unused-vars": [0],
43+
"@typescript-eslint/ban-types": [0],
44+
"react/display-name": [0],
45+
"react/jsx-no-undef": [2],
46+
"react/jsx-uses-react": [1],
47+
"react/jsx-wrap-multilines": [2],
48+
"react/no-string-refs": [0],
49+
"@typescript-eslint/consistent-type-imports": [
50+
2,
51+
{ "fixStyle": "separate-type-imports" }
52+
],
53+
"@typescript-eslint/consistent-type-exports": [2],
54+
"valid-jsdoc": [2]
55+
}
56+
},
57+
{
58+
"files": ["**/test/**/*.{ts,tsx}"],
59+
"parserOptions": { "project": "./test/tsconfig.test.json" }
60+
}
61+
]
62+
}

package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"clean": "rimraf lib dist es coverage",
4141
"api-types": "api-extractor run --local",
4242
"format": "prettier --write \"{src,test}/**/*.{js,ts,tsx}\" \"docs/**/*.md\"",
43-
"lint": "eslint src --ext ts,tsx,js test/utils test/components test/hooks",
43+
"lint": "eslint src test",
44+
"lint:fix": "eslint src test --fix",
4445
"prepare": "yarn clean && yarn build",
4546
"pretest": "yarn lint",
4647
"test": "jest",
@@ -89,22 +90,22 @@
8990
"@testing-library/react-native": "^7.1.0",
9091
"@types/react": "18.2.25",
9192
"@types/react-native": "^0.67.4",
92-
"@typescript-eslint/eslint-plugin": "^4.28.0",
93-
"@typescript-eslint/parser": "^4.28.0",
93+
"@typescript-eslint/eslint-plugin": "^6.17.0",
94+
"@typescript-eslint/parser": "^6.17.0",
9495
"babel-eslint": "^10.1.0",
9596
"babel-jest": "^29",
9697
"codecov": "^3.8.0",
9798
"cross-env": "^7.0.2",
98-
"eslint": "^7.12.0",
99-
"eslint-config-prettier": "^6.14.0",
100-
"eslint-plugin-import": "^2.22.1",
101-
"eslint-plugin-prettier": "^3.1.4",
102-
"eslint-plugin-react": "^7.21.5",
99+
"eslint": "^8.56.0",
100+
"eslint-config-prettier": "^9.1.0",
101+
"eslint-plugin-import": "^2.29.1",
102+
"eslint-plugin-prettier": "^5.1.2",
103+
"eslint-plugin-react": "^7.33.2",
103104
"glob": "^7.1.6",
104105
"jest": "^29",
105106
"jest-environment-jsdom": "^29.5.0",
106107
"metro-react-native-babel-preset": "^0.76.6",
107-
"prettier": "^2.1.2",
108+
"prettier": "^3.1.1",
108109
"react": "18.2.0",
109110
"react-dom": "18.2.0",
110111
"react-native": "^0.71.11",

src/components/Context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getContext(): Context<ReactReduxContextValue | null> {
3535
let realContext = contextMap.get(React.createContext)
3636
if (!realContext) {
3737
realContext = React.createContext<ReactReduxContextValue | null>(
38-
null as any
38+
null as any,
3939
)
4040
if (process.env.NODE_ENV !== 'production') {
4141
realContext.displayName = 'ReactRedux'

src/components/connect.tsx

+18-17
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type EffectFunc = (...args: any[]) => void | ReturnType<React.EffectCallback>
7070
function useIsomorphicLayoutEffectWithArgs(
7171
effectFunc: EffectFunc,
7272
effectArgs: any[],
73-
dependencies?: React.DependencyList
73+
dependencies?: React.DependencyList,
7474
) {
7575
useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies)
7676
}
@@ -83,7 +83,7 @@ function captureWrapperProps(
8383
wrapperProps: unknown,
8484
// actualChildProps: unknown,
8585
childPropsFromStoreUpdate: React.MutableRefObject<unknown>,
86-
notifyNestedSubs: () => void
86+
notifyNestedSubs: () => void,
8787
) {
8888
// We want to capture the wrapper props and child props we used for later comparisons
8989
lastWrapperProps.current = wrapperProps
@@ -110,7 +110,7 @@ function subscribeUpdates(
110110
childPropsFromStoreUpdate: React.MutableRefObject<unknown>,
111111
notifyNestedSubs: () => void,
112112
// forceComponentUpdateDispatch: React.Dispatch<any>,
113-
additionalSubscribeListener: () => void
113+
additionalSubscribeListener: () => void,
114114
) {
115115
// If we're not subscribed to the store, nothing to do here
116116
if (!shouldHandleStateChanges) return () => {}
@@ -136,7 +136,7 @@ function subscribeUpdates(
136136
// to determine what the child props should be
137137
newChildProps = childPropsSelector(
138138
latestStoreState,
139-
lastWrapperProps.current
139+
lastWrapperProps.current,
140140
)
141141
} catch (e) {
142142
error = e
@@ -466,13 +466,13 @@ function connect<
466466

467467
// the context consumer to use
468468
context = ReactReduxContext,
469-
}: ConnectOptions<unknown, unknown, unknown, unknown> = {}
469+
}: ConnectOptions<unknown, unknown, unknown, unknown> = {},
470470
): unknown {
471471
if (process.env.NODE_ENV !== 'production') {
472472
if (pure !== undefined && !hasWarnedAboutDeprecatedPureOption) {
473473
hasWarnedAboutDeprecatedPureOption = true
474474
warning(
475-
'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
475+
'The `pure` option has been removed. `connect` is now always a "pure/memoized" component',
476476
)
477477
}
478478
}
@@ -486,7 +486,7 @@ function connect<
486486
const shouldHandleStateChanges = Boolean(mapStateToProps)
487487

488488
const wrapWithConnect = <TProps,>(
489-
WrappedComponent: ComponentType<TProps>
489+
WrappedComponent: ComponentType<TProps>,
490490
) => {
491491
type WrappedComponentProps = TProps &
492492
ConnectPropsMaybeWithoutContext<TProps>
@@ -496,8 +496,8 @@ function connect<
496496
if (!isValid)
497497
throw new Error(
498498
`You must pass a component to the function returned by connect. Instead received ${stringifyComponent(
499-
WrappedComponent
500-
)}`
499+
WrappedComponent,
500+
)}`,
501501
)
502502
}
503503

@@ -529,7 +529,7 @@ function connect<
529529
}
530530

531531
function ConnectFunction<TOwnProps>(
532-
props: InternalConnectProps & TOwnProps
532+
props: InternalConnectProps & TOwnProps,
533533
) {
534534
const [propsContext, reactReduxForwardedRef, wrapperProps] =
535535
React.useMemo(() => {
@@ -548,11 +548,11 @@ function connect<
548548
if (process.env.NODE_ENV !== 'production') {
549549
const isValid = /*#__PURE__*/ isContextConsumer(
550550
// @ts-ignore
551-
<propsContext.Consumer />
551+
<propsContext.Consumer />,
552552
)
553553
if (!isValid) {
554554
throw new Error(
555-
'You must pass a valid React context consumer as `props.context`'
555+
'You must pass a valid React context consumer as `props.context`',
556556
)
557557
}
558558
ResultContext = propsContext
@@ -583,7 +583,7 @@ function connect<
583583
`Could not find "store" in the context of ` +
584584
`"${displayName}". Either wrap the root component in a <Provider>, ` +
585585
`or pass a custom React context provider to <Provider> and the corresponding ` +
586-
`React context consumer to ${displayName} in connect options.`
586+
`React context consumer to ${displayName} in connect options.`,
587587
)
588588
}
589589

@@ -609,7 +609,7 @@ function connect<
609609
// connected to the store via props shouldn't use subscription from context, or vice versa.
610610
const subscription = createSubscription(
611611
store,
612-
didStoreComeFromProps ? undefined : contextValue!.subscription
612+
didStoreComeFromProps ? undefined : contextValue!.subscription,
613613
)
614614

615615
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
@@ -703,7 +703,7 @@ function connect<
703703
isMounted,
704704
childPropsFromStoreUpdate,
705705
notifyNestedSubs,
706-
reactListener
706+
reactListener,
707707
)
708708
}
709709

@@ -730,10 +730,11 @@ function connect<
730730
actualChildPropsSelector,
731731
getServerState
732732
? () => childPropsSelector(getServerState(), wrapperProps)
733-
: actualChildPropsSelector
733+
: actualChildPropsSelector,
734734
)
735735
} catch (err) {
736736
if (latestSubscriptionCallbackError.current) {
737+
// eslint-disable-next-line no-extra-semi
737738
;(
738739
err as Error
739740
).message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
@@ -797,7 +798,7 @@ function connect<
797798
if (forwardRef) {
798799
const _forwarded = React.forwardRef(function forwardConnectRef(
799800
props,
800-
ref
801+
ref,
801802
) {
802803
// @ts-ignore
803804
return <Connect {...props} reactReduxForwardedRef={ref} />

src/connect/invalidArgFactory.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import type { Action, Dispatch } from 'redux'
33
export function createInvalidArgFactory(arg: unknown, name: string) {
44
return (
55
dispatch: Dispatch<Action<string>>,
6-
options: { readonly wrappedComponentName: string }
6+
options: { readonly wrappedComponentName: string },
77
) => {
88
throw new Error(
99
`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${
1010
options.wrappedComponentName
11-
}.`
11+
}.`,
1212
)
1313
}
1414
}

src/connect/mapDispatchToProps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import type { MapDispatchToPropsParam } from './selectorFactory'
77
export function mapDispatchToPropsFactory<TDispatchProps, TOwnProps>(
88
mapDispatchToProps:
99
| MapDispatchToPropsParam<TDispatchProps, TOwnProps>
10-
| undefined
10+
| undefined,
1111
) {
1212
return mapDispatchToProps && typeof mapDispatchToProps === 'object'
1313
? wrapMapToPropsConstant((dispatch: Dispatch<Action<string>>) =>
1414
// @ts-ignore
15-
bindActionCreators(mapDispatchToProps, dispatch)
15+
bindActionCreators(mapDispatchToProps, dispatch),
1616
)
1717
: !mapDispatchToProps
1818
? wrapMapToPropsConstant((dispatch: Dispatch<Action<string>>) => ({

src/connect/mapStateToProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createInvalidArgFactory } from './invalidArgFactory'
33
import type { MapStateToPropsParam } from './selectorFactory'
44

55
export function mapStateToPropsFactory<TStateProps, TOwnProps, State>(
6-
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>
6+
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
77
) {
88
return !mapStateToProps
99
? wrapMapToPropsConstant(() => ({}))

0 commit comments

Comments
 (0)