@tanstack/eslint-plugin-query 5.0.0-beta.5 → 5.0.0-rc.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 (72) hide show
  1. package/build/legacy/{configs/index.test.cjs → __tests__/configs.test.cjs} +4 -4
  2. package/build/legacy/__tests__/configs.test.cjs.map +1 -0
  3. package/build/legacy/{configs/index.test.js → __tests__/configs.test.js} +3 -3
  4. package/build/legacy/__tests__/configs.test.js.map +1 -0
  5. package/build/legacy/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.cjs +3 -3
  6. package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +1 -0
  7. package/build/legacy/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.js +3 -3
  8. package/build/legacy/__tests__/exhaustive-deps.test.js.map +1 -0
  9. package/build/legacy/{configs/index.cjs → configs.cjs} +3 -3
  10. package/build/legacy/configs.cjs.map +1 -0
  11. package/build/legacy/{configs/index.d.cts → configs.d.cts} +1 -1
  12. package/build/legacy/{configs/index.d.ts → configs.d.ts} +1 -1
  13. package/build/legacy/{configs/index.js → configs.js} +3 -3
  14. package/build/legacy/configs.js.map +1 -0
  15. package/build/legacy/index.d.cts +2 -2
  16. package/build/legacy/index.d.ts +2 -2
  17. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.rule.cjs → exhaustive-deps.rule.cjs} +4 -4
  18. package/build/legacy/rules/exhaustive-deps.rule.cjs.map +1 -0
  19. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.rule.js → exhaustive-deps.rule.js} +4 -4
  20. package/build/legacy/rules/exhaustive-deps.rule.js.map +1 -0
  21. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.utils.cjs → exhaustive-deps.utils.cjs} +2 -2
  22. package/build/legacy/rules/exhaustive-deps.utils.cjs.map +1 -0
  23. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.utils.d.cts → exhaustive-deps.utils.d.cts} +1 -1
  24. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.utils.d.ts → exhaustive-deps.utils.d.ts} +1 -1
  25. package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.utils.js → exhaustive-deps.utils.js} +2 -2
  26. package/build/legacy/rules/exhaustive-deps.utils.js.map +1 -0
  27. package/build/legacy/{rules/index.cjs → rules.cjs} +3 -3
  28. package/build/legacy/rules.cjs.map +1 -0
  29. package/build/legacy/rules.js +9 -0
  30. package/build/legacy/rules.js.map +1 -0
  31. package/build/legacy/utils/ast-utils.cjs.map +1 -1
  32. package/build/legacy/utils/ast-utils.d.cts +7 -7
  33. package/build/legacy/utils/ast-utils.d.ts +7 -7
  34. package/build/legacy/utils/ast-utils.js.map +1 -1
  35. package/build/legacy/utils/detect-react-query-imports.cjs.map +1 -1
  36. package/build/legacy/utils/detect-react-query-imports.js.map +1 -1
  37. package/build/legacy/utils/unique-by.cjs.map +1 -1
  38. package/build/legacy/utils/unique-by.d.cts +1 -1
  39. package/build/legacy/utils/unique-by.d.ts +1 -1
  40. package/build/legacy/utils/unique-by.js.map +1 -1
  41. package/package.json +6 -2
  42. package/src/{configs/index.test.ts → __tests__/configs.test.ts} +1 -1
  43. package/src/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.ts +2 -2
  44. package/src/{configs/index.ts → configs.ts} +1 -1
  45. package/src/rules/{exhaustive-deps/exhaustive-deps.rule.ts → exhaustive-deps.rule.ts} +3 -3
  46. package/src/rules/{exhaustive-deps/exhaustive-deps.utils.ts → exhaustive-deps.utils.ts} +2 -2
  47. package/src/rules.ts +5 -0
  48. package/src/utils/ast-utils.ts +13 -11
  49. package/src/utils/detect-react-query-imports.ts +1 -1
  50. package/src/utils/unique-by.ts +1 -1
  51. package/build/legacy/configs/index.cjs.map +0 -1
  52. package/build/legacy/configs/index.js.map +0 -1
  53. package/build/legacy/configs/index.test.cjs.map +0 -1
  54. package/build/legacy/configs/index.test.js.map +0 -1
  55. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.rule.cjs.map +0 -1
  56. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.rule.js.map +0 -1
  57. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.test.cjs.map +0 -1
  58. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.test.js.map +0 -1
  59. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.utils.cjs.map +0 -1
  60. package/build/legacy/rules/exhaustive-deps/exhaustive-deps.utils.js.map +0 -1
  61. package/build/legacy/rules/index.cjs.map +0 -1
  62. package/build/legacy/rules/index.js +0 -9
  63. package/build/legacy/rules/index.js.map +0 -1
  64. package/src/rules/index.ts +0 -5
  65. /package/build/legacy/{configs/index.test.d.cts → __tests__/configs.test.d.cts} +0 -0
  66. /package/build/legacy/{configs/index.test.d.ts → __tests__/configs.test.d.ts} +0 -0
  67. /package/build/legacy/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.d.cts +0 -0
  68. /package/build/legacy/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.d.ts +0 -0
  69. /package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.rule.d.cts → exhaustive-deps.rule.d.cts} +0 -0
  70. /package/build/legacy/rules/{exhaustive-deps/exhaustive-deps.rule.d.ts → exhaustive-deps.rule.d.ts} +0 -0
  71. /package/build/legacy/{rules/index.d.cts → rules.d.cts} +0 -0
  72. /package/build/legacy/{rules/index.d.ts → rules.d.ts} +0 -0
@@ -14,10 +14,10 @@ declare const ASTUtils: {
14
14
  isProperty(node: TSESTree.Node): node is TSESTree.Property;
15
15
  isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression;
16
16
  isPropertyWithIdentifierKey(node: TSESTree.Node, key: string): node is TSESTree.Property;
17
- findPropertyWithIdentifierKey(properties: TSESTree.ObjectLiteralElement[], key: string): TSESTree.Property | undefined;
18
- getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[];
17
+ findPropertyWithIdentifierKey(properties: Array<TSESTree.ObjectLiteralElement>, key: string): TSESTree.Property | undefined;
18
+ getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier>;
19
19
  isAncestorIsCallee(identifier: TSESTree.Node): boolean;
20
- traverseUpOnly(identifier: TSESTree.Node, allowedNodeTypes: AST_NODE_TYPES[]): TSESTree.Node;
20
+ traverseUpOnly(identifier: TSESTree.Node, allowedNodeTypes: Array<AST_NODE_TYPES>): TSESTree.Node;
21
21
  isDeclaredInNode(params: {
22
22
  functionNode: TSESTree.Node;
23
23
  reference: TSESLintScopeManager.Reference;
@@ -27,15 +27,15 @@ declare const ASTUtils: {
27
27
  scopeManager: TSESLint.Scope.ScopeManager;
28
28
  sourceCode: Readonly<TSESLint.SourceCode>;
29
29
  node: TSESTree.Node;
30
- }): TSESLint.Scope.Reference[];
30
+ }): Array<TSESLint.Scope.Reference>;
31
31
  mapKeyNodeToText(node: TSESTree.Node, sourceCode: Readonly<TSESLint.SourceCode>): string;
32
32
  isValidReactComponentOrHookName(identifier: TSESTree.Identifier | null): boolean;
33
- getFunctionAncestor(context: Readonly<RuleContext<string, readonly unknown[]>>): TSESTree.Node | undefined;
33
+ getFunctionAncestor(context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>): TSESTree.Node | undefined;
34
34
  getReferencedExpressionByIdentifier(params: {
35
35
  node: TSESTree.Node;
36
- context: Readonly<RuleContext<string, readonly unknown[]>>;
36
+ context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>;
37
37
  }): TSESTree.Expression | null;
38
- getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[];
38
+ getNestedReturnStatements(node: TSESTree.Node): Array<TSESTree.ReturnStatement>;
39
39
  };
40
40
 
41
41
  export { ASTUtils };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/ast-utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { uniqueBy } from './unique-by'\nimport type { TSESLint, TSESTree } from '@typescript-eslint/utils'\nimport type TSESLintScopeManager from '@typescript-eslint/scope-manager'\nimport type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\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 returnStat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AAU;AAAA,MACvD;AAAA,IACF;AAEA,QAAI,UAAU,QAAQ,KAAK,SAAS,MAAM;AACxC,uBAAiB,KAAK,GAAG,SAAS,0BAA0B,KAAK,IAAI,CAAC;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/ast-utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { uniqueBy } from './unique-by'\nimport type { TSESLint, TSESTree } from '@typescript-eslint/utils'\nimport type TSESLintScopeManager from '@typescript-eslint/scope-manager'\nimport type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\n\nexport const ASTUtils = {\n isNodeOfOneOf<T extends AST_NODE_TYPES>(\n node: TSESTree.Node,\n types: ReadonlyArray<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 Array<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: Array<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): Array<TSESTree.Identifier> {\n const identifiers: Array<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: Array<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 }): Array<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, ReadonlyArray<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, ReadonlyArray<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(\n node: TSESTree.Node,\n ): Array<TSESTree.ReturnStatement> {\n const returnStatements: Array<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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAKlB,IAAM,WAAW;AAAA,EACtB,cACE,MACA,OACqC;AACrC,WAAO,MAAM,SAAS,KAAK,IAAS;AAAA,EACtC;AAAA,EACA,aAAa,MAAkD;AAC7D,WAAO,KAAK,SAAS,eAAe;AAAA,EACtC;AAAA,EACA,qBACE,MACA,MAC6B;AAC7B,WAAO,SAAS,aAAa,IAAI,KAAK,KAAK,SAAS;AAAA,EACtD;AAAA,EACA,2BACE,MACA,MACmD;AACnD,WAAO,SAAS,aAAa,IAAI,KAAK,KAAK,SAAS,KAAK,IAAI;AAAA,EAC/D;AAAA,EACA,WAAW,MAAgD;AACzD,WAAO,KAAK,SAAS,eAAe;AAAA,EACtC;AAAA,EACA,mBAAmB,MAAwD;AACzE,WAAO,KAAK,SAAS,eAAe;AAAA,EACtC;AAAA,EACA,4BACE,MACA,KAC2B;AAC3B,WACE,SAAS,WAAW,IAAI,KAAK,SAAS,qBAAqB,KAAK,KAAK,GAAG;AAAA,EAE5E;AAAA,EACA,8BACE,YACA,KAC+B;AAC/B,WAAO,WAAW;AAAA,MAAK,CAAC,MACtB,SAAS,4BAA4B,GAAG,GAAG;AAAA,IAC7C;AAAA,EACF;AAAA,EACA,qBAAqB,MAAiD;AACpE,UAAM,cAA0C,CAAC;AAEjD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,KAAK,KAAK,CAAC;AAAA,IACzE;AAEA,QAAI,aAAa,QAAQ,KAAK,YAAY,MAAM;AAC9C,uBAAiB,KAAK,GAAG,SAAS,0BAA0B,KAAK,OAAO,CAAC;AAAA,IAC3E;AAEA,QAAI,eAAe,QAAQ,KAAK,cAAc,MAAM;AAClD,uBAAiB;AAAA,QACf,GAAG,SAAS,0BAA0B,KAAK,SAAS;AAAA,MACtD;AAAA,IACF;AAEA,QACE,gBAAgB,QAChB,KAAK,eAAe,QACpB,KAAK,eAAe,OACpB;AACA,uBAAiB;AAAA,QACf,GAAG,SAAS,0BAA0B,KAAK,UAAU;AAAA,MACvD;AAAA,IACF;AAEA,QAAI,UAAU,QAAQ,KAAK,SAAS,MAAM;AACxC,uBAAiB,KAAK,GAAG,SAAS,0BAA0B,KAAK,IAAI,CAAC;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/detect-react-query-imports.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,2BAA2B,QAAgC;AACzE,SAAO,CAAC,SAAS,uBAAuB;AACtC,UAAM,gCAAyD,CAAC;AAEhE,UAAM,UAAmB;AAAA,MACvB,sBAAsB,MAAM;AAC1B,eAAO,CAAC,CAAC,8BAA8B,KAAK,CAAC,cAAc;AACzD,cAAI,UAAU,SAAS,mBAAmB;AACxC,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAEA,UAAM,wBAA+C;AAAA,MACnD,kBAAkB,MAAM;AACtB,YACE,KAAK,WAAW,SAAS,KACzB,KAAK,eAAe,WACpB,KAAK,OAAO,MAAM,WAAW,YAAY,KACzC,KAAK,OAAO,MAAM,SAAS,QAAQ,GACnC;AACA,wCAA8B,KAAK,GAAG,KAAK,UAAU;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAGA,UAAM,mBAAmB,OAAO,SAAS,oBAAoB,OAAO;AACpE,UAAM,2BAAkD,CAAC;AAEzD,UAAM,UAAU,IAAI;AAAA,MAClB,OAAO,KAAK,qBAAqB,EAAE,OAAO,OAAO,KAAK,gBAAgB,CAAC;AAAA,IACzE;AAIA,YAAQ,QAAQ,CAAC,gBAAgB;AAC/B,+BAAyB,WAAW,IAAI,CAAC,SAAS;AA1DxD;AA2DQ,YAAI,eAAe,uBAAuB;AACxC,sCAAsB,iBAAtB,+CAAqC;AAAA,QACvC;AAGA,YAAI,iBAAiB,WAAW,GAAG;AACjC,kBAAO,sBAAiB,iBAAjB,0CAAgC;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/detect-react-query-imports.ts"],"sourcesContent":["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: Array<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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,2BAA2B,QAAgC;AACzE,SAAO,CAAC,SAAS,uBAAuB;AACtC,UAAM,gCAA8D,CAAC;AAErE,UAAM,UAAmB;AAAA,MACvB,sBAAsB,MAAM;AAC1B,eAAO,CAAC,CAAC,8BAA8B,KAAK,CAAC,cAAc;AACzD,cAAI,UAAU,SAAS,mBAAmB;AACxC,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAEA,UAAM,wBAA+C;AAAA,MACnD,kBAAkB,MAAM;AACtB,YACE,KAAK,WAAW,SAAS,KACzB,KAAK,eAAe,WACpB,KAAK,OAAO,MAAM,WAAW,YAAY,KACzC,KAAK,OAAO,MAAM,SAAS,QAAQ,GACnC;AACA,wCAA8B,KAAK,GAAG,KAAK,UAAU;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAGA,UAAM,mBAAmB,OAAO,SAAS,oBAAoB,OAAO;AACpE,UAAM,2BAAkD,CAAC;AAEzD,UAAM,UAAU,IAAI;AAAA,MAClB,OAAO,KAAK,qBAAqB,EAAE,OAAO,OAAO,KAAK,gBAAgB,CAAC;AAAA,IACzE;AAIA,YAAQ,QAAQ,CAAC,gBAAgB;AAC/B,+BAAyB,WAAW,IAAI,CAAC,SAAS;AA1DxD;AA2DQ,YAAI,eAAe,uBAAuB;AACxC,sCAAsB,iBAAtB,+CAAqC;AAAA,QACvC;AAGA,YAAI,iBAAiB,WAAW,GAAG;AACjC,kBAAO,sBAAiB,iBAAjB,0CAAgC;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/detect-react-query-imports.ts"],"sourcesContent":["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"],"mappings":";AAkBO,SAAS,2BAA2B,QAAgC;AACzE,SAAO,CAAC,SAAS,uBAAuB;AACtC,UAAM,gCAAyD,CAAC;AAEhE,UAAM,UAAmB;AAAA,MACvB,sBAAsB,MAAM;AAC1B,eAAO,CAAC,CAAC,8BAA8B,KAAK,CAAC,cAAc;AACzD,cAAI,UAAU,SAAS,mBAAmB;AACxC,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAEA,UAAM,wBAA+C;AAAA,MACnD,kBAAkB,MAAM;AACtB,YACE,KAAK,WAAW,SAAS,KACzB,KAAK,eAAe,WACpB,KAAK,OAAO,MAAM,WAAW,YAAY,KACzC,KAAK,OAAO,MAAM,SAAS,QAAQ,GACnC;AACA,wCAA8B,KAAK,GAAG,KAAK,UAAU;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAGA,UAAM,mBAAmB,OAAO,SAAS,oBAAoB,OAAO;AACpE,UAAM,2BAAkD,CAAC;AAEzD,UAAM,UAAU,IAAI;AAAA,MAClB,OAAO,KAAK,qBAAqB,EAAE,OAAO,OAAO,KAAK,gBAAgB,CAAC;AAAA,IACzE;AAIA,YAAQ,QAAQ,CAAC,gBAAgB;AAC/B,+BAAyB,WAAW,IAAI,CAAC,SAAS;AA1DxD;AA2DQ,YAAI,eAAe,uBAAuB;AACxC,sCAAsB,iBAAtB,+CAAqC;AAAA,QACvC;AAGA,YAAI,iBAAiB,WAAW,GAAG;AACjC,kBAAO,sBAAiB,iBAAjB,0CAAgC;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/detect-react-query-imports.ts"],"sourcesContent":["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: Array<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"],"mappings":";AAkBO,SAAS,2BAA2B,QAAgC;AACzE,SAAO,CAAC,SAAS,uBAAuB;AACtC,UAAM,gCAA8D,CAAC;AAErE,UAAM,UAAmB;AAAA,MACvB,sBAAsB,MAAM;AAC1B,eAAO,CAAC,CAAC,8BAA8B,KAAK,CAAC,cAAc;AACzD,cAAI,UAAU,SAAS,mBAAmB;AACxC,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAEA,UAAM,wBAA+C;AAAA,MACnD,kBAAkB,MAAM;AACtB,YACE,KAAK,WAAW,SAAS,KACzB,KAAK,eAAe,WACpB,KAAK,OAAO,MAAM,WAAW,YAAY,KACzC,KAAK,OAAO,MAAM,SAAS,QAAQ,GACnC;AACA,wCAA8B,KAAK,GAAG,KAAK,UAAU;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAGA,UAAM,mBAAmB,OAAO,SAAS,oBAAoB,OAAO;AACpE,UAAM,2BAAkD,CAAC;AAEzD,UAAM,UAAU,IAAI;AAAA,MAClB,OAAO,KAAK,qBAAqB,EAAE,OAAO,OAAO,KAAK,gBAAgB,CAAC;AAAA,IACzE;AAIA,YAAQ,QAAQ,CAAC,gBAAgB;AAC/B,+BAAyB,WAAW,IAAI,CAAC,SAAS;AA1DxD;AA2DQ,YAAI,eAAe,uBAAuB;AACxC,sCAAsB,iBAAtB,+CAAqC;AAAA,QACvC;AAGA,YAAI,iBAAiB,WAAW,GAAG;AACjC,kBAAO,sBAAiB,iBAAjB,0CAAgC;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/unique-by.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,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;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/unique-by.ts"],"sourcesContent":["export function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T> {\n return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,SAAY,KAAe,IAAiC;AAC1E,SAAO,IAAI,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1E;","names":[]}
@@ -1,3 +1,3 @@
1
- declare function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[];
1
+ declare function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T>;
2
2
 
3
3
  export { uniqueBy };
@@ -1,3 +1,3 @@
1
- declare function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[];
1
+ declare function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T>;
2
2
 
3
3
  export { uniqueBy };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/unique-by.ts"],"sourcesContent":["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"],"mappings":";AAAO,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;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/unique-by.ts"],"sourcesContent":["export function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T> {\n return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)\n}\n"],"mappings":";AAAO,SAAS,SAAY,KAAe,IAAiC;AAC1E,SAAO,IAAI,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1E;","names":[]}
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@tanstack/eslint-plugin-query",
3
- "version": "5.0.0-beta.5",
3
+ "version": "5.0.0-rc.0",
4
4
  "description": "ESLint plugin for TanStack Query",
5
5
  "author": "Eliya Cohen",
6
6
  "license": "MIT",
7
- "repository": "tanstack/query",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/TanStack/query.git",
10
+ "directory": "packages/eslint-plugin-query"
11
+ },
8
12
  "homepage": "https://tanstack.com/query",
9
13
  "funding": {
10
14
  "type": "github",
@@ -1,4 +1,4 @@
1
- import { configs } from './index'
1
+ import { configs } from '../configs'
2
2
 
3
3
  describe('configs', () => {
4
4
  it('should match snapshot', () => {
@@ -1,6 +1,6 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils'
2
- import { normalizeIndent } from '../../utils/test-utils'
3
- import { rule } from './exhaustive-deps.rule'
2
+ import { normalizeIndent } from '../utils/test-utils'
3
+ import { rule } from '../rules/exhaustive-deps.rule'
4
4
 
5
5
  const ruleTester = new ESLintUtils.RuleTester({
6
6
  parser: '@typescript-eslint/parser',
@@ -1,4 +1,4 @@
1
- import { rules } from '../rules'
1
+ import { rules } from './rules'
2
2
  import type { TSESLint } from '@typescript-eslint/utils'
3
3
 
4
4
  function generateRecommendedConfig(
@@ -1,7 +1,7 @@
1
1
  import { AST_NODE_TYPES } from '@typescript-eslint/utils'
2
- import { ASTUtils } from '../../utils/ast-utils'
3
- import { createRule } from '../../utils/create-rule'
4
- import { uniqueBy } from '../../utils/unique-by'
2
+ import { ASTUtils } from '../utils/ast-utils'
3
+ import { createRule } from '../utils/create-rule'
4
+ import { uniqueBy } from '../utils/unique-by'
5
5
  import { ExhaustiveDepsUtils } from './exhaustive-deps.utils'
6
6
  import type { TSESLint } from '@typescript-eslint/utils'
7
7
 
@@ -1,10 +1,10 @@
1
1
  import { AST_NODE_TYPES } from '@typescript-eslint/utils'
2
- import { ASTUtils } from '../../utils/ast-utils'
2
+ import { ASTUtils } from '../utils/ast-utils'
3
3
  import type { TSESLint } from '@typescript-eslint/utils'
4
4
 
5
5
  export const ExhaustiveDepsUtils = {
6
6
  isRelevantReference(params: {
7
- context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>
7
+ context: Readonly<TSESLint.RuleContext<string, ReadonlyArray<unknown>>>
8
8
  reference: TSESLint.Scope.Reference
9
9
  scopeManager: TSESLint.Scope.ScopeManager
10
10
  }) {
package/src/rules.ts ADDED
@@ -0,0 +1,5 @@
1
+ import * as exhaustiveDeps from './rules/exhaustive-deps.rule'
2
+
3
+ export const rules = {
4
+ [exhaustiveDeps.name]: exhaustiveDeps.rule,
5
+ }
@@ -7,7 +7,7 @@ import type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'
7
7
  export const ASTUtils = {
8
8
  isNodeOfOneOf<T extends AST_NODE_TYPES>(
9
9
  node: TSESTree.Node,
10
- types: readonly T[],
10
+ types: ReadonlyArray<T>,
11
11
  ): node is TSESTree.Node & { type: T } {
12
12
  return types.includes(node.type as T)
13
13
  },
@@ -20,7 +20,7 @@ export const ASTUtils = {
20
20
  ): node is TSESTree.Identifier {
21
21
  return ASTUtils.isIdentifier(node) && node.name === name
22
22
  },
23
- isIdentifierWithOneOfNames<T extends string[]>(
23
+ isIdentifierWithOneOfNames<T extends Array<string>>(
24
24
  node: TSESTree.Node,
25
25
  name: T,
26
26
  ): node is TSESTree.Identifier & { name: T[number] } {
@@ -41,15 +41,15 @@ export const ASTUtils = {
41
41
  )
42
42
  },
43
43
  findPropertyWithIdentifierKey(
44
- properties: TSESTree.ObjectLiteralElement[],
44
+ properties: Array<TSESTree.ObjectLiteralElement>,
45
45
  key: string,
46
46
  ): TSESTree.Property | undefined {
47
47
  return properties.find((x) =>
48
48
  ASTUtils.isPropertyWithIdentifierKey(x, key),
49
49
  ) as TSESTree.Property | undefined
50
50
  },
51
- getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[] {
52
- const identifiers: TSESTree.Identifier[] = []
51
+ getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier> {
52
+ const identifiers: Array<TSESTree.Identifier> = []
53
53
 
54
54
  if (ASTUtils.isIdentifier(node)) {
55
55
  identifiers.push(node)
@@ -131,7 +131,7 @@ export const ASTUtils = {
131
131
  },
132
132
  traverseUpOnly(
133
133
  identifier: TSESTree.Node,
134
- allowedNodeTypes: AST_NODE_TYPES[],
134
+ allowedNodeTypes: Array<AST_NODE_TYPES>,
135
135
  ): TSESTree.Node {
136
136
  const parent = identifier.parent
137
137
 
@@ -159,7 +159,7 @@ export const ASTUtils = {
159
159
  scopeManager: TSESLint.Scope.ScopeManager
160
160
  sourceCode: Readonly<TSESLint.SourceCode>
161
161
  node: TSESTree.Node
162
- }): TSESLint.Scope.Reference[] {
162
+ }): Array<TSESLint.Scope.Reference> {
163
163
  const { scopeManager, sourceCode, node } = params
164
164
  const scope = scopeManager.acquire(node)
165
165
 
@@ -207,7 +207,7 @@ export const ASTUtils = {
207
207
  return identifier !== null && /^(use|[A-Z])/.test(identifier.name)
208
208
  },
209
209
  getFunctionAncestor(
210
- context: Readonly<RuleContext<string, readonly unknown[]>>,
210
+ context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>,
211
211
  ) {
212
212
  return context.getAncestors().find((x) => {
213
213
  if (x.type === AST_NODE_TYPES.FunctionDeclaration) {
@@ -227,7 +227,7 @@ export const ASTUtils = {
227
227
  },
228
228
  getReferencedExpressionByIdentifier(params: {
229
229
  node: TSESTree.Node
230
- context: Readonly<RuleContext<string, readonly unknown[]>>
230
+ context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>
231
231
  }) {
232
232
  const { node, context } = params
233
233
 
@@ -242,8 +242,10 @@ export const ASTUtils = {
242
242
 
243
243
  return resolvedNode.init
244
244
  },
245
- getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[] {
246
- const returnStatements: TSESTree.ReturnStatement[] = []
245
+ getNestedReturnStatements(
246
+ node: TSESTree.Node,
247
+ ): Array<TSESTree.ReturnStatement> {
248
+ const returnStatements: Array<TSESTree.ReturnStatement> = []
247
249
 
248
250
  if (node.type === AST_NODE_TYPES.ReturnStatement) {
249
251
  returnStatements.push(node)
@@ -18,7 +18,7 @@ export type EnhancedCreate = (
18
18
 
19
19
  export function detectTanstackQueryImports(create: EnhancedCreate): Create {
20
20
  return (context, optionsWithDefault) => {
21
- const tanstackQueryImportSpecifiers: TSESTree.ImportClause[] = []
21
+ const tanstackQueryImportSpecifiers: Array<TSESTree.ImportClause> = []
22
22
 
23
23
  const helpers: Helpers = {
24
24
  isTanstackQueryImport(node) {
@@ -1,3 +1,3 @@
1
- export function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[] {
1
+ export function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T> {
2
2
  return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)
3
3
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/configs/index.ts"],"sourcesContent":["import { rules } from '../rules'\nimport type { TSESLint } from '@typescript-eslint/utils'\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,mBAAsB;AAGtB,SAAS,0BACP,UACA;AACA,SAAO,OAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM;AAC7D,UAAM,EAAE,YAAY,IAAI,KAAK,KAAK,QAAQ,CAAC;AAE3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmB,IAAI,EAAE,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,kBAAK;AAAA,EACxC;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/configs/index.ts"],"sourcesContent":["import { rules } from '../rules'\nimport type { TSESLint } from '@typescript-eslint/utils'\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,SAAS,aAAa;AAGtB,SAAS,0BACP,UACA;AACA,SAAO,OAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM;AAC7D,UAAM,EAAE,YAAY,IAAI,KAAK,KAAK,QAAQ,CAAC;AAE3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmB,IAAI,EAAE,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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/configs/index.test.ts"],"sourcesContent":["import { configs } from './index'\n\ndescribe('configs', () => {\n it('should match snapshot', () => {\n expect(configs).toMatchInlineSnapshot(`\n {\n \"recommended\": {\n \"plugins\": [\n \"@tanstack/eslint-plugin-query\",\n ],\n \"rules\": {\n \"@tanstack/query/exhaustive-deps\": \"error\",\n },\n },\n }\n `)\n })\n})\n"],"mappings":";;;AAAA,mBAAwB;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,yBAAyB,MAAM;AAChC,WAAO,oBAAO,EAAE,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWrC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/configs/index.test.ts"],"sourcesContent":["import { configs } from './index'\n\ndescribe('configs', () => {\n it('should match snapshot', () => {\n expect(configs).toMatchInlineSnapshot(`\n {\n \"recommended\": {\n \"plugins\": [\n \"@tanstack/eslint-plugin-query\",\n ],\n \"rules\": {\n \"@tanstack/query/exhaustive-deps\": \"error\",\n },\n },\n }\n `)\n })\n})\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,yBAAyB,MAAM;AAChC,WAAO,OAAO,EAAE,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWrC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.rule.ts"],"sourcesContent":["import { 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'\nimport type { TSESLint } from '@typescript-eslint/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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAAyB;AACzB,yBAA2B;AAC3B,uBAAyB;AACzB,6BAAoC;AAGpC,IAAM,YAAY;AAClB,IAAM,WAAW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AAA,UACH;AAEA,kBAAQ,OAAO;AAAA,YACb;AAAA,YACA,WAAW;AAAA,YACX,MAAM;AAAA,cACJ,MAAM,kBAAkB,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,KAAK,IAAI;AAAA,YAC1D;AAAA,YACA,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.rule.ts"],"sourcesContent":["import { 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'\nimport type { TSESLint } from '@typescript-eslint/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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAGpC,IAAM,YAAY;AAClB,IAAM,WAAW;AAEV,IAAM,OAAO;AAEb,IAAM,OAAO,WAAW;AAAA,EAC7B;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,IACA,UAAU;AAAA,MACR,aAAa;AAAA,MACb,OAAO;AAAA,IACT;AAAA,IACA,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,QAAQ,CAAC;AAAA,EACX;AAAA,EACA,gBAAgB,CAAC;AAAA,EAEjB,OAAO,SAAS;AACd,WAAO;AAAA,MACL,SAAS,MAAM;AACb,YACE,KAAK,WAAW,UAChB,CAAC,SAAS,mBAAmB,KAAK,MAAM,KACxC,CAAC,SAAS,qBAAqB,KAAK,KAAK,SAAS,GAClD;AACA;AAAA,QACF;AAEA,cAAM,eAAe,QAAQ,cAAc,EAAE;AAC7C,cAAM,WAAW,SAAS;AAAA,UACxB,KAAK,OAAO;AAAA,UACZ;AAAA,QACF;AACA,cAAM,UAAU,SAAS;AAAA,UACvB,KAAK,OAAO;AAAA,UACZ;AAAA,QACF;AAEA,YACE,iBAAiB,QACjB,aAAa,UACb,YAAY,UACZ,QAAQ,MAAM,SAAS,eAAe,yBACtC;AACA;AAAA,QACF;AAEA,YAAI,eAAe,SAAS;AAE5B,YACE,aAAa,SAAS,eAAe,kBACrC,aAAa,WAAW,SAAS,eAAe,iBAChD;AACA,yBAAe,aAAa;AAAA,QAC9B;AAEA,YAAI,aAAa,SAAS,eAAe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Q,aAAa,EACrB,QAAQ,OAAO,KAAK,aAAa,GAAG;AAEvC,gBAAM,cAAsD,CAAC;AAE7D,cAAI,aAAa,SAAS,eAAe,iBAAiB;AACxD,wBAAY,KAAK;AAAA,cACf,WAAW;AAAA,cACX,MAAM,EAAE,QAAQ,oBAAoB;AAAA,cACpC,IAAI,OAAO;AACT,uBAAO,MAAM,YAAY,eAAe,mBAAmB;AAAA,cAC7D;AAAA,YACF,CAAC;AAAA,UACH;AAEA,kBAAQ,OAAO;AAAA,YACb;AAAA,YACA,WAAW;AAAA,YACX,MAAM;AAAA,cACJ,MAAM,kBAAkB,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,KAAK,IAAI;AAAA,YAC1D;AAAA,YACA,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './exhaustive-deps.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('exhaustive-deps', rule, {\n valid: [\n {\n name: 'should pass when deps are passed in array (react)',\n code: 'useQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array (solid)',\n code: 'createQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should pass when deps are passed in template literal',\n // eslint-disable-next-line no-template-curly-in-string\n code: 'useQuery({ queryKey: [`entity/${id}`], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should not pass fetch',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => fetch(id) });',\n },\n {\n name: 'should not pass axios.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => axios.get(id) });',\n },\n {\n name: 'should not pass api.entity.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.entity.get(id) });',\n },\n {\n name: 'should not pass api when is being used for calling a function',\n code: `\n import useApi from './useApi'\n\n const useFoo = () => {\n const api = useApi();\n return useQuery({\n queryKey: ['foo'],\n queryFn: () => api.fetchFoo(),\n })\n }\n `,\n },\n {\n name: 'should pass props.src',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props.src], queryFn: () => api.entity.get(props.src) });\n }\n `,\n },\n {\n name: 'identify !!props.id (unary expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", !!props.id], queryFn: () => api.entity.get(props.id) });\n }\n `,\n },\n {\n name: 'identify props?.id (chain expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props?.id], queryFn: () => api.entity.get(props?.id) });\n }\n `,\n },\n {\n name: 'identify props!.id (ts non null expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props!.id], queryFn: () => api.entity.get(props!.id) });\n }\n `,\n },\n {\n name: 'should ignore keys from callback',\n code: `\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep1],\n queryFn: ({ queryKey: [, dep] }) => fetch(dep),\n });\n }\n `,\n },\n {\n name: 'should ignore type identifiers',\n code: `\n type Result = {};\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep],\n queryFn: () => api.get<Result>(dep),\n });\n }\n `,\n },\n {\n name: 'should add \"...args\" to deps',\n code: `\n function foo(...args) {}\n function useData(arg, ...args) {\n return useQuery({\n queryKey: ['foo', arg, ...args],\n queryFn: async () => foo([arg, ...args])\n });\n }\n `,\n },\n {\n name: 'should not add class to deps',\n code: `\n class Foo {}\n useQuery({ queryKey: ['foo'], queryFn: async () => new Foo() });\n `,\n },\n {\n name: 'should not add `undefined` to deps',\n code: `\n useQuery({\n queryKey: [],\n queryFn: async () => {\n if (undefined) {\n return null;\n }\n return 1\n },\n });\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep as first arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ x: num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object 2',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in array',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo([num]),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in second arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(1, num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep is object prop',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (obj: { num: number }) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(obj.num),\n queryFn: () => Promise.resolve(obj.num),\n })\n `,\n },\n {\n name: 'should not treat new Error as missing dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: ['foo'],\n queryFn: () => Promise.reject(new Error('1')),\n })\n `,\n },\n {\n name: 'should see id when there is a const assertion',\n code: normalizeIndent`\n const useX = (id: number) => {\n return useQuery({\n queryKey: ['foo', id] as const,\n queryFn: async () => id,\n })\n }\n `,\n },\n {\n name: 'should not fail if queryKey is having the whole object while queryFn uses some props of it',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n },\n {\n name: 'should not fail if queryKey does not include an internal dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: [\"api\"],\n queryFn: async () => {\n const response = Promise.resolve([]);\n const data = await response.json();\n return data[0].name;\n },\n });\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function declaration)',\n code: `\n const CONST_VAL = 1\n function MyComponent() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function expression)',\n code: `\n const CONST_VAL = 1\n const MyComponent = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, anonymous function)',\n code: `\n const CONST_VAL = 1\n const MyComponent = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (non react component/hook function)',\n code: `\n const CONST_VAL = 1\n function fn() {\n return {\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n }\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function declaration)',\n code: `\n const CONST_VAL = 1\n function useHook() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function expression)',\n code: `\n const CONST_VAL = 1\n const useHook = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, anonymous function)',\n code: `\n const CONST_VAL = 1\n const useHook = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore references of the queryClient',\n code: `\n const CONST_VAL = 1\n function useHook() {\n const queryClient = useQueryClient()\n const kueryKlient = useQueryClient()\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => {\n doSomething(queryClient)\n queryClient.invalidateQueries()\n doSomethingSus(kueryKlient)\n }\n });\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'should fail when deps are missing in query factory',\n code: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity'], queryFn: () => fetchEntity(id) })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: \"['entity', id]\" },\n output: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity', id], queryFn: () => fetchEntity(id) })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (react)',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (solid)',\n code: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when deps are passed incorrectly',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[\"entity/${id}\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should pass missing dep while key has a template literal',\n code: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`], queryFn: () => api.getEntity(a, b) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'b' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[`entity/${a}`, b]' },\n output: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`, b], queryFn: () => api.getEntity(a, b) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep exists inside setter and missing in queryKey',\n code: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\"],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\", id],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey',\n code: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'd, e' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", a, [b], { c }, 1, true, d, e]' },\n output: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true, d, e],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey #2',\n code: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7]],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'dep8' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result:\n \"['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8]\",\n },\n output: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when two deps that depend on each other are missing',\n code: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\"], queryFn: () => api.get(map[key]) });\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'map[key]' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: '[\"key\", map[key]]',\n },\n output: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\", map[key]], queryFn: () => api.get(map[key]) });\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when queryKey is a queryKeyFactory while having missing dep',\n code: normalizeIndent`\n const fooQueryKeyFactory = { foo: () => ['foo'] as const }\n\n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(),\n queryFn: () => Promise.resolve(num),\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'num' },\n },\n ],\n },\n {\n name: 'should fail if queryFn is using multiple object props when only one of them is in the queryKey',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state.foo],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'state.bar' },\n },\n ],\n },\n ],\n})\n"],"mappings":";;;AAAA,mBAA4B;AAC5B,wBAAgC;AAChC,6BAAqB;AAErB,IAAM,aAAa,IAAI,yBAAY,WAAW;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU,CAAC;AACb,CAAC;AAED,WAAW,IAAI,mBAAmB,6BAAM;AAAA,EACtC,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA;AAAA,MAEN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKR;AAA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AAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAKN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,IAAI;AAAA,UAClB,aAAa;AAAA,YACX;AAAA,cACE,WAAW;AAAA,cACX,MAAM;AAAA,gBACJ,QAAQ;AAAA,cACV;AAAA,cACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,YAKV;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,MAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,YAAY;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './exhaustive-deps.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('exhaustive-deps', rule, {\n valid: [\n {\n name: 'should pass when deps are passed in array (react)',\n code: 'useQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array (solid)',\n code: 'createQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should pass when deps are passed in template literal',\n // eslint-disable-next-line no-template-curly-in-string\n code: 'useQuery({ queryKey: [`entity/${id}`], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should not pass fetch',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => fetch(id) });',\n },\n {\n name: 'should not pass axios.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => axios.get(id) });',\n },\n {\n name: 'should not pass api.entity.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.entity.get(id) });',\n },\n {\n name: 'should not pass api when is being used for calling a function',\n code: `\n import useApi from './useApi'\n\n const useFoo = () => {\n const api = useApi();\n return useQuery({\n queryKey: ['foo'],\n queryFn: () => api.fetchFoo(),\n })\n }\n `,\n },\n {\n name: 'should pass props.src',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props.src], queryFn: () => api.entity.get(props.src) });\n }\n `,\n },\n {\n name: 'identify !!props.id (unary expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", !!props.id], queryFn: () => api.entity.get(props.id) });\n }\n `,\n },\n {\n name: 'identify props?.id (chain expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props?.id], queryFn: () => api.entity.get(props?.id) });\n }\n `,\n },\n {\n name: 'identify props!.id (ts non null expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props!.id], queryFn: () => api.entity.get(props!.id) });\n }\n `,\n },\n {\n name: 'should ignore keys from callback',\n code: `\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep1],\n queryFn: ({ queryKey: [, dep] }) => fetch(dep),\n });\n }\n `,\n },\n {\n name: 'should ignore type identifiers',\n code: `\n type Result = {};\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep],\n queryFn: () => api.get<Result>(dep),\n });\n }\n `,\n },\n {\n name: 'should add \"...args\" to deps',\n code: `\n function foo(...args) {}\n function useData(arg, ...args) {\n return useQuery({\n queryKey: ['foo', arg, ...args],\n queryFn: async () => foo([arg, ...args])\n });\n }\n `,\n },\n {\n name: 'should not add class to deps',\n code: `\n class Foo {}\n useQuery({ queryKey: ['foo'], queryFn: async () => new Foo() });\n `,\n },\n {\n name: 'should not add `undefined` to deps',\n code: `\n useQuery({\n queryKey: [],\n queryFn: async () => {\n if (undefined) {\n return null;\n }\n return 1\n },\n });\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep as first arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ x: num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object 2',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in array',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo([num]),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in second arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(1, num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep is object prop',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (obj: { num: number }) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(obj.num),\n queryFn: () => Promise.resolve(obj.num),\n })\n `,\n },\n {\n name: 'should not treat new Error as missing dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: ['foo'],\n queryFn: () => Promise.reject(new Error('1')),\n })\n `,\n },\n {\n name: 'should see id when there is a const assertion',\n code: normalizeIndent`\n const useX = (id: number) => {\n return useQuery({\n queryKey: ['foo', id] as const,\n queryFn: async () => id,\n })\n }\n `,\n },\n {\n name: 'should not fail if queryKey is having the whole object while queryFn uses some props of it',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n },\n {\n name: 'should not fail if queryKey does not include an internal dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: [\"api\"],\n queryFn: async () => {\n const response = Promise.resolve([]);\n const data = await response.json();\n return data[0].name;\n },\n });\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function declaration)',\n code: `\n const CONST_VAL = 1\n function MyComponent() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function expression)',\n code: `\n const CONST_VAL = 1\n const MyComponent = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, anonymous function)',\n code: `\n const CONST_VAL = 1\n const MyComponent = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (non react component/hook function)',\n code: `\n const CONST_VAL = 1\n function fn() {\n return {\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n }\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function declaration)',\n code: `\n const CONST_VAL = 1\n function useHook() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function expression)',\n code: `\n const CONST_VAL = 1\n const useHook = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, anonymous function)',\n code: `\n const CONST_VAL = 1\n const useHook = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore references of the queryClient',\n code: `\n const CONST_VAL = 1\n function useHook() {\n const queryClient = useQueryClient()\n const kueryKlient = useQueryClient()\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => {\n doSomething(queryClient)\n queryClient.invalidateQueries()\n doSomethingSus(kueryKlient)\n }\n });\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'should fail when deps are missing in query factory',\n code: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity'], queryFn: () => fetchEntity(id) })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: \"['entity', id]\" },\n output: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity', id], queryFn: () => fetchEntity(id) })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (react)',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (solid)',\n code: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when deps are passed incorrectly',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[\"entity/${id}\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should pass missing dep while key has a template literal',\n code: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`], queryFn: () => api.getEntity(a, b) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'b' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[`entity/${a}`, b]' },\n output: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`, b], queryFn: () => api.getEntity(a, b) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep exists inside setter and missing in queryKey',\n code: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\"],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\", id],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey',\n code: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'd, e' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", a, [b], { c }, 1, true, d, e]' },\n output: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true, d, e],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey #2',\n code: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7]],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'dep8' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result:\n \"['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8]\",\n },\n output: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when two deps that depend on each other are missing',\n code: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\"], queryFn: () => api.get(map[key]) });\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'map[key]' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: '[\"key\", map[key]]',\n },\n output: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\", map[key]], queryFn: () => api.get(map[key]) });\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when queryKey is a queryKeyFactory while having missing dep',\n code: normalizeIndent`\n const fooQueryKeyFactory = { foo: () => ['foo'] as const }\n\n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(),\n queryFn: () => Promise.resolve(num),\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'num' },\n },\n ],\n },\n {\n name: 'should fail if queryFn is using multiple object props when only one of them is in the queryKey',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state.foo],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'state.bar' },\n },\n ],\n },\n ],\n})\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,YAAY;AAErB,IAAM,aAAa,IAAI,YAAY,WAAW;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU,CAAC;AACb,CAAC;AAED,WAAW,IAAI,mBAAmB,MAAM;AAAA,EACtC,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA;AAAA,MAEN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA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QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,IAAI;AAAA,UAClB,aAAa;AAAA,YACX;AAAA,cACE,WAAW;AAAA,cACX,MAAM;AAAA,gBACJ,QAAQ;AAAA,cACV;AAAA,cACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,YAKV;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAKN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,IAAI;AAAA,UAClB,aAAa;AAAA,YACX;AAAA,cACE,WAAW;AAAA,cACX,MAAM;AAAA,gBACJ,QAAQ;AAAA,cACV;AAAA,cACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,YAKV;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,MAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,YAAY;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport type { TSESLint } from '@typescript-eslint/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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAAyB;AAGlB,IAAM,sBAAsB;AAAA,EACjC,oBAAoB,QAIjB;AATL;AAUI,UAAM,EAAE,WAAW,cAAc,QAAQ,IAAI;AAC7C,UAAM,YAAY,0BAAS,oBAAoB,OAAO;AAEtD,QACE,cAAc,UACd,CAAC,0BAAS,iBAAiB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IAChB,CAAC,GACD;AACA,aAAO;AAAA,IACT;AAEA,WACE,UAAU,WAAW,SAAS,iBAC9B,eAAU,WAAW,WAArB,mBAA6B,UAAS,4BAAe,iBACrD,CAAC,oBAAoB,uBAAuB,SAAS;AAAA,EAEzD;AAAA,EACA,uBAAuB,WAAqC;AA9B9D;AA+BI,UAAM,cAAa,qBAAU,aAAV,mBAAoB,KAAK,OAAzB,mBAA6B;AAEhD,YACE,yCAAY,UAAS,4BAAe,wBACpC,gBAAW,SAAX,mBAAiB,UAAS,4BAAe,kBACzC,WAAW,KAAK,OAAO,SAAS,4BAAe,cAC/C,WAAW,KAAK,OAAO,SAAS;AAAA,EAEpC;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport type { TSESLint } from '@typescript-eslint/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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAGlB,IAAM,sBAAsB;AAAA,EACjC,oBAAoB,QAIjB;AATL;AAUI,UAAM,EAAE,WAAW,cAAc,QAAQ,IAAI;AAC7C,UAAM,YAAY,SAAS,oBAAoB,OAAO;AAEtD,QACE,cAAc,UACd,CAAC,SAAS,iBAAiB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IAChB,CAAC,GACD;AACA,aAAO;AAAA,IACT;AAEA,WACE,UAAU,WAAW,SAAS,iBAC9B,eAAU,WAAW,WAArB,mBAA6B,UAAS,eAAe,iBACrD,CAAC,oBAAoB,uBAAuB,SAAS;AAAA,EAEzD;AAAA,EACA,uBAAuB,WAAqC;AA9B9D;AA+BI,UAAM,cAAa,qBAAU,aAAV,mBAAoB,KAAK,OAAzB,mBAA6B;AAEhD,YACE,yCAAY,UAAS,eAAe,wBACpC,gBAAW,SAAX,mBAAiB,UAAS,eAAe,kBACzC,WAAW,KAAK,OAAO,SAAS,eAAe,cAC/C,WAAW,KAAK,OAAO,SAAS;AAAA,EAEpC;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/rules/index.ts"],"sourcesContent":["import * as exhaustiveDeps from './exhaustive-deps/exhaustive-deps.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgC;AAEzB,IAAM,QAAQ;AAAA,EACnB,CAAgB,mBAAI,GAAkB;AACxC;","names":[]}
@@ -1,9 +0,0 @@
1
- // src/rules/index.ts
2
- import * as exhaustiveDeps from "./exhaustive-deps/exhaustive-deps.rule.js";
3
- var rules = {
4
- [exhaustiveDeps.name]: exhaustiveDeps.rule
5
- };
6
- export {
7
- rules
8
- };
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/rules/index.ts"],"sourcesContent":["import * as exhaustiveDeps from './exhaustive-deps/exhaustive-deps.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n}\n"],"mappings":";AAAA,YAAY,oBAAoB;AAEzB,IAAM,QAAQ;AAAA,EACnB,CAAgB,mBAAI,GAAkB;AACxC;","names":[]}