@tanstack/eslint-plugin-query 5.0.0-alpha.6 → 5.0.0-alpha.68

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/build/lib/configs/index.d.ts +1 -0
  2. package/build/lib/configs/index.d.ts.map +1 -0
  3. package/build/lib/configs/index.test.d.ts +1 -0
  4. package/build/lib/configs/index.test.d.ts.map +1 -0
  5. package/build/lib/index.cjs +465 -0
  6. package/build/lib/index.cjs.map +1 -0
  7. package/build/lib/index.d.ts +1 -0
  8. package/build/lib/index.d.ts.map +1 -0
  9. package/build/lib/index.js +437 -6
  10. package/build/lib/index.js.map +1 -0
  11. package/build/lib/rules/exhaustive-deps/exhaustive-deps.rule.d.ts +1 -0
  12. package/build/lib/rules/exhaustive-deps/exhaustive-deps.rule.d.ts.map +1 -0
  13. package/build/lib/rules/exhaustive-deps/exhaustive-deps.test.d.ts +1 -0
  14. package/build/lib/rules/exhaustive-deps/exhaustive-deps.test.d.ts.map +1 -0
  15. package/build/lib/rules/exhaustive-deps/exhaustive-deps.utils.d.ts +10 -0
  16. package/build/lib/rules/exhaustive-deps/exhaustive-deps.utils.d.ts.map +1 -0
  17. package/build/lib/rules/index.d.ts +1 -0
  18. package/build/lib/rules/index.d.ts.map +1 -0
  19. package/build/lib/utils/ast-utils.d.ts +9 -0
  20. package/build/lib/utils/ast-utils.d.ts.map +1 -0
  21. package/build/lib/utils/create-rule.d.ts +2 -1
  22. package/build/lib/utils/create-rule.d.ts.map +1 -0
  23. package/build/lib/utils/detect-react-query-imports.d.ts +6 -5
  24. package/build/lib/utils/detect-react-query-imports.d.ts.map +1 -0
  25. package/build/lib/utils/object-utils.d.ts +1 -0
  26. package/build/lib/utils/object-utils.d.ts.map +1 -0
  27. package/build/lib/utils/test-utils.d.ts +1 -0
  28. package/build/lib/utils/test-utils.d.ts.map +1 -0
  29. package/build/lib/utils/unique-by.d.ts +1 -0
  30. package/build/lib/utils/unique-by.d.ts.map +1 -0
  31. package/package.json +29 -22
  32. package/src/configs/index.test.ts +18 -0
  33. package/src/configs/index.ts +22 -0
  34. package/src/index.ts +2 -0
  35. package/src/rules/exhaustive-deps/exhaustive-deps.rule.ts +154 -0
  36. package/src/rules/exhaustive-deps/exhaustive-deps.test.ts +721 -0
  37. package/src/rules/exhaustive-deps/exhaustive-deps.utils.ts +41 -0
  38. package/src/rules/index.ts +5 -0
  39. package/src/utils/ast-utils.ts +318 -0
  40. package/src/utils/create-rule.ts +20 -0
  41. package/src/utils/detect-react-query-imports.ts +75 -0
  42. package/src/utils/object-utils.ts +5 -0
  43. package/src/utils/test-utils.ts +5 -0
  44. package/src/utils/unique-by.ts +3 -0
  45. package/build/.tsbuildinfo +0 -1
@@ -4,3 +4,4 @@ export declare const configs: {
4
4
  rules: Record<string, "error" | "strict" | "warn">;
5
5
  };
6
6
  };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configs/index.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,OAAO;;;;;CAKnB,CAAA"}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/configs/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,465 @@
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 name2 in all)
8
+ __defProp(target, name2, { get: all[name2], 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 src_exports = {};
22
+ __export(src_exports, {
23
+ configs: () => configs,
24
+ rules: () => rules
25
+ });
26
+ module.exports = __toCommonJS(src_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, name2) {
48
+ return ASTUtils.isIdentifier(node) && node.name === name2;
49
+ },
50
+ isIdentifierWithOneOfNames(node, name2) {
51
+ return ASTUtils.isIdentifier(node) && name2.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 (node.type === import_utils.AST_NODE_TYPES.Property) {
95
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.value));
96
+ }
97
+ if (node.type === import_utils.AST_NODE_TYPES.SpreadElement) {
98
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
99
+ }
100
+ if (node.type === import_utils.AST_NODE_TYPES.MemberExpression) {
101
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.object));
102
+ }
103
+ if (node.type === import_utils.AST_NODE_TYPES.UnaryExpression) {
104
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
105
+ }
106
+ if (node.type === import_utils.AST_NODE_TYPES.ChainExpression) {
107
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
108
+ }
109
+ if (node.type === import_utils.AST_NODE_TYPES.TSNonNullExpression) {
110
+ identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
111
+ }
112
+ return identifiers;
113
+ },
114
+ isAncestorIsCallee(identifier) {
115
+ let previousNode = identifier;
116
+ let currentNode = identifier.parent;
117
+ while (currentNode !== void 0) {
118
+ if (currentNode.type === import_utils.AST_NODE_TYPES.CallExpression && currentNode.callee === previousNode) {
119
+ return true;
120
+ }
121
+ if (currentNode.type !== import_utils.AST_NODE_TYPES.MemberExpression) {
122
+ return false;
123
+ }
124
+ previousNode = currentNode;
125
+ currentNode = currentNode.parent;
126
+ }
127
+ return false;
128
+ },
129
+ traverseUpOnly(identifier, allowedNodeTypes) {
130
+ const parent = identifier.parent;
131
+ if (parent !== void 0 && allowedNodeTypes.includes(parent.type)) {
132
+ return ASTUtils.traverseUpOnly(parent, allowedNodeTypes);
133
+ }
134
+ return identifier;
135
+ },
136
+ isDeclaredInNode(params) {
137
+ const { functionNode, reference, scopeManager } = params;
138
+ const scope = scopeManager.acquire(functionNode);
139
+ if (scope === null) {
140
+ return false;
141
+ }
142
+ return scope.set.has(reference.identifier.name);
143
+ },
144
+ getExternalRefs(params) {
145
+ const { scopeManager, sourceCode, node } = params;
146
+ const scope = scopeManager.acquire(node);
147
+ if (scope === null) {
148
+ return [];
149
+ }
150
+ const references = scope.references.filter((x) => x.isRead() && !scope.set.has(x.identifier.name)).map((x) => {
151
+ const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [
152
+ import_utils.AST_NODE_TYPES.MemberExpression,
153
+ import_utils.AST_NODE_TYPES.Identifier
154
+ ]);
155
+ return {
156
+ variable: x,
157
+ node: referenceNode,
158
+ text: sourceCode.getText(referenceNode)
159
+ };
160
+ });
161
+ const localRefIds = new Set(
162
+ [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0]))
163
+ );
164
+ const externalRefs = references.filter(
165
+ (x) => x.variable.resolved === null || !localRefIds.has(x.text)
166
+ );
167
+ return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable);
168
+ },
169
+ mapKeyNodeToText(node, sourceCode) {
170
+ return sourceCode.getText(
171
+ ASTUtils.traverseUpOnly(node, [
172
+ import_utils.AST_NODE_TYPES.MemberExpression,
173
+ import_utils.AST_NODE_TYPES.Identifier
174
+ ])
175
+ );
176
+ },
177
+ isValidReactComponentOrHookName(identifier) {
178
+ return identifier !== null && /^(use|[A-Z])/.test(identifier.name);
179
+ },
180
+ getFunctionAncestor(context) {
181
+ return context.getAncestors().find((x) => {
182
+ var _a;
183
+ if (x.type === import_utils.AST_NODE_TYPES.FunctionDeclaration) {
184
+ return true;
185
+ }
186
+ return ((_a = x.parent) == null ? void 0 : _a.type) === import_utils.AST_NODE_TYPES.VariableDeclarator && x.parent.id.type === import_utils.AST_NODE_TYPES.Identifier && ASTUtils.isNodeOfOneOf(x, [
187
+ import_utils.AST_NODE_TYPES.FunctionDeclaration,
188
+ import_utils.AST_NODE_TYPES.FunctionExpression,
189
+ import_utils.AST_NODE_TYPES.ArrowFunctionExpression
190
+ ]);
191
+ });
192
+ },
193
+ getReferencedExpressionByIdentifier(params) {
194
+ var _a, _b, _c;
195
+ const { node, context } = params;
196
+ const resolvedNode = (_c = (_b = (_a = context.getScope().references.find((ref) => ref.identifier === node)) == null ? void 0 : _a.resolved) == null ? void 0 : _b.defs[0]) == null ? void 0 : _c.node;
197
+ if ((resolvedNode == null ? void 0 : resolvedNode.type) !== import_utils.AST_NODE_TYPES.VariableDeclarator) {
198
+ return null;
199
+ }
200
+ return resolvedNode.init;
201
+ },
202
+ getNestedReturnStatements(node) {
203
+ const returnStatements = [];
204
+ if (node.type === import_utils.AST_NODE_TYPES.ReturnStatement) {
205
+ returnStatements.push(node);
206
+ }
207
+ if ("body" in node && node.body !== void 0 && node.body !== null) {
208
+ Array.isArray(node.body) ? node.body.forEach((x) => {
209
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
210
+ }) : returnStatements.push(
211
+ ...ASTUtils.getNestedReturnStatements(node.body)
212
+ );
213
+ }
214
+ if ("consequent" in node) {
215
+ Array.isArray(node.consequent) ? node.consequent.forEach((x) => {
216
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
217
+ }) : returnStatements.push(
218
+ ...ASTUtils.getNestedReturnStatements(node.consequent)
219
+ );
220
+ }
221
+ if ("alternate" in node && node.alternate !== null) {
222
+ Array.isArray(node.alternate) ? node.alternate.forEach((x) => {
223
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
224
+ }) : returnStatements.push(
225
+ ...ASTUtils.getNestedReturnStatements(node.alternate)
226
+ );
227
+ }
228
+ if ("cases" in node) {
229
+ node.cases.forEach((x) => {
230
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
231
+ });
232
+ }
233
+ if ("block" in node) {
234
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block));
235
+ }
236
+ if ("handler" in node && node.handler !== null) {
237
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler));
238
+ }
239
+ if ("finalizer" in node && node.finalizer !== null) {
240
+ returnStatements.push(
241
+ ...ASTUtils.getNestedReturnStatements(node.finalizer)
242
+ );
243
+ }
244
+ if ("expression" in node && node.expression !== true && node.expression !== false) {
245
+ returnStatements.push(
246
+ ...ASTUtils.getNestedReturnStatements(node.expression)
247
+ );
248
+ }
249
+ if ("test" in node && node.test !== null) {
250
+ returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test));
251
+ }
252
+ return returnStatements;
253
+ }
254
+ };
255
+
256
+ // src/utils/create-rule.ts
257
+ var import_utils2 = require("@typescript-eslint/utils");
258
+
259
+ // src/utils/detect-react-query-imports.ts
260
+ function detectTanstackQueryImports(create) {
261
+ return (context, optionsWithDefault) => {
262
+ const tanstackQueryImportSpecifiers = [];
263
+ const helpers = {
264
+ isTanstackQueryImport(node) {
265
+ return !!tanstackQueryImportSpecifiers.find((specifier) => {
266
+ if (specifier.type === "ImportSpecifier") {
267
+ return node.name === specifier.local.name;
268
+ }
269
+ return false;
270
+ });
271
+ }
272
+ };
273
+ const detectionInstructions = {
274
+ ImportDeclaration(node) {
275
+ if (node.specifiers.length > 0 && node.importKind === "value" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-query")) {
276
+ tanstackQueryImportSpecifiers.push(...node.specifiers);
277
+ }
278
+ }
279
+ };
280
+ const ruleInstructions = create(context, optionsWithDefault, helpers);
281
+ const enhancedRuleInstructions = {};
282
+ const allKeys = new Set(
283
+ Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
284
+ );
285
+ allKeys.forEach((instruction) => {
286
+ enhancedRuleInstructions[instruction] = (node) => {
287
+ var _a, _b;
288
+ if (instruction in detectionInstructions) {
289
+ (_a = detectionInstructions[instruction]) == null ? void 0 : _a.call(detectionInstructions, node);
290
+ }
291
+ if (ruleInstructions[instruction]) {
292
+ return (_b = ruleInstructions[instruction]) == null ? void 0 : _b.call(ruleInstructions, node);
293
+ }
294
+ return void 0;
295
+ };
296
+ });
297
+ return enhancedRuleInstructions;
298
+ };
299
+ }
300
+
301
+ // src/utils/create-rule.ts
302
+ var getDocsUrl = (ruleName) => `https://tanstack.com/query/v4/docs/eslint/${ruleName}`;
303
+ function createRule({ create, ...rest }) {
304
+ return import_utils2.ESLintUtils.RuleCreator(getDocsUrl)({
305
+ ...rest,
306
+ create: detectTanstackQueryImports(create)
307
+ });
308
+ }
309
+
310
+ // src/rules/exhaustive-deps/exhaustive-deps.utils.ts
311
+ var import_utils3 = require("@typescript-eslint/utils");
312
+ var ExhaustiveDepsUtils = {
313
+ isRelevantReference(params) {
314
+ var _a;
315
+ const { reference, scopeManager, context } = params;
316
+ const component = ASTUtils.getFunctionAncestor(context);
317
+ if (component !== void 0 && !ASTUtils.isDeclaredInNode({
318
+ scopeManager,
319
+ reference,
320
+ functionNode: component
321
+ })) {
322
+ return false;
323
+ }
324
+ return reference.identifier.name !== "undefined" && ((_a = reference.identifier.parent) == null ? void 0 : _a.type) !== import_utils3.AST_NODE_TYPES.NewExpression && !ExhaustiveDepsUtils.isQueryClientReference(reference);
325
+ },
326
+ isQueryClientReference(reference) {
327
+ var _a, _b, _c;
328
+ const declarator = (_b = (_a = reference.resolved) == null ? void 0 : _a.defs[0]) == null ? void 0 : _b.node;
329
+ return (declarator == null ? void 0 : declarator.type) === import_utils3.AST_NODE_TYPES.VariableDeclarator && ((_c = declarator.init) == null ? void 0 : _c.type) === import_utils3.AST_NODE_TYPES.CallExpression && declarator.init.callee.type === import_utils3.AST_NODE_TYPES.Identifier && declarator.init.callee.name === "useQueryClient";
330
+ }
331
+ };
332
+
333
+ // src/rules/exhaustive-deps/exhaustive-deps.rule.ts
334
+ var QUERY_KEY = "queryKey";
335
+ var QUERY_FN = "queryFn";
336
+ var name = "exhaustive-deps";
337
+ var rule = createRule({
338
+ name,
339
+ meta: {
340
+ type: "problem",
341
+ docs: {
342
+ description: "Exhaustive deps rule for useQuery",
343
+ recommended: "error"
344
+ },
345
+ messages: {
346
+ missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,
347
+ fixTo: "Fix to {{result}}"
348
+ },
349
+ hasSuggestions: true,
350
+ fixable: "code",
351
+ schema: []
352
+ },
353
+ defaultOptions: [],
354
+ create(context) {
355
+ return {
356
+ Property(node) {
357
+ if (node.parent === void 0 || !ASTUtils.isObjectExpression(node.parent) || !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)) {
358
+ return;
359
+ }
360
+ const scopeManager = context.getSourceCode().scopeManager;
361
+ const queryKey = ASTUtils.findPropertyWithIdentifierKey(
362
+ node.parent.properties,
363
+ QUERY_KEY
364
+ );
365
+ const queryFn = ASTUtils.findPropertyWithIdentifierKey(
366
+ node.parent.properties,
367
+ QUERY_FN
368
+ );
369
+ if (scopeManager === null || queryKey === void 0 || queryFn === void 0 || queryFn.value.type !== import_utils4.AST_NODE_TYPES.ArrowFunctionExpression) {
370
+ return;
371
+ }
372
+ let queryKeyNode = queryKey.value;
373
+ if (queryKeyNode.type === import_utils4.AST_NODE_TYPES.TSAsExpression && queryKeyNode.expression.type === import_utils4.AST_NODE_TYPES.ArrayExpression) {
374
+ queryKeyNode = queryKeyNode.expression;
375
+ }
376
+ if (queryKeyNode.type === import_utils4.AST_NODE_TYPES.Identifier) {
377
+ const expression = ASTUtils.getReferencedExpressionByIdentifier({
378
+ context,
379
+ node: queryKeyNode
380
+ });
381
+ if ((expression == null ? void 0 : expression.type) === import_utils4.AST_NODE_TYPES.ArrayExpression) {
382
+ queryKeyNode = expression;
383
+ }
384
+ }
385
+ const sourceCode = context.getSourceCode();
386
+ const queryKeyValue = queryKeyNode;
387
+ const externalRefs = ASTUtils.getExternalRefs({
388
+ scopeManager,
389
+ sourceCode,
390
+ node: queryFn.value
391
+ });
392
+ const relevantRefs = externalRefs.filter(
393
+ (reference) => ExhaustiveDepsUtils.isRelevantReference({
394
+ context,
395
+ reference,
396
+ scopeManager
397
+ })
398
+ );
399
+ const existingKeys = ASTUtils.getNestedIdentifiers(queryKeyValue).map(
400
+ (identifier) => ASTUtils.mapKeyNodeToText(identifier, sourceCode)
401
+ );
402
+ const missingRefs = relevantRefs.map((ref) => ({
403
+ ref,
404
+ text: ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode)
405
+ })).filter(({ ref, text }) => {
406
+ return !ref.isTypeReference && !ASTUtils.isAncestorIsCallee(ref.identifier) && !existingKeys.some((existingKey) => existingKey === text) && !existingKeys.includes(text.split(".")[0] ?? "");
407
+ }).map(({ ref, text }) => ({
408
+ identifier: ref.identifier,
409
+ text
410
+ }));
411
+ const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text);
412
+ if (uniqueMissingRefs.length > 0) {
413
+ const missingAsText = uniqueMissingRefs.map((ref) => ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode)).join(", ");
414
+ const existingWithMissing = sourceCode.getText(queryKeyValue).replace(/\]$/, `, ${missingAsText}]`);
415
+ const suggestions = [];
416
+ if (queryKeyNode.type === import_utils4.AST_NODE_TYPES.ArrayExpression) {
417
+ suggestions.push({
418
+ messageId: "fixTo",
419
+ data: { result: existingWithMissing },
420
+ fix(fixer) {
421
+ return fixer.replaceText(queryKeyValue, existingWithMissing);
422
+ }
423
+ });
424
+ }
425
+ context.report({
426
+ node,
427
+ messageId: "missingDeps",
428
+ data: {
429
+ deps: uniqueMissingRefs.map((ref) => ref.text).join(", ")
430
+ },
431
+ suggest: suggestions
432
+ });
433
+ }
434
+ }
435
+ };
436
+ }
437
+ });
438
+
439
+ // src/rules/index.ts
440
+ var rules = {
441
+ [name]: rule
442
+ };
443
+
444
+ // src/configs/index.ts
445
+ function generateRecommendedConfig(allRules) {
446
+ return Object.entries(allRules).reduce((memo, [name2, rule2]) => {
447
+ const { recommended } = rule2.meta.docs || {};
448
+ return {
449
+ ...memo,
450
+ ...recommended ? { [`@tanstack/query/${name2}`]: recommended } : {}
451
+ };
452
+ }, {});
453
+ }
454
+ var configs = {
455
+ recommended: {
456
+ plugins: ["@tanstack/eslint-plugin-query"],
457
+ rules: generateRecommendedConfig(rules)
458
+ }
459
+ };
460
+ // Annotate the CommonJS export names for ESM import in node:
461
+ 0 && (module.exports = {
462
+ configs,
463
+ rules
464
+ });
465
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/rules/exhaustive-deps/exhaustive-deps.rule.ts","../../src/utils/ast-utils.ts","../../src/utils/unique-by.ts","../../src/utils/create-rule.ts","../../src/utils/detect-react-query-imports.ts","../../src/rules/exhaustive-deps/exhaustive-deps.utils.ts","../../src/rules/index.ts","../../src/configs/index.ts"],"sourcesContent":["export { configs } from './configs'\nexport { rules } from './rules'\n","import type { TSESLint } from '@typescript-eslint/utils'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport { createRule } from '../../utils/create-rule'\nimport { uniqueBy } from '../../utils/unique-by'\nimport { ExhaustiveDepsUtils } from './exhaustive-deps.utils'\n\nconst QUERY_KEY = 'queryKey'\nconst QUERY_FN = 'queryFn'\n\nexport const name = 'exhaustive-deps'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Exhaustive deps rule for useQuery',\n recommended: 'error',\n },\n messages: {\n missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,\n fixTo: 'Fix to {{result}}',\n },\n hasSuggestions: true,\n fixable: 'code',\n schema: [],\n },\n defaultOptions: [],\n\n create(context) {\n return {\n Property(node) {\n if (\n node.parent === undefined ||\n !ASTUtils.isObjectExpression(node.parent) ||\n !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)\n ) {\n return\n }\n\n const scopeManager = context.getSourceCode().scopeManager\n const queryKey = ASTUtils.findPropertyWithIdentifierKey(\n node.parent.properties,\n QUERY_KEY,\n )\n const queryFn = ASTUtils.findPropertyWithIdentifierKey(\n node.parent.properties,\n QUERY_FN,\n )\n\n if (\n scopeManager === null ||\n queryKey === undefined ||\n queryFn === undefined ||\n queryFn.value.type !== AST_NODE_TYPES.ArrowFunctionExpression\n ) {\n return\n }\n\n let queryKeyNode = queryKey.value\n\n if (\n queryKeyNode.type === AST_NODE_TYPES.TSAsExpression &&\n queryKeyNode.expression.type === AST_NODE_TYPES.ArrayExpression\n ) {\n queryKeyNode = queryKeyNode.expression\n }\n\n if (queryKeyNode.type === AST_NODE_TYPES.Identifier) {\n const expression = ASTUtils.getReferencedExpressionByIdentifier({\n context,\n node: queryKeyNode,\n })\n\n if (expression?.type === AST_NODE_TYPES.ArrayExpression) {\n queryKeyNode = expression\n }\n }\n\n const sourceCode = context.getSourceCode()\n const queryKeyValue = queryKeyNode\n const externalRefs = ASTUtils.getExternalRefs({\n scopeManager,\n sourceCode,\n node: queryFn.value,\n })\n\n const relevantRefs = externalRefs.filter((reference) =>\n ExhaustiveDepsUtils.isRelevantReference({\n context,\n reference,\n scopeManager,\n }),\n )\n\n const existingKeys = ASTUtils.getNestedIdentifiers(queryKeyValue).map(\n (identifier) => ASTUtils.mapKeyNodeToText(identifier, sourceCode),\n )\n\n const missingRefs = relevantRefs\n .map((ref) => ({\n ref: ref,\n text: ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode),\n }))\n .filter(({ ref, text }) => {\n return (\n !ref.isTypeReference &&\n !ASTUtils.isAncestorIsCallee(ref.identifier) &&\n !existingKeys.some((existingKey) => existingKey === text) &&\n !existingKeys.includes(text.split('.')[0] ?? '')\n )\n })\n .map(({ ref, text }) => ({\n identifier: ref.identifier,\n text: text,\n }))\n\n const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text)\n\n if (uniqueMissingRefs.length > 0) {\n const missingAsText = uniqueMissingRefs\n .map((ref) => ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode))\n .join(', ')\n\n const existingWithMissing = sourceCode\n .getText(queryKeyValue)\n .replace(/\\]$/, `, ${missingAsText}]`)\n\n const suggestions: TSESLint.ReportSuggestionArray<string> = []\n\n if (queryKeyNode.type === AST_NODE_TYPES.ArrayExpression) {\n suggestions.push({\n messageId: 'fixTo',\n data: { result: existingWithMissing },\n fix(fixer) {\n return fixer.replaceText(queryKeyValue, existingWithMissing)\n },\n })\n }\n\n context.report({\n node: node,\n messageId: 'missingDeps',\n data: {\n deps: uniqueMissingRefs.map((ref) => ref.text).join(', '),\n },\n suggest: suggestions,\n })\n }\n },\n }\n },\n})\n","import type { TSESLint, TSESTree } from '@typescript-eslint/utils'\nimport type TSESLintScopeManager from '@typescript-eslint/scope-manager'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\nimport { uniqueBy } from './unique-by'\n\nexport const ASTUtils = {\n isNodeOfOneOf<T extends AST_NODE_TYPES>(\n node: TSESTree.Node,\n types: readonly T[],\n ): node is TSESTree.Node & { type: T } {\n return types.includes(node.type as T)\n },\n isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier {\n return node.type === AST_NODE_TYPES.Identifier\n },\n isIdentifierWithName(\n node: TSESTree.Node,\n name: string,\n ): node is TSESTree.Identifier {\n return ASTUtils.isIdentifier(node) && node.name === name\n },\n isIdentifierWithOneOfNames<T extends string[]>(\n node: TSESTree.Node,\n name: T,\n ): node is TSESTree.Identifier & { name: T[number] } {\n return ASTUtils.isIdentifier(node) && name.includes(node.name)\n },\n isProperty(node: TSESTree.Node): node is TSESTree.Property {\n return node.type === AST_NODE_TYPES.Property\n },\n isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression {\n return node.type === AST_NODE_TYPES.ObjectExpression\n },\n isPropertyWithIdentifierKey(\n node: TSESTree.Node,\n key: string,\n ): node is TSESTree.Property {\n return (\n ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key)\n )\n },\n findPropertyWithIdentifierKey(\n properties: TSESTree.ObjectLiteralElement[],\n key: string,\n ): TSESTree.Property | undefined {\n return properties.find((x) =>\n ASTUtils.isPropertyWithIdentifierKey(x, key),\n ) as TSESTree.Property | undefined\n },\n getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[] {\n const identifiers: TSESTree.Identifier[] = []\n\n if (ASTUtils.isIdentifier(node)) {\n identifiers.push(node)\n }\n\n if ('arguments' in node) {\n node.arguments.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('elements' in node) {\n node.elements.forEach((x) => {\n if (x !== null) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n }\n })\n }\n\n if ('properties' in node) {\n node.properties.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('expressions' in node) {\n node.expressions.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if (node.type === AST_NODE_TYPES.Property) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.value))\n }\n\n if (node.type === AST_NODE_TYPES.SpreadElement) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.MemberExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.object))\n }\n\n if (node.type === AST_NODE_TYPES.UnaryExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.ChainExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n if (node.type === AST_NODE_TYPES.TSNonNullExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n return identifiers\n },\n isAncestorIsCallee(identifier: TSESTree.Node) {\n let previousNode = identifier\n let currentNode = identifier.parent\n\n while (currentNode !== undefined) {\n if (\n currentNode.type === AST_NODE_TYPES.CallExpression &&\n currentNode.callee === previousNode\n ) {\n return true\n }\n\n if (currentNode.type !== AST_NODE_TYPES.MemberExpression) {\n return false\n }\n\n previousNode = currentNode\n currentNode = currentNode.parent\n }\n\n return false\n },\n traverseUpOnly(\n identifier: TSESTree.Node,\n allowedNodeTypes: AST_NODE_TYPES[],\n ): TSESTree.Node {\n const parent = identifier.parent\n\n if (parent !== undefined && allowedNodeTypes.includes(parent.type)) {\n return ASTUtils.traverseUpOnly(parent, allowedNodeTypes)\n }\n\n return identifier\n },\n isDeclaredInNode(params: {\n functionNode: TSESTree.Node\n reference: TSESLintScopeManager.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { functionNode, reference, scopeManager } = params\n const scope = scopeManager.acquire(functionNode)\n\n if (scope === null) {\n return false\n }\n\n return scope.set.has(reference.identifier.name)\n },\n getExternalRefs(params: {\n scopeManager: TSESLint.Scope.ScopeManager\n sourceCode: Readonly<TSESLint.SourceCode>\n node: TSESTree.Node\n }): TSESLint.Scope.Reference[] {\n const { scopeManager, sourceCode, node } = params\n const scope = scopeManager.acquire(node)\n\n if (scope === null) {\n return []\n }\n\n const references = scope.references\n .filter((x) => x.isRead() && !scope.set.has(x.identifier.name))\n .map((x) => {\n const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ])\n\n return {\n variable: x,\n node: referenceNode,\n text: sourceCode.getText(referenceNode),\n }\n })\n\n const localRefIds = new Set(\n [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0])),\n )\n\n const externalRefs = references.filter(\n (x) => x.variable.resolved === null || !localRefIds.has(x.text),\n )\n\n return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)\n },\n mapKeyNodeToText(\n node: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n ) {\n return sourceCode.getText(\n ASTUtils.traverseUpOnly(node, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ]),\n )\n },\n isValidReactComponentOrHookName(identifier: TSESTree.Identifier | null) {\n return identifier !== null && /^(use|[A-Z])/.test(identifier.name)\n },\n getFunctionAncestor(\n context: Readonly<RuleContext<string, readonly unknown[]>>,\n ) {\n return context.getAncestors().find((x) => {\n if (x.type === AST_NODE_TYPES.FunctionDeclaration) {\n return true\n }\n\n return (\n x.parent?.type === AST_NODE_TYPES.VariableDeclarator &&\n x.parent.id.type === AST_NODE_TYPES.Identifier &&\n ASTUtils.isNodeOfOneOf(x, [\n AST_NODE_TYPES.FunctionDeclaration,\n AST_NODE_TYPES.FunctionExpression,\n AST_NODE_TYPES.ArrowFunctionExpression,\n ])\n )\n })\n },\n getReferencedExpressionByIdentifier(params: {\n node: TSESTree.Node\n context: Readonly<RuleContext<string, readonly unknown[]>>\n }) {\n const { node, context } = params\n\n const resolvedNode = context\n .getScope()\n .references.find((ref) => ref.identifier === node)?.resolved\n ?.defs[0]?.node\n\n if (resolvedNode?.type !== AST_NODE_TYPES.VariableDeclarator) {\n return null\n }\n\n return resolvedNode.init\n },\n getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[] {\n const returnStatements: TSESTree.ReturnStatement[] = []\n\n if (node.type === AST_NODE_TYPES.ReturnStatement) {\n returnStatements.push(node)\n }\n\n if ('body' in node && node.body !== undefined && node.body !== null) {\n Array.isArray(node.body)\n ? node.body.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.body),\n )\n }\n\n if ('consequent' in node) {\n Array.isArray(node.consequent)\n ? node.consequent.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.consequent),\n )\n }\n\n if ('alternate' in node && node.alternate !== null) {\n Array.isArray(node.alternate)\n ? node.alternate.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.alternate),\n )\n }\n\n if ('cases' in node) {\n node.cases.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n }\n\n if ('block' in node) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block))\n }\n\n if ('handler' in node && node.handler !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler))\n }\n\n if ('finalizer' in node && node.finalizer !== null) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.finalizer),\n )\n }\n\n if (\n 'expression' in node &&\n node.expression !== true &&\n node.expression !== false\n ) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.expression),\n )\n }\n\n if ('test' in node && node.test !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test))\n }\n\n return returnStatements\n },\n}\n","export function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[] {\n return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)\n}\n","import { ESLintUtils } from '@typescript-eslint/utils'\nimport type { EnhancedCreate } from './detect-react-query-imports'\nimport { detectTanstackQueryImports } from './detect-react-query-imports'\n\nconst getDocsUrl = (ruleName: string): string =>\n `https://tanstack.com/query/v4/docs/eslint/${ruleName}`\n\ntype EslintRule = Omit<\n Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0],\n 'create'\n> & {\n create: EnhancedCreate\n}\n\nexport function createRule({ create, ...rest }: EslintRule) {\n return ESLintUtils.RuleCreator(getDocsUrl)({\n ...rest,\n create: detectTanstackQueryImports(create),\n })\n}\n","import type { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils'\n\ntype Create = Parameters<\n ReturnType<typeof ESLintUtils.RuleCreator>\n>[0]['create']\n\ntype Context = Parameters<Create>[0]\ntype Options = Parameters<Create>[1]\ntype Helpers = {\n isTanstackQueryImport: (node: TSESTree.Identifier) => boolean\n}\n\nexport type EnhancedCreate = (\n context: Context,\n options: Options,\n helpers: Helpers,\n) => ReturnType<Create>\n\nexport function detectTanstackQueryImports(create: EnhancedCreate): Create {\n return (context, optionsWithDefault) => {\n const tanstackQueryImportSpecifiers: TSESTree.ImportClause[] = []\n\n const helpers: Helpers = {\n isTanstackQueryImport(node) {\n return !!tanstackQueryImportSpecifiers.find((specifier) => {\n if (specifier.type === 'ImportSpecifier') {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n }\n\n const detectionInstructions: TSESLint.RuleListener = {\n ImportDeclaration(node) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value.startsWith('@tanstack/') &&\n node.source.value.endsWith('-query')\n ) {\n tanstackQueryImportSpecifiers.push(...node.specifiers)\n }\n },\n }\n\n // Call original rule definition\n const ruleInstructions = create(context, optionsWithDefault, helpers)\n const enhancedRuleInstructions: TSESLint.RuleListener = {}\n\n const allKeys = new Set(\n Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)),\n )\n\n // Iterate over ALL instructions keys so we can override original rule instructions\n // to prevent their execution if conditions to report errors are not met.\n allKeys.forEach((instruction) => {\n enhancedRuleInstructions[instruction] = (node) => {\n if (instruction in detectionInstructions) {\n detectionInstructions[instruction]?.(node)\n }\n\n // TODO: canReportErrors()\n if (ruleInstructions[instruction]) {\n return ruleInstructions[instruction]?.(node)\n }\n\n return undefined\n }\n })\n\n return enhancedRuleInstructions\n }\n}\n","import type { TSESLint } from '@typescript-eslint/utils'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\n\nexport const ExhaustiveDepsUtils = {\n isRelevantReference(params: {\n context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>\n reference: TSESLint.Scope.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { reference, scopeManager, context } = params\n const component = ASTUtils.getFunctionAncestor(context)\n\n if (\n component !== undefined &&\n !ASTUtils.isDeclaredInNode({\n scopeManager,\n reference,\n functionNode: component,\n })\n ) {\n return false\n }\n\n return (\n reference.identifier.name !== 'undefined' &&\n reference.identifier.parent?.type !== AST_NODE_TYPES.NewExpression &&\n !ExhaustiveDepsUtils.isQueryClientReference(reference)\n )\n },\n isQueryClientReference(reference: TSESLint.Scope.Reference) {\n const declarator = reference.resolved?.defs[0]?.node\n\n return (\n declarator?.type === AST_NODE_TYPES.VariableDeclarator &&\n declarator.init?.type === AST_NODE_TYPES.CallExpression &&\n declarator.init.callee.type === AST_NODE_TYPES.Identifier &&\n declarator.init.callee.name === 'useQueryClient'\n )\n },\n}\n","import * as exhaustiveDeps from './exhaustive-deps/exhaustive-deps.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n}\n","import type { TSESLint } from '@typescript-eslint/utils'\nimport { rules } from '../rules'\n\nfunction generateRecommendedConfig(\n allRules: Record<string, TSESLint.RuleModule<any, any>>,\n) {\n return Object.entries(allRules).reduce((memo, [name, rule]) => {\n const { recommended } = rule.meta.docs || {}\n\n return {\n ...memo,\n ...(recommended ? { [`@tanstack/query/${name}`]: recommended } : {}),\n }\n }, {} as Record<string, 'strict' | 'error' | 'warn'>)\n}\n\nexport const configs = {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-query'],\n rules: generateRecommendedConfig(rules),\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAA+B;;;ACC/B,mBAA+B;;;ACFxB,SAAS,SAAY,KAAU,IAA4B;AAChE,SAAO,IAAI,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1E;;;ADIO,IAAM,WAAW;AAAA,EACtB,cACE,MACA,OACqC;AACrC,WAAO,MAAM,SAAS,KAAK,IAAS;AAAA,EACtC;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,IAAIA,MAAK,KAAK,QAAQ,CAAC;AAE3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmBD,OAAM,GAAG,YAAY,IAAI,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,CAAgD;AACtD;AAEO,IAAM,UAAU;AAAA,EACrB,aAAa;AAAA,IACX,SAAS,CAAC,+BAA+B;AAAA,IACzC,OAAO,0BAA0B,KAAK;AAAA,EACxC;AACF;","names":["import_utils","name","import_utils","import_utils","name","rule"]}
@@ -1,2 +1,3 @@
1
1
  export { configs } from './configs';
2
2
  export { rules } from './rules';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA"}