@tanstack/eslint-plugin-query 5.91.5 → 5.94.4

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 (45) hide show
  1. package/package.json +1 -1
  2. package/build/legacy/_tsup-dts-rollup.d.cts +0 -275
  3. package/build/legacy/_tsup-dts-rollup.d.ts +0 -275
  4. package/build/legacy/chunk-HD2KSEKJ.js +0 -1145
  5. package/build/legacy/chunk-HD2KSEKJ.js.map +0 -1
  6. package/build/legacy/index.cjs +0 -1214
  7. package/build/legacy/index.cjs.map +0 -1
  8. package/build/legacy/index.d.cts +0 -3
  9. package/build/legacy/index.d.ts +0 -3
  10. package/build/legacy/index.js +0 -50
  11. package/build/legacy/index.js.map +0 -1
  12. package/build/legacy/rules.cjs +0 -1171
  13. package/build/legacy/rules.cjs.map +0 -1
  14. package/build/legacy/rules.d.cts +0 -1
  15. package/build/legacy/rules.d.ts +0 -1
  16. package/build/legacy/rules.js +0 -7
  17. package/build/legacy/rules.js.map +0 -1
  18. package/build/legacy/types.cjs +0 -19
  19. package/build/legacy/types.cjs.map +0 -1
  20. package/build/legacy/types.d.cts +0 -1
  21. package/build/legacy/types.d.ts +0 -1
  22. package/build/legacy/types.js +0 -1
  23. package/build/legacy/types.js.map +0 -1
  24. package/build/modern/_tsup-dts-rollup.d.cts +0 -275
  25. package/build/modern/_tsup-dts-rollup.d.ts +0 -275
  26. package/build/modern/chunk-XO2SGL7P.js +0 -1137
  27. package/build/modern/chunk-XO2SGL7P.js.map +0 -1
  28. package/build/modern/index.cjs +0 -1207
  29. package/build/modern/index.cjs.map +0 -1
  30. package/build/modern/index.d.cts +0 -3
  31. package/build/modern/index.d.ts +0 -3
  32. package/build/modern/index.js +0 -50
  33. package/build/modern/index.js.map +0 -1
  34. package/build/modern/rules.cjs +0 -1164
  35. package/build/modern/rules.cjs.map +0 -1
  36. package/build/modern/rules.d.cts +0 -1
  37. package/build/modern/rules.d.ts +0 -1
  38. package/build/modern/rules.js +0 -7
  39. package/build/modern/rules.js.map +0 -1
  40. package/build/modern/types.cjs +0 -20
  41. package/build/modern/types.cjs.map +0 -1
  42. package/build/modern/types.d.cts +0 -1
  43. package/build/modern/types.d.ts +0 -1
  44. package/build/modern/types.js +0 -1
  45. package/build/modern/types.js.map +0 -1
@@ -1,1214 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name8 in all)
8
- __defProp(target, name8, { get: all[name8], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- default: () => index_default,
24
- plugin: () => plugin
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/rules/exhaustive-deps/exhaustive-deps.rule.ts
29
- var import_utils4 = require("@typescript-eslint/utils");
30
-
31
- // src/utils/ast-utils.ts
32
- var import_utils = require("@typescript-eslint/utils");
33
-
34
- // src/utils/unique-by.ts
35
- function uniqueBy(arr, fn) {
36
- return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
37
- }
38
-
39
- // src/utils/ast-utils.ts
40
- var ASTUtils = {
41
- isNodeOfOneOf(node, types) {
42
- return types.includes(node.type);
43
- },
44
- isIdentifier(node) {
45
- return node.type === import_utils.AST_NODE_TYPES.Identifier;
46
- },
47
- isIdentifierWithName(node, name8) {
48
- return ASTUtils.isIdentifier(node) && node.name === name8;
49
- },
50
- isIdentifierWithOneOfNames(node, name8) {
51
- return ASTUtils.isIdentifier(node) && name8.includes(node.name);
52
- },
53
- isProperty(node) {
54
- return node.type === import_utils.AST_NODE_TYPES.Property;
55
- },
56
- isObjectExpression(node) {
57
- return node.type === import_utils.AST_NODE_TYPES.ObjectExpression;
58
- },
59
- isPropertyWithIdentifierKey(node, key) {
60
- return ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key);
61
- },
62
- findPropertyWithIdentifierKey(properties, key) {
63
- return properties.find(
64
- (x) => ASTUtils.isPropertyWithIdentifierKey(x, key)
65
- );
66
- },
67
- getNestedIdentifiers(node) {
68
- const identifiers = [];
69
- if (ASTUtils.isIdentifier(node)) {
70
- identifiers.push(node);
71
- }
72
- if ("arguments" in node) {
73
- node.arguments.forEach((x) => {
74
- identifiers.push(...ASTUtils.getNestedIdentifiers(x));
75
- });
76
- }
77
- if ("elements" in node) {
78
- node.elements.forEach((x) => {
79
- if (x !== null) {
80
- identifiers.push(...ASTUtils.getNestedIdentifiers(x));
81
- }
82
- });
83
- }
84
- if ("properties" in node) {
85
- node.properties.forEach((x) => {
86
- identifiers.push(...ASTUtils.getNestedIdentifiers(x));
87
- });
88
- }
89
- if ("expressions" in node) {
90
- node.expressions.forEach((x) => {
91
- identifiers.push(...ASTUtils.getNestedIdentifiers(x));
92
- });
93
- }
94
- if ("left" in node) {
95
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.left));
96
- }
97
- if ("right" in node) {
98
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.right));
99
- }
100
- if (node.type === import_utils.AST_NODE_TYPES.Property) {
101
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.value));
102
- }
103
- if (node.type === import_utils.AST_NODE_TYPES.SpreadElement) {
104
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
105
- }
106
- if (node.type === import_utils.AST_NODE_TYPES.MemberExpression) {
107
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.object));
108
- }
109
- if (node.type === import_utils.AST_NODE_TYPES.UnaryExpression) {
110
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
111
- }
112
- if (node.type === import_utils.AST_NODE_TYPES.ChainExpression) {
113
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
114
- }
115
- if (node.type === import_utils.AST_NODE_TYPES.TSNonNullExpression) {
116
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
117
- }
118
- if (node.type === import_utils.AST_NODE_TYPES.ArrowFunctionExpression) {
119
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.body));
120
- }
121
- if (node.type === import_utils.AST_NODE_TYPES.FunctionExpression) {
122
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.body));
123
- }
124
- if (node.type === import_utils.AST_NODE_TYPES.BlockStatement) {
125
- identifiers.push(
126
- ...node.body.map((body) => ASTUtils.getNestedIdentifiers(body)).flat()
127
- );
128
- }
129
- if (node.type === import_utils.AST_NODE_TYPES.ReturnStatement && node.argument) {
130
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
131
- }
132
- return identifiers;
133
- },
134
- isAncestorIsCallee(identifier) {
135
- let previousNode = identifier;
136
- let currentNode = identifier.parent;
137
- while (currentNode !== void 0) {
138
- if (currentNode.type === import_utils.AST_NODE_TYPES.CallExpression && currentNode.callee === previousNode) {
139
- return true;
140
- }
141
- if (currentNode.type !== import_utils.AST_NODE_TYPES.MemberExpression) {
142
- return false;
143
- }
144
- previousNode = currentNode;
145
- currentNode = currentNode.parent;
146
- }
147
- return false;
148
- },
149
- traverseUpOnly(identifier, allowedNodeTypes) {
150
- const parent = identifier.parent;
151
- if (parent !== void 0 && allowedNodeTypes.includes(parent.type)) {
152
- return ASTUtils.traverseUpOnly(parent, allowedNodeTypes);
153
- }
154
- return identifier;
155
- },
156
- isDeclaredInNode(params) {
157
- const { functionNode, reference, scopeManager } = params;
158
- const scope = scopeManager.acquire(functionNode);
159
- if (scope === null) {
160
- return false;
161
- }
162
- return scope.set.has(reference.identifier.name);
163
- },
164
- getExternalRefs(params) {
165
- const { scopeManager, sourceCode, node } = params;
166
- const scope = scopeManager.acquire(node);
167
- if (scope === null) {
168
- return [];
169
- }
170
- const collectReferences = (currentScope) => {
171
- const references2 = [...currentScope.references];
172
- for (const childScope of currentScope.childScopes) {
173
- references2.push(...collectReferences(childScope));
174
- }
175
- return references2;
176
- };
177
- const references = collectReferences(scope).filter((x) => x.isRead() && !scope.set.has(x.identifier.name)).map((x) => {
178
- const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [
179
- import_utils.AST_NODE_TYPES.MemberExpression,
180
- import_utils.AST_NODE_TYPES.Identifier
181
- ]);
182
- return {
183
- variable: x,
184
- node: referenceNode,
185
- text: sourceCode.getText(referenceNode)
186
- };
187
- });
188
- const localRefIds = new Set(
189
- [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0]))
190
- );
191
- const externalRefs = references.filter(
192
- (x) => x.variable.resolved === null || !localRefIds.has(x.text)
193
- );
194
- return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable);
195
- },
196
- mapKeyNodeToText(node, sourceCode) {
197
- return sourceCode.getText(
198
- ASTUtils.traverseUpOnly(node, [
199
- import_utils.AST_NODE_TYPES.MemberExpression,
200
- import_utils.AST_NODE_TYPES.TSNonNullExpression,
201
- import_utils.AST_NODE_TYPES.Identifier
202
- ])
203
- );
204
- },
205
- mapKeyNodeToBaseText(node, sourceCode) {
206
- return ASTUtils.mapKeyNodeToText(node, sourceCode).replace(
207
- /(?:\?(\.)|!)/g,
208
- "$1"
209
- );
210
- },
211
- isValidReactComponentOrHookName(identifier) {
212
- return identifier !== null && identifier !== void 0 && /^(use|[A-Z])/.test(identifier.name);
213
- },
214
- getFunctionAncestor(sourceCode, node) {
215
- var _a;
216
- for (const ancestor of sourceCode.getAncestors(node)) {
217
- if (ASTUtils.isNodeOfOneOf(ancestor, [
218
- import_utils.AST_NODE_TYPES.FunctionDeclaration,
219
- import_utils.AST_NODE_TYPES.FunctionExpression,
220
- import_utils.AST_NODE_TYPES.ArrowFunctionExpression
221
- ])) {
222
- return ancestor;
223
- }
224
- if (((_a = ancestor.parent) == null ? void 0 : _a.type) === import_utils.AST_NODE_TYPES.VariableDeclarator && ancestor.parent.id.type === import_utils.AST_NODE_TYPES.Identifier && ASTUtils.isNodeOfOneOf(ancestor, [
225
- import_utils.AST_NODE_TYPES.FunctionDeclaration,
226
- import_utils.AST_NODE_TYPES.FunctionExpression,
227
- import_utils.AST_NODE_TYPES.ArrowFunctionExpression
228
- ])) {
229
- return ancestor;
230
- }
231
- }
232
- return void 0;
233
- },
234
- getReferencedExpressionByIdentifier(params) {
235
- var _a, _b, _c;
236
- const { node, context } = params;
237
- const sourceCode = context.sourceCode ?? context.getSourceCode();
238
- const scope = context.sourceCode.getScope(node) ? sourceCode.getScope(node) : context.getScope();
239
- const resolvedNode = (_c = (_b = (_a = scope.references.find((ref) => ref.identifier === node)) == null ? void 0 : _a.resolved) == null ? void 0 : _b.defs[0]) == null ? void 0 : _c.node;
240
- if ((resolvedNode == null ? void 0 : resolvedNode.type) !== import_utils.AST_NODE_TYPES.VariableDeclarator) {
241
- return null;
242
- }
243
- return resolvedNode.init;
244
- },
245
- getClosestVariableDeclarator(node) {
246
- let currentNode = node;
247
- while (currentNode.type !== import_utils.AST_NODE_TYPES.Program) {
248
- if (currentNode.type === import_utils.AST_NODE_TYPES.VariableDeclarator) {
249
- return currentNode;
250
- }
251
- currentNode = currentNode.parent;
252
- }
253
- return void 0;
254
- },
255
- getNestedReturnStatements(node) {
256
- const returnStatements = [];
257
- if (node.type === import_utils.AST_NODE_TYPES.ReturnStatement) {
258
- returnStatements.push(node);
259
- }
260
- if ("body" in node && node.body !== void 0 && node.body !== null) {
261
- Array.isArray(node.body) ? node.body.forEach((x) => {
262
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
263
- }) : returnStatements.push(
264
- ...ASTUtils.getNestedReturnStatements(node.body)
265
- );
266
- }
267
- if ("consequent" in node) {
268
- Array.isArray(node.consequent) ? node.consequent.forEach((x) => {
269
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
270
- }) : returnStatements.push(
271
- ...ASTUtils.getNestedReturnStatements(node.consequent)
272
- );
273
- }
274
- if ("alternate" in node && node.alternate !== null) {
275
- Array.isArray(node.alternate) ? node.alternate.forEach((x) => {
276
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
277
- }) : returnStatements.push(
278
- ...ASTUtils.getNestedReturnStatements(node.alternate)
279
- );
280
- }
281
- if ("cases" in node) {
282
- node.cases.forEach((x) => {
283
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
284
- });
285
- }
286
- if ("block" in node) {
287
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block));
288
- }
289
- if ("handler" in node && node.handler !== null) {
290
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler));
291
- }
292
- if ("finalizer" in node && node.finalizer !== null) {
293
- returnStatements.push(
294
- ...ASTUtils.getNestedReturnStatements(node.finalizer)
295
- );
296
- }
297
- if ("expression" in node && node.expression !== true && node.expression !== false) {
298
- returnStatements.push(
299
- ...ASTUtils.getNestedReturnStatements(node.expression)
300
- );
301
- }
302
- if ("test" in node && node.test !== null) {
303
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test));
304
- }
305
- return returnStatements;
306
- }
307
- };
308
-
309
- // src/utils/get-docs-url.ts
310
- var getDocsUrl = (ruleName) => `https://tanstack.com/query/latest/docs/eslint/${ruleName}`;
311
-
312
- // src/utils/detect-react-query-imports.ts
313
- var import_utils2 = require("@typescript-eslint/utils");
314
- function detectTanstackQueryImports(create) {
315
- return (context, optionsWithDefault) => {
316
- const tanstackQueryImportSpecifiers = [];
317
- const helpers = {
318
- isSpecificTanstackQueryImport(node, source) {
319
- return !!tanstackQueryImportSpecifiers.find((specifier) => {
320
- if (specifier.type === import_utils2.TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.parent.type === import_utils2.TSESTree.AST_NODE_TYPES.ImportDeclaration && specifier.parent.source.value === source) {
321
- return node.name === specifier.local.name;
322
- }
323
- return false;
324
- });
325
- },
326
- isTanstackQueryImport(node) {
327
- return !!tanstackQueryImportSpecifiers.find((specifier) => {
328
- if (specifier.type === import_utils2.TSESTree.AST_NODE_TYPES.ImportSpecifier) {
329
- return node.name === specifier.local.name;
330
- }
331
- return false;
332
- });
333
- }
334
- };
335
- const detectionInstructions = {
336
- ImportDeclaration(node) {
337
- if (node.specifiers.length > 0 && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
338
- (node.importKind === "value" || node.importKind === void 0) && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-query")) {
339
- tanstackQueryImportSpecifiers.push(...node.specifiers);
340
- }
341
- }
342
- };
343
- const ruleInstructions = create(context, optionsWithDefault, helpers);
344
- const enhancedRuleInstructions = {};
345
- const allKeys = new Set(
346
- Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
347
- );
348
- allKeys.forEach((instruction) => {
349
- enhancedRuleInstructions[instruction] = (node) => {
350
- var _a;
351
- if (instruction in detectionInstructions) {
352
- (_a = detectionInstructions[instruction]) == null ? void 0 : _a.call(detectionInstructions, node);
353
- }
354
- const ruleInstruction = ruleInstructions[instruction];
355
- if (ruleInstruction) {
356
- return ruleInstruction(node);
357
- }
358
- return void 0;
359
- };
360
- });
361
- return enhancedRuleInstructions;
362
- };
363
- }
364
-
365
- // src/rules/exhaustive-deps/exhaustive-deps.utils.ts
366
- var import_utils3 = require("@typescript-eslint/utils");
367
- var ExhaustiveDepsUtils = {
368
- isRelevantReference(params) {
369
- var _a, _b;
370
- const { sourceCode, reference, scopeManager, node, filename } = params;
371
- const component = ASTUtils.getFunctionAncestor(sourceCode, node);
372
- const queryFnScope = scopeManager.acquire(node);
373
- if (queryFnScope === null) {
374
- return false;
375
- }
376
- let currentScope = ((_a = reference.resolved) == null ? void 0 : _a.scope) ?? null;
377
- while (currentScope !== null) {
378
- if (currentScope === queryFnScope) {
379
- return false;
380
- }
381
- currentScope = currentScope.upper;
382
- }
383
- if (component !== void 0) {
384
- if (!ASTUtils.isDeclaredInNode({
385
- scopeManager,
386
- reference,
387
- functionNode: component
388
- })) {
389
- return false;
390
- }
391
- } else {
392
- const isVueFile = filename.endsWith(".vue");
393
- if (!isVueFile) {
394
- return false;
395
- }
396
- const definition = (_b = reference.resolved) == null ? void 0 : _b.defs[0];
397
- const isGlobalVariable = definition === void 0;
398
- const isImport = (definition == null ? void 0 : definition.type) === "ImportBinding";
399
- if (isGlobalVariable || isImport) {
400
- return false;
401
- }
402
- }
403
- return reference.identifier.name !== "undefined" && reference.identifier.parent.type !== import_utils3.AST_NODE_TYPES.NewExpression && !ExhaustiveDepsUtils.isInstanceOfKind(reference.identifier.parent);
404
- },
405
- isInstanceOfKind(node) {
406
- return node.type === import_utils3.AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof";
407
- },
408
- collectQueryKeyDeps(params) {
409
- const { sourceCode, scopeManager, queryKeyNode } = params;
410
- const deps = /* @__PURE__ */ new Set();
411
- const visitorKeys = sourceCode.visitorKeys;
412
- function add(identifier) {
413
- deps.add(ASTUtils.mapKeyNodeToBaseText(identifier, sourceCode));
414
- }
415
- function visitChildren(node) {
416
- const keys = visitorKeys[node.type] ?? [];
417
- for (const key of keys) {
418
- const value = node[key];
419
- if (Array.isArray(value)) {
420
- for (const item of value) {
421
- if (ExhaustiveDepsUtils.isNode(item)) {
422
- visit(item);
423
- }
424
- }
425
- continue;
426
- }
427
- if (ExhaustiveDepsUtils.isNode(value)) {
428
- visit(value);
429
- }
430
- }
431
- }
432
- function visit(node) {
433
- if (!node) return;
434
- switch (node.type) {
435
- case import_utils3.AST_NODE_TYPES.Identifier:
436
- add(node);
437
- return;
438
- case import_utils3.AST_NODE_TYPES.ArrowFunctionExpression:
439
- case import_utils3.AST_NODE_TYPES.FunctionExpression:
440
- for (const reference of ExhaustiveDepsUtils.collectExternalRefsInFunction(
441
- {
442
- functionNode: node,
443
- scopeManager
444
- }
445
- )) {
446
- if (reference.identifier.type === import_utils3.AST_NODE_TYPES.Identifier) {
447
- add(reference.identifier);
448
- }
449
- }
450
- return;
451
- case import_utils3.AST_NODE_TYPES.Property:
452
- visit(node.value);
453
- return;
454
- case import_utils3.AST_NODE_TYPES.MemberExpression:
455
- if (node.parent.type === import_utils3.AST_NODE_TYPES.CallExpression && node.parent.callee === node && node.object.type === import_utils3.AST_NODE_TYPES.Identifier) {
456
- deps.add(node.object.name);
457
- } else {
458
- visit(node.object);
459
- }
460
- return;
461
- case import_utils3.AST_NODE_TYPES.CallExpression:
462
- node.arguments.forEach((argument) => visit(argument));
463
- if (node.callee.type === import_utils3.AST_NODE_TYPES.MemberExpression || node.callee.type === import_utils3.AST_NODE_TYPES.ChainExpression || node.callee.type === import_utils3.AST_NODE_TYPES.TSNonNullExpression) {
464
- visit(node.callee);
465
- }
466
- return;
467
- }
468
- visitChildren(node);
469
- }
470
- visit(queryKeyNode);
471
- return deps;
472
- },
473
- isNode(value) {
474
- return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
475
- },
476
- collectExternalRefsInFunction(params) {
477
- const { functionNode, scopeManager } = params;
478
- const functionScope = scopeManager.acquire(functionNode);
479
- if (functionScope === null) {
480
- return [];
481
- }
482
- const externalRefs = [];
483
- function collect(scope) {
484
- for (const reference of scope.references) {
485
- if (!reference.isRead() || reference.resolved === null) {
486
- continue;
487
- }
488
- let currentScope = reference.resolved.scope;
489
- let declaredInsideFunction = false;
490
- while (currentScope !== null) {
491
- if (currentScope === functionScope) {
492
- declaredInsideFunction = true;
493
- break;
494
- }
495
- currentScope = currentScope.upper;
496
- }
497
- if (!declaredInsideFunction) {
498
- externalRefs.push(reference);
499
- }
500
- }
501
- for (const childScope of scope.childScopes) {
502
- collect(childScope);
503
- }
504
- }
505
- collect(functionScope);
506
- return externalRefs;
507
- }
508
- };
509
-
510
- // src/rules/exhaustive-deps/exhaustive-deps.rule.ts
511
- var QUERY_KEY = "queryKey";
512
- var QUERY_FN = "queryFn";
513
- var name = "exhaustive-deps";
514
- var createRule = import_utils4.ESLintUtils.RuleCreator(getDocsUrl);
515
- var rule = createRule({
516
- name,
517
- meta: {
518
- type: "problem",
519
- docs: {
520
- description: "Exhaustive deps rule for useQuery",
521
- recommended: "error"
522
- },
523
- messages: {
524
- missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,
525
- fixTo: "Fix to {{result}}"
526
- },
527
- hasSuggestions: true,
528
- fixable: "code",
529
- schema: []
530
- },
531
- defaultOptions: [],
532
- create: detectTanstackQueryImports((context) => {
533
- return {
534
- Property: (node) => {
535
- if (!ASTUtils.isObjectExpression(node.parent) || !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)) {
536
- return;
537
- }
538
- const scopeManager = context.sourceCode.scopeManager;
539
- const queryKey = ASTUtils.findPropertyWithIdentifierKey(
540
- node.parent.properties,
541
- QUERY_KEY
542
- );
543
- const queryFn = ASTUtils.findPropertyWithIdentifierKey(
544
- node.parent.properties,
545
- QUERY_FN
546
- );
547
- if (scopeManager === null || queryKey === void 0 || queryFn === void 0 || !ASTUtils.isNodeOfOneOf(queryFn.value, [
548
- import_utils4.AST_NODE_TYPES.ArrowFunctionExpression,
549
- import_utils4.AST_NODE_TYPES.FunctionExpression,
550
- import_utils4.AST_NODE_TYPES.ConditionalExpression
551
- ])) {
552
- return;
553
- }
554
- const queryKeyNode = dereferenceVariablesAndTypeAssertions(
555
- queryKey.value,
556
- context
557
- );
558
- const externalRefs = ASTUtils.getExternalRefs({
559
- scopeManager,
560
- sourceCode: context.sourceCode,
561
- node: getQueryFnRelevantNode(queryFn)
562
- });
563
- const relevantRefs = externalRefs.filter(
564
- (reference) => ExhaustiveDepsUtils.isRelevantReference({
565
- sourceCode: context.sourceCode,
566
- reference,
567
- scopeManager,
568
- node: getQueryFnRelevantNode(queryFn),
569
- filename: context.filename
570
- })
571
- );
572
- const queryKeyDeps = ExhaustiveDepsUtils.collectQueryKeyDeps({
573
- sourceCode: context.sourceCode,
574
- scopeManager,
575
- queryKeyNode
576
- });
577
- const missingRefs = relevantRefs.map((ref) => ({
578
- ref,
579
- text: ASTUtils.isAncestorIsCallee(ref.identifier) ? ref.identifier.name : ASTUtils.mapKeyNodeToBaseText(
580
- ref.identifier,
581
- context.sourceCode
582
- )
583
- })).filter(({ ref, text }) => {
584
- return !ref.isTypeReference && !queryKeyDeps.has(text) && !queryKeyDeps.has(text.split(/[?.]/)[0] ?? "");
585
- }).map(({ ref, text }) => ({
586
- identifier: ref.identifier,
587
- text
588
- }));
589
- const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text);
590
- if (uniqueMissingRefs.length > 0) {
591
- const missingAsText = uniqueMissingRefs.map((ref) => ref.text).join(", ");
592
- const queryKeyValue = context.sourceCode.getText(queryKeyNode);
593
- const existingWithMissing = queryKeyValue === "[]" ? `[${missingAsText}]` : queryKeyValue.replace(/\]$/, `, ${missingAsText}]`);
594
- const suggestions = [];
595
- if (queryKeyNode.type === import_utils4.AST_NODE_TYPES.ArrayExpression) {
596
- suggestions.push({
597
- messageId: "fixTo",
598
- data: { result: existingWithMissing },
599
- fix(fixer) {
600
- return fixer.replaceText(queryKeyNode, existingWithMissing);
601
- }
602
- });
603
- }
604
- context.report({
605
- node,
606
- messageId: "missingDeps",
607
- data: {
608
- deps: uniqueMissingRefs.map((ref) => ref.text).join(", ")
609
- },
610
- suggest: suggestions
611
- });
612
- }
613
- }
614
- };
615
- })
616
- });
617
- function getQueryFnRelevantNode(queryFn) {
618
- if (queryFn.value.type !== import_utils4.AST_NODE_TYPES.ConditionalExpression) {
619
- return queryFn.value;
620
- }
621
- if (queryFn.value.consequent.type === import_utils4.AST_NODE_TYPES.Identifier && queryFn.value.consequent.name === "skipToken") {
622
- return queryFn.value.alternate;
623
- }
624
- return queryFn.value.consequent;
625
- }
626
- function dereferenceVariablesAndTypeAssertions(queryKeyNode, context) {
627
- const visitedNodes = /* @__PURE__ */ new Set();
628
- for (let i = 0; i < 1 << 8; ++i) {
629
- if (visitedNodes.has(queryKeyNode)) {
630
- return queryKeyNode;
631
- }
632
- visitedNodes.add(queryKeyNode);
633
- switch (queryKeyNode.type) {
634
- case import_utils4.AST_NODE_TYPES.TSAsExpression:
635
- queryKeyNode = queryKeyNode.expression;
636
- break;
637
- case import_utils4.AST_NODE_TYPES.Identifier: {
638
- const expression = ASTUtils.getReferencedExpressionByIdentifier({
639
- context,
640
- node: queryKeyNode
641
- });
642
- if (expression == null) {
643
- return queryKeyNode;
644
- }
645
- queryKeyNode = expression;
646
- break;
647
- }
648
- default:
649
- return queryKeyNode;
650
- }
651
- }
652
- return queryKeyNode;
653
- }
654
-
655
- // src/rules/stable-query-client/stable-query-client.rule.ts
656
- var import_utils5 = require("@typescript-eslint/utils");
657
- var name2 = "stable-query-client";
658
- var createRule2 = import_utils5.ESLintUtils.RuleCreator(getDocsUrl);
659
- var rule2 = createRule2({
660
- name: name2,
661
- meta: {
662
- type: "problem",
663
- docs: {
664
- description: "Makes sure that QueryClient is stable",
665
- recommended: "error"
666
- },
667
- messages: {
668
- unstable: [
669
- "QueryClient is not stable. It should be either extracted from the component or wrapped in React.useState.",
670
- "See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable"
671
- ].join("\n"),
672
- fixTo: "Fix to {{result}}"
673
- },
674
- hasSuggestions: true,
675
- fixable: "code",
676
- schema: []
677
- },
678
- defaultOptions: [],
679
- create: detectTanstackQueryImports((context, _, helpers) => {
680
- return {
681
- NewExpression: (node) => {
682
- if (node.callee.type !== import_utils5.AST_NODE_TYPES.Identifier || node.callee.name !== "QueryClient" || node.parent.type !== import_utils5.AST_NODE_TYPES.VariableDeclarator || !helpers.isSpecificTanstackQueryImport(
683
- node.callee,
684
- "@tanstack/react-query"
685
- )) {
686
- return;
687
- }
688
- const fnAncestor = ASTUtils.getFunctionAncestor(
689
- context.sourceCode,
690
- node
691
- );
692
- const isReactServerComponent = (fnAncestor == null ? void 0 : fnAncestor.async) === true;
693
- if (!ASTUtils.isValidReactComponentOrHookName(fnAncestor == null ? void 0 : fnAncestor.id) || isReactServerComponent) {
694
- return;
695
- }
696
- context.report({
697
- node: node.parent,
698
- messageId: "unstable",
699
- fix: (() => {
700
- const { parent } = node;
701
- if (parent.id.type !== import_utils5.AST_NODE_TYPES.Identifier) {
702
- return;
703
- }
704
- const sourceCode = context.sourceCode ?? context.getSourceCode();
705
- const nodeText = sourceCode.getText(node);
706
- const variableName = parent.id.name;
707
- return (fixer) => {
708
- return fixer.replaceTextRange(
709
- [parent.range[0], parent.range[1]],
710
- `[${variableName}] = React.useState(() => ${nodeText})`
711
- );
712
- };
713
- })()
714
- });
715
- }
716
- };
717
- })
718
- });
719
-
720
- // src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts
721
- var import_utils7 = require("@typescript-eslint/utils");
722
-
723
- // src/rules/no-rest-destructuring/no-rest-destructuring.utils.ts
724
- var import_utils6 = require("@typescript-eslint/utils");
725
- var NoRestDestructuringUtils = {
726
- isObjectRestDestructuring(node) {
727
- if (node.type !== import_utils6.AST_NODE_TYPES.ObjectPattern) {
728
- return false;
729
- }
730
- return node.properties.some((p) => p.type === import_utils6.AST_NODE_TYPES.RestElement);
731
- }
732
- };
733
-
734
- // src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts
735
- var name3 = "no-rest-destructuring";
736
- var queryHooks = [
737
- "useQuery",
738
- "useQueries",
739
- "useInfiniteQuery",
740
- "useSuspenseQuery",
741
- "useSuspenseQueries",
742
- "useSuspenseInfiniteQuery"
743
- ];
744
- var createRule3 = import_utils7.ESLintUtils.RuleCreator(getDocsUrl);
745
- var rule3 = createRule3({
746
- name: name3,
747
- meta: {
748
- type: "problem",
749
- docs: {
750
- description: "Disallows rest destructuring in queries",
751
- recommended: "warn"
752
- },
753
- messages: {
754
- objectRestDestructure: `Object rest destructuring on a query will observe all changes to the query, leading to excessive re-renders.`
755
- },
756
- schema: []
757
- },
758
- defaultOptions: [],
759
- create: detectTanstackQueryImports((context, _, helpers) => {
760
- const queryResultVariables = /* @__PURE__ */ new Set();
761
- return {
762
- CallExpression: (node) => {
763
- if (!ASTUtils.isIdentifierWithOneOfNames(node.callee, queryHooks) || node.parent.type !== import_utils7.AST_NODE_TYPES.VariableDeclarator || !helpers.isTanstackQueryImport(node.callee)) {
764
- return;
765
- }
766
- const returnValue = node.parent.id;
767
- if (node.callee.name !== "useQueries" && node.callee.name !== "useSuspenseQueries") {
768
- if (NoRestDestructuringUtils.isObjectRestDestructuring(returnValue)) {
769
- return context.report({
770
- node: node.parent,
771
- messageId: "objectRestDestructure"
772
- });
773
- }
774
- if (returnValue.type === import_utils7.AST_NODE_TYPES.Identifier) {
775
- queryResultVariables.add(returnValue.name);
776
- }
777
- return;
778
- }
779
- if (returnValue.type !== import_utils7.AST_NODE_TYPES.ArrayPattern) {
780
- if (returnValue.type === import_utils7.AST_NODE_TYPES.Identifier) {
781
- queryResultVariables.add(returnValue.name);
782
- }
783
- return;
784
- }
785
- returnValue.elements.forEach((queryResult) => {
786
- if (queryResult === null) {
787
- return;
788
- }
789
- if (NoRestDestructuringUtils.isObjectRestDestructuring(queryResult)) {
790
- context.report({
791
- node: queryResult,
792
- messageId: "objectRestDestructure"
793
- });
794
- }
795
- });
796
- },
797
- VariableDeclarator: (node) => {
798
- var _a;
799
- if (((_a = node.init) == null ? void 0 : _a.type) === import_utils7.AST_NODE_TYPES.Identifier && queryResultVariables.has(node.init.name) && NoRestDestructuringUtils.isObjectRestDestructuring(node.id)) {
800
- context.report({
801
- node,
802
- messageId: "objectRestDestructure"
803
- });
804
- }
805
- },
806
- SpreadElement: (node) => {
807
- if (node.argument.type === import_utils7.AST_NODE_TYPES.Identifier && queryResultVariables.has(node.argument.name)) {
808
- context.report({
809
- node,
810
- messageId: "objectRestDestructure"
811
- });
812
- }
813
- }
814
- };
815
- })
816
- });
817
-
818
- // src/rules/no-unstable-deps/no-unstable-deps.rule.ts
819
- var import_utils8 = require("@typescript-eslint/utils");
820
- var name4 = "no-unstable-deps";
821
- var reactHookNames = ["useEffect", "useCallback", "useMemo"];
822
- var useQueryHookNames = [
823
- "useQuery",
824
- "useSuspenseQuery",
825
- "useQueries",
826
- "useSuspenseQueries",
827
- "useInfiniteQuery",
828
- "useSuspenseInfiniteQuery"
829
- ];
830
- var allHookNames = ["useMutation", ...useQueryHookNames];
831
- var createRule4 = import_utils8.ESLintUtils.RuleCreator(getDocsUrl);
832
- var rule4 = createRule4({
833
- name: name4,
834
- meta: {
835
- type: "problem",
836
- docs: {
837
- description: "Disallow putting the result of query hooks directly in a React hook dependency array",
838
- recommended: "error"
839
- },
840
- messages: {
841
- noUnstableDeps: `The result of {{queryHook}} is not referentially stable, so don't pass it directly into the dependencies array of {{reactHook}}. Instead, destructure the return value of {{queryHook}} and pass the destructured values into the dependency array of {{reactHook}}.`
842
- },
843
- schema: []
844
- },
845
- defaultOptions: [],
846
- create: detectTanstackQueryImports((context, _options, helpers) => {
847
- const trackedVariables = {};
848
- const hookAliasMap = {};
849
- function getReactHook(node) {
850
- if (node.callee.type === "Identifier") {
851
- const calleeName = node.callee.name;
852
- if (reactHookNames.includes(calleeName) || calleeName in hookAliasMap) {
853
- return calleeName;
854
- }
855
- } else if (node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "React" && node.callee.property.type === "Identifier" && reactHookNames.includes(node.callee.property.name)) {
856
- return node.callee.property.name;
857
- }
858
- return void 0;
859
- }
860
- function collectVariableNames(pattern, queryHook) {
861
- if (pattern.type === import_utils8.AST_NODE_TYPES.Identifier) {
862
- trackedVariables[pattern.name] = queryHook;
863
- }
864
- }
865
- function hasCombineProperty(callExpression) {
866
- if (callExpression.arguments.length === 0) return false;
867
- const firstArg = callExpression.arguments[0];
868
- if (!firstArg || firstArg.type !== import_utils8.AST_NODE_TYPES.ObjectExpression)
869
- return false;
870
- return firstArg.properties.some(
871
- (prop) => prop.type === import_utils8.AST_NODE_TYPES.Property && prop.key.type === import_utils8.AST_NODE_TYPES.Identifier && prop.key.name === "combine"
872
- );
873
- }
874
- return {
875
- ImportDeclaration(node) {
876
- if (node.specifiers.length > 0 && node.importKind === "value" && node.source.value === "React") {
877
- node.specifiers.forEach((specifier) => {
878
- if (specifier.type === import_utils8.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils8.AST_NODE_TYPES.Identifier && reactHookNames.includes(specifier.imported.name)) {
879
- hookAliasMap[specifier.local.name] = specifier.imported.name;
880
- }
881
- });
882
- }
883
- },
884
- VariableDeclarator(node) {
885
- if (node.init !== null && node.init.type === import_utils8.AST_NODE_TYPES.CallExpression && node.init.callee.type === import_utils8.AST_NODE_TYPES.Identifier && allHookNames.includes(node.init.callee.name) && helpers.isTanstackQueryImport(node.init.callee)) {
886
- if (node.init.callee.name === "useQueries" && hasCombineProperty(node.init)) {
887
- return;
888
- }
889
- collectVariableNames(node.id, node.init.callee.name);
890
- }
891
- },
892
- CallExpression: (node) => {
893
- var _a;
894
- const reactHook = getReactHook(node);
895
- if (reactHook !== void 0 && node.arguments.length > 1 && ((_a = node.arguments[1]) == null ? void 0 : _a.type) === import_utils8.AST_NODE_TYPES.ArrayExpression) {
896
- const depsArray = node.arguments[1].elements;
897
- depsArray.forEach((dep) => {
898
- if (dep !== null && dep.type === import_utils8.AST_NODE_TYPES.Identifier && trackedVariables[dep.name] !== void 0) {
899
- const queryHook = trackedVariables[dep.name];
900
- context.report({
901
- node: dep,
902
- messageId: "noUnstableDeps",
903
- data: {
904
- queryHook,
905
- reactHook
906
- }
907
- });
908
- }
909
- });
910
- }
911
- }
912
- };
913
- })
914
- });
915
-
916
- // src/utils/create-property-order-rule.ts
917
- var import_utils9 = require("@typescript-eslint/utils");
918
-
919
- // src/utils/sort-data-by-order.ts
920
- function sortDataByOrder(data, orderRules, key) {
921
- const getSubsetIndex = (item, subsets) => {
922
- var _a;
923
- for (let i = 0; i < subsets.length; i++) {
924
- if ((_a = subsets[i]) == null ? void 0 : _a.includes(item)) {
925
- return i;
926
- }
927
- }
928
- return null;
929
- };
930
- const orderSets = orderRules.reduce(
931
- (sets, [A, B]) => [...sets, A, B],
932
- []
933
- );
934
- const inOrderArray = data.filter(
935
- (item) => getSubsetIndex(item[key], orderSets) !== null
936
- );
937
- let wasResorted = false;
938
- const sortedArray = inOrderArray.sort((a, b) => {
939
- const aKey = a[key], bKey = b[key];
940
- const aSubsetIndex = getSubsetIndex(aKey, orderSets);
941
- const bSubsetIndex = getSubsetIndex(bKey, orderSets);
942
- if (aSubsetIndex !== null && bSubsetIndex !== null && aSubsetIndex !== bSubsetIndex) {
943
- return aSubsetIndex - bSubsetIndex;
944
- }
945
- return 0;
946
- });
947
- const inOrderIterator = sortedArray.values();
948
- const result = data.map((item) => {
949
- if (getSubsetIndex(item[key], orderSets) !== null) {
950
- const sortedItem = inOrderIterator.next().value;
951
- if (sortedItem[key] !== item[key]) {
952
- wasResorted = true;
953
- }
954
- return sortedItem;
955
- }
956
- return item;
957
- });
958
- if (!wasResorted) {
959
- return null;
960
- }
961
- return result;
962
- }
963
-
964
- // src/utils/create-property-order-rule.ts
965
- var createRule5 = import_utils9.ESLintUtils.RuleCreator(getDocsUrl);
966
- function createPropertyOrderRule(options, targetFunctions, orderRules) {
967
- const targetFunctionSet = new Set(targetFunctions);
968
- function isTargetFunction(node) {
969
- return targetFunctionSet.has(node);
970
- }
971
- return createRule5({
972
- ...options,
973
- create: detectTanstackQueryImports((context) => {
974
- return {
975
- CallExpression(node) {
976
- if (node.callee.type !== import_utils9.AST_NODE_TYPES.Identifier) {
977
- return;
978
- }
979
- const functions = node.callee.name;
980
- if (!isTargetFunction(functions)) {
981
- return;
982
- }
983
- const argument = node.arguments[0];
984
- if (argument === void 0 || argument.type !== "ObjectExpression") {
985
- return;
986
- }
987
- const allProperties = argument.properties;
988
- if (allProperties.length < 2) {
989
- return;
990
- }
991
- const properties = allProperties.flatMap((p, index) => {
992
- if (p.type === import_utils9.AST_NODE_TYPES.Property && p.key.type === import_utils9.AST_NODE_TYPES.Identifier) {
993
- return { name: p.key.name, property: p };
994
- } else return { name: `_property_${index}`, property: p };
995
- });
996
- const sortedProperties = sortDataByOrder(
997
- properties,
998
- orderRules,
999
- "name"
1000
- );
1001
- if (sortedProperties === null) {
1002
- return;
1003
- }
1004
- context.report({
1005
- node: argument,
1006
- data: { function: node.callee.name },
1007
- messageId: "invalidOrder",
1008
- fix(fixer) {
1009
- const sourceCode = context.sourceCode;
1010
- const reorderedText = sortedProperties.reduce(
1011
- (sourceText, specifier, index) => {
1012
- let textBetweenProperties = "";
1013
- if (index < allProperties.length - 1) {
1014
- textBetweenProperties = sourceCode.getText().slice(
1015
- allProperties[index].range[1],
1016
- allProperties[index + 1].range[0]
1017
- );
1018
- }
1019
- return sourceText + sourceCode.getText(specifier.property) + textBetweenProperties;
1020
- },
1021
- ""
1022
- );
1023
- return fixer.replaceTextRange(
1024
- [allProperties[0].range[0], allProperties.at(-1).range[1]],
1025
- reorderedText
1026
- );
1027
- }
1028
- });
1029
- }
1030
- };
1031
- })
1032
- });
1033
- }
1034
-
1035
- // src/rules/infinite-query-property-order/constants.ts
1036
- var infiniteQueryFunctions = [
1037
- "infiniteQueryOptions",
1038
- "useInfiniteQuery",
1039
- "useSuspenseInfiniteQuery"
1040
- ];
1041
- var sortRules = [
1042
- [["queryFn"], ["getPreviousPageParam", "getNextPageParam"]]
1043
- ];
1044
-
1045
- // src/rules/infinite-query-property-order/infinite-query-property-order.rule.ts
1046
- var name5 = "infinite-query-property-order";
1047
- var rule5 = createPropertyOrderRule(
1048
- {
1049
- name: name5,
1050
- meta: {
1051
- type: "problem",
1052
- docs: {
1053
- description: "Ensure correct order of inference sensitive properties for infinite queries",
1054
- recommended: "error"
1055
- },
1056
- messages: {
1057
- invalidOrder: "Invalid order of properties for `{{function}}`."
1058
- },
1059
- schema: [],
1060
- hasSuggestions: true,
1061
- fixable: "code"
1062
- },
1063
- defaultOptions: []
1064
- },
1065
- infiniteQueryFunctions,
1066
- sortRules
1067
- );
1068
-
1069
- // src/rules/no-void-query-fn/no-void-query-fn.rule.ts
1070
- var import_utils10 = require("@typescript-eslint/utils");
1071
- var TypeFlags = {
1072
- Void: 16384,
1073
- Undefined: 32768
1074
- };
1075
- var name6 = "no-void-query-fn";
1076
- var createRule6 = import_utils10.ESLintUtils.RuleCreator(getDocsUrl);
1077
- var rule6 = createRule6({
1078
- name: name6,
1079
- meta: {
1080
- type: "problem",
1081
- docs: {
1082
- description: "Ensures queryFn returns a non-undefined value",
1083
- recommended: "error"
1084
- },
1085
- messages: {
1086
- noVoidReturn: "queryFn must return a non-undefined value"
1087
- },
1088
- schema: []
1089
- },
1090
- defaultOptions: [],
1091
- create: detectTanstackQueryImports((context) => {
1092
- return {
1093
- Property(node) {
1094
- var _a;
1095
- if (!ASTUtils.isObjectExpression(node.parent) || !ASTUtils.isIdentifierWithName(node.key, "queryFn")) {
1096
- return;
1097
- }
1098
- const parserServices = context.sourceCode.parserServices;
1099
- if (!parserServices || !parserServices.esTreeNodeToTSNodeMap || !parserServices.program) {
1100
- return;
1101
- }
1102
- const checker = parserServices.program.getTypeChecker();
1103
- const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node.value);
1104
- const type = checker.getTypeAtLocation(tsNode);
1105
- if (type.getCallSignatures().length > 0) {
1106
- const returnType = (_a = type.getCallSignatures()[0]) == null ? void 0 : _a.getReturnType();
1107
- if (!returnType) {
1108
- return;
1109
- }
1110
- if (isIllegalReturn(checker, returnType)) {
1111
- context.report({
1112
- node: node.value,
1113
- messageId: "noVoidReturn"
1114
- });
1115
- }
1116
- }
1117
- }
1118
- };
1119
- })
1120
- });
1121
- function isIllegalReturn(checker, type) {
1122
- const awaited = checker.getAwaitedType(type);
1123
- if (!awaited) return false;
1124
- if (awaited.isUnion()) {
1125
- return awaited.types.some((t) => isIllegalReturn(checker, t));
1126
- }
1127
- return awaited.flags & (TypeFlags.Void | TypeFlags.Undefined) ? true : false;
1128
- }
1129
-
1130
- // src/rules/mutation-property-order/constants.ts
1131
- var mutationFunctions = ["useMutation"];
1132
- var sortRules2 = [[["onMutate"], ["onError", "onSettled"]]];
1133
-
1134
- // src/rules/mutation-property-order/mutation-property-order.rule.ts
1135
- var name7 = "mutation-property-order";
1136
- var rule7 = createPropertyOrderRule(
1137
- {
1138
- name: name7,
1139
- meta: {
1140
- type: "problem",
1141
- docs: {
1142
- description: "Ensure correct order of inference-sensitive properties in useMutation()",
1143
- recommended: "error"
1144
- },
1145
- messages: {
1146
- invalidOrder: "Invalid order of properties for `{{function}}`."
1147
- },
1148
- schema: [],
1149
- hasSuggestions: true,
1150
- fixable: "code"
1151
- },
1152
- defaultOptions: []
1153
- },
1154
- mutationFunctions,
1155
- sortRules2
1156
- );
1157
-
1158
- // src/rules.ts
1159
- var rules = {
1160
- [name]: rule,
1161
- [name2]: rule2,
1162
- [name3]: rule3,
1163
- [name4]: rule4,
1164
- [name5]: rule5,
1165
- [name6]: rule6,
1166
- [name7]: rule7
1167
- };
1168
-
1169
- // src/index.ts
1170
- var plugin = {
1171
- meta: {
1172
- name: "@tanstack/eslint-plugin-query"
1173
- },
1174
- configs: {
1175
- recommended: {
1176
- plugins: ["@tanstack/query"],
1177
- rules: {
1178
- "@tanstack/query/exhaustive-deps": "error",
1179
- "@tanstack/query/no-rest-destructuring": "warn",
1180
- "@tanstack/query/stable-query-client": "error",
1181
- "@tanstack/query/no-unstable-deps": "error",
1182
- "@tanstack/query/infinite-query-property-order": "error",
1183
- "@tanstack/query/no-void-query-fn": "error",
1184
- "@tanstack/query/mutation-property-order": "error"
1185
- }
1186
- },
1187
- "flat/recommended": [
1188
- {
1189
- name: "tanstack/query/flat/recommended",
1190
- plugins: {
1191
- "@tanstack/query": {}
1192
- // Assigned after plugin object created
1193
- },
1194
- rules: {
1195
- "@tanstack/query/exhaustive-deps": "error",
1196
- "@tanstack/query/no-rest-destructuring": "warn",
1197
- "@tanstack/query/stable-query-client": "error",
1198
- "@tanstack/query/no-unstable-deps": "error",
1199
- "@tanstack/query/infinite-query-property-order": "error",
1200
- "@tanstack/query/no-void-query-fn": "error",
1201
- "@tanstack/query/mutation-property-order": "error"
1202
- }
1203
- }
1204
- ]
1205
- },
1206
- rules
1207
- };
1208
- plugin.configs["flat/recommended"][0].plugins["@tanstack/query"] = plugin;
1209
- var index_default = plugin;
1210
- // Annotate the CommonJS export names for ESM import in node:
1211
- 0 && (module.exports = {
1212
- plugin
1213
- });
1214
- //# sourceMappingURL=index.cjs.map