@tanstack/eslint-plugin-query 5.101.4 → 5.102.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 (68) hide show
  1. package/build/legacy/index.cjs +46 -1812
  2. package/build/legacy/index.cjs.map +1 -1
  3. package/build/legacy/index.d.cts +82 -3
  4. package/build/legacy/index.d.cts.map +1 -0
  5. package/build/legacy/index.d.ts +82 -3
  6. package/build/legacy/index.d.ts.map +1 -0
  7. package/build/legacy/index.js +39 -56
  8. package/build/legacy/index.js.map +1 -1
  9. package/build/legacy/rules-Bv1SB3jU.js +1172 -0
  10. package/build/legacy/rules-Bv1SB3jU.js.map +1 -0
  11. package/build/legacy/rules-ChMfhjqW.cjs +1177 -0
  12. package/build/legacy/rules-ChMfhjqW.cjs.map +1 -0
  13. package/build/legacy/rules.cjs +3 -1761
  14. package/build/legacy/rules.d.cts +7 -1
  15. package/build/legacy/rules.d.cts.map +1 -0
  16. package/build/legacy/rules.d.ts +7 -1
  17. package/build/legacy/rules.d.ts.map +1 -0
  18. package/build/legacy/rules.js +2 -7
  19. package/build/legacy/types.cjs +1 -19
  20. package/build/legacy/types.d.cts +7 -1
  21. package/build/legacy/types.d.cts.map +1 -0
  22. package/build/legacy/types.d.ts +7 -1
  23. package/build/legacy/types.d.ts.map +1 -0
  24. package/build/legacy/types.js +1 -1
  25. package/build/modern/index.cjs +46 -1798
  26. package/build/modern/index.cjs.map +1 -1
  27. package/build/modern/index.d.cts +83 -3
  28. package/build/modern/index.d.cts.map +1 -0
  29. package/build/modern/index.d.ts +83 -3
  30. package/build/modern/index.d.ts.map +1 -0
  31. package/build/modern/index.js +40 -56
  32. package/build/modern/index.js.map +1 -1
  33. package/build/modern/rules-B1yVUvLh.cjs +1158 -0
  34. package/build/modern/rules-B1yVUvLh.cjs.map +1 -0
  35. package/build/modern/rules-DzixDjO7.js +1153 -0
  36. package/build/modern/rules-DzixDjO7.js.map +1 -0
  37. package/build/modern/rules.cjs +3 -1747
  38. package/build/modern/rules.d.cts +8 -1
  39. package/build/modern/rules.d.cts.map +1 -0
  40. package/build/modern/rules.d.ts +8 -1
  41. package/build/modern/rules.d.ts.map +1 -0
  42. package/build/modern/rules.js +3 -7
  43. package/build/modern/types.cjs +1 -19
  44. package/build/modern/types.d.cts +8 -1
  45. package/build/modern/types.d.cts.map +1 -0
  46. package/build/modern/types.d.ts +8 -1
  47. package/build/modern/types.d.ts.map +1 -0
  48. package/build/modern/types.js +2 -1
  49. package/package.json +4 -6
  50. package/src/rules/exhaustive-deps/exhaustive-deps.utils.ts +1 -1
  51. package/src/rules/no-unstable-deps/no-unstable-deps.rule.ts +3 -3
  52. package/src/utils/ast-utils.ts +0 -194
  53. package/build/legacy/_tsup-dts-rollup.d.cts +0 -319
  54. package/build/legacy/_tsup-dts-rollup.d.ts +0 -319
  55. package/build/legacy/chunk-25PZGVEE.js +0 -1735
  56. package/build/legacy/chunk-25PZGVEE.js.map +0 -1
  57. package/build/legacy/rules.cjs.map +0 -1
  58. package/build/legacy/rules.js.map +0 -1
  59. package/build/legacy/types.cjs.map +0 -1
  60. package/build/legacy/types.js.map +0 -1
  61. package/build/modern/_tsup-dts-rollup.d.cts +0 -319
  62. package/build/modern/_tsup-dts-rollup.d.ts +0 -319
  63. package/build/modern/chunk-LDCUUAIY.js +0 -1721
  64. package/build/modern/chunk-LDCUUAIY.js.map +0 -1
  65. package/build/modern/rules.cjs.map +0 -1
  66. package/build/modern/rules.js.map +0 -1
  67. package/build/modern/types.cjs.map +0 -1
  68. package/build/modern/types.js.map +0 -1
@@ -1 +1,8 @@
1
- export { rules } from './_tsup-dts-rollup.cjs';
1
+ import { ExtraRuleDocs } from "./types.cjs";
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ //#region src/rules.d.ts
4
+ declare const rules: Record<string, ESLintUtils.RuleModule<string, ReadonlyArray<unknown>, ExtraRuleDocs, ESLintUtils.RuleListener>>;
5
+ //#endregion
6
+ export { rules };
7
+
8
+ //# sourceMappingURL=rules.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.cts","names":[],"sources":["../../src/rules.ts"],"mappings":";;;cAWa,OAAO,eAElB,YAAY,mBAEV,wBACA,eACA,YAAY"}
@@ -1 +1,8 @@
1
- export { rules } from './_tsup-dts-rollup.js';
1
+ import { ExtraRuleDocs } from "./types.js";
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ //#region src/rules.d.ts
4
+ declare const rules: Record<string, ESLintUtils.RuleModule<string, ReadonlyArray<unknown>, ExtraRuleDocs, ESLintUtils.RuleListener>>;
5
+ //#endregion
6
+ export { rules };
7
+
8
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","names":[],"sources":["../../src/rules.ts"],"mappings":";;;cAWa,OAAO,eAElB,YAAY,mBAEV,wBACA,eACA,YAAY"}
@@ -1,7 +1,3 @@
1
- import {
2
- rules
3
- } from "./chunk-LDCUUAIY.js";
4
- export {
5
- rules
6
- };
7
- //# sourceMappingURL=rules.js.map
1
+ import { t as rules } from "./rules-DzixDjO7.js";
2
+ export { rules };
3
+
@@ -1,20 +1,2 @@
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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
15
2
 
16
- // src/types.ts
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- module.exports = module.exports.default
20
- //# sourceMappingURL=types.cjs.map
@@ -1 +1,8 @@
1
- export { ExtraRuleDocs } from './_tsup-dts-rollup.cjs';
1
+ //#region src/types.d.ts
2
+ type ExtraRuleDocs = {
3
+ recommended: 'strict' | 'error' | 'warn';
4
+ };
5
+ //#endregion
6
+ export { ExtraRuleDocs };
7
+
8
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";KAAY;EACV"}
@@ -1 +1,8 @@
1
- export { ExtraRuleDocs } from './_tsup-dts-rollup.js';
1
+ //#region src/types.d.ts
2
+ type ExtraRuleDocs = {
3
+ recommended: 'strict' | 'error' | 'warn';
4
+ };
5
+ //#endregion
6
+ export { ExtraRuleDocs };
7
+
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";KAAY;EACV"}
@@ -1 +1,2 @@
1
- //# sourceMappingURL=types.js.map
1
+ export {};
2
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/eslint-plugin-query",
3
- "version": "5.101.4",
3
+ "version": "5.102.0",
4
4
  "description": "ESLint plugin for TanStack Query",
5
5
  "author": "Eliya Cohen",
6
6
  "license": "MIT",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "peerDependencies": {
53
53
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
54
- "typescript": "^5.4.0 || ^6.0.0"
54
+ "typescript": "^5.6.0 || ^6.0.0 || ^7.0.0"
55
55
  },
56
56
  "peerDependenciesMeta": {
57
57
  "typescript": {
@@ -63,17 +63,15 @@
63
63
  "compile": "tsc --build",
64
64
  "test:eslint": "eslint --concurrency=auto ./src",
65
65
  "test:types": "npm-run-all --serial test:types:*",
66
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build",
67
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build",
68
66
  "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
69
67
  "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
70
68
  "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build",
71
69
  "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build",
72
70
  "test:types:tscurrent": "tsc --build",
73
- "test:types:ts60": "node ../../node_modules/typescript60/lib/tsc.js --build",
71
+ "test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --build",
74
72
  "test:lib": "vitest",
75
73
  "test:lib:dev": "pnpm run test:lib --watch",
76
74
  "test:build": "publint --strict && attw --pack",
77
- "build": "tsup --tsconfig tsconfig.prod.json"
75
+ "build": "tsdown --tsconfig tsconfig.prod.json"
78
76
  }
79
77
  }
@@ -285,7 +285,7 @@ export const ExhaustiveDepsUtils = {
285
285
  isInstanceOfKind(node: TSESTree.Node) {
286
286
  return (
287
287
  node.type === AST_NODE_TYPES.BinaryExpression &&
288
- node.operator === 'instanceof'
288
+ (node as TSESTree.SymmetricBinaryExpression).operator === 'instanceof'
289
289
  )
290
290
  },
291
291
 
@@ -35,9 +35,9 @@ export const rule = createRule({
35
35
  defaultOptions: [],
36
36
 
37
37
  create: detectTanstackQueryImports((context, _options, helpers) => {
38
- const trackedVariables: Record<string, string> = {}
39
- const trackedCustomHooks: Record<string, string> = {}
40
- const hookAliasMap: Record<string, string> = {}
38
+ const trackedVariables: Record<string, string> = Object.create(null)
39
+ const trackedCustomHooks: Record<string, string> = Object.create(null)
40
+ const hookAliasMap: Record<string, string> = Object.create(null)
41
41
  const pendingVariableDeclarators: Array<TSESTree.VariableDeclarator> = []
42
42
  const pendingDependencyChecks: Array<{
43
43
  reactHook: string
@@ -46,91 +46,6 @@ export const ASTUtils = {
46
46
  ASTUtils.isPropertyWithIdentifierKey(x, key),
47
47
  )
48
48
  },
49
- getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier> {
50
- const identifiers: Array<TSESTree.Identifier> = []
51
-
52
- if (ASTUtils.isIdentifier(node)) {
53
- identifiers.push(node)
54
- }
55
-
56
- if ('arguments' in node) {
57
- node.arguments.forEach((x) => {
58
- identifiers.push(...ASTUtils.getNestedIdentifiers(x))
59
- })
60
- }
61
-
62
- if ('elements' in node) {
63
- node.elements.forEach((x) => {
64
- if (x !== null) {
65
- identifiers.push(...ASTUtils.getNestedIdentifiers(x))
66
- }
67
- })
68
- }
69
-
70
- if ('properties' in node) {
71
- node.properties.forEach((x) => {
72
- identifiers.push(...ASTUtils.getNestedIdentifiers(x))
73
- })
74
- }
75
-
76
- if ('expressions' in node) {
77
- node.expressions.forEach((x) => {
78
- identifiers.push(...ASTUtils.getNestedIdentifiers(x))
79
- })
80
- }
81
-
82
- if ('left' in node) {
83
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.left))
84
- }
85
-
86
- if ('right' in node) {
87
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.right))
88
- }
89
-
90
- if (node.type === AST_NODE_TYPES.Property) {
91
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.value))
92
- }
93
-
94
- if (node.type === AST_NODE_TYPES.SpreadElement) {
95
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))
96
- }
97
-
98
- if (node.type === AST_NODE_TYPES.MemberExpression) {
99
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.object))
100
- }
101
-
102
- if (node.type === AST_NODE_TYPES.UnaryExpression) {
103
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))
104
- }
105
-
106
- if (node.type === AST_NODE_TYPES.ChainExpression) {
107
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))
108
- }
109
-
110
- if (node.type === AST_NODE_TYPES.TSNonNullExpression) {
111
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))
112
- }
113
-
114
- if (node.type === AST_NODE_TYPES.ArrowFunctionExpression) {
115
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.body))
116
- }
117
-
118
- if (node.type === AST_NODE_TYPES.FunctionExpression) {
119
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.body))
120
- }
121
-
122
- if (node.type === AST_NODE_TYPES.BlockStatement) {
123
- identifiers.push(
124
- ...node.body.map((body) => ASTUtils.getNestedIdentifiers(body)).flat(),
125
- )
126
- }
127
-
128
- if (node.type === AST_NODE_TYPES.ReturnStatement && node.argument) {
129
- identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))
130
- }
131
-
132
- return identifiers
133
- },
134
49
  traverseUpOnly(
135
50
  identifier: TSESTree.Node,
136
51
  allowedNodeTypes: Array<AST_NODE_TYPES>,
@@ -233,27 +148,6 @@ export const ASTUtils = {
233
148
 
234
149
  return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)
235
150
  },
236
- mapKeyNodeToText(
237
- node: TSESTree.Node,
238
- sourceCode: Readonly<TSESLint.SourceCode>,
239
- ) {
240
- return sourceCode.getText(
241
- ASTUtils.traverseUpOnly(node, [
242
- AST_NODE_TYPES.MemberExpression,
243
- AST_NODE_TYPES.TSNonNullExpression,
244
- AST_NODE_TYPES.Identifier,
245
- ]),
246
- )
247
- },
248
- mapKeyNodeToBaseText(
249
- node: TSESTree.Node,
250
- sourceCode: Readonly<TSESLint.SourceCode>,
251
- ) {
252
- return ASTUtils.mapKeyNodeToText(node, sourceCode).replace(
253
- /(?:\?(\.)|!)/g,
254
- '$1',
255
- )
256
- },
257
151
  isValidReactComponentOrHookName(
258
152
  identifier: TSESTree.Identifier | null | undefined,
259
153
  ) {
@@ -316,92 +210,4 @@ export const ASTUtils = {
316
210
 
317
211
  return resolvedNode.init
318
212
  },
319
- getClosestVariableDeclarator(node: TSESTree.Node) {
320
- let currentNode: TSESTree.Node | undefined = node
321
-
322
- while (currentNode.type !== AST_NODE_TYPES.Program) {
323
- if (currentNode.type === AST_NODE_TYPES.VariableDeclarator) {
324
- return currentNode
325
- }
326
-
327
- currentNode = currentNode.parent
328
- }
329
-
330
- return undefined
331
- },
332
- getNestedReturnStatements(
333
- node: TSESTree.Node,
334
- ): Array<TSESTree.ReturnStatement> {
335
- const returnStatements: Array<TSESTree.ReturnStatement> = []
336
-
337
- if (node.type === AST_NODE_TYPES.ReturnStatement) {
338
- returnStatements.push(node)
339
- }
340
-
341
- if ('body' in node && node.body !== undefined && node.body !== null) {
342
- Array.isArray(node.body)
343
- ? node.body.forEach((x) => {
344
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x))
345
- })
346
- : returnStatements.push(
347
- ...ASTUtils.getNestedReturnStatements(node.body),
348
- )
349
- }
350
-
351
- if ('consequent' in node) {
352
- Array.isArray(node.consequent)
353
- ? node.consequent.forEach((x) => {
354
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x))
355
- })
356
- : returnStatements.push(
357
- ...ASTUtils.getNestedReturnStatements(node.consequent),
358
- )
359
- }
360
-
361
- if ('alternate' in node && node.alternate !== null) {
362
- Array.isArray(node.alternate)
363
- ? node.alternate.forEach((x) => {
364
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x))
365
- })
366
- : returnStatements.push(
367
- ...ASTUtils.getNestedReturnStatements(node.alternate),
368
- )
369
- }
370
-
371
- if ('cases' in node) {
372
- node.cases.forEach((x) => {
373
- returnStatements.push(...ASTUtils.getNestedReturnStatements(x))
374
- })
375
- }
376
-
377
- if ('block' in node) {
378
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block))
379
- }
380
-
381
- if ('handler' in node && node.handler !== null) {
382
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler))
383
- }
384
-
385
- if ('finalizer' in node && node.finalizer !== null) {
386
- returnStatements.push(
387
- ...ASTUtils.getNestedReturnStatements(node.finalizer),
388
- )
389
- }
390
-
391
- if (
392
- 'expression' in node &&
393
- node.expression !== true &&
394
- node.expression !== false
395
- ) {
396
- returnStatements.push(
397
- ...ASTUtils.getNestedReturnStatements(node.expression),
398
- )
399
- }
400
-
401
- if ('test' in node && node.test !== null) {
402
- returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test))
403
- }
404
-
405
- return returnStatements
406
- },
407
213
  }