Skip to content

Commit 4f9187a

Browse files
committed
chore: bump deps
1 parent c424564 commit 4f9187a

20 files changed

+3667
-3881
lines changed

.eslintrc.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"extends": [
55
"plugin:react/recommended",
66
"plugin:@typescript-eslint/recommended",
7-
"prettier",
8-
"prettier/@typescript-eslint"
7+
"prettier"
98
],
109
"globals": {
1110
"Atomics": "readonly",
@@ -27,7 +26,7 @@
2726
"@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false }],
2827
"@typescript-eslint/no-explicit-any": "off",
2928
"@typescript-eslint/no-var-requires": "off",
30-
"@typescript-eslint/ban-ts-ignore": "off",
29+
"@typescript-eslint/ban-ts-comment": "off",
3130
"no-console": ["error", { "allow": ["warn", "error"] }]
3231
},
3332
"settings": {

demo/index.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ class Count extends Ayanami<State> {
7373
}
7474
}
7575

76+
const InputComponent = React.memo(() => {
77+
const [input, actions] = useAyanami(Count, { selector: (state) => state.input })
78+
79+
return (
80+
<div>
81+
<h3>{input}</h3>
82+
<input value={input} onChange={(e) => actions.changeInput(e.target.value)} />
83+
</div>
84+
)
85+
})
86+
InputComponent.displayName = 'InputComponent'
87+
7688
function CountComponent() {
7789
const [{ count, input }, actions] = useAyanami(Count)
7890
const [{ tips }] = useAyanami(Tips)
@@ -93,16 +105,4 @@ function CountComponent() {
93105
)
94106
}
95107

96-
const InputComponent = React.memo(() => {
97-
const [input, actions] = useAyanami(Count, { selector: (state) => state.input })
98-
99-
return (
100-
<div>
101-
<h3>{input}</h3>
102-
<input value={input} onChange={(e) => actions.changeInput(e.target.value)} />
103-
</div>
104-
)
105-
})
106-
InputComponent.displayName = 'InputComponent'
107-
108108
ReactDOM.render(<CountComponent />, document.querySelector('#app'))

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@
6767
"@types/lodash": "^4.14.136",
6868
"@types/node": "^12.6.9",
6969
"@types/react": "^17.0.3",
70-
"@types/react-dom": "^16.8.5",
71-
"@types/react-test-renderer": "^16.8.3",
70+
"@types/react-dom": "^17.0.2",
71+
"@types/react-test-renderer": "^17.0.1",
7272
"@types/shallowequal": "^1.1.1",
73-
"@typescript-eslint/eslint-plugin": "^2.1.0",
74-
"@typescript-eslint/parser": "^2.0.0",
73+
"@typescript-eslint/eslint-plugin": "^4.18.0",
74+
"@typescript-eslint/parser": "^4.18.0",
7575
"codecov": "^3.5.0",
76-
"eslint": "6.6.0",
77-
"eslint-config-prettier": "^6.0.0",
78-
"eslint-plugin-react": "^7.14.3",
76+
"eslint": "7.22.0",
77+
"eslint-config-prettier": "^8.1.0",
78+
"eslint-plugin-react": "^7.21.5",
7979
"husky": "^4.3.0",
8080
"immer": "^8.0.1",
8181
"jest": "^24.8.0",
@@ -85,21 +85,21 @@
8585
"npm-run-all": "^4.1.5",
8686
"parcel": "^1.12.3",
8787
"prettier": "^2.2.1",
88-
"react": "^16.8.6",
89-
"react-dom": "^16.8.6",
90-
"react-test-renderer": "^16.8.6",
88+
"react": "^17.0.1",
89+
"react-dom": "^17.0.1",
90+
"react-test-renderer": "^17.0.1",
9191
"reflect-metadata": "^0.1.13",
9292
"rxjs": "^6.5.2",
9393
"shx": "^0.3.2",
9494
"ts-jest": "^24.0.2",
95-
"tslib": "^1.10.0",
96-
"typescript": "^3.5.3"
95+
"tslib": "^2.1.0",
96+
"typescript": "^4.2.3"
9797
},
9898
"peerDependencies": {
9999
"@asuka/di": "^0.2.0",
100-
"immer": "^3.2.0",
100+
"immer": "^8.0.1",
101101
"lodash": "^4.17.15",
102-
"react": "^16.8.6",
102+
"react": "^17.0.1",
103103
"reflect-metadata": "^0.1.13",
104104
"rxjs": "^6.5.2"
105105
}

src/connect.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ type ConnectedComponent<P, S, A> = React.FunctionComponent<Omit<P, keyof S | key
88
type ConnectComponent<S, A> = <P>(Component: React.ComponentType<P>) => ConnectedComponent<P, S, A>
99

1010
export interface ComponentConnectedWithAyanami<M extends Ayanami<S>, S> {
11-
(): ConnectComponent<{}, {}>
11+
(): ConnectComponent<Record<string, unknown>, Record<string, unknown>>
1212

13-
<MS>(mapStateToProps: (state: S) => MS): ConnectComponent<MS, {}>
13+
<MS>(mapStateToProps: (state: S) => MS): ConnectComponent<MS, Record<string, unknown>>
1414

1515
<MS, MA>(
1616
mapStateToProps: (state: S) => MS,
@@ -20,7 +20,7 @@ export interface ComponentConnectedWithAyanami<M extends Ayanami<S>, S> {
2020
<MA>(
2121
mapStateToProps: null,
2222
mapActionsToProps: (actions: ActionMethodOfAyanami<M, S>) => MA,
23-
): ConnectComponent<{}, MA>
23+
): ConnectComponent<Record<string, unknown>, MA>
2424
}
2525

2626
export function connectAyanami<M extends Ayanami<S>, S>(

src/core/ayanami.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export abstract class Ayanami<State> {
4545
}
4646
}
4747

48-
destroy() {
48+
destroy(): void {
4949
destroyIkariFrom(this)
5050
}
5151

src/core/decorators/action-related.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import { Ayanami } from '../ayanami'
33
import { ConstructorOf } from '../types'
44

55
export function createActionDecorator(symbols: ActionSymbols) {
6-
return () => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
6+
return () => (
7+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
8+
target: any,
9+
propertyKey: string,
10+
descriptor: PropertyDescriptor,
11+
): PropertyDescriptor => {
712
addActionName(symbols, target.constructor, propertyKey)
813
return descriptor
914
}
1015
}
1116

17+
// eslint-disable-next-line @typescript-eslint/ban-types
1218
function addActionName(symbols: ActionSymbols, constructor: Function, actionName: string) {
1319
const decoratedActionNames = Reflect.getMetadata(symbols.decorator, constructor) || []
1420
Reflect.defineMetadata(symbols.decorator, [...decoratedActionNames, actionName], constructor)
@@ -21,7 +27,7 @@ export function getActionNames<T extends Ayanami<any>>(
2127
return Reflect.getMetadata(symbols.decorator, constructor) || []
2228
}
2329

24-
export function getAllActionNames<T extends Ayanami<any>>(instance: T) {
30+
export function getAllActionNames<T extends Ayanami<any>>(instance: T): (keyof T)[] {
2531
return allActionSymbols.reduce<(keyof T)[]>(
2632
(result, symbols) => [
2733
...result,

src/core/ikari.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export function combineWithIkari<S>(ayanami: Ayanami<S>): Ikari<S> {
5252
} else {
5353
const { effects, reducers, immerReducers, defineActions } = getOriginalFunctions(ayanami)
5454

55-
Object.assign(ayanami, mapValues(defineActions, ({ observable }) => observable))
55+
Object.assign(
56+
ayanami,
57+
mapValues(defineActions, ({ observable }) => observable),
58+
)
5659

5760
return Ikari.createAndBindAt(ayanami, {
5861
nameForLog: ayanami.constructor.name,
@@ -103,6 +106,7 @@ export class Ikari<State> {
103106
// @internal
104107
terminate$ = new Subject<typeof TERMINATE_ACTION | null>()
105108

109+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
106110
constructor(readonly ayanami: Ayanami<State>, private readonly config: Readonly<Config<State>>) {
107111
const [effectActions$, effectActions] = setupEffectActions(
108112
this.config.effects,
@@ -158,7 +162,7 @@ export class Ikari<State> {
158162
)
159163
}
160164

161-
destroy() {
165+
destroy(): void {
162166
this.subscription.unsubscribe()
163167
this.triggerActions = {}
164168
}

src/core/scope/same-scope-decorator.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
export const SameScopeMetadataKey = Symbol('SameScopeInjectionParams')
22

3-
export const SameScope = () => (target: any, _propertyKey: string, parameterIndex: number) => {
3+
export const SameScope = () => (
4+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5+
target: any,
6+
_propertyKey: string,
7+
parameterIndex: number,
8+
): void => {
49
let sameScopeInjectionParams: boolean[] = []
510
if (Reflect.hasMetadata(SameScopeMetadataKey, target)) {
611
sameScopeInjectionParams = Reflect.getMetadata(SameScopeMetadataKey, target)

src/core/scope/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function getInstanceFrom<T>(constructor: ConstructorOf<T>, scope: Scope): T | un
7777
return scopeMap && scopeMap.get(scope)
7878
}
7979

80+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
8081
export function createScopeWithRequest(req: Request, scope: any | undefined) {
8182
if (!scope) {
8283
return req

src/core/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { Draft } from 'immer'
44
import { Ayanami } from './ayanami'
55

66
// https://stackoverflow.com/questions/55541275/typescript-check-for-the-any-type
7-
type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N
7+
type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
88

99
type IsAny<T> = IfAny<T, true, false>
1010

1111
// https://stackoverflow.com/questions/55542332/typescript-conditional-type-with-discriminated-union
1212
type IsVoid<T> = IsAny<T> extends true ? false : [T] extends [void] ? true : false
1313

1414
// using class type to avoid conflict with user defined params
15+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1516
class ArgumentsType<_Arguments extends any[]> {}
1617

1718
export type ActionMethod<
@@ -43,6 +44,7 @@ export interface ReducerAction<State> {
4344
readonly nextState: State
4445
}
4546

47+
// eslint-disable-next-line @typescript-eslint/ban-types
4648
type UnpackEffectFunctionArguments<T extends Function> = T extends (
4749
...payload: infer Arguments
4850
) => Observable<EffectAction>
@@ -61,6 +63,7 @@ type UnpackEffectPayload<Func, State> = Func extends () => Observable<EffectActi
6163
? UnpackEffectFunctionArguments<Func>
6264
: never
6365

66+
// eslint-disable-next-line @typescript-eslint/ban-types
6467
type UnpackReducerFunctionArguments<T extends Function> = T extends (
6568
state: any,
6669
...payload: infer Arguments

src/core/utils/get-effect-action-factories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Ayanami } from '../ayanami'
22
import { EffectAction } from '../types'
33
import { getAllActionNames } from '../decorators'
44

5-
export function getEffectActionFactories(target: Ayanami<any>) {
5+
export function getEffectActionFactories(target: Ayanami<any>): any {
66
return getAllActionNames(target).reduce(
77
(result: any, name: string) => ({
88
...result,

src/core/utils/get-original-functions.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import { effectSymbols, reducerSymbols, immerReducerSymbols, defineActionSymbols
1414
const getOriginalFunctionNames = (ayanami: Ayanami<any>) => ({
1515
effects: getActionNames(effectSymbols, ayanami.constructor as ConstructorOf<Ayanami<any>>),
1616
reducers: getActionNames(reducerSymbols, ayanami.constructor as ConstructorOf<Ayanami<any>>),
17-
defineActions: getActionNames(defineActionSymbols, ayanami.constructor as ConstructorOf<
18-
Ayanami<any>
19-
>),
20-
immerReducers: getActionNames(immerReducerSymbols, ayanami.constructor as ConstructorOf<
21-
Ayanami<any>
22-
>),
17+
defineActions: getActionNames(
18+
defineActionSymbols,
19+
ayanami.constructor as ConstructorOf<Ayanami<any>>,
20+
),
21+
immerReducers: getActionNames(
22+
immerReducerSymbols,
23+
ayanami.constructor as ConstructorOf<Ayanami<any>>,
24+
),
2325
})
2426

2527
const transformDefineActions = (actionNames: string[]): OriginalDefineActions => {
@@ -37,6 +39,7 @@ const transformDefineActions = (actionNames: string[]): OriginalDefineActions =>
3739
return result
3840
}
3941

42+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4043
export const getOriginalFunctions = (ayanami: Ayanami<any>) => {
4144
const { effects, reducers, immerReducers, defineActions } = getOriginalFunctionNames(ayanami)
4245

src/hooks/shallow-equal.ts

-9
This file was deleted.

src/hooks/use-subscribe-ayanami-state.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import { Subscription } from 'rxjs'
33
import identity from 'lodash/identity'
4-
import { shallowEqual } from './shallow-equal'
4+
import shallowEqual from 'shallowequal'
55
import { Ayanami } from '../core'
66

77
export function useSubscribeAyanamiState<M extends Ayanami<S>, S, U = S>(

src/redux-devtools-extension.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ interface DevTools {
66
}
77

88
interface GlobalState {
9-
[modelName: string]: object
9+
[modelName: string]: Record<string, unknown>
1010
}
1111

1212
const FakeReduxDevTools = {
1313
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14-
connect: (_config: object) => ({ send: noop, init: noop }),
14+
connect: (_config: Record<string, unknown>) => ({ send: noop, init: noop }),
1515
}
1616

1717
const ReduxDevTools =
@@ -34,18 +34,18 @@ const getDevTools = (() => {
3434

3535
let isEnableLog = false
3636

37-
export function enableReduxLog() {
37+
export function enableReduxLog(): void {
3838
isEnableLog = true
3939
}
4040

41-
export function disableReduxLog() {
41+
export function disableReduxLog(): void {
4242
isEnableLog = false
4343
}
4444

4545
export function logStateAction(
4646
namespace: string,
4747
infos: { actionName: string; params: string; state?: any },
48-
) {
48+
): void {
4949
if (isEnableLog) {
5050
const action = {
5151
type: `${namespace}/${infos.actionName}`,

src/ssr/express.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface SSREffectOptions<Payload> {
4242
skipFirstClientDispatch?: boolean
4343
}
4444

45+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4546
export function SSREffect<T, Payload>(options?: SSREffectOptions<Payload>) {
4647
const { payloadGetter, skipFirstClientDispatch } = {
4748
payloadGetter: undefined,
@@ -53,7 +54,7 @@ export function SSREffect<T, Payload>(options?: SSREffectOptions<Payload>) {
5354
addDecorator(target, method, payloadGetter)
5455
if (!isSSREnabled() && skipFirstClientDispatch) {
5556
const originalValue = descriptor.value
56-
descriptor.value = function(
57+
descriptor.value = function (
5758
this: any,
5859
action$: Observable<Payload>,
5960
state$?: Observable<any>,

src/ssr/flag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const isSSREnabled = () => {
1+
export const isSSREnabled = (): boolean => {
22
return typeof process.env.ENABLE_AYANAMI_SSR !== 'undefined'
33
? process.env.ENABLE_AYANAMI_SSR === 'true'
44
: typeof process !== 'undefined' &&

src/ssr/ssr-module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const configSets = new Set<string>()
66
export const moduleNameKey = Symbol.for('__MODULE__NAME__')
77
export const globalKey = Symbol.for('__GLOBAL_MODULE_CACHE__')
88

9-
export const SSRModule = (config: string | InjectableConfig & { name: string }) => {
9+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
10+
export const SSRModule = (config: string | (InjectableConfig & { name: string })) => {
1011
const injectableConfig: InjectableConfig = { providers: [] }
1112
let name: string
1213
if (typeof config === 'string') {

test/specs/effect.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Count extends Ayanami<CountState> {
3535
count: 0,
3636
}
3737

38+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
3839
constructor(readonly tips: Tips) {
3940
super()
4041
}
@@ -105,7 +106,7 @@ describe('Effect spec:', () => {
105106

106107
describe('Error handles', () => {
107108
it(`Error won't affect the main state$`, () => {
108-
const errorLog = jest.spyOn(console, 'error').mockImplementation(() => {})
109+
const errorLog = jest.spyOn(console, 'error').mockImplementation(() => void 0)
109110
countActions.error()
110111
expect(errorLog.mock.calls.length).toBe(1)
111112
errorLog.mockRestore()

0 commit comments

Comments
 (0)