Skip to content

chore: add typescript-eslint/require-await rule #9116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default [
],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/require-await': 'error',
'no-case-declarations': 'off',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('injectInfiniteQuery', () => {
vi.useRealTimers()
})

test('should narrow type after isSuccess', async () => {
test('should narrow type after isSuccess', () => {
const query = TestBed.runInInjectionContext(() => {
return injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe('broadcastQueryClient', () => {
queryCache = queryClient.getQueryCache()
})

it('should subscribe to the query cache', async () => {
it('should subscribe to the query cache', () => {
broadcastQueryClient({
queryClient,
broadcastChannel: 'test_channel',
})
expect(queryCache.hasListeners()).toBe(true)
})

it('should not have any listeners after cleanup', async () => {
it('should not have any listeners after cleanup', () => {
const unsubscribe = broadcastQueryClient({
queryClient,
broadcastChannel: 'test_channel',
Expand Down
2 changes: 1 addition & 1 deletion packages/query-codemods/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check

import vitest from '@vitest/eslint-plugin'
import rootConfig from './root.eslint.config.js'

export default [
Expand All @@ -9,6 +8,7 @@ export default [
rules: {
'cspell/spellchecker': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/require-await': 'off',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minseong0324 I'm going to treat it like this now.

We can apply @typescript-eslint/require-await rule as error to the rest by turning off the this rule only for @tanstack/query-codemods

'import/no-duplicates': 'off',
'import/no-unresolved': 'off',
'import/order': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/__tests__/queryObserver.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('queryObserver', () => {
vi.useRealTimers()
})

test('should trigger a fetch when subscribed', async () => {
test('should trigger a fetch when subscribed', () => {
const key = queryKey()
const queryFn = vi
.fn<(...args: Array<unknown>) => string>()
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/__tests__/useQuery.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('useQuery', () => {
)
expectTypeOf(testFuncStyle.data).toEqualTypeOf<boolean | undefined>()

it('should return the correct states for a successful query', async () => {
it('should return the correct states for a successful query', () => {
const state = useQuery<string, Error>({
queryKey: key,
queryFn: () => Promise.resolve('test'),
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ describe('useQuery', () => {
expect(states[1]).toMatchObject({ data: 'test' })
})

it('should not fetch when refetchOnMount is false and data has been fetched already', async () => {
it('should not fetch when refetchOnMount is false and data has been fetched already', () => {
const key = queryKey()
const states: Array<UseQueryResult<string>> = []

Expand Down Expand Up @@ -1106,7 +1106,7 @@ describe('useQuery', () => {
})
})

it('should not refetch disabled query when invalidated with invalidateQueries', async () => {
it('should not refetch disabled query when invalidated with invalidateQueries', () => {
const key = queryKey()
const states: Array<UseQueryResult<number>> = []
let count = 0
Expand Down
Loading