@tanstack/eslint-plugin-query 5.94.4 → 5.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +329 -0
  2. package/build/legacy/_tsup-dts-rollup.d.ts +329 -0
  3. package/build/legacy/chunk-T44AUBX4.js +1344 -0
  4. package/build/legacy/chunk-T44AUBX4.js.map +1 -0
  5. package/build/legacy/index.cjs +1413 -0
  6. package/build/legacy/index.cjs.map +1 -0
  7. package/build/legacy/index.d.cts +3 -0
  8. package/build/legacy/index.d.ts +3 -0
  9. package/build/legacy/index.js +50 -0
  10. package/build/legacy/index.js.map +1 -0
  11. package/build/legacy/rules.cjs +1370 -0
  12. package/build/legacy/rules.cjs.map +1 -0
  13. package/build/legacy/rules.d.cts +1 -0
  14. package/build/legacy/rules.d.ts +1 -0
  15. package/build/legacy/rules.js +7 -0
  16. package/build/legacy/rules.js.map +1 -0
  17. package/build/legacy/types.cjs +19 -0
  18. package/build/legacy/types.cjs.map +1 -0
  19. package/build/legacy/types.d.cts +1 -0
  20. package/build/legacy/types.d.ts +1 -0
  21. package/build/legacy/types.js +1 -0
  22. package/build/legacy/types.js.map +1 -0
  23. package/build/modern/_tsup-dts-rollup.d.cts +329 -0
  24. package/build/modern/_tsup-dts-rollup.d.ts +329 -0
  25. package/build/modern/chunk-XH4ABCYA.js +1335 -0
  26. package/build/modern/chunk-XH4ABCYA.js.map +1 -0
  27. package/build/modern/index.cjs +1405 -0
  28. package/build/modern/index.cjs.map +1 -0
  29. package/build/modern/index.d.cts +3 -0
  30. package/build/modern/index.d.ts +3 -0
  31. package/build/modern/index.js +50 -0
  32. package/build/modern/index.js.map +1 -0
  33. package/build/modern/rules.cjs +1362 -0
  34. package/build/modern/rules.cjs.map +1 -0
  35. package/build/modern/rules.d.cts +1 -0
  36. package/build/modern/rules.d.ts +1 -0
  37. package/build/modern/rules.js +7 -0
  38. package/build/modern/rules.js.map +1 -0
  39. package/build/modern/types.cjs +20 -0
  40. package/build/modern/types.cjs.map +1 -0
  41. package/build/modern/types.d.cts +1 -0
  42. package/build/modern/types.d.ts +1 -0
  43. package/build/modern/types.js +1 -0
  44. package/build/modern/types.js.map +1 -0
  45. package/package.json +1 -1
  46. package/src/rules/exhaustive-deps/exhaustive-deps.rule.ts +136 -90
  47. package/src/rules/exhaustive-deps/exhaustive-deps.utils.ts +248 -22
  48. package/src/utils/ast-utils.ts +2 -25
@@ -0,0 +1,329 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import type { ESLint } from 'eslint';
3
+ import { ESLintUtils } from '@typescript-eslint/utils';
4
+ import type { Linter } from 'eslint';
5
+ import { Options as Options_2 } from 'tsup';
6
+ import { RuleListener } from '@typescript-eslint/utils/ts-eslint';
7
+ import { RuleModule } from '@typescript-eslint/utils/ts-eslint';
8
+ import type { TSESLint } from '@typescript-eslint/utils';
9
+ import { TSESTree } from '@typescript-eslint/utils';
10
+
11
+ export declare const ASTUtils: {
12
+ isNodeOfOneOf<T extends AST_NODE_TYPES>(node: TSESTree.Node, types: ReadonlyArray<T>): node is TSESTree.Node & {
13
+ type: T;
14
+ };
15
+ isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier;
16
+ isIdentifierWithName(node: TSESTree.Node, name: string): node is TSESTree.Identifier;
17
+ isIdentifierWithOneOfNames<T extends Array<string>>(node: TSESTree.Node, name: T): node is TSESTree.Identifier & {
18
+ name: T[number];
19
+ };
20
+ isProperty(node: TSESTree.Node): node is TSESTree.Property;
21
+ isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression;
22
+ isPropertyWithIdentifierKey(node: TSESTree.Node, key: string): node is TSESTree.Property;
23
+ findPropertyWithIdentifierKey(properties: Array<TSESTree.ObjectLiteralElement>, key: string): TSESTree.Property | undefined;
24
+ getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier>;
25
+ traverseUpOnly(identifier: TSESTree.Node, allowedNodeTypes: Array<AST_NODE_TYPES>): TSESTree.Node;
26
+ isDeclaredInNode(params: {
27
+ functionNode: TSESTree.Node;
28
+ reference: TSESLint.Scope.Reference;
29
+ scopeManager: TSESLint.Scope.ScopeManager;
30
+ }): boolean;
31
+ getExternalRefs(params: {
32
+ scopeManager: TSESLint.Scope.ScopeManager;
33
+ sourceCode: Readonly<TSESLint.SourceCode>;
34
+ node: TSESTree.Node;
35
+ }): Array<TSESLint.Scope.Reference>;
36
+ mapKeyNodeToText(node: TSESTree.Node, sourceCode: Readonly<TSESLint.SourceCode>): string;
37
+ mapKeyNodeToBaseText(node: TSESTree.Node, sourceCode: Readonly<TSESLint.SourceCode>): string;
38
+ isValidReactComponentOrHookName(identifier: TSESTree.Identifier | null | undefined): boolean;
39
+ getFunctionAncestor(sourceCode: Readonly<TSESLint.SourceCode>, node: TSESTree.Node): TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | undefined;
40
+ getReferencedExpressionByIdentifier(params: {
41
+ node: TSESTree.Node;
42
+ context: Readonly<TSESLint.RuleContext<string, ReadonlyArray<unknown>>>;
43
+ }): TSESTree.Expression | null;
44
+ getClosestVariableDeclarator(node: TSESTree.Node): TSESTree.VariableDeclaratorDefiniteAssignment | TSESTree.VariableDeclaratorMaybeInit | undefined;
45
+ getNestedReturnStatements(node: TSESTree.Node): Array<TSESTree.ReturnStatement>;
46
+ };
47
+
48
+ declare type CheckedProperties = (typeof checkedProperties)[number];
49
+
50
+ export declare const checkedProperties: readonly ["queryFn", "getPreviousPageParam", "getNextPageParam"];
51
+
52
+ declare type CheckedProperties_2 = (typeof checkedProperties_alias_1)[number];
53
+
54
+ export declare const checkedProperties_alias_1: readonly ["onMutate", "onError", "onSettled"];
55
+
56
+ declare type Context = Parameters<Create>[0];
57
+
58
+ declare type Create = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]['create'];
59
+
60
+ export declare function createPropertyOrderRule<TFunc extends string, TProp extends string>(options: Omit<Parameters<typeof createRule>[0], 'create'>, targetFunctions: ReadonlyArray<TFunc> | Array<TFunc>, orderRules: ReadonlyArray<Readonly<[ReadonlyArray<TProp>, ReadonlyArray<TProp>]>>): ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
61
+ name: string;
62
+ };
63
+
64
+ declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, ExtraRuleDocs>>) => ESLintUtils.RuleModule<MessageIds, Options, ExtraRuleDocs, ESLintUtils.RuleListener> & {
65
+ name: string;
66
+ };
67
+
68
+ export declare const default_alias_1: any[];
69
+
70
+ export declare const default_alias_2: any[];
71
+
72
+ export declare const default_alias_3: Options_2 | Options_2[] | ((overrideOptions: Options_2) => Options_2 | Options_2[] | Promise<Options_2 | Options_2[]>);
73
+
74
+ export declare const default_alias_4: Record<string, any>;
75
+
76
+ export declare function detectTanstackQueryImports(create: EnhancedCreate): Create;
77
+
78
+ declare type EnhancedCreate = (context: Context, options: Options, helpers: Helpers) => ReturnType<Create>;
79
+
80
+ export declare const ExhaustiveDepsUtils: {
81
+ isRelevantReference(params: {
82
+ sourceCode: Readonly<TSESLint.SourceCode>;
83
+ reference: TSESLint.Scope.Reference;
84
+ scopeManager: TSESLint.Scope.ScopeManager;
85
+ node: TSESTree.Node;
86
+ filename: string;
87
+ }): boolean;
88
+ /**
89
+ * Given required refs and existing queryKey entries, compute missing dependency paths
90
+ * respecting allowlisted variables and types.
91
+ */
92
+ computeFilteredMissingPaths(params: {
93
+ requiredRefs: Array<{
94
+ path: string;
95
+ root: string;
96
+ allowlistedByType: boolean;
97
+ }>;
98
+ allowlistedVariables: Set<string>;
99
+ existingRootIdentifiers: Set<string>;
100
+ existingFullPaths: Set<string>;
101
+ }): Array<string>;
102
+ /**
103
+ * Extract existing queryKey deps as root identifiers and full member paths.
104
+ */
105
+ collectQueryKeyDeps(params: {
106
+ sourceCode: Readonly<TSESLint.SourceCode>;
107
+ scopeManager: TSESLint.Scope.ScopeManager;
108
+ queryKeyNode: TSESTree.Node;
109
+ }): {
110
+ roots: Set<string>;
111
+ paths: Set<string>;
112
+ };
113
+ isNode(value: unknown): value is TSESTree.Node;
114
+ /**
115
+ * Checks whether the resolved variable is allowlisted by its type annotation
116
+ */
117
+ variableIsAllowlistedByType(params: {
118
+ allowlistedTypes: Set<string>;
119
+ variable: TSESLint.Scope.Variable | null;
120
+ }): boolean;
121
+ isInstanceOfKind(node: TSESTree.Node): boolean;
122
+ /**
123
+ * Normalizes a chain by removing optional chaining operators
124
+ *
125
+ * Example: `a?.b.c!` -> `a.b.c`
126
+ */
127
+ normalizeChain(text: string): string;
128
+ /**
129
+ * Computes the reference path for an identifier
130
+ *
131
+ * Example: `a.b.c!` -> `{ path: 'a.b.c', root: 'a' }`
132
+ */
133
+ computeRefPath(params: {
134
+ identifier: TSESTree.Identifier;
135
+ sourceCode: Readonly<TSESLint.SourceCode>;
136
+ }): {
137
+ path: string;
138
+ root: string;
139
+ coversRootMembers: boolean;
140
+ } | null;
141
+ collectExternalRefsInFunction(params: {
142
+ functionNode: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
143
+ scopeManager: TSESLint.Scope.ScopeManager;
144
+ }): Array<TSESLint.Scope.Reference>;
145
+ /**
146
+ * Recursively collects type identifiers from a type annotation
147
+ */
148
+ collectTypeIdentifiers(typeNode: TSESTree.TypeNode, out: Set<string>): void;
149
+ /**
150
+ * Gets the function expression nodes from a queryFn property, handling conditional expressions.
151
+ * When neither branch is skipToken, returns both branches so all deps are scanned.
152
+ */
153
+ getQueryFnNodes(queryFn: TSESTree.Property): Array<TSESTree.Node>;
154
+ };
155
+
156
+ export declare function expectArrayEqualIgnoreOrder<T>(a: Array<T>, b: Array<T>): void;
157
+
158
+ export declare type ExtraRuleDocs = {
159
+ recommended: 'strict' | 'error' | 'warn';
160
+ };
161
+
162
+ export declare function generateInterleavedCombinations<TData, TAdditional, TResult extends TData | TAdditional>(data: Array<TData> | ReadonlyArray<TData>, additional: Array<TAdditional> | ReadonlyArray<TAdditional>): Array<Array<TResult>>;
163
+
164
+ export declare function generateInvalidPermutations(arr: ReadonlyArray<CheckedProperties>): Array<{
165
+ invalid: Array<CheckedProperties>;
166
+ valid: Array<CheckedProperties>;
167
+ }>;
168
+
169
+ export declare function generateInvalidPermutations_alias_1(arr: ReadonlyArray<CheckedProperties_2>): Array<{
170
+ invalid: Array<CheckedProperties_2>;
171
+ valid: Array<CheckedProperties_2>;
172
+ }>;
173
+
174
+ export declare function generatePartialCombinations<T>(arr: ReadonlyArray<T>, minLength: number): Array<Array<T>>;
175
+
176
+ export declare function generatePermutations<T>(arr: Array<T>): Array<Array<T>>;
177
+
178
+ export declare const getDocsUrl: (ruleName: string) => string;
179
+
180
+ declare type Helpers = {
181
+ isSpecificTanstackQueryImport: (node: TSESTree.Identifier, source: string) => boolean;
182
+ isTanstackQueryImport: (node: TSESTree.Identifier) => boolean;
183
+ };
184
+
185
+ export declare type InfiniteQueryFunctions = (typeof infiniteQueryFunctions)[number];
186
+
187
+ export declare const infiniteQueryFunctions: readonly ["infiniteQueryOptions", "useInfiniteQuery", "useSuspenseInfiniteQuery"];
188
+
189
+ export declare type InfiniteQueryProperties = (typeof checkedProperties)[number];
190
+
191
+ /**
192
+ * @param {Object} opts - Options for building configurations.
193
+ * @param {string[]} opts.entry - The entry array.
194
+ * @returns {import('tsup').Options}
195
+ */
196
+ export declare function legacyConfig(opts: {
197
+ entry: string[];
198
+ }): Options_2;
199
+
200
+ /**
201
+ * @param {Object} opts - Options for building configurations.
202
+ * @param {string[]} opts.entry - The entry array.
203
+ * @returns {import('tsup').Options}
204
+ */
205
+ export declare function modernConfig(opts: {
206
+ entry: string[];
207
+ }): Options_2;
208
+
209
+ export declare type MutationFunctions = (typeof mutationFunctions)[number];
210
+
211
+ export declare const mutationFunctions: readonly ["useMutation"];
212
+
213
+ export declare type MutationProperties = (typeof checkedProperties_alias_1)[number];
214
+
215
+ declare const name_2 = "exhaustive-deps";
216
+ export { name_2 as name }
217
+
218
+ export declare const name_alias_1 = "infinite-query-property-order";
219
+
220
+ export declare const name_alias_2 = "mutation-property-order";
221
+
222
+ export declare const name_alias_3 = "no-rest-destructuring";
223
+
224
+ export declare const name_alias_4 = "no-unstable-deps";
225
+
226
+ export declare const name_alias_5 = "no-void-query-fn";
227
+
228
+ export declare const name_alias_6 = "stable-query-client";
229
+
230
+ export declare const NoRestDestructuringUtils: {
231
+ isObjectRestDestructuring(node: TSESTree.Node): boolean;
232
+ };
233
+
234
+ export declare function normalizeIndent(template: TemplateStringsArray): string;
235
+
236
+ declare type Options = Parameters<Create>[1];
237
+
238
+ declare const plugin: {
239
+ meta: {
240
+ name: string;
241
+ };
242
+ configs: {
243
+ recommended: {
244
+ plugins: string[];
245
+ rules: {
246
+ '@tanstack/query/exhaustive-deps': "error";
247
+ '@tanstack/query/no-rest-destructuring': "warn";
248
+ '@tanstack/query/stable-query-client': "error";
249
+ '@tanstack/query/no-unstable-deps': "error";
250
+ '@tanstack/query/infinite-query-property-order': "error";
251
+ '@tanstack/query/no-void-query-fn': "error";
252
+ '@tanstack/query/mutation-property-order': "error";
253
+ };
254
+ };
255
+ 'flat/recommended': {
256
+ name: string;
257
+ plugins: {
258
+ '@tanstack/query': {};
259
+ };
260
+ rules: {
261
+ '@tanstack/query/exhaustive-deps': "error";
262
+ '@tanstack/query/no-rest-destructuring': "warn";
263
+ '@tanstack/query/stable-query-client': "error";
264
+ '@tanstack/query/no-unstable-deps': "error";
265
+ '@tanstack/query/infinite-query-property-order': "error";
266
+ '@tanstack/query/no-void-query-fn': "error";
267
+ '@tanstack/query/mutation-property-order': "error";
268
+ };
269
+ }[];
270
+ };
271
+ rules: Record<string, RuleModule<string, readonly unknown[], ExtraRuleDocs, RuleListener>>;
272
+ };
273
+ export { plugin as default_alias }
274
+ export { plugin }
275
+
276
+ declare interface Plugin_2 extends Omit<ESLint.Plugin, 'rules'> {
277
+ rules: Record<RuleKey, RuleModule<any, any, any>>;
278
+ configs: {
279
+ recommended: ESLint.ConfigData;
280
+ 'flat/recommended': Array<Linter.Config>;
281
+ };
282
+ }
283
+ export { Plugin_2 as Plugin }
284
+
285
+ export declare const reactHookNames: string[];
286
+
287
+ export declare const rule: ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
288
+ name: string;
289
+ };
290
+
291
+ export declare const rule_alias_1: RuleModule<string, readonly unknown[], ExtraRuleDocs, RuleListener> & {
292
+ name: string;
293
+ };
294
+
295
+ export declare const rule_alias_2: RuleModule<string, readonly unknown[], ExtraRuleDocs, RuleListener> & {
296
+ name: string;
297
+ };
298
+
299
+ export declare const rule_alias_3: ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
300
+ name: string;
301
+ };
302
+
303
+ export declare const rule_alias_4: ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
304
+ name: string;
305
+ };
306
+
307
+ export declare const rule_alias_5: ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
308
+ name: string;
309
+ };
310
+
311
+ export declare const rule_alias_6: ESLintUtils.RuleModule<string, readonly unknown[], ExtraRuleDocs, ESLintUtils.RuleListener> & {
312
+ name: string;
313
+ };
314
+
315
+ declare type RuleKey = keyof typeof rules;
316
+
317
+ export declare const rules: Record<string, ESLintUtils.RuleModule<string, ReadonlyArray<unknown>, ExtraRuleDocs, ESLintUtils.RuleListener>>;
318
+
319
+ export declare function sortDataByOrder<T, TKey extends keyof T>(data: Array<T> | ReadonlyArray<T>, orderRules: ReadonlyArray<Readonly<[ReadonlyArray<T[TKey]>, ReadonlyArray<T[TKey]>]>>, key: TKey): Array<T> | null;
320
+
321
+ export declare const sortRules: readonly [readonly [readonly ["queryFn"], readonly ["getPreviousPageParam", "getNextPageParam"]]];
322
+
323
+ export declare const sortRules_alias_1: readonly [readonly [readonly ["onMutate"], readonly ["onError", "onSettled"]]];
324
+
325
+ export declare function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T>;
326
+
327
+ export declare const useQueryHookNames: string[];
328
+
329
+ export { }