Skip to content

chore: add @typescript-eslint/require-await for notice error and remove unnecessary async #9011

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

Closed
Closed
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
10 changes: 9 additions & 1 deletion packages/query-core/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@

import rootConfig from './root.eslint.config.js'

export default [...rootConfig]
export default [
...rootConfig,
{
files: ['**/__tests__/**'],
rules: {
'@typescript-eslint/require-await': 'error',
},
},
]
2 changes: 1 addition & 1 deletion packages/query-core/src/__tests__/hydration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('dehydration and rehydration', () => {
test('should not dehydrate queries if dehydrateQueries is set to false', async () => {
const queryCache = new QueryCache()
const queryClient = createQueryClient({ queryCache })
vi.waitFor(() =>
await vi.waitFor(() =>
queryClient.prefetchQuery({
queryKey: ['string'],
queryFn: () => fetchData('string'),
Expand Down
8 changes: 7 additions & 1 deletion packages/query-devtools/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

import rootConfig from './root.eslint.config.js'

export default [...rootConfig]
export default [
...rootConfig,
{
files: ['**/__tests__/**'],
rules: { '@typescript-eslint/require-await': 'error' },
},
]
16 changes: 8 additions & 8 deletions packages/query-devtools/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { deleteNestedDataByPath, updateNestedDataByPath } from '../utils'
describe('Utils tests', () => {
describe('updatedNestedDataByPath', () => {
describe('array', () => {
it('should update data correctly', async () => {
it('should update data correctly', () => {
const oldData = ['one', 'two', 'three']

const newData = updateNestedDataByPath(oldData, ['1'], 'new')
Expand All @@ -29,7 +29,7 @@ describe('Utils tests', () => {
})

describe('object', () => {
it('should update data correctly', async () => {
it('should update data correctly', () => {
const oldData = { title: 'Hello world', id: 1, createdAt: '2021-01-01' }

const newData = updateNestedDataByPath(
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('Utils tests', () => {
})

describe('set', () => {
it('should update data correctly', async () => {
it('should update data correctly', () => {
const oldData = new Set([123, 321, 'hello', 'world'])

const newData = updateNestedDataByPath(oldData, ['2'], 'hi')
Expand All @@ -85,7 +85,7 @@ describe('Utils tests', () => {
})

describe('map', () => {
it('should update data correctly', async () => {
it('should update data correctly', () => {
const oldData = new Map([
['en', 'hello'],
['fr', 'bonjour'],
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Utils tests', () => {
})

describe('nested data', () => {
it('should update data correctly', async () => {
it('should update data correctly', () => {
/* eslint-disable cspell/spellchecker */
const oldData = new Map([
[
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('Utils tests', () => {
})

describe('deleteNestedDataByPath', () => {
it('should delete item from array correctly', async () => {
it('should delete item from array correctly', () => {
const oldData = ['one', 'two', 'three']

const newData = deleteNestedDataByPath(oldData, ['1'])
Expand All @@ -399,7 +399,7 @@ describe('Utils tests', () => {
`)
})

it('should delete item from object correctly', async () => {
it('should delete item from object correctly', () => {
const oldData = { title: 'Hello world', id: 1, createdAt: '2021-01-01' }

const newData = deleteNestedDataByPath(oldData, ['createdAt'])
Expand Down Expand Up @@ -472,7 +472,7 @@ describe('Utils tests', () => {
})

describe('nested data', () => {
it('should delete nested items correctly', async () => {
it('should delete nested items correctly', () => {
/* eslint-disable cspell/spellchecker */
const oldData = new Map([
[
Expand Down
8 changes: 7 additions & 1 deletion packages/query-persist-client-core/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

import rootConfig from './root.eslint.config.js'

export default [...rootConfig]
export default [
...rootConfig,
{
files: ['**/__tests__/**'],
rules: { '@typescript-eslint/require-await': 'error' },
},
]
2 changes: 1 addition & 1 deletion packages/query-persist-client-core/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function createMockPersister(): Persister {
let storedState: PersistedClient | undefined

return {
async persistClient(persistClient: PersistedClient) {
persistClient(persistClient: PersistedClient) {
storedState = persistClient
},
async restoreClient() {
Expand Down
8 changes: 7 additions & 1 deletion packages/query-sync-storage-persister/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

import rootConfig from './root.eslint.config.js'

export default [...rootConfig]
export default [
...rootConfig,
{
files: ['**/__tests__/**'],
rules: { '@typescript-eslint/require-await': 'error' },
},
]
6 changes: 6 additions & 0 deletions packages/react-query-devtools/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ export default [
'react-hooks/rules-of-hooks': 'error',
},
},
{
files: ['**/__tests__/**'],
rules: {
'@typescript-eslint/require-await': 'error',
},
},
]
6 changes: 6 additions & 0 deletions packages/react-query-persist-client/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ export default [
'react-hooks/rules-of-hooks': 'error',
},
},
{
files: ['**/__tests__/**'],
rules: {
'@typescript-eslint/require-await': 'error',
},
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const createMockPersister = (): Persister => {
let storedState: PersistedClient | undefined

return {
async persistClient(persistClient: PersistedClient) {
persistClient(persistClient: PersistedClient) {
storedState = persistClient
},
async restoreClient() {
Expand Down Expand Up @@ -706,7 +706,7 @@ describe('PersistQueryClientProvider', () => {
let storedState: PersistedClient | undefined

return {
async persistClient(persistClient) {
persistClient(persistClient) {
storedState = persistClient
},
async restoreClient() {
Expand Down
Loading