Skip to content

Commit

Permalink
chore: Update ESLint config (#7637)
Browse files Browse the repository at this point in the history
* chore: Update ESLint config

* Fix errors

* Fix knip
  • Loading branch information
lachlancollins authored Jun 28, 2024
1 parent e6a0fdd commit febbde6
Show file tree
Hide file tree
Showing 48 changed files with 77 additions and 159 deletions.
22 changes: 13 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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: [
Expand All @@ -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',
},
},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -72,7 +72,6 @@
"solid-js": "^1.8.17",
"tsup": "^8.0.2",
"typescript": "5.3.3",
"typescript-eslint": "^7.14.1",
"typescript47": "npm:[email protected]",
"typescript48": "npm:[email protected]",
"typescript49": "npm:[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -169,7 +169,7 @@ export function createNoopInjectionToken<
type TReturn = TMulti extends true ? Array<TValue> : 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<TReturn>(description)
return [
Expand Down
6 changes: 3 additions & 3 deletions packages/query-codemods/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const defineTest = require('jscodeshift/dist/testUtils').defineTest

defineTest(
Expand Down
5 changes: 0 additions & 5 deletions packages/query-codemods/src/v4/key-transformation.cjs
Original file line number Diff line number Diff line change
@@ -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 = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
3 changes: 0 additions & 3 deletions packages/query-codemods/src/v5/is-loading/is-loading.cjs
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -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')

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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')

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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')

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const UnknownUsageError = require('./unknown-usage-error.cjs')

module.exports = ({ jscodeshift, utils }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {
Expand Down
4 changes: 2 additions & 2 deletions packages/query-core/src/focusManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class FocusManager extends Subscribable<Listener> {
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
Expand Down Expand Up @@ -78,7 +78,7 @@ export class FocusManager extends Subscribable<Listener> {
}

// 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'
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/query-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/onlineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class OnlineManager extends Subscribable<Listener> {
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)
Expand Down
4 changes: 3 additions & 1 deletion packages/query-core/src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,6 +29,8 @@ import type {
MutationKey,
MutationObserverOptions,
MutationOptions,
NoInfer,
OmitKeyof,
QueryClientConfig,
QueryKey,
QueryObserverOptions,
Expand Down
6 changes: 3 additions & 3 deletions packages/query-devtools/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/query-persist-client-core/src/createPersister.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { matchQuery } from '@tanstack/query-core'
import type { QueryFilters } from '@tanstack/query-core'
import type {
Query,
QueryFilters,
QueryFunctionContext,
QueryKey,
QueryState,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/HydrationBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading

0 comments on commit febbde6

Please sign in to comment.