Skip to content

Commit b32ad24

Browse files
authored
ci(eslint): add @cspell/eslint-plugin to prevent misspelling (error) (TanStack#6718)
* ci: add @cspell/eslint-plugin to prevent misspelling * ci(eslint/cspell): convert rule as error * fix(cspell): reduce unnecessary words to check * fix(eslint): remove `ouuid` as @cspell/spellchecker's words
1 parent 8fff654 commit b32ad24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+675
-141
lines changed

.eslintrc.cjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const config = {
66
parser: '@typescript-eslint/parser',
77
plugins: ['@typescript-eslint', 'import'],
88
extends: [
9+
'plugin:@cspell/recommended',
910
'plugin:@typescript-eslint/eslint-recommended',
1011
'plugin:@typescript-eslint/recommended',
1112
'plugin:import/recommended',
@@ -34,6 +35,27 @@ const config = {
3435
},
3536
},
3637
rules: {
38+
'@cspell/spellchecker': [
39+
'error',
40+
{
41+
cspell: {
42+
words: [
43+
'tanstack', // Our package scope
44+
'tsqd', // Our public interface (TanStack Query Devtools shorthand)
45+
'retryer', // Our public interface
46+
'Promisable', // Our public interface
47+
'extralight', // Our public interface
48+
'codemod', // We support our codemod
49+
50+
'TSES', // @typescript-eslint package's interface
51+
'tsup', // We use tsup as builder
52+
'solidjs', // Our target framework
53+
'tabular-nums', // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
54+
'todos', // Too general word to be caught as error
55+
],
56+
},
57+
},
58+
],
3759
'@typescript-eslint/array-type': [
3860
'error',
3961
{ default: 'generic', readonly: 'generic' },

examples/react/optimistic-updates-cache/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function Example() {
4141
// When mutate is called:
4242
onMutate: async (newTodo: string) => {
4343
setText('')
44-
// Cancel any outgoing refetches
44+
// Cancel any outgoing refetch
4545
// (so they don't overwrite our optimistic update)
4646
await queryClient.cancelQueries(todoListOptions)
4747

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"namespace": "@tanstack",
3939
"devDependencies": {
40+
"@cspell/eslint-plugin": "^8.3.2",
4041
"@solidjs/testing-library": "^0.8.5",
4142
"@tanstack/config": "^0.3.2",
4243
"@testing-library/jest-dom": "^6.1.5",

packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @cspell/spellchecker */
12
/**
23
* The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.
34
*
@@ -8,6 +9,7 @@
89
* For more information about the original code, see
910
* https://github.com/nartc/ngxtension-platform
1011
*/
12+
/* eslint-enable */
1113

1214
import {
1315
InjectionToken,

packages/angular-query-experimental/src/util/assert-injector/assert-injector.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @cspell/spellchecker */
12
/**
23
* The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.
34
*
@@ -8,6 +9,7 @@
89
* For more information about the original code, see
910
* https://github.com/nartc/ngxtension-platform
1011
*/
12+
/* eslint-enable */
1113

1214
import {
1315
Injector,

packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @cspell/spellchecker */
12
/**
23
* The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.
34
*
@@ -8,6 +9,7 @@
89
* For more information about the original code, see
910
* https://github.com/nartc/ngxtension-platform
1011
*/
12+
/* eslint-enable */
1113

1214
import { TestBed } from '@angular/core/testing'
1315
import { createNoopInjectionToken } from './create-injection-token'

packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @cspell/spellchecker */
12
/**
23
* The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.
34
*
@@ -8,6 +9,7 @@
89
* For more information about the original code, see
910
* https://github.com/nartc/ngxtension-platform
1011
*/
12+
/* eslint-enable */
1113

1214
import {
1315
type EnvironmentProviders,

packages/codemods/src/v5/remove-overloads/__testfixtures__/default-import.input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ export const WithIdentifiers = () => {
200200
}
201201

202202
export const SecondArgumentIsAFunctionExample = () => {
203-
useQuery(ordersCacheKeys.groupOrders(ouuid), () => api.getPatientGroupOrders(ouuid).then((r) => r.data))
203+
useQuery(ordersCacheKeys.groupOrders(id), () => api.getPatientGroupOrders(id).then((r) => r.data))
204204

205205
const rest = 'rest'
206206
const of = 1
207207
const functionArguments = { foo: 'bar' }
208208

209-
useQuery(ordersCacheKeys.groupOrders(ouuid), () => api.getPatientGroupOrders(ouuid).then((r) => r.data), rest, of, functionArguments)
209+
useQuery(ordersCacheKeys.groupOrders(id), () => api.getPatientGroupOrders(id).then((r) => r.data), rest, of, functionArguments)
210210
}

packages/codemods/src/v5/remove-overloads/__testfixtures__/default-import.output.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,16 @@ export const WithIdentifiers = () => {
486486

487487
export const SecondArgumentIsAFunctionExample = () => {
488488
useQuery({
489-
queryKey: ordersCacheKeys.groupOrders(ouuid),
490-
queryFn: () => api.getPatientGroupOrders(ouuid).then((r) => r.data)
489+
queryKey: ordersCacheKeys.groupOrders(id),
490+
queryFn: () => api.getPatientGroupOrders(id).then((r) => r.data)
491491
})
492492

493493
const rest = 'rest'
494494
const of = 1
495495
const functionArguments = { foo: 'bar' }
496496

497497
useQuery({
498-
queryKey: ordersCacheKeys.groupOrders(ouuid),
499-
queryFn: () => api.getPatientGroupOrders(ouuid).then((r) => r.data)
498+
queryKey: ordersCacheKeys.groupOrders(id),
499+
queryFn: () => api.getPatientGroupOrders(id).then((r) => r.data)
500500
}, rest, of, functionArguments)
501501
}

packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ ruleTester.run('exhaustive-deps', rule, {
364364
const CONST_VAL = 1
365365
function useHook() {
366366
const queryClient = useQueryClient()
367-
const kueryKlient = useQueryClient()
367+
const queryClient2 = useQueryClient()
368368
useQuery({
369369
queryKey: ["foo"],
370370
queryFn: () => {
371371
doSomething(queryClient)
372372
queryClient.invalidateQueries()
373-
doSomethingSus(kueryKlient)
373+
doSomethingSus(queryClient2)
374374
}
375375
});
376376
}

packages/eslint-plugin-query/src/rules/no-rest-desctructuring/no-rest-destructuring.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ruleTester = new ESLintUtils.RuleTester({
77
settings: {},
88
})
99

10-
ruleTester.run('no-rest-desctructuring', rule, {
10+
ruleTester.run('no-rest-destructuring', rule, {
1111
valid: [
1212
{
1313
name: 'useQuery is not captured',

packages/query-core/src/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class Query<
330330
): Promise<TData> {
331331
if (this.state.fetchStatus !== 'idle') {
332332
if (this.state.dataUpdatedAt && fetchOptions?.cancelRefetch) {
333-
// Silently cancel current fetch if the user wants to cancel refetches
333+
// Silently cancel current fetch if the user wants to cancel refetch
334334
this.cancel({ silent: true })
335335
} else if (this.#promise) {
336336
// make sure that retries that were potentially cancelled due to unmounts can continue

packages/query-core/src/queryObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class QueryObserver<
234234
// arrives, it finds the old `observer.currentResult` which is related
235235
// to the old QueryKey. Which means that currentResult and selectData are
236236
// out of sync already.
237-
// To solve this, we move the cursor of the currentResult everytime
237+
// To solve this, we move the cursor of the currentResult every time
238238
// an observer reads an optimistic value.
239239

240240
// When keeping the previous data, the result doesn't change until new

packages/query-core/src/tests/hydration.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function fetchData<TData>(value: TData, ms?: number): Promise<TData> {
1515
}
1616

1717
describe('dehydration and rehydration', () => {
18-
test('should work with serializeable values', async () => {
18+
test('should work with serializable values', async () => {
1919
const queryCache = new QueryCache()
2020
const queryClient = createQueryClient({ queryCache })
2121
await queryClient.prefetchQuery({

packages/query-core/src/tests/infiniteQueryBehavior.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe('InfiniteQueryBehavior', () => {
167167
// Refetch the infinite query
168168
await observer.refetch()
169169

170-
// Only 2 pages should be refetched
170+
// Only 2 pages should refetch
171171
expect(queryFnSpy).toHaveBeenCalledTimes(2)
172172

173173
expect(queryFnSpy).toHaveBeenNthCalledWith(1, {

packages/query-core/src/tests/notifyManager.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ describe('notifyManager', () => {
6868
expect(notifySpy).toHaveBeenCalledTimes(1)
6969
})
7070

71-
it('typedefs should catch proper signatures', async () => {
71+
it('typeDefs should catch proper signatures', async () => {
7272
const notifyManagerTest = createNotifyManager()
7373

7474
// we define some fn with its signature:
7575
const fn: (a: string, b: number) => string = (a, b) => a + b
7676

77-
//now somefn expect to be called with args [a: string, b: number]
77+
//now someFn expect to be called with args [a: string, b: number]
7878
const someFn = notifyManagerTest.batchCalls(fn)
7979

8080
someFn('im happy', 4)

packages/query-core/src/tests/queryClient.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('queryClient', () => {
196196
expect(() => {
197197
queryClient.setQueryData([key, user], (prevUser?: typeof user) => ({
198198
...prevUser!,
199-
name: 'Edvin',
199+
name: 'James',
200200
}))
201201
}).not.toThrow()
202202
})
@@ -433,7 +433,7 @@ describe('queryClient', () => {
433433
).resolves.toEqual('bar')
434434
})
435435

436-
test('should return the cached query data if the query is found and cached query data is falsey', async () => {
436+
test('should return the cached query data if the query is found and cached query data is falsy', async () => {
437437
const key = queryKey()
438438
const queryFn = () => Promise.resolve(0)
439439

packages/query-core/src/tests/queryObserver.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ describe('queryObserver', () => {
682682
unsubscribe()
683683
})
684684

685-
test('should not use replaceEqualDeep for select value when structuralSharing option is true and placeholderdata is defined', () => {
685+
test('should not use replaceEqualDeep for select value when structuralSharing option is true and placeholderData is defined', () => {
686686
const key = queryKey()
687687

688688
const data = { value: 'data' }
@@ -719,7 +719,7 @@ describe('queryObserver', () => {
719719
expect(observer.getCurrentResult().data).toBe(selectedData2)
720720
})
721721

722-
test('should not use an undefined value returned by select as placeholderdata', () => {
722+
test('should not use an undefined value returned by select as placeholderData', () => {
723723
const key = queryKey()
724724

725725
const data = { value: 'data' }

packages/query-core/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export interface QueryObserverOptions<
278278
) => boolean | 'always')
279279
/**
280280
* If set to `true`, the query will refetch on mount if the data is stale.
281-
* If set to `false`, will disable additional instances of a query to trigger background refetches.
281+
* If set to `false`, will disable additional instances of a query to trigger background refetch.
282282
* If set to `'always'`, the query will always refetch on mount.
283283
* If set to a function, the function will be executed with the latest data and query to compute the value
284284
* Defaults to `true`.

packages/query-devtools/src/Devtools.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,16 @@ const DevtoolsPanel: Component<DevtoolsPanelProps> = (props) => {
330330
}
331331
}
332332

333-
const unsub = () => {
333+
const unsubscribe = () => {
334334
if (isResizing()) {
335335
setIsResizing(false)
336336
}
337337
document.removeEventListener('mousemove', runDrag, false)
338-
document.removeEventListener('mouseUp', unsub, false)
338+
document.removeEventListener('mouseUp', unsubscribe, false)
339339
}
340340

341341
document.addEventListener('mousemove', runDrag, false)
342-
document.addEventListener('mouseup', unsub, false)
342+
document.addEventListener('mouseup', unsubscribe, false)
343343
}
344344

345345
let panelRef!: HTMLDivElement
@@ -2062,7 +2062,7 @@ const setupQueryCacheSubscription = () => {
20622062
return client.getQueryCache()
20632063
})
20642064

2065-
const unsub = queryCache().subscribe((q) => {
2065+
const unsubscribe = queryCache().subscribe((q) => {
20662066
batch(() => {
20672067
for (const [callback, value] of queryCacheMap.entries()) {
20682068
if (!value.shouldUpdate(q)) continue
@@ -2073,10 +2073,10 @@ const setupQueryCacheSubscription = () => {
20732073

20742074
onCleanup(() => {
20752075
queryCacheMap.clear()
2076-
unsub()
2076+
unsubscribe()
20772077
})
20782078

2079-
return unsub
2079+
return unsubscribe
20802080
}
20812081

20822082
const createSubscribeToQueryCacheBatcher = <T,>(
@@ -2122,7 +2122,7 @@ const setupMutationCacheSubscription = () => {
21222122
return client.getMutationCache()
21232123
})
21242124

2125-
const unsub = mutationCache().subscribe(() => {
2125+
const unsubscribe = mutationCache().subscribe(() => {
21262126
for (const [callback, setter] of mutationCacheMap.entries()) {
21272127
queueMicrotask(() => {
21282128
setter(callback(mutationCache))
@@ -2132,10 +2132,10 @@ const setupMutationCacheSubscription = () => {
21322132

21332133
onCleanup(() => {
21342134
mutationCacheMap.clear()
2135-
unsub()
2135+
unsubscribe()
21362136
})
21372137

2138-
return unsub
2138+
return unsubscribe
21392139
}
21402140

21412141
const createSubscribeToMutationCacheBatcher = <T,>(

packages/query-devtools/src/__tests__/utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ describe('Utils tests', () => {
9191
['fr', 'bonjour'],
9292
])
9393

94+
/* eslint-disable @cspell/spellchecker */
9495
const newData = updateNestedDataByPath(oldData, ['fr'], 'salut')
9596

9697
expect(newData).not.toBe(oldData) // should not be the same reference
@@ -108,10 +109,12 @@ describe('Utils tests', () => {
108109
}
109110
`)
110111
})
112+
/* eslint-enable */
111113
})
112114

113115
describe('nested data', () => {
114116
it('should update data correctly', async () => {
117+
/* eslint-disable @cspell/spellchecker */
115118
const oldData = new Map([
116119
[
117120
'pumpkin-pie',
@@ -368,6 +371,7 @@ describe('Utils tests', () => {
368371
},
369372
}
370373
`)
374+
/* eslint-enable */
371375
})
372376
})
373377
})
@@ -469,6 +473,7 @@ describe('Utils tests', () => {
469473

470474
describe('nested data', () => {
471475
it('should delete nested items correctly', async () => {
476+
/* eslint-disable @cspell/spellchecker */
472477
const oldData = new Map([
473478
[
474479
'pumpkin-pie',
@@ -720,6 +725,7 @@ describe('Utils tests', () => {
720725
},
721726
}
722727
`)
728+
/* eslint-enable */
723729
})
724730
})
725731
})

packages/query-devtools/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createSignal, lazy } from 'solid-js'
33
import { setupStyleSheet } from './utils'
44
import type {
55
QueryClient,
6-
onlineManager as TonlineManager,
6+
onlineManager as TOnlineManager,
77
} from '@tanstack/query-core'
88
import type { DevtoolsComponentType } from './Devtools'
99
import type {
@@ -21,7 +21,7 @@ export interface TanstackQueryDevtoolsConfig extends QueryDevtoolsProps {
2121

2222
class TanstackQueryDevtools {
2323
#client: Signal<QueryClient>
24-
#onlineManager: typeof TonlineManager
24+
#onlineManager: typeof TOnlineManager
2525
#queryFlavor: string
2626
#version: string
2727
#isMounted = false

0 commit comments

Comments
 (0)