Skip to content

Commit

Permalink
Merge pull request #4135 from aryaemami59/format-all-files
Browse files Browse the repository at this point in the history
Format all files
  • Loading branch information
EskiMojo14 committed Jan 29, 2024
2 parents 527e0b6 + b0ce4df commit d36a3a1
Show file tree
Hide file tree
Showing 331 changed files with 3,220 additions and 3,224 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/tests.yml
Expand Up @@ -149,7 +149,17 @@ jobs:
fail-fast: false
matrix:
node: ['18.x']
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm', 'react-native', 'expo']
example:
[
'cra4',
'cra5',
'next',
'vite',
'node-standard',
'node-esm',
'react-native',
'expo',
]
defaults:
run:
working-directory: ./examples/publish-ci/${{ matrix.example }}
Expand Down
1 change: 0 additions & 1 deletion .prettierrc.json
Expand Up @@ -3,4 +3,3 @@
"singleQuote": true,
"endOfLine": "auto"
}

2 changes: 1 addition & 1 deletion .yarn/releases/yarn-3.2.4.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/actionCreatorMiddleware.mdx
Expand Up @@ -53,7 +53,7 @@ import reducer from './reducer'

// Augment middleware to consider all functions with a static type property to be action creators
const isActionCreator = (
action: unknown
action: unknown,
): action is Function & { type: unknown } =>
typeof action === 'function' && 'type' in action

Expand Down
14 changes: 7 additions & 7 deletions docs/api/combineSlices.mdx
Expand Up @@ -235,15 +235,15 @@ declare module '.' {

const withInjected = rootReducer.inject(
{ reducerPath: 'removable', reducer: removableReducer },
{ overrideExisting: true }
{ overrideExisting: true },
)

const emptyReducer = () => null

const removeReducer = () =>
rootReducer.inject(
{ reducerPath: 'removable', reducer: emptyReducer },
{ overrideExisting: true }
{ overrideExisting: true },
)
```

Expand Down Expand Up @@ -273,14 +273,14 @@ const withCounter = rootReducer.inject(counterSlice)
const selectCounterValue = (rootState: RootState) => rootState.counter?.value // number | undefined

const wrappedSelectCounterValue = withCounter.selector(
(rootState) => rootState.counter.value // number
(rootState) => rootState.counter.value, // number
)

console.log(
selectCounterValue({}), // undefined
selectCounterValue({ counter: { value: 2 } }), // 2
wrappedSelectCounterValue({}), // 0
wrappedSelectCounterValue({ counter: { value: 2 } }) // 2
wrappedSelectCounterValue({ counter: { value: 2 } }), // 2
)
```

Expand All @@ -303,7 +303,7 @@ interface RootState {

const selectCounterValue = withCounter.selector(
(combinedState) => combinedState.counter.value,
(rootState: RootState) => rootState.innerCombined
(rootState: RootState) => rootState.innerCombined,
)

console.log(
Expand All @@ -316,7 +316,7 @@ console.log(
value: 2,
},
},
}) // 2
}), // 2
)
```

Expand Down Expand Up @@ -365,6 +365,6 @@ If the slice state is undefined in the store state passed, the selector will ins
console.log(
injectedCounterSlice.selectors.selectValue({}), // 0
injectedCounterSlice.selectors.selectValue({ counter: { value: 2 } }), // 2
aCounterSlice.selectors.selectValue({ aCounter: { value: 2 } }) // 2
aCounterSlice.selectors.selectValue({ aCounter: { value: 2 } }), // 2
)
```
2 changes: 1 addition & 1 deletion docs/api/createAction.mdx
Expand Up @@ -148,6 +148,6 @@ export const epic = (actions$: Observable<Action>) =>
map((action) => {
// action.payload can be safely used as number here (and will also be correctly inferred by TypeScript)
// ...
})
}),
)
```
24 changes: 12 additions & 12 deletions docs/api/createAsyncThunk.mdx
Expand Up @@ -35,7 +35,7 @@ const fetchUserById = createAsyncThunk(
async (userId: number, thunkAPI) => {
const response = await userAPI.fetchById(userId)
return response.data
}
},
)

interface UsersState {
Expand Down Expand Up @@ -190,23 +190,23 @@ interface RejectedWithValueAction<ThunkArg, RejectedValue> {

type Pending = <ThunkArg>(
requestId: string,
arg: ThunkArg
arg: ThunkArg,
) => PendingAction<ThunkArg>

type Fulfilled = <ThunkArg, PromiseResult>(
payload: PromiseResult,
requestId: string,
arg: ThunkArg
arg: ThunkArg,
) => FulfilledAction<ThunkArg, PromiseResult>

type Rejected = <ThunkArg>(
requestId: string,
arg: ThunkArg
arg: ThunkArg,
) => RejectedAction<ThunkArg>

type RejectedWithValue = <ThunkArg, RejectedValue>(
requestId: string,
arg: ThunkArg
arg: ThunkArg,
) => RejectedWithValueAction<ThunkArg, RejectedValue>
```
Expand Down Expand Up @@ -365,7 +365,7 @@ const updateUser = createAsyncThunk(
// by explicitly returning it using the `rejectWithValue()` utility
return rejectWithValue(err.response.data)
}
}
},
)
```

Expand All @@ -391,7 +391,7 @@ const fetchUserById = createAsyncThunk(
return false
}
},
}
},
)
```

Expand Down Expand Up @@ -419,7 +419,7 @@ export const fetchUserById = createAsyncThunk(
'fetchUserById',
(userId: string) => {
/* ... */
}
},
)

// file: MyComponent.ts
Expand Down Expand Up @@ -456,7 +456,7 @@ const fetchUserById = createAsyncThunk(
signal: thunkAPI.signal,
})
return await response.json()
}
},
)
```

Expand Down Expand Up @@ -486,7 +486,7 @@ const readStream = createAsyncThunk(
done = read.done
}
return result
}
},
)
```

Expand All @@ -510,7 +510,7 @@ const fetchUserById = createAsyncThunk(
cancelToken: source.token,
})
return response.data
}
},
)
```

Expand Down Expand Up @@ -749,7 +749,7 @@ const UsersComponent = (props: { id: string }) => {
// This is an example of an onSubmit handler using Formik meant to demonstrate accessing the payload of the rejected action
const handleUpdateUser = async (
values: FormValues,
formikHelpers: FormikHelpers<FormValues>
formikHelpers: FormikHelpers<FormValues>,
) => {
const resultAction = await dispatch(updateUser({ id: props.id, ...values }))
if (updateUser.fulfilled.match(resultAction)) {
Expand Down
10 changes: 5 additions & 5 deletions docs/api/createDynamicMiddleware.mdx
Expand Up @@ -80,7 +80,7 @@ The "dynamic middleware instance" returned from `createDynamicMiddleware` is an
```ts no-transpile
export type DynamicMiddlewareInstance<
State = unknown,
Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>
Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>,
> = {
middleware: DynamicMiddleware<State, Dispatch>
addMiddleware: AddMiddleware<State, Dispatch>
Expand Down Expand Up @@ -116,7 +116,7 @@ Accepts a set of middleware, and creates an action. When dispatched, it injects
```ts no-transpile
const listenerDispatch = store.dispatch(
withMiddleware(listenerMiddleware.middleware)
withMiddleware(listenerMiddleware.middleware),
)

const unsubscribe = listenerDispatch(addListener({ type, effect }))
Expand All @@ -131,7 +131,7 @@ _These depend on having `react-redux` installed._
```ts no-transpile
interface ReactDynamicMiddlewareInstance<
State = any,
Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>
Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>,
> extends DynamicMiddlewareInstance<State, Dispatch> {
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<
State,
Expand All @@ -140,7 +140,7 @@ interface ReactDynamicMiddlewareInstance<
createDispatchWithMiddlewareHookFactory: (
context?: Context<
ReactReduxContextValue<State, ActionFromDispatch<Dispatch>>
>
>,
) => CreateDispatchWithMiddlewareHook<State, Dispatch>
}
```
Expand All @@ -151,7 +151,7 @@ Accepts a set of middleware, and returns a [`useDispatch`](https://react-redux.j

```ts no-transpile
const useListenerDispatch = createDispatchWithMiddlewareHook(
listenerInstance.middleware
listenerInstance.middleware,
)

const Component = () => {
Expand Down
17 changes: 9 additions & 8 deletions docs/api/createEntityAdapter.mdx
Expand Up @@ -82,7 +82,7 @@ console.log(store.getState().books)

// Can create a set of memoized selectors based on the location of this entity state
const booksSelectors = booksAdapter.getSelectors<RootState>(
(state) => state.books
(state) => state.books,
)

// And then use the selectors to retrieve values
Expand Down Expand Up @@ -148,21 +148,21 @@ export interface EntityStateAdapter<T> {
removeMany<S extends EntityState<T>>(state: S, keys: EntityId[]): S
removeMany<S extends EntityState<T>>(
state: S,
keys: PayloadAction<EntityId[]>
keys: PayloadAction<EntityId[]>,
): S

removeAll<S extends EntityState<T>>(state: S): S

updateOne<S extends EntityState<T>>(state: S, update: Update<T>): S
updateOne<S extends EntityState<T>>(
state: S,
update: PayloadAction<Update<T>>
update: PayloadAction<Update<T>>,
): S

updateMany<S extends EntityState<T>>(state: S, updates: Update<T>[]): S
updateMany<S extends EntityState<T>>(
state: S,
updates: PayloadAction<Update<T>[]>
updates: PayloadAction<Update<T>[]>,
): S

upsertOne<S extends EntityState<T>>(state: S, entity: T): S
Expand All @@ -171,7 +171,7 @@ export interface EntityStateAdapter<T> {
upsertMany<S extends EntityState<T>>(state: S, entities: T[]): S
upsertMany<S extends EntityState<T>>(
state: S,
entities: PayloadAction<T[]>
entities: PayloadAction<T[]>,
): S
}

Expand All @@ -190,7 +190,7 @@ export interface EntityAdapter<T> extends EntityStateAdapter<T> {
getInitialState<S extends object>(state: S): EntityState<T> & S
getSelectors(): EntitySelectors<T, EntityState<T>>
getSelectors<V>(
selectState: (state: V) => EntityState<T>
selectState: (state: V) => EntityState<T>,
): EntitySelectors<T, V>
}
```
Expand Down Expand Up @@ -225,7 +225,8 @@ All three options will insert _new_ entities into the list. However they differ
Each method has a signature that looks like:

```ts no-transpile
(state: EntityState<T>, argument: TypeOrPayloadAction<Argument<T>>) => EntityState<T>
;(state: EntityState<T>, argument: TypeOrPayloadAction<Argument<T>>) =>
EntityState<T>
```

In other words, they accept a state that looks like `{ids: [], entities: {}}`, and calculate and return a new state.
Expand Down Expand Up @@ -407,7 +408,7 @@ store.dispatch(
booksReceived([
{ id: 'b', title: 'Book 3' },
{ id: 'c', title: 'Book 2' },
])
]),
)

console.log(booksSelectors.selectIds(store.getState()))
Expand Down

0 comments on commit d36a3a1

Please sign in to comment.