Open History to see the last commit
1// @ts-check
2
3// @ts-ignore Needed due to moduleResolution Node vs Bundler
4import { tanstackConfig } from '@tanstack/eslint-config'
5import pluginCspell from '@cspell/eslint-plugin'
6import vitest from '@vitest/eslint-plugin'
7
8export default [
9 ...tanstackConfig,
10 {
11 name: 'tanstack/temp',
12 plugins: {
13 cspell: pluginCspell,
14 },
15 rules: {
16 'cspell/spellchecker': [
17 'warn',
18 {
19 cspell: {
20 words: [
21 'Promisable', // Our public interface
22 'TSES', // @typescript-eslint package's interface
23 'codemod', // We support our codemod
24 'combinate', // Library name
25 'datatag', // Query options tagging
26 'extralight', // Our public interface
27 'jscodeshift',
28 'refetches', // Query refetch operations
29 'retryer', // Our public interface
30 'solidjs', // Our target framework
31 'tabular-nums', // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
32 'tanstack', // Our package scope
33 'todos', // Too general word to be caught as error
34 'tsqd', // Our public interface (TanStack Query Devtools shorthand)
35 'tsdown', // We use tsdown as builder
36 'typecheck', // Field of vite.config.ts
37 'vue-demi', // dependency of @tanstack/vue-query
38 'ɵkind', // Angular specific
39 'ɵproviders', // Angular specific
40 ],
41 },
42 },
43 ],
44 '@typescript-eslint/no-empty-function': 'off',
45 '@typescript-eslint/no-unsafe-function-type': 'off',
46 'no-case-declarations': 'off',
47 /**
48 * Disallows direct calls to deprecated imperative query methods of `QueryClient`
49 * for new tests and code
50 *
51 * Existing tests that directly test the methods from before the refactoring
52 * will be grandfathered in and allowed to continue using the deprecated methods.
53 * They should not be removed, but new tests should use the new methods instead.
54 */
55 'no-restricted-syntax': [
56 'error',
57 {
58 selector:
59 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="fetchQuery"], [callee.computed=true][callee.property.value="fetchQuery"])',
60 message: 'Use queryClient.query(options) instead.',
61 },
62 {
63 selector:
64 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="prefetchQuery"], [callee.computed=true][callee.property.value="prefetchQuery"])',
65 message:
66 'Use queryClient.query(options).catch(noop) instead if errors should be swallowed.',
67 },
68 {
69 selector:
70 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="ensureQueryData"], [callee.computed=true][callee.property.value="ensureQueryData"])',
71 message:
72 "Use queryClient.query({ ...options, staleTime: 'static' }) instead.",
73 },
74 {
75 selector:
76 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="fetchInfiniteQuery"], [callee.computed=true][callee.property.value="fetchInfiniteQuery"])',
77 message: 'Use queryClient.infiniteQuery(options) instead.',
78 },
79 {
80 selector:
81 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="prefetchInfiniteQuery"], [callee.computed=true][callee.property.value="prefetchInfiniteQuery"])',
82 message:
83 'Use queryClient.infiniteQuery(options).catch(noop) instead if errors should be swallowed.',
84 },
85 {
86 selector:
87 'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="ensureInfiniteQueryData"], [callee.computed=true][callee.property.value="ensureInfiniteQueryData"])',
88 message:
89 "Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead.",
90 },
91 ],
92 'prefer-const': 'off',
93 },
94 },
95 {
96 files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'],
97 plugins: { vitest },
98 rules: {
99 ...vitest.configs.recommended.rules,
100 'vitest/consistent-test-it': [
101 'error',
102 { fn: 'it', withinDescribe: 'it' },
103 ],
104 'vitest/no-standalone-expect': [
105 'error',
106 {
107 additionalTestBlockFunctions: ['itIf'],
108 },
109 ],
110 },
111 settings: { vitest: { typecheck: true } },
112 },
113]