From febbde676d0888d8dd4868177868a3316686cb58 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Fri, 28 Jun 2024 11:17:57 +1000 Subject: [PATCH] chore: Update ESLint config (#7637) * chore: Update ESLint config * Fix errors * Fix knip --- eslint.config.js | 22 +++++++++++-------- package.json | 3 +-- .../src/angular-query-devtools.component.ts | 10 ++++----- .../src/infinite-query-options.ts | 9 +++++--- .../assert-injector/assert-injector.test.ts | 2 +- .../util/assert-injector/assert-injector.ts | 2 +- .../create-injection-token.test.ts | 2 +- .../create-injection-token.ts | 4 ++-- packages/query-codemods/eslint.config.js | 6 ++--- .../v4/__tests__/key-transformation.test.cjs | 1 - .../replace-import-specifier.test.cjs | 1 - .../src/v4/key-transformation.cjs | 5 ----- .../is-loading/__tests__/is-loading.test.cjs | 1 - .../src/v5/is-loading/is-loading.cjs | 3 --- .../__tests__/keep-previous-data.test.cjs | 1 - .../keep-previous-data/keep-previous-data.cjs | 4 ---- .../__tests__/remove-overloads.test.cjs | 1 - .../v5/remove-overloads/remove-overloads.cjs | 3 --- .../filter-aware-usage-transformer.cjs | 5 ----- .../query-fn-aware-usage-transformer.cjs | 3 --- .../src/v5/remove-overloads/utils/index.cjs | 1 - .../__tests__/rename-hydrate.test.cjs | 1 - .../__tests__/rename-properties.test.cjs | 1 - packages/query-core/src/focusManager.ts | 4 ++-- packages/query-core/src/hydration.ts | 4 ++-- packages/query-core/src/onlineManager.ts | 2 +- packages/query-core/src/queryClient.ts | 4 +++- .../src/__tests__/utils.test.ts | 6 ++--- .../src/createPersister.ts | 2 +- packages/react-query/eslint.config.js | 2 +- .../react-query/src/HydrationBoundary.tsx | 2 +- .../src/__tests__/HydrationBoundary.test.tsx | 3 +-- .../__tests__/QueryClientProvider.test.tsx | 4 +--- .../QueryResetErrorBoundary.test.tsx | 3 +-- .../react-query/src/infiniteQueryOptions.ts | 9 +++++--- packages/react-query/src/suspense.ts | 2 +- .../src/useSuspenseInfiniteQuery.ts | 6 ++--- .../__tests__/createInfiniteQuery.test.tsx | 2 +- .../src/__tests__/createQuery.test.tsx | 2 +- .../src/__tests__/suspense.test.tsx | 4 ++-- .../svelte-query-devtools/eslint.config.js | 10 --------- .../eslint.config.js | 10 --------- packages/svelte-query/eslint.config.js | 10 --------- packages/vue-query-devtools/eslint.config.js | 15 +------------ packages/vue-query/eslint.config.js | 15 +------------ .../vue-query/src/infiniteQueryOptions.ts | 9 +++++--- packages/vue-query/src/queryClient.ts | 2 +- pnpm-lock.yaml | 13 +++++------ 48 files changed, 77 insertions(+), 159 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 2359ffe8f1..92d3182183 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,18 +1,19 @@ // @ts-check -// @ts-ignore -import { rootConfig } from '@tanstack/config/eslint' -// @ts-ignore -import cspellConfigs from '@cspell/eslint-plugin/configs' +// @ts-ignore Needed due to moduleResolution Node vs Bundler +import { tanstackConfig } from '@tanstack/config/eslint' +import pluginCspell from '@cspell/eslint-plugin' export default [ - ...rootConfig, - cspellConfigs.recommended, + ...tanstackConfig, { name: 'tanstack/temp', + plugins: { + cspell: pluginCspell, + }, rules: { - '@cspell/spellchecker': [ - 'error', + 'cspell/spellchecker': [ + 'warn', { cspell: { words: [ @@ -34,8 +35,11 @@ export default [ }, }, ], - '@typescript-eslint/no-empty-function': 'off', + 'ts/ban-types': 'off', + 'ts/no-empty-function': 'off', + 'ts/require-await': 'off', 'no-case-declarations': 'off', + 'no-empty': 'off', 'no-prototype-builtins': 'off', }, }, diff --git a/package.json b/package.json index b80e048960..523a70301d 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@cspell/eslint-plugin": "^8.9.1", "@eslint-react/eslint-plugin": "^1.5.16", "@solidjs/testing-library": "^0.8.8", - "@tanstack/config": "^0.8.1", + "@tanstack/config": "^0.8.6", "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^15.0.7", "@types/node": "^20.12.12", @@ -72,7 +72,6 @@ "solid-js": "^1.8.17", "tsup": "^8.0.2", "typescript": "5.3.3", - "typescript-eslint": "^7.14.1", "typescript47": "npm:typescript@4.7", "typescript48": "npm:typescript@4.8", "typescript49": "npm:typescript@4.9", diff --git a/packages/angular-query-devtools-experimental/src/angular-query-devtools.component.ts b/packages/angular-query-devtools-experimental/src/angular-query-devtools.component.ts index 568b305427..b0ba8274a5 100644 --- a/packages/angular-query-devtools-experimental/src/angular-query-devtools.component.ts +++ b/packages/angular-query-devtools-experimental/src/angular-query-devtools.component.ts @@ -1,9 +1,5 @@ import { isPlatformBrowser } from '@angular/common' import * as queryDevtools from '@tanstack/query-devtools' -import { - injectQueryClient, - onlineManager, -} from '@tanstack/angular-query-experimental' import { ChangeDetectionStrategy, Component, @@ -14,7 +10,11 @@ import { booleanAttribute, inject, } from '@angular/core' -import { QueryClient } from '@tanstack/angular-query-experimental' +import { + QueryClient, + injectQueryClient, + onlineManager, +} from '@tanstack/angular-query-experimental' import type { AfterViewInit, OnChanges, diff --git a/packages/angular-query-experimental/src/infinite-query-options.ts b/packages/angular-query-experimental/src/infinite-query-options.ts index 66b2b12186..3508951398 100644 --- a/packages/angular-query-experimental/src/infinite-query-options.ts +++ b/packages/angular-query-experimental/src/infinite-query-options.ts @@ -1,7 +1,10 @@ -import type { DataTag } from '@tanstack/query-core' -import type { InfiniteData } from '@tanstack/query-core' +import type { + DataTag, + DefaultError, + InfiniteData, + QueryKey, +} from '@tanstack/query-core' import type { CreateInfiniteQueryOptions, NonUndefinedGuard } from './types' -import type { DefaultError, QueryKey } from '@tanstack/query-core' /** * @public diff --git a/packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts b/packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts index 70bb2bcf36..7d57c7cd6d 100644 --- a/packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts +++ b/packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @cspell/spellchecker */ +/* eslint-disable cspell/spellchecker */ /** * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app. * diff --git a/packages/angular-query-experimental/src/util/assert-injector/assert-injector.ts b/packages/angular-query-experimental/src/util/assert-injector/assert-injector.ts index 9896271f73..bfbcf8afc8 100644 --- a/packages/angular-query-experimental/src/util/assert-injector/assert-injector.ts +++ b/packages/angular-query-experimental/src/util/assert-injector/assert-injector.ts @@ -1,4 +1,4 @@ -/* eslint-disable @cspell/spellchecker */ +/* eslint-disable cspell/spellchecker */ /** * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app. * diff --git a/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts b/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts index be1a7f7dbe..5b5bb41b78 100644 --- a/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts +++ b/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @cspell/spellchecker */ +/* eslint-disable cspell/spellchecker */ /** * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app. * diff --git a/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.ts b/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.ts index 7bc1a0a11d..4e3fb0c5ed 100644 --- a/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.ts +++ b/packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.ts @@ -1,4 +1,4 @@ -/* eslint-disable @cspell/spellchecker */ +/* eslint-disable cspell/spellchecker */ /** * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app. * @@ -169,7 +169,7 @@ export function createNoopInjectionToken< type TReturn = TMulti extends true ? Array : TValue const token = - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition (options as CreateInjectionTokenOptions<() => void, []>)?.token || new InjectionToken(description) return [ diff --git a/packages/query-codemods/eslint.config.js b/packages/query-codemods/eslint.config.js index faca05d79a..1ed6ecd31e 100644 --- a/packages/query-codemods/eslint.config.js +++ b/packages/query-codemods/eslint.config.js @@ -6,9 +6,9 @@ export default [ ...rootConfig, { rules: { - '@cspell/spellchecker': 'off', - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/no-unnecessary-condition': 'off', + 'cspell/spellchecker': 'off', + 'ts/no-unnecessary-condition': 'off', + 'import/no-duplicates': 'off', 'import/no-unresolved': 'off', 'import/order': 'off', 'no-shadow': 'off', diff --git a/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs b/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs index 5d5cdafa68..96fcf878a4 100644 --- a/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs +++ b/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'key-transformation.cjs', null, 'default-import', { diff --git a/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs b/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs index 26b3418d68..60f29c2977 100644 --- a/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs +++ b/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest( diff --git a/packages/query-codemods/src/v4/key-transformation.cjs b/packages/query-codemods/src/v4/key-transformation.cjs index cdb20625c4..ad62c084a5 100644 --- a/packages/query-codemods/src/v4/key-transformation.cjs +++ b/packages/query-codemods/src/v4/key-transformation.cjs @@ -1,12 +1,7 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUtilsObject = require('../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createKeyReplacer = require('./utils/replacers/key-replacer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUseQueryLikeTransformer = require('../utils/transformers/use-query-like-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryClientTransformer = require('../utils/transformers/query-client-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryCacheTransformer = require('../utils/transformers/query-cache-transformer.cjs') const transformQueryClientUsages = ({ diff --git a/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs b/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs index b474bfa9a9..89aa803626 100644 --- a/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs +++ b/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'is-loading.cjs', null, 'default-import', { diff --git a/packages/query-codemods/src/v5/is-loading/is-loading.cjs b/packages/query-codemods/src/v5/is-loading/is-loading.cjs index acf7e3fa80..eb7f1b0110 100644 --- a/packages/query-codemods/src/v5/is-loading/is-loading.cjs +++ b/packages/query-codemods/src/v5/is-loading/is-loading.cjs @@ -1,8 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUtilsObject = require('../../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer.cjs') const originalName = 'isLoading' diff --git a/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs b/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs index 433a46752e..3aff3e0d0b 100644 --- a/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs +++ b/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'keep-previous-data.cjs', null, 'default', { diff --git a/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs b/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs index 7d438495ae..3f3e3b7df7 100644 --- a/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs +++ b/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs @@ -1,10 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUtilsObject = require('../../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const AlreadyHasPlaceholderDataProperty = require('./utils/already-has-placeholder-data-property.cjs') /** diff --git a/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs b/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs index bb83a14035..17abee9f87 100644 --- a/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs +++ b/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'remove-overloads.cjs', null, 'default-import', { diff --git a/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs b/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs index 9c3ce67166..9a7865ba5b 100644 --- a/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs +++ b/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs @@ -1,8 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUtilsObject = require('../../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const transformFilterAwareUsages = require('./transformers/filter-aware-usage-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const transformQueryFnAwareUsages = require('./transformers/query-fn-aware-usage-transformer.cjs') module.exports = (file, api) => { diff --git a/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs b/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs index f7056f94b1..33e098b777 100644 --- a/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs +++ b/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs @@ -1,12 +1,7 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createV5UtilsObject = require('../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const UnknownUsageError = require('../utils/unknown-usage-error.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryCacheTransformer = require('../../../utils/transformers/query-cache-transformer.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createUseQueryLikeTransformer = require('../../../utils/transformers/use-query-like-transformer.cjs') /** diff --git a/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs b/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs index d7fde1d4d7..3f29d41661 100644 --- a/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +++ b/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs @@ -1,8 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const createV5UtilsObject = require('../utils/index.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const UnknownUsageError = require('../utils/unknown-usage-error.cjs') -// eslint-disable-next-line @typescript-eslint/no-var-requires const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer.cjs') /** diff --git a/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs b/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs index 469964d1f4..5e81bf4469 100644 --- a/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs +++ b/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const UnknownUsageError = require('./unknown-usage-error.cjs') module.exports = ({ jscodeshift, utils }) => { diff --git a/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs b/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs index 53ed74a496..6feb77db58 100644 --- a/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs +++ b/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'rename-hydrate.cjs', null, 'default-import', { diff --git a/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs b/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs index 8a214e85df..75eef2dc0a 100644 --- a/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs +++ b/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest(__dirname, 'rename-properties.cjs', null, 'rename-cache-time', { diff --git a/packages/query-core/src/focusManager.ts b/packages/query-core/src/focusManager.ts index cb0d859871..71026d62c0 100644 --- a/packages/query-core/src/focusManager.ts +++ b/packages/query-core/src/focusManager.ts @@ -17,7 +17,7 @@ export class FocusManager extends Subscribable { super() this.#setup = (onFocus) => { // addEventListener does not exist in React Native, but window does - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition if (!isServer && window.addEventListener) { const listener = () => onFocus() // Listen to visibilitychange @@ -78,7 +78,7 @@ export class FocusManager extends Subscribable { } // document global can be unavailable in react native - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition return globalThis.document?.visibilityState !== 'hidden' } } diff --git a/packages/query-core/src/hydration.ts b/packages/query-core/src/hydration.ts index 64d0eb7a2c..74a62f7c7a 100644 --- a/packages/query-core/src/hydration.ts +++ b/packages/query-core/src/hydration.ts @@ -130,9 +130,9 @@ export function hydrate( const mutationCache = client.getMutationCache() const queryCache = client.getQueryCache() - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition const mutations = (dehydratedState as DehydratedState).mutations || [] - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition const queries = (dehydratedState as DehydratedState).queries || [] mutations.forEach(({ state, ...mutationOptions }) => { diff --git a/packages/query-core/src/onlineManager.ts b/packages/query-core/src/onlineManager.ts index daf77d5a4c..655f661b64 100644 --- a/packages/query-core/src/onlineManager.ts +++ b/packages/query-core/src/onlineManager.ts @@ -14,7 +14,7 @@ export class OnlineManager extends Subscribable { super() this.#setup = (onOnline) => { // addEventListener does not exist in React Native, but window does - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition if (!isServer && window.addEventListener) { const onlineListener = () => onOnline(true) const offlineListener = () => onOnline(false) diff --git a/packages/query-core/src/queryClient.ts b/packages/query-core/src/queryClient.ts index 1bc89fccba..49855e668b 100644 --- a/packages/query-core/src/queryClient.ts +++ b/packages/query-core/src/queryClient.ts @@ -13,10 +13,10 @@ import { focusManager } from './focusManager' import { onlineManager } from './onlineManager' import { notifyManager } from './notifyManager' import { infiniteQueryBehavior } from './infiniteQueryBehavior' -import type { DataTag, NoInfer, OmitKeyof } from './types' import type { QueryState } from './query' import type { CancelOptions, + DataTag, DefaultError, DefaultOptions, DefaultedQueryObserverOptions, @@ -29,6 +29,8 @@ import type { MutationKey, MutationObserverOptions, MutationOptions, + NoInfer, + OmitKeyof, QueryClientConfig, QueryKey, QueryObserverOptions, diff --git a/packages/query-devtools/src/__tests__/utils.test.ts b/packages/query-devtools/src/__tests__/utils.test.ts index a39454c42e..e57933cd2d 100644 --- a/packages/query-devtools/src/__tests__/utils.test.ts +++ b/packages/query-devtools/src/__tests__/utils.test.ts @@ -91,7 +91,7 @@ describe('Utils tests', () => { ['fr', 'bonjour'], ]) - /* eslint-disable @cspell/spellchecker */ + /* eslint-disable cspell/spellchecker */ const newData = updateNestedDataByPath(oldData, ['fr'], 'salut') expect(newData).not.toBe(oldData) // should not be the same reference @@ -114,7 +114,7 @@ describe('Utils tests', () => { describe('nested data', () => { it('should update data correctly', async () => { - /* eslint-disable @cspell/spellchecker */ + /* eslint-disable cspell/spellchecker */ const oldData = new Map([ [ 'pumpkin-pie', @@ -473,7 +473,7 @@ describe('Utils tests', () => { describe('nested data', () => { it('should delete nested items correctly', async () => { - /* eslint-disable @cspell/spellchecker */ + /* eslint-disable cspell/spellchecker */ const oldData = new Map([ [ 'pumpkin-pie', diff --git a/packages/query-persist-client-core/src/createPersister.ts b/packages/query-persist-client-core/src/createPersister.ts index 8aa239e6ac..288e03dc77 100644 --- a/packages/query-persist-client-core/src/createPersister.ts +++ b/packages/query-persist-client-core/src/createPersister.ts @@ -1,7 +1,7 @@ import { matchQuery } from '@tanstack/query-core' -import type { QueryFilters } from '@tanstack/query-core' import type { Query, + QueryFilters, QueryFunctionContext, QueryKey, QueryState, diff --git a/packages/react-query/eslint.config.js b/packages/react-query/eslint.config.js index a648870ebe..37039cd5f6 100644 --- a/packages/react-query/eslint.config.js +++ b/packages/react-query/eslint.config.js @@ -28,7 +28,7 @@ export default [ { files: ['**/__tests__/**'], rules: { - '@typescript-eslint/no-unnecessary-condition': 'off', + 'ts/no-unnecessary-condition': 'off', 'react-compiler/react-compiler': 'off', }, }, diff --git a/packages/react-query/src/HydrationBoundary.tsx b/packages/react-query/src/HydrationBoundary.tsx index 47f56f3587..9499479540 100644 --- a/packages/react-query/src/HydrationBoundary.tsx +++ b/packages/react-query/src/HydrationBoundary.tsx @@ -58,7 +58,7 @@ export const HydrationBoundary = ({ } const queryCache = client.getQueryCache() - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition const queries = (state as DehydratedState).queries || [] const newQueries: DehydratedState['queries'] = [] diff --git a/packages/react-query/src/__tests__/HydrationBoundary.test.tsx b/packages/react-query/src/__tests__/HydrationBoundary.test.tsx index 42abd2a2ae..66835d1ed3 100644 --- a/packages/react-query/src/__tests__/HydrationBoundary.test.tsx +++ b/packages/react-query/src/__tests__/HydrationBoundary.test.tsx @@ -1,9 +1,8 @@ -import { beforeAll, describe, expect, test } from 'vitest' +import { beforeAll, describe, expect, test, vi } from 'vitest' import * as React from 'react' import { render } from '@testing-library/react' import * as coreModule from '@tanstack/query-core' -import { vi } from 'vitest' import { HydrationBoundary, QueryCache, diff --git a/packages/react-query/src/__tests__/QueryClientProvider.test.tsx b/packages/react-query/src/__tests__/QueryClientProvider.test.tsx index be40266d36..1a04474f29 100644 --- a/packages/react-query/src/__tests__/QueryClientProvider.test.tsx +++ b/packages/react-query/src/__tests__/QueryClientProvider.test.tsx @@ -1,7 +1,5 @@ -import { describe, expect, test } from 'vitest' +import { describe, expect, test, vi } from 'vitest' import { render, waitFor } from '@testing-library/react' - -import { vi } from 'vitest' import { QueryCache, QueryClientProvider, useQuery, useQueryClient } from '..' import { createQueryClient, queryKey, sleep } from './utils' diff --git a/packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx b/packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx index d7721b7bde..4b3f6a6e74 100644 --- a/packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx +++ b/packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx @@ -1,9 +1,8 @@ -import { describe, expect, it } from 'vitest' +import { describe, expect, it, vi } from 'vitest' import { fireEvent, waitFor } from '@testing-library/react' import { ErrorBoundary } from 'react-error-boundary' import * as React from 'react' -import { vi } from 'vitest' import { QueryCache, QueryErrorResetBoundary, diff --git a/packages/react-query/src/infiniteQueryOptions.ts b/packages/react-query/src/infiniteQueryOptions.ts index 122bb1f858..a63def60e1 100644 --- a/packages/react-query/src/infiniteQueryOptions.ts +++ b/packages/react-query/src/infiniteQueryOptions.ts @@ -1,7 +1,10 @@ -import type { DataTag } from '@tanstack/query-core' -import type { InfiniteData } from '@tanstack/query-core' +import type { + DataTag, + DefaultError, + InfiniteData, + QueryKey, +} from '@tanstack/query-core' import type { UseInfiniteQueryOptions } from './types' -import type { DefaultError, QueryKey } from '@tanstack/query-core' export type UndefinedInitialDataInfiniteOptions< TQueryFnData, diff --git a/packages/react-query/src/suspense.ts b/packages/react-query/src/suspense.ts index e342665d71..533069ae6b 100644 --- a/packages/react-query/src/suspense.ts +++ b/packages/react-query/src/suspense.ts @@ -1,5 +1,5 @@ -import type { DefaultError } from '@tanstack/query-core' import type { + DefaultError, DefaultedQueryObserverOptions, Query, QueryKey, diff --git a/packages/react-query/src/useSuspenseInfiniteQuery.ts b/packages/react-query/src/useSuspenseInfiniteQuery.ts index 44dbe1cf03..d64ef0c694 100644 --- a/packages/react-query/src/useSuspenseInfiniteQuery.ts +++ b/packages/react-query/src/useSuspenseInfiniteQuery.ts @@ -2,15 +2,13 @@ import { InfiniteQueryObserver } from '@tanstack/query-core' import { useBaseQuery } from './useBaseQuery' import { defaultThrowOnError } from './suspense' -import type { - InfiniteQueryObserverSuccessResult, - QueryObserver, -} from '@tanstack/query-core' import type { DefaultError, InfiniteData, + InfiniteQueryObserverSuccessResult, QueryClient, QueryKey, + QueryObserver, } from '@tanstack/query-core' import type { UseSuspenseInfiniteQueryOptions, diff --git a/packages/solid-query/src/__tests__/createInfiniteQuery.test.tsx b/packages/solid-query/src/__tests__/createInfiniteQuery.test.tsx index e41253fb13..14708401c8 100644 --- a/packages/solid-query/src/__tests__/createInfiniteQuery.test.tsx +++ b/packages/solid-query/src/__tests__/createInfiniteQuery.test.tsx @@ -166,7 +166,7 @@ describe('useInfiniteQuery', () => { const start = 1 const state = createInfiniteQuery(() => ({ queryKey: key, - queryFn: async ({ pageParam }) => { + queryFn: ({ pageParam }) => { if (pageParam === 2) { throw new Error('error') } diff --git a/packages/solid-query/src/__tests__/createQuery.test.tsx b/packages/solid-query/src/__tests__/createQuery.test.tsx index 0e06b118bc..5ad263d7e4 100644 --- a/packages/solid-query/src/__tests__/createQuery.test.tsx +++ b/packages/solid-query/src/__tests__/createQuery.test.tsx @@ -4435,7 +4435,7 @@ describe('createQuery', () => { readonly [typeof key, number] > = async (ctx) => { const [, limit] = ctx.queryKey - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + // eslint-disable-next-line ts/no-unnecessary-condition const value = limit % 2 && ctx.signal ? 'abort' : `data ${limit}` await sleep(25) return value diff --git a/packages/solid-query/src/__tests__/suspense.test.tsx b/packages/solid-query/src/__tests__/suspense.test.tsx index ed282886d2..f3d8e55012 100644 --- a/packages/solid-query/src/__tests__/suspense.test.tsx +++ b/packages/solid-query/src/__tests__/suspense.test.tsx @@ -121,7 +121,7 @@ describe("useQuery's in Suspense mode", () => { await waitFor(() => rendered.getByText('data: 1')) - // eslint-disable-next-line @cspell/spellchecker + // eslint-disable-next-line cspell/spellchecker // TODO(lukemurray): in react this is 1 in solid this is 2 because suspense // occurs on read. expect(states.length).toBe(2) @@ -133,7 +133,7 @@ describe("useQuery's in Suspense mode", () => { fireEvent.click(rendered.getByText('next')) await waitFor(() => rendered.getByText('data: 2')) - // eslint-disable-next-line @cspell/spellchecker + // eslint-disable-next-line cspell/spellchecker // TODO(lukemurray): in react this is 2 and in solid it is 4 expect(states.length).toBe(4) expect(states[3]).toMatchObject({ diff --git a/packages/svelte-query-devtools/eslint.config.js b/packages/svelte-query-devtools/eslint.config.js index 6ed66be34b..d0e37929b0 100644 --- a/packages/svelte-query-devtools/eslint.config.js +++ b/packages/svelte-query-devtools/eslint.config.js @@ -1,21 +1,11 @@ // @ts-check -import tseslint from 'typescript-eslint' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from '../../eslint.config.js' export default [ ...rootConfig, ...pluginSvelte.configs['flat/recommended'], - { - files: ['**/*.svelte'], - languageOptions: { - parserOptions: { - extraFileExtensions: ['.svelte'], - parser: tseslint.parser, - }, - }, - }, { rules: { 'svelte/block-lang': ['error', { script: ['ts'] }], diff --git a/packages/svelte-query-persist-client/eslint.config.js b/packages/svelte-query-persist-client/eslint.config.js index 6ed66be34b..d0e37929b0 100644 --- a/packages/svelte-query-persist-client/eslint.config.js +++ b/packages/svelte-query-persist-client/eslint.config.js @@ -1,21 +1,11 @@ // @ts-check -import tseslint from 'typescript-eslint' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from '../../eslint.config.js' export default [ ...rootConfig, ...pluginSvelte.configs['flat/recommended'], - { - files: ['**/*.svelte'], - languageOptions: { - parserOptions: { - extraFileExtensions: ['.svelte'], - parser: tseslint.parser, - }, - }, - }, { rules: { 'svelte/block-lang': ['error', { script: ['ts'] }], diff --git a/packages/svelte-query/eslint.config.js b/packages/svelte-query/eslint.config.js index 6ed66be34b..d0e37929b0 100644 --- a/packages/svelte-query/eslint.config.js +++ b/packages/svelte-query/eslint.config.js @@ -1,21 +1,11 @@ // @ts-check -import tseslint from 'typescript-eslint' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from '../../eslint.config.js' export default [ ...rootConfig, ...pluginSvelte.configs['flat/recommended'], - { - files: ['**/*.svelte'], - languageOptions: { - parserOptions: { - extraFileExtensions: ['.svelte'], - parser: tseslint.parser, - }, - }, - }, { rules: { 'svelte/block-lang': ['error', { script: ['ts'] }], diff --git a/packages/vue-query-devtools/eslint.config.js b/packages/vue-query-devtools/eslint.config.js index 8ac8dd40ab..8665fe9297 100644 --- a/packages/vue-query-devtools/eslint.config.js +++ b/packages/vue-query-devtools/eslint.config.js @@ -1,20 +1,7 @@ // @ts-check -import tseslint from 'typescript-eslint' // @ts-expect-error import pluginVue from 'eslint-plugin-vue' import rootConfig from '../../eslint.config.js' -export default [ - ...rootConfig, - ...pluginVue.configs['flat/base'], - { - files: ['**/*.vue'], - languageOptions: { - parserOptions: { - extraFileExtensions: ['.vue'], - parser: tseslint.parser, - }, - }, - }, -] +export default [...rootConfig, ...pluginVue.configs['flat/base']] diff --git a/packages/vue-query/eslint.config.js b/packages/vue-query/eslint.config.js index 8ac8dd40ab..8665fe9297 100644 --- a/packages/vue-query/eslint.config.js +++ b/packages/vue-query/eslint.config.js @@ -1,20 +1,7 @@ // @ts-check -import tseslint from 'typescript-eslint' // @ts-expect-error import pluginVue from 'eslint-plugin-vue' import rootConfig from '../../eslint.config.js' -export default [ - ...rootConfig, - ...pluginVue.configs['flat/base'], - { - files: ['**/*.vue'], - languageOptions: { - parserOptions: { - extraFileExtensions: ['.vue'], - parser: tseslint.parser, - }, - }, - }, -] +export default [...rootConfig, ...pluginVue.configs['flat/base']] diff --git a/packages/vue-query/src/infiniteQueryOptions.ts b/packages/vue-query/src/infiniteQueryOptions.ts index f457718728..3069219a10 100644 --- a/packages/vue-query/src/infiniteQueryOptions.ts +++ b/packages/vue-query/src/infiniteQueryOptions.ts @@ -1,7 +1,10 @@ -import type { DataTag } from '@tanstack/query-core' -import type { InfiniteData } from '@tanstack/query-core' +import type { + DataTag, + DefaultError, + InfiniteData, + QueryKey, +} from '@tanstack/query-core' import type { UseInfiniteQueryOptions } from './useInfiniteQuery' -import type { DefaultError, QueryKey } from '@tanstack/query-core' export type UndefinedInitialDataInfiniteOptions< TQueryFnData, diff --git a/packages/vue-query/src/queryClient.ts b/packages/vue-query/src/queryClient.ts index 019c9d56f7..281eca714a 100644 --- a/packages/vue-query/src/queryClient.ts +++ b/packages/vue-query/src/queryClient.ts @@ -174,7 +174,7 @@ export class QueryClient extends QC { filters: MaybeRefDeep = {}, options: MaybeRefDeep = {}, ): Promise { - // eslint-disable-next-line @cspell/spellchecker + // eslint-disable-next-line cspell/spellchecker // (dosipiuk): We need to delay `invalidate` execution to next macro task for all reactive values to be updated. // This ensures that `context` in `queryFn` while `invalidating` along reactive variable change has correct value. return new Promise((resolve) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2e893d258..6f1ee47262 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,8 +26,8 @@ importers: specifier: ^0.8.8 version: 0.8.8(@solidjs/router@0.13.3(solid-js@1.8.17))(solid-js@1.8.17) '@tanstack/config': - specifier: ^0.8.1 - version: 0.8.1(@types/node@20.12.12)(esbuild@0.19.11)(eslint@8.57.0)(rollup@4.14.1)(typescript@5.3.3)(vite@5.2.11(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.29.1)) + specifier: ^0.8.6 + version: 0.8.6(@types/node@20.12.12)(esbuild@0.19.11)(eslint@8.57.0)(rollup@4.14.1)(typescript@5.3.3)(vite@5.2.11(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.29.1)) '@testing-library/jest-dom': specifier: ^6.4.5 version: 6.4.5(vitest@1.6.0(@types/node@20.12.12)(jsdom@24.0.0)(less@4.2.0)(sass@1.71.1)(terser@5.29.1)) @@ -103,9 +103,6 @@ importers: typescript: specifier: 5.3.3 version: 5.3.3 - typescript-eslint: - specifier: ^7.14.1 - version: 7.14.1(eslint@8.57.0)(typescript@5.3.3) typescript47: specifier: npm:typescript@4.7 version: typescript@4.7.4 @@ -6369,8 +6366,8 @@ packages: '@swc/helpers@0.5.2': resolution: {integrity: sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==} - '@tanstack/config@0.8.1': - resolution: {integrity: sha512-d+4A38/PokW/ljv8Q/EOeStpN9EvUwoj1SQORzBbQe7T/YcEMdMWuNp30A/S3DCYQvV4iDFwILSzqle+fxA+ag==} + '@tanstack/config@0.8.6': + resolution: {integrity: sha512-SrvXII1DM3izYsrCoFfS4i+H/rGT30IOhG96De3J0/mbkCicB8rWSgV0FfrLoIlQc4FUyULNCw7/Pn3iZCGM7g==} engines: {node: '>=18'} hasBin: true @@ -24226,7 +24223,7 @@ snapshots: dependencies: tslib: 2.6.2 - '@tanstack/config@0.8.1(@types/node@20.12.12)(esbuild@0.19.11)(eslint@8.57.0)(rollup@4.14.1)(typescript@5.3.3)(vite@5.2.11(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.29.1))': + '@tanstack/config@0.8.6(@types/node@20.12.12)(esbuild@0.19.11)(eslint@8.57.0)(rollup@4.14.1)(typescript@5.3.3)(vite@5.2.11(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.29.1))': dependencies: '@commitlint/parse': 19.0.3 '@eslint/js': 9.5.0