Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9b6b9de
Add `configs` to `workspaces`
aryaemami59 Aug 27, 2024
7781664
use foreach so publish doesn't fail if package doesn't have tests, an…
EskiMojo14 Feb 8, 2024
b6e81dc
Build `config` packages on `postinstall`
aryaemami59 Aug 27, 2024
260f923
Initialize all the `config` packages
aryaemami59 Aug 27, 2024
a7586d3
Use the shareable Prettier config
aryaemami59 Aug 27, 2024
3f14e4a
Use the shareable ESLint config
aryaemami59 Aug 27, 2024
cc7230b
Use shareable `tsconfig.json` files
aryaemami59 Aug 28, 2024
0d71b78
Use the shareable Vitest config
aryaemami59 Aug 28, 2024
dca79bc
Run `yarn format` to format all files
aryaemami59 Sep 3, 2024
6ce8871
Add `AnyNonNullishValue` helper type
aryaemami59 Sep 3, 2024
275c2e0
Add `AnyFunction` helper type
aryaemami59 Sep 3, 2024
5b9b778
Add `EmptyObject` helper type
aryaemami59 Sep 3, 2024
718d0d2
Add `AnyObject` helper type
aryaemami59 Sep 3, 2024
e70c337
Add `isObject` and `hasBodyAndHeaders` utility functions
aryaemami59 Sep 3, 2024
a69e82c
Change all `let` variables to `const` to comply with `prefer-const` rule
aryaemami59 Sep 3, 2024
dc41266
Make `hasBodyAndHeaders` assertion looser
aryaemami59 Sep 3, 2024
88d1f17
Use `hasBodyAndHeaders` to fix TS issues in `fetchBaseQuery.test.tsx`
aryaemami59 Sep 3, 2024
0170457
Fix lint issues related to the `no-prototype-builtins` rule
aryaemami59 Sep 3, 2024
137f315
Fix `no-unsafe-optional-chaining` related problems
aryaemami59 Feb 3, 2024
2f78ece
Fix `@typescript-eslint/prefer-as-const` related problems
aryaemami59 Sep 3, 2024
affc5e8
Fix `no-extra-boolean-cast` related problems
aryaemami59 Sep 3, 2024
a596a5a
Fix `no-constant-condition` related problems
aryaemami59 Feb 3, 2024
b79b9e5
Fix `no-empty` related problems
aryaemami59 Feb 3, 2024
24c50e3
Replace all `Function` references with `AnyFunction`
aryaemami59 Feb 3, 2024
61086e8
Move custom matchers into `vitest.setup.ts`
aryaemami59 Feb 8, 2024
9127134
Fix `@typescript-eslint/no-unnecessary-type-constraint` related problems
aryaemami59 Sep 3, 2024
e6778e9
Disable `prefer-rest-params` inside `composeWithDevTools`
aryaemami59 Feb 8, 2024
d9d6b89
Fix `@typescript-eslint/no-var-requires` related problems
aryaemami59 Feb 3, 2024
f232712
Fix issues related to the `@typescript-eslint/prefer-function-type` rule
aryaemami59 Feb 3, 2024
618b4e2
Fix problems related to the `@typescript-eslint/no-empty-function` rule
aryaemami59 Feb 7, 2024
51521c0
Fix problems related to the `sort-imports` rule
aryaemami59 Sep 3, 2024
8704baa
Replace all `{}` types with `AnyNonNullishValue`
aryaemami59 Feb 3, 2024
9500a85
Remove unused ESLint disable directives
aryaemami59 Sep 4, 2024
a143442
Fix `@typescript-eslint/no-unused-expressions` related issues
aryaemami59 Jul 31, 2024
147cb81
Fix problems related to the `@typescript-eslint/array-type` rule
aryaemami59 Sep 4, 2024
48e889d
Fix `noImplicitReturns`-related issues in `src/tests/utils/helpers.tsx`
aryaemami59 Sep 4, 2024
a93bc7d
Fix issues related to `hasBodyAndHeaders` usage
aryaemami59 Sep 4, 2024
2d307b2
Lint files and check formatting during CI
aryaemami59 Sep 4, 2024
c7c2d3c
Fix TS issues related to `AnyNonNullishValue`
aryaemami59 Sep 5, 2024
d2f46c9
Fix TS issues related to `EmptyObject`
aryaemami59 Sep 5, 2024
2854438
Remove unused imports
aryaemami59 Sep 21, 2024
bc933f4
Resolve remaining lint errors
aryaemami59 Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run yarn format to format all files
  • Loading branch information
aryaemami59 committed Oct 22, 2025
commit dca79bcbc9a7690342b4165b0ce4f2a28ce0b056
2 changes: 1 addition & 1 deletion docs/api/createListenerMiddleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ To fix this, the middleware provides types for defining "pre-typed" versions of
import { createListenerMiddleware, addListener } from '@reduxjs/toolkit'
import type { RootState, AppDispatch } from './store'

declare type ExtraArgument = {foo: string};
declare type ExtraArgument = { foo: string }

export const listenerMiddleware = createListenerMiddleware()

Expand Down
6 changes: 0 additions & 6 deletions docs/rtk-query/api/created-api/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ selectFromResult: () => ({})
:::

- **Parameters**

- `options`: A set of options that control the subscription behavior of the hook:
- `selectFromResult`: A callback that can be used to customize the mutation result returned as the second item in the tuple
- `fixedCacheKey`: An optional string used to enable shared results across hook instances
Expand Down Expand Up @@ -622,7 +621,6 @@ type UseLazyQueryLastPromiseInfo = {
```

- **Parameters**

- `options`: A set of options that control the fetching behavior and returned result value of the hook. Options affecting fetching behavior will only have an effect after the lazy query has been triggered at least once.

- **Returns**: A tuple containing:
Expand Down Expand Up @@ -666,7 +664,6 @@ type PrefetchCallback = (arg: any, options?: UsePrefetchOptions) => void
```

- **Parameters**

- `endpointName`: The name of the endpoint to prefetch data for
- `options`: A set of options that control whether the prefetch request should occur

Expand Down Expand Up @@ -734,7 +731,6 @@ type UseQueryStateResult<T> = {
```

- **Parameters**

- `arg`: The argument passed to the query defined in the endpoint.
You can also pass in `skipToken` here as an alternative way of skipping the selection, see [skipToken](#skiptoken)
- `options`: A set of options that control the return value for the hook
Expand Down Expand Up @@ -773,7 +769,6 @@ type UseQuerySubscriptionResult = {
```

- **Parameters**

- `arg`: The argument passed to the query defined in the endpoint.
You can also pass in `skipToken` here as an alternative way of skipping the query, see [skipToken](#skiptoken)
- `options`: A set of options that control the fetching behavior of the hook
Expand Down Expand Up @@ -829,7 +824,6 @@ type UseLazyQuerySubscriptionTrigger = (
```

- **Parameters**

- `options`: A set of options that control the fetching behavior of the hook. The options will only have an effect after the lazy query has been triggered at least once.

- **Returns**: A tuple containing:
Expand Down
4 changes: 2 additions & 2 deletions docs/rtk-query/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ This comparison table strives to be as accurate and as unbiased as possible. If
| **API Definition** | declarative | on use, declarative | GraphQL schema | GraphQL schema |
| **Cache by** | endpoint + serialized arguments | user-defined query-key | type/id | type/id? |
| **Invalidation Strategy + Refetching** | declarative, by type and/or type/id | manual by cache key | automatic cache updates on per-entity level, manual query invalidation by cache key | declarative, by type OR automatic cache updates on per-entity level, manual query invalidation by cache key |
| **Polling** | yes | yes | yes | yes |
| **Parallel queries** | yes | yes | yes | yes |
| **Polling** | yes | yes | yes | yes |
| **Parallel queries** | yes | yes | yes | yes |
| **Dependent queries** | yes | yes | yes | yes |
| **Skip queries** | yes | yes | yes | yes |
| **Lagged queries** | yes | yes | no | ? |
Expand Down
4 changes: 3 additions & 1 deletion docs/rtk-query/usage/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ function PostsList() {

return (
<ul>
{posts?.data?.map((post) => <PostById key={post.id} id={post.id} />)}
{posts?.data?.map((post) => (
<PostById key={post.id} id={post.id} />
))}
</ul>
)
}
Expand Down
2 changes: 1 addition & 1 deletion errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"41": "getPreviousPageParam for endpoint '' must be a function if maxPages is used",
"42": "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.",
"43": "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`"
}
}
10 changes: 5 additions & 5 deletions examples/action-listener/counter/src/index.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family:
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

h1 {
Expand Down
10 changes: 5 additions & 5 deletions examples/publish-ci/cra4/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family:
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
10 changes: 5 additions & 5 deletions examples/publish-ci/cra5/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family:
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
10 changes: 5 additions & 5 deletions examples/publish-ci/vite/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family:
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
90 changes: 45 additions & 45 deletions examples/query/react/infinite-queries/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,105 +1,105 @@
import { screen, waitFor } from "@testing-library/react"
import App from "./App"
import { renderWithProviders } from "./utils/test-utils"
import { screen, waitFor } from '@testing-library/react'
import App from './App'
import { renderWithProviders } from './utils/test-utils'

test("App should have correct initial render", () => {
test('App should have correct initial render', () => {
renderWithProviders(<App />)

// The app should be rendered correctly
expect(screen.getByText(/learn/i)).toBeInTheDocument()

// Initial state: count should be 0, incrementValue should be 2
expect(screen.getByLabelText("Count")).toHaveTextContent("0")
expect(screen.getByLabelText("Set increment amount")).toHaveValue(2)
expect(screen.getByLabelText('Count')).toHaveTextContent('0')
expect(screen.getByLabelText('Set increment amount')).toHaveValue(2)
})

test("Increment value and Decrement value should work as expected", async () => {
test('Increment value and Decrement value should work as expected', async () => {
const { user } = renderWithProviders(<App />)

// Click on "+" => Count should be 1
await user.click(screen.getByLabelText("Increment value"))
expect(screen.getByLabelText("Count")).toHaveTextContent("1")
await user.click(screen.getByLabelText('Increment value'))
expect(screen.getByLabelText('Count')).toHaveTextContent('1')

// Click on "-" => Count should be 0
await user.click(screen.getByLabelText("Decrement value"))
expect(screen.getByLabelText("Count")).toHaveTextContent("0")
await user.click(screen.getByLabelText('Decrement value'))
expect(screen.getByLabelText('Count')).toHaveTextContent('0')
})

test("Add Amount should work as expected", async () => {
test('Add Amount should work as expected', async () => {
const { user } = renderWithProviders(<App />)

// "Add Amount" button is clicked => Count should be 2
await user.click(screen.getByText("Add Amount"))
expect(screen.getByLabelText("Count")).toHaveTextContent("2")
await user.click(screen.getByText('Add Amount'))
expect(screen.getByLabelText('Count')).toHaveTextContent('2')

const incrementValueInput = screen.getByLabelText("Set increment amount")
const incrementValueInput = screen.getByLabelText('Set increment amount')
// incrementValue is 2, click on "Add Amount" => Count should be 4
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "2")
await user.click(screen.getByText("Add Amount"))
expect(screen.getByLabelText("Count")).toHaveTextContent("4")
await user.type(incrementValueInput, '2')
await user.click(screen.getByText('Add Amount'))
expect(screen.getByLabelText('Count')).toHaveTextContent('4')

// [Negative number] incrementValue is -1, click on "Add Amount" => Count should be 3
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "-1")
await user.click(screen.getByText("Add Amount"))
expect(screen.getByLabelText("Count")).toHaveTextContent("3")
await user.type(incrementValueInput, '-1')
await user.click(screen.getByText('Add Amount'))
expect(screen.getByLabelText('Count')).toHaveTextContent('3')
})

it("Add Async should work as expected", async () => {
it('Add Async should work as expected', async () => {
const { user } = renderWithProviders(<App />)

// "Add Async" button is clicked => Count should be 2
await user.click(screen.getByText("Add Async"))
await user.click(screen.getByText('Add Async'))

await waitFor(() =>
expect(screen.getByLabelText("Count")).toHaveTextContent("2"),
expect(screen.getByLabelText('Count')).toHaveTextContent('2'),
)

const incrementValueInput = screen.getByLabelText("Set increment amount")
const incrementValueInput = screen.getByLabelText('Set increment amount')
// incrementValue is 2, click on "Add Async" => Count should be 4
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "2")
await user.type(incrementValueInput, '2')

await user.click(screen.getByText("Add Async"))
await user.click(screen.getByText('Add Async'))
await waitFor(() =>
expect(screen.getByLabelText("Count")).toHaveTextContent("4"),
expect(screen.getByLabelText('Count')).toHaveTextContent('4'),
)

// [Negative number] incrementValue is -1, click on "Add Async" => Count should be 3
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "-1")
await user.click(screen.getByText("Add Async"))
await user.type(incrementValueInput, '-1')
await user.click(screen.getByText('Add Async'))
await waitFor(() =>
expect(screen.getByLabelText("Count")).toHaveTextContent("3"),
expect(screen.getByLabelText('Count')).toHaveTextContent('3'),
)
})

test("Add If Odd should work as expected", async () => {
test('Add If Odd should work as expected', async () => {
const { user } = renderWithProviders(<App />)

// "Add If Odd" button is clicked => Count should stay 0
await user.click(screen.getByText("Add If Odd"))
expect(screen.getByLabelText("Count")).toHaveTextContent("0")
await user.click(screen.getByText('Add If Odd'))
expect(screen.getByLabelText('Count')).toHaveTextContent('0')

// Click on "+" => Count should be updated to 1
await user.click(screen.getByLabelText("Increment value"))
expect(screen.getByLabelText("Count")).toHaveTextContent("1")
await user.click(screen.getByLabelText('Increment value'))
expect(screen.getByLabelText('Count')).toHaveTextContent('1')

// "Add If Odd" button is clicked => Count should be updated to 3
await user.click(screen.getByText("Add If Odd"))
expect(screen.getByLabelText("Count")).toHaveTextContent("3")
await user.click(screen.getByText('Add If Odd'))
expect(screen.getByLabelText('Count')).toHaveTextContent('3')

const incrementValueInput = screen.getByLabelText("Set increment amount")
const incrementValueInput = screen.getByLabelText('Set increment amount')
// incrementValue is 1, click on "Add If Odd" => Count should be updated to 4
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "1")
await user.click(screen.getByText("Add If Odd"))
expect(screen.getByLabelText("Count")).toHaveTextContent("4")
await user.type(incrementValueInput, '1')
await user.click(screen.getByText('Add If Odd'))
expect(screen.getByLabelText('Count')).toHaveTextContent('4')

// click on "Add If Odd" => Count should stay 4
await user.clear(incrementValueInput)
await user.type(incrementValueInput, "-1")
await user.click(screen.getByText("Add If Odd"))
expect(screen.getByLabelText("Count")).toHaveTextContent("4")
await user.type(incrementValueInput, '-1')
await user.click(screen.getByText('Add If Odd'))
expect(screen.getByLabelText('Count')).toHaveTextContent('4')
})
20 changes: 10 additions & 10 deletions examples/query/react/infinite-queries/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { BrowserRouter, Link, Route, Routes, useLocation } from "react-router"
import "./App.css"
import { BrowserRouter, Link, Route, Routes, useLocation } from 'react-router'
import './App.css'

import { Outlet } from "react-router"
import BidirectionalCursorInfScroll from "./features/bidirectional-cursor-infinite-scroll/BidirectionalCursorInfScroll"
import { Outlet } from 'react-router'
import BidirectionalCursorInfScroll from './features/bidirectional-cursor-infinite-scroll/BidirectionalCursorInfScroll'
import {
InfiniteScrollAbout,
InfiniteScrollExample,
} from "./features/infinite-scroll/InfiniteScrollExample"
import LimitOffsetExample from "./features/limit-offset/LimitOffsetExample"
import { InfiniteScrollMaxPagesExample } from "./features/max-pages/InfiniteScrollMaxExample"
import PaginationInfScrollExample from "./features/pagination-infinite-scroll/PaginationInfScrollExample"
import { PaginationExample } from "./features/pagination/PaginationExample"
import { FlatlistExample } from "./features/rn-flatlist/FlatlistExample"
} from './features/infinite-scroll/InfiniteScrollExample'
import LimitOffsetExample from './features/limit-offset/LimitOffsetExample'
import { InfiniteScrollMaxPagesExample } from './features/max-pages/InfiniteScrollMaxExample'
import PaginationInfScrollExample from './features/pagination-infinite-scroll/PaginationInfScrollExample'
import { PaginationExample } from './features/pagination/PaginationExample'
import { FlatlistExample } from './features/rn-flatlist/FlatlistExample'

const Menu = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { asyncThunkCreator, buildCreateSlice } from "@reduxjs/toolkit"
import { asyncThunkCreator, buildCreateSlice } from '@reduxjs/toolkit'

// `buildCreateSlice` allows us to create a slice with async thunks.
export const createAppSlice = buildCreateSlice({
Expand Down
4 changes: 2 additions & 2 deletions examples/query/react/infinite-queries/src/app/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// We disable the ESLint rule here because this is the designated place
// for importing and re-exporting the typed versions of hooks.
/* eslint-disable @typescript-eslint/no-restricted-imports */
import { useDispatch, useSelector } from "react-redux"
import type { AppDispatch, RootState } from "./store"
import { useDispatch, useSelector } from 'react-redux'
import type { AppDispatch, RootState } from './store'

// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
Expand Down
12 changes: 6 additions & 6 deletions examples/query/react/infinite-queries/src/app/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Action, ThunkAction } from "@reduxjs/toolkit"
import { combineSlices, configureStore } from "@reduxjs/toolkit"
import { setupListeners } from "@reduxjs/toolkit/query"
import { baseApi } from "../features/baseApi"
import type { Action, ThunkAction } from '@reduxjs/toolkit'
import { combineSlices, configureStore } from '@reduxjs/toolkit'
import { setupListeners } from '@reduxjs/toolkit/query'
import { baseApi } from '../features/baseApi'

// `combineSlices` automatically combines the reducers using
// their `reducerPath`s, therefore we no longer need to call `combineReducers`.
Expand All @@ -16,7 +16,7 @@ export const makeStore = (preloadedState?: Partial<RootState>) => {
reducer: rootReducer,
// Adding the api middleware enables caching, invalidation, polling,
// and other useful features of `rtk-query`.
middleware: getDefaultMiddleware => {
middleware: (getDefaultMiddleware) => {
return getDefaultMiddleware().concat(baseApi.middleware)
},
preloadedState,
Expand All @@ -32,7 +32,7 @@ export const store = makeStore()
// Infer the type of `store`
export type AppStore = typeof store
// Infer the `AppDispatch` type from the store itself
export type AppDispatch = AppStore["dispatch"]
export type AppDispatch = AppStore['dispatch']
export type AppThunk<ThunkReturnType = void> = ThunkAction<
ThunkReturnType,
RootState,
Expand Down
Loading