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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/build/lib/configs/index.d.ts +7 -0
  2. package/build/lib/configs/index.d.ts.map +1 -0
  3. package/build/lib/configs/index.test.d.ts +2 -0
  4. package/build/lib/configs/index.test.d.ts.map +1 -0
  5. package/build/lib/index.cjs +465 -5
  6. package/build/lib/index.cjs.map +1 -0
  7. package/build/lib/index.d.ts +3 -14
  8. package/build/lib/index.d.ts.map +1 -0
  9. package/build/lib/index.js +437 -5
  10. package/build/lib/index.js.map +1 -0
  11. package/build/lib/rules/exhaustive-deps/exhaustive-deps.rule.d.ts +4 -0
  12. package/build/lib/rules/exhaustive-deps/exhaustive-deps.rule.d.ts.map +1 -0
  13. package/build/lib/rules/exhaustive-deps/exhaustive-deps.test.d.ts +2 -0
  14. package/build/lib/rules/exhaustive-deps/exhaustive-deps.test.d.ts.map +1 -0
  15. package/build/lib/rules/exhaustive-deps/exhaustive-deps.utils.d.ts +10 -0
  16. package/build/lib/rules/exhaustive-deps/exhaustive-deps.utils.d.ts.map +1 -0
  17. package/build/lib/rules/index.d.ts +4 -0
  18. package/build/lib/rules/index.d.ts.map +1 -0
  19. package/build/lib/utils/ast-utils.d.ts +40 -0
  20. package/build/lib/utils/ast-utils.d.ts.map +1 -0
  21. package/build/lib/utils/create-rule.d.ts +8 -0
  22. package/build/lib/utils/create-rule.d.ts.map +1 -0
  23. package/build/lib/utils/detect-react-query-imports.d.ts +11 -0
  24. package/build/lib/utils/detect-react-query-imports.d.ts.map +1 -0
  25. package/build/lib/utils/object-utils.d.ts +2 -0
  26. package/build/lib/utils/object-utils.d.ts.map +1 -0
  27. package/build/lib/utils/test-utils.d.ts +2 -0
  28. package/build/lib/utils/test-utils.d.ts.map +1 -0
  29. package/build/lib/utils/unique-by.d.ts +2 -0
  30. package/build/lib/utils/unique-by.d.ts.map +1 -0
  31. package/package.json +7 -20
  32. package/src/configs/index.test.ts +18 -0
  33. package/src/configs/index.ts +22 -0
  34. package/src/index.ts +2 -0
  35. package/src/rules/exhaustive-deps/exhaustive-deps.rule.ts +154 -0
  36. package/src/rules/exhaustive-deps/exhaustive-deps.test.ts +721 -0
  37. package/src/rules/exhaustive-deps/exhaustive-deps.utils.ts +41 -0
  38. package/src/rules/index.ts +5 -0
  39. package/src/utils/ast-utils.ts +318 -0
  40. package/src/utils/create-rule.ts +20 -0
  41. package/src/utils/detect-react-query-imports.ts +75 -0
  42. package/src/utils/object-utils.ts +5 -0
  43. package/src/utils/test-utils.ts +5 -0
  44. package/src/utils/unique-by.ts +3 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/exhaustive-deps/exhaustive-deps.rule.ts","../../src/utils/ast-utils.ts","../../src/utils/unique-by.ts","../../src/utils/create-rule.ts","../../src/utils/detect-react-query-imports.ts","../../src/rules/exhaustive-deps/exhaustive-deps.utils.ts","../../src/rules/index.ts","../../src/configs/index.ts"],"sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport { createRule } from '../../utils/create-rule'\nimport { uniqueBy } from '../../utils/unique-by'\nimport { ExhaustiveDepsUtils } from './exhaustive-deps.utils'\n\nconst QUERY_KEY = 'queryKey'\nconst QUERY_FN = 'queryFn'\n\nexport const name = 'exhaustive-deps'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Exhaustive deps rule for useQuery',\n recommended: 'error',\n },\n messages: {\n missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,\n fixTo: 'Fix to {{result}}',\n },\n hasSuggestions: true,\n fixable: 'code',\n schema: [],\n },\n defaultOptions: [],\n\n create(context) {\n return {\n Property(node) {\n if (\n node.parent === undefined ||\n !ASTUtils.isObjectExpression(node.parent) ||\n !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)\n ) {\n return\n }\n\n const scopeManager = context.getSourceCode().scopeManager\n const queryKey = ASTUtils.findPropertyWithIdentifierKey(\n node.parent.properties,\n QUERY_KEY,\n )\n const queryFn = ASTUtils.findPropertyWithIdentifierKey(\n node.parent.properties,\n QUERY_FN,\n )\n\n if (\n scopeManager === null ||\n queryKey === undefined ||\n queryFn === undefined ||\n queryFn.value.type !== AST_NODE_TYPES.ArrowFunctionExpression\n ) {\n return\n }\n\n let queryKeyNode = queryKey.value\n\n if (\n queryKeyNode.type === AST_NODE_TYPES.TSAsExpression &&\n queryKeyNode.expression.type === AST_NODE_TYPES.ArrayExpression\n ) {\n queryKeyNode = queryKeyNode.expression\n }\n\n if (queryKeyNode.type === AST_NODE_TYPES.Identifier) {\n const expression = ASTUtils.getReferencedExpressionByIdentifier({\n context,\n node: queryKeyNode,\n })\n\n if (expression?.type === AST_NODE_TYPES.ArrayExpression) {\n queryKeyNode = expression\n }\n }\n\n const sourceCode = context.getSourceCode()\n const queryKeyValue = queryKeyNode\n const externalRefs = ASTUtils.getExternalRefs({\n scopeManager,\n sourceCode,\n node: queryFn.value,\n })\n\n const relevantRefs = externalRefs.filter((reference) =>\n ExhaustiveDepsUtils.isRelevantReference({\n context,\n reference,\n scopeManager,\n }),\n )\n\n const existingKeys = ASTUtils.getNestedIdentifiers(queryKeyValue).map(\n (identifier) => ASTUtils.mapKeyNodeToText(identifier, sourceCode),\n )\n\n const missingRefs = relevantRefs\n .map((ref) => ({\n ref: ref,\n text: ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode),\n }))\n .filter(({ ref, text }) => {\n return (\n !ref.isTypeReference &&\n !ASTUtils.isAncestorIsCallee(ref.identifier) &&\n !existingKeys.some((existingKey) => existingKey === text) &&\n !existingKeys.includes(text.split('.')[0] ?? '')\n )\n })\n .map(({ ref, text }) => ({\n identifier: ref.identifier,\n text: text,\n }))\n\n const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text)\n\n if (uniqueMissingRefs.length > 0) {\n const missingAsText = uniqueMissingRefs\n .map((ref) => ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode))\n .join(', ')\n\n const existingWithMissing = sourceCode\n .getText(queryKeyValue)\n .replace(/\\]$/, `, ${missingAsText}]`)\n\n const suggestions: TSESLint.ReportSuggestionArray<string> = []\n\n if (queryKeyNode.type === AST_NODE_TYPES.ArrayExpression) {\n suggestions.push({\n messageId: 'fixTo',\n data: { result: existingWithMissing },\n fix(fixer) {\n return fixer.replaceText(queryKeyValue, existingWithMissing)\n },\n })\n }\n\n context.report({\n node: node,\n messageId: 'missingDeps',\n data: {\n deps: uniqueMissingRefs.map((ref) => ref.text).join(', '),\n },\n suggest: suggestions,\n })\n }\n },\n }\n },\n})\n","import type { TSESLint, TSESTree } from '@typescript-eslint/utils'\nimport type TSESLintScopeManager from '@typescript-eslint/scope-manager'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\nimport { uniqueBy } from './unique-by'\n\nexport const ASTUtils = {\n isNodeOfOneOf<T extends AST_NODE_TYPES>(\n node: TSESTree.Node,\n types: readonly T[],\n ): node is TSESTree.Node & { type: T } {\n return types.includes(node.type as T)\n },\n isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier {\n return node.type === AST_NODE_TYPES.Identifier\n },\n isIdentifierWithName(\n node: TSESTree.Node,\n name: string,\n ): node is TSESTree.Identifier {\n return ASTUtils.isIdentifier(node) && node.name === name\n },\n isIdentifierWithOneOfNames<T extends string[]>(\n node: TSESTree.Node,\n name: T,\n ): node is TSESTree.Identifier & { name: T[number] } {\n return ASTUtils.isIdentifier(node) && name.includes(node.name)\n },\n isProperty(node: TSESTree.Node): node is TSESTree.Property {\n return node.type === AST_NODE_TYPES.Property\n },\n isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression {\n return node.type === AST_NODE_TYPES.ObjectExpression\n },\n isPropertyWithIdentifierKey(\n node: TSESTree.Node,\n key: string,\n ): node is TSESTree.Property {\n return (\n ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key)\n )\n },\n findPropertyWithIdentifierKey(\n properties: TSESTree.ObjectLiteralElement[],\n key: string,\n ): TSESTree.Property | undefined {\n return properties.find((x) =>\n ASTUtils.isPropertyWithIdentifierKey(x, key),\n ) as TSESTree.Property | undefined\n },\n getNestedIdentifiers(node: TSESTree.Node): TSESTree.Identifier[] {\n const identifiers: TSESTree.Identifier[] = []\n\n if (ASTUtils.isIdentifier(node)) {\n identifiers.push(node)\n }\n\n if ('arguments' in node) {\n node.arguments.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('elements' in node) {\n node.elements.forEach((x) => {\n if (x !== null) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n }\n })\n }\n\n if ('properties' in node) {\n node.properties.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('expressions' in node) {\n node.expressions.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if (node.type === AST_NODE_TYPES.Property) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.value))\n }\n\n if (node.type === AST_NODE_TYPES.SpreadElement) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.MemberExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.object))\n }\n\n if (node.type === AST_NODE_TYPES.UnaryExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.ChainExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n if (node.type === AST_NODE_TYPES.TSNonNullExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n return identifiers\n },\n isAncestorIsCallee(identifier: TSESTree.Node) {\n let previousNode = identifier\n let currentNode = identifier.parent\n\n while (currentNode !== undefined) {\n if (\n currentNode.type === AST_NODE_TYPES.CallExpression &&\n currentNode.callee === previousNode\n ) {\n return true\n }\n\n if (currentNode.type !== AST_NODE_TYPES.MemberExpression) {\n return false\n }\n\n previousNode = currentNode\n currentNode = currentNode.parent\n }\n\n return false\n },\n traverseUpOnly(\n identifier: TSESTree.Node,\n allowedNodeTypes: AST_NODE_TYPES[],\n ): TSESTree.Node {\n const parent = identifier.parent\n\n if (parent !== undefined && allowedNodeTypes.includes(parent.type)) {\n return ASTUtils.traverseUpOnly(parent, allowedNodeTypes)\n }\n\n return identifier\n },\n isDeclaredInNode(params: {\n functionNode: TSESTree.Node\n reference: TSESLintScopeManager.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { functionNode, reference, scopeManager } = params\n const scope = scopeManager.acquire(functionNode)\n\n if (scope === null) {\n return false\n }\n\n return scope.set.has(reference.identifier.name)\n },\n getExternalRefs(params: {\n scopeManager: TSESLint.Scope.ScopeManager\n sourceCode: Readonly<TSESLint.SourceCode>\n node: TSESTree.Node\n }): TSESLint.Scope.Reference[] {\n const { scopeManager, sourceCode, node } = params\n const scope = scopeManager.acquire(node)\n\n if (scope === null) {\n return []\n }\n\n const references = scope.references\n .filter((x) => x.isRead() && !scope.set.has(x.identifier.name))\n .map((x) => {\n const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ])\n\n return {\n variable: x,\n node: referenceNode,\n text: sourceCode.getText(referenceNode),\n }\n })\n\n const localRefIds = new Set(\n [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0])),\n )\n\n const externalRefs = references.filter(\n (x) => x.variable.resolved === null || !localRefIds.has(x.text),\n )\n\n return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)\n },\n mapKeyNodeToText(\n node: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n ) {\n return sourceCode.getText(\n ASTUtils.traverseUpOnly(node, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ]),\n )\n },\n isValidReactComponentOrHookName(identifier: TSESTree.Identifier | null) {\n return identifier !== null && /^(use|[A-Z])/.test(identifier.name)\n },\n getFunctionAncestor(\n context: Readonly<RuleContext<string, readonly unknown[]>>,\n ) {\n return context.getAncestors().find((x) => {\n if (x.type === AST_NODE_TYPES.FunctionDeclaration) {\n return true\n }\n\n return (\n x.parent?.type === AST_NODE_TYPES.VariableDeclarator &&\n x.parent.id.type === AST_NODE_TYPES.Identifier &&\n ASTUtils.isNodeOfOneOf(x, [\n AST_NODE_TYPES.FunctionDeclaration,\n AST_NODE_TYPES.FunctionExpression,\n AST_NODE_TYPES.ArrowFunctionExpression,\n ])\n )\n })\n },\n getReferencedExpressionByIdentifier(params: {\n node: TSESTree.Node\n context: Readonly<RuleContext<string, readonly unknown[]>>\n }) {\n const { node, context } = params\n\n const resolvedNode = context\n .getScope()\n .references.find((ref) => ref.identifier === node)?.resolved\n ?.defs[0]?.node\n\n if (resolvedNode?.type !== AST_NODE_TYPES.VariableDeclarator) {\n return null\n }\n\n return resolvedNode.init\n },\n getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[] {\n const returnStatements: TSESTree.ReturnStatement[] = []\n\n if (node.type === AST_NODE_TYPES.ReturnStatement) {\n returnStatements.push(node)\n }\n\n if ('body' in node && node.body !== undefined && node.body !== null) {\n Array.isArray(node.body)\n ? node.body.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.body),\n )\n }\n\n if ('consequent' in node) {\n Array.isArray(node.consequent)\n ? node.consequent.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.consequent),\n )\n }\n\n if ('alternate' in node && node.alternate !== null) {\n Array.isArray(node.alternate)\n ? node.alternate.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.alternate),\n )\n }\n\n if ('cases' in node) {\n node.cases.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n }\n\n if ('block' in node) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block))\n }\n\n if ('handler' in node && node.handler !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler))\n }\n\n if ('finalizer' in node && node.finalizer !== null) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.finalizer),\n )\n }\n\n if (\n 'expression' in node &&\n node.expression !== true &&\n node.expression !== false\n ) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.expression),\n )\n }\n\n if ('test' in node && node.test !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test))\n }\n\n return returnStatements\n },\n}\n","export function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[] {\n return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)\n}\n","import { ESLintUtils } from '@typescript-eslint/utils'\nimport type { EnhancedCreate } from './detect-react-query-imports'\nimport { detectTanstackQueryImports } from './detect-react-query-imports'\n\nconst getDocsUrl = (ruleName: string): string =>\n `https://tanstack.com/query/v4/docs/eslint/${ruleName}`\n\ntype EslintRule = Omit<\n Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0],\n 'create'\n> & {\n create: EnhancedCreate\n}\n\nexport function createRule({ create, ...rest }: EslintRule) {\n return ESLintUtils.RuleCreator(getDocsUrl)({\n ...rest,\n create: detectTanstackQueryImports(create),\n })\n}\n","import type { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils'\n\ntype Create = Parameters<\n ReturnType<typeof ESLintUtils.RuleCreator>\n>[0]['create']\n\ntype Context = Parameters<Create>[0]\ntype Options = Parameters<Create>[1]\ntype Helpers = {\n isTanstackQueryImport: (node: TSESTree.Identifier) => boolean\n}\n\nexport type EnhancedCreate = (\n context: Context,\n options: Options,\n helpers: Helpers,\n) => ReturnType<Create>\n\nexport function detectTanstackQueryImports(create: EnhancedCreate): Create {\n return (context, optionsWithDefault) => {\n const tanstackQueryImportSpecifiers: TSESTree.ImportClause[] = []\n\n const helpers: Helpers = {\n isTanstackQueryImport(node) {\n return !!tanstackQueryImportSpecifiers.find((specifier) => {\n if (specifier.type === 'ImportSpecifier') {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n }\n\n const detectionInstructions: TSESLint.RuleListener = {\n ImportDeclaration(node) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value.startsWith('@tanstack/') &&\n node.source.value.endsWith('-query')\n ) {\n tanstackQueryImportSpecifiers.push(...node.specifiers)\n }\n },\n }\n\n // Call original rule definition\n const ruleInstructions = create(context, optionsWithDefault, helpers)\n const enhancedRuleInstructions: TSESLint.RuleListener = {}\n\n const allKeys = new Set(\n Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)),\n )\n\n // Iterate over ALL instructions keys so we can override original rule instructions\n // to prevent their execution if conditions to report errors are not met.\n allKeys.forEach((instruction) => {\n enhancedRuleInstructions[instruction] = (node) => {\n if (instruction in detectionInstructions) {\n detectionInstructions[instruction]?.(node)\n }\n\n // TODO: canReportErrors()\n if (ruleInstructions[instruction]) {\n return ruleInstructions[instruction]?.(node)\n }\n\n return undefined\n }\n })\n\n return enhancedRuleInstructions\n }\n}\n","import type { TSESLint } from '@typescript-eslint/utils'\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\n\nexport const ExhaustiveDepsUtils = {\n isRelevantReference(params: {\n context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>\n reference: TSESLint.Scope.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { reference, scopeManager, context } = params\n const component = ASTUtils.getFunctionAncestor(context)\n\n if (\n component !== undefined &&\n !ASTUtils.isDeclaredInNode({\n scopeManager,\n reference,\n functionNode: component,\n })\n ) {\n return false\n }\n\n return (\n reference.identifier.name !== 'undefined' &&\n reference.identifier.parent?.type !== AST_NODE_TYPES.NewExpression &&\n !ExhaustiveDepsUtils.isQueryClientReference(reference)\n )\n },\n isQueryClientReference(reference: TSESLint.Scope.Reference) {\n const declarator = reference.resolved?.defs[0]?.node\n\n return (\n declarator?.type === AST_NODE_TYPES.VariableDeclarator &&\n declarator.init?.type === AST_NODE_TYPES.CallExpression &&\n declarator.init.callee.type === AST_NODE_TYPES.Identifier &&\n declarator.init.callee.name === 'useQueryClient'\n )\n },\n}\n","import * as exhaustiveDeps from './exhaustive-deps/exhaustive-deps.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n}\n","import type { TSESLint } from '@typescript-eslint/utils'\nimport { rules } from '../rules'\n\nfunction generateRecommendedConfig(\n allRules: Record<string, TSESLint.RuleModule<any, any>>,\n) {\n return Object.entries(allRules).reduce((memo, [name, rule]) => {\n const { recommended } = rule.meta.docs || {}\n\n return {\n ...memo,\n ...(recommended ? { [`@tanstack/query/${name}`]: recommended } : {}),\n }\n }, {} as Record<string, 'strict' | 'error' | 'warn'>)\n}\n\nexport const configs = {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-query'],\n rules: generateRecommendedConfig(rules),\n },\n}\n"],"mappings":";AACA,SAAS,kBAAAA,uBAAsB;;;ACC/B,SAAS,sBAAsB;;;ACFxB,SAAS,SAAY,KAAU,IAA4B;AAChE,SAAO,IAAI,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1E;;;ADIO,IAAM,WAAW;AAAA,EACtB,cACE,MACA,OACqC;AACrC,WAAO,MAAM,SAAS,KAAK,IAAS;AAAA,EACtC;AAAA,EACA,aAAa,MAAkD;AAC7D,WAAO,KAAK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AAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmBD,OAAM,GAAG,YAAY,IAAI,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,CAAgD;AACtD;AAEO,IAAM,UAAU;AAAA,EACrB,aAAa;AAAA,IACX,SAAS,CAAC,+BAA+B;AAAA,IACzC,OAAO,0BAA0B,KAAK;AAAA,EACxC;AACF;","names":["AST_NODE_TYPES","name","AST_NODE_TYPES","AST_NODE_TYPES","AST_NODE_TYPES","name","rule"]}
@@ -0,0 +1,4 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils';
2
+ export declare const name = "exhaustive-deps";
3
+ export declare const rule: TSESLint.RuleModule<string, readonly unknown[], TSESLint.RuleListener>;
4
+ //# sourceMappingURL=exhaustive-deps.rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exhaustive-deps.rule.d.ts","sourceRoot":"","sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAUxD,eAAO,MAAM,IAAI,oBAAoB,CAAA;AAErC,eAAO,MAAM,IAAI,wEA6If,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=exhaustive-deps.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exhaustive-deps.test.d.ts","sourceRoot":"","sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils';
2
+ export declare const ExhaustiveDepsUtils: {
3
+ isRelevantReference(params: {
4
+ context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>;
5
+ reference: TSESLint.Scope.Reference;
6
+ scopeManager: TSESLint.Scope.ScopeManager;
7
+ }): boolean;
8
+ isQueryClientReference(reference: TSESLint.Scope.Reference): boolean;
9
+ };
10
+ //# sourceMappingURL=exhaustive-deps.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exhaustive-deps.utils.d.ts","sourceRoot":"","sources":["../../../../src/rules/exhaustive-deps/exhaustive-deps.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAIxD,eAAO,MAAM,mBAAmB;gCACF;QAC1B,OAAO,EAAE,SAAS,SAAS,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAA;QACnE,SAAS,EAAE,SAAS,KAAK,CAAC,SAAS,CAAA;QACnC,YAAY,EAAE,SAAS,KAAK,CAAC,YAAY,CAAA;KAC1C;sCAqBiC,SAAS,KAAK,CAAC,SAAS;CAU3D,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const rules: {
2
+ "exhaustive-deps": import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, readonly unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
3
+ };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;CAEjB,CAAA"}
@@ -0,0 +1,40 @@
1
+ import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
2
+ import type TSESLintScopeManager from '@typescript-eslint/scope-manager';
3
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
4
+ import type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint';
5
+ export declare const ASTUtils: {
6
+ isNodeOfOneOf<T extends TSESTree.AST_NODE_TYPES>(node: TSESTree.Node, types: readonly T[]): node is TSESTree.Node & {
7
+ type: T;
8
+ };
9
+ isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier;
10
+ isIdentifierWithName(node: TSESTree.Node, name: string): node is TSESTree.Identifier;
11
+ isIdentifierWithOneOfNames<T_1 extends string[]>(node: TSESTree.Node, name: T_1): node is TSESTree.Identifier & {
12
+ name: T_1[number];
13
+ };
14
+ isProperty(node: TSESTree.Node): node is TSESTree.Property;
15
+ isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression;
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[];
19
+ isAncestorIsCallee(identifier: TSESTree.Node): boolean;
20
+ traverseUpOnly(identifier: TSESTree.Node, allowedNodeTypes: AST_NODE_TYPES[]): TSESTree.Node;
21
+ isDeclaredInNode(params: {
22
+ functionNode: TSESTree.Node;
23
+ reference: TSESLintScopeManager.Reference;
24
+ scopeManager: TSESLint.Scope.ScopeManager;
25
+ }): boolean;
26
+ getExternalRefs(params: {
27
+ scopeManager: TSESLint.Scope.ScopeManager;
28
+ sourceCode: Readonly<TSESLint.SourceCode>;
29
+ node: TSESTree.Node;
30
+ }): TSESLint.Scope.Reference[];
31
+ mapKeyNodeToText(node: TSESTree.Node, sourceCode: Readonly<TSESLint.SourceCode>): string;
32
+ isValidReactComponentOrHookName(identifier: TSESTree.Identifier | null): boolean;
33
+ getFunctionAncestor(context: Readonly<RuleContext<string, readonly unknown[]>>): TSESTree.Node | undefined;
34
+ getReferencedExpressionByIdentifier(params: {
35
+ node: TSESTree.Node;
36
+ context: Readonly<RuleContext<string, readonly unknown[]>>;
37
+ }): TSESTree.Expression | null;
38
+ getNestedReturnStatements(node: TSESTree.Node): TSESTree.ReturnStatement[];
39
+ };
40
+ //# sourceMappingURL=ast-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,oBAAoB,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAG1E,eAAO,MAAM,QAAQ;2DAEX,aAAa;;;uBAKF,aAAa;+BAIxB,aAAa,QACb,MAAM;2DAKN,aAAa;;;qBAKJ,aAAa;6BAGL,aAAa;sCAI9B,aAAa,OACd,MAAM;8CAOC,SAAS,oBAAoB,EAAE,OACtC,MAAM,GACV,SAAS,QAAQ,GAAG,SAAS;+BAKL,aAAa,GAAG,SAAS,UAAU,EAAE;mCA2DjC,aAAa;+BAuB9B,aAAa,oBACP,cAAc,EAAE,GACjC,aAAa;6BASS;QACvB,YAAY,EAAE,aAAa,CAAA;QAC3B,SAAS,EAAE,qBAAqB,SAAS,CAAA;QACzC,YAAY,EAAE,SAAS,KAAK,CAAC,YAAY,CAAA;KAC1C;4BAUuB;QACtB,YAAY,EAAE,SAAS,KAAK,CAAC,YAAY,CAAA;QACzC,UAAU,EAAE,SAAS,SAAS,UAAU,CAAC,CAAA;QACzC,IAAI,EAAE,aAAa,CAAA;KACpB,GAAG,SAAS,KAAK,CAAC,SAAS,EAAE;2BAkCtB,aAAa,cACP,SAAS,SAAS,UAAU,CAAC;gDASC,SAAS,UAAU,GAAG,IAAI;iCAI3D,SAAS,YAAY,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC;gDAkBhB;QAC1C,IAAI,EAAE,aAAa,CAAA;QACnB,OAAO,EAAE,SAAS,YAAY,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAA;KAC3D;oCAc+B,aAAa,GAAG,SAAS,eAAe,EAAE;CAyE3E,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import type { EnhancedCreate } from './detect-react-query-imports';
3
+ type EslintRule = Omit<Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0], 'create'> & {
4
+ create: EnhancedCreate;
5
+ };
6
+ export declare function createRule({ create, ...rest }: EslintRule): import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, readonly unknown[], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
7
+ export {};
8
+ //# sourceMappingURL=create-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-rule.d.ts","sourceRoot":"","sources":["../../../src/utils/create-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAMlE,KAAK,UAAU,GAAG,IAAI,CACpB,UAAU,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EACzD,QAAQ,CACT,GAAG;IACF,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,UAAU,sKAKzD"}
@@ -0,0 +1,11 @@
1
+ import type { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
2
+ type Create = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]['create'];
3
+ type Context = Parameters<Create>[0];
4
+ type Options = Parameters<Create>[1];
5
+ type Helpers = {
6
+ isTanstackQueryImport: (node: TSESTree.Identifier) => boolean;
7
+ };
8
+ export type EnhancedCreate = (context: Context, options: Options, helpers: Helpers) => ReturnType<Create>;
9
+ export declare function detectTanstackQueryImports(create: EnhancedCreate): Create;
10
+ export {};
11
+ //# sourceMappingURL=detect-react-query-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-react-query-imports.d.ts","sourceRoot":"","sources":["../../../src/utils/detect-react-query-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAE/E,KAAK,MAAM,GAAG,UAAU,CACtB,UAAU,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,CAC3C,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AAEd,KAAK,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,KAAK,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,KAAK,OAAO,GAAG;IACb,qBAAqB,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,KAAK,OAAO,CAAA;CAC9D,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,KACb,UAAU,CAAC,MAAM,CAAC,CAAA;AAEvB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAwDzE"}
@@ -0,0 +1,2 @@
1
+ export declare function objectKeys<T extends Record<string, unknown>>(obj: T): Array<keyof T>;
2
+ //# sourceMappingURL=object-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/object-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,GAAG,EAAE,CAAC,GACL,KAAK,CAAC,MAAM,CAAC,CAAC,CAEhB"}
@@ -0,0 +1,2 @@
1
+ export declare function normalizeIndent(template: TemplateStringsArray): string;
2
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/test-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,UAI7D"}
@@ -0,0 +1,2 @@
1
+ export declare function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[];
2
+ //# sourceMappingURL=unique-by.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unique-by.d.ts","sourceRoot":"","sources":["../../../src/utils/unique-by.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,EAAE,CAEhE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/eslint-plugin-query",
3
- "version": "5.0.0-alpha.59",
3
+ "version": "5.0.0-alpha.68",
4
4
  "description": "ESLint plugin for TanStack Query",
5
5
  "author": "Eliya Cohen",
6
6
  "license": "MIT",
@@ -24,29 +24,14 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "files": [
27
- "build"
27
+ "build",
28
+ "src"
28
29
  ],
29
- "tsup": {
30
- "entry": [
31
- "src/index.ts"
32
- ],
33
- "external": [
34
- "eslint"
35
- ],
36
- "format": [
37
- "cjs",
38
- "esm"
39
- ],
40
- "clean": true,
41
- "bundle": true,
42
- "outDir": "build/lib"
43
- },
44
30
  "devDependencies": {
45
31
  "@typescript-eslint/eslint-plugin": "^5.54.0",
46
32
  "@typescript-eslint/parser": "^5.54.0",
47
33
  "@typescript-eslint/utils": "^5.54.0",
48
- "eslint": "^8.34.0",
49
- "tsup": "^6.7.0"
34
+ "eslint": "^8.34.0"
50
35
  },
51
36
  "peerDependencies": {
52
37
  "eslint": "^8.0.0"
@@ -59,6 +44,8 @@
59
44
  "test:lib": "vitest run --coverage",
60
45
  "test:lib:dev": "pnpm run test:lib --watch",
61
46
  "test:build": "publint --strict",
62
- "build": "tsup --minify --dts"
47
+ "build": "pnpm build:tsup && pnpm build:types",
48
+ "build:tsup": "tsup",
49
+ "build:types": "tsc --emitDeclarationOnly"
63
50
  }
64
51
  }
@@ -0,0 +1,18 @@
1
+ import { configs } from './index'
2
+
3
+ describe('configs', () => {
4
+ it('should match snapshot', () => {
5
+ expect(configs).toMatchInlineSnapshot(`
6
+ {
7
+ "recommended": {
8
+ "plugins": [
9
+ "@tanstack/eslint-plugin-query",
10
+ ],
11
+ "rules": {
12
+ "@tanstack/query/exhaustive-deps": "error",
13
+ },
14
+ },
15
+ }
16
+ `)
17
+ })
18
+ })
@@ -0,0 +1,22 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+ import { rules } from '../rules'
3
+
4
+ function generateRecommendedConfig(
5
+ allRules: Record<string, TSESLint.RuleModule<any, any>>,
6
+ ) {
7
+ return Object.entries(allRules).reduce((memo, [name, rule]) => {
8
+ const { recommended } = rule.meta.docs || {}
9
+
10
+ return {
11
+ ...memo,
12
+ ...(recommended ? { [`@tanstack/query/${name}`]: recommended } : {}),
13
+ }
14
+ }, {} as Record<string, 'strict' | 'error' | 'warn'>)
15
+ }
16
+
17
+ export const configs = {
18
+ recommended: {
19
+ plugins: ['@tanstack/eslint-plugin-query'],
20
+ rules: generateRecommendedConfig(rules),
21
+ },
22
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { configs } from './configs'
2
+ export { rules } from './rules'
@@ -0,0 +1,154 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
3
+ import { ASTUtils } from '../../utils/ast-utils'
4
+ import { createRule } from '../../utils/create-rule'
5
+ import { uniqueBy } from '../../utils/unique-by'
6
+ import { ExhaustiveDepsUtils } from './exhaustive-deps.utils'
7
+
8
+ const QUERY_KEY = 'queryKey'
9
+ const QUERY_FN = 'queryFn'
10
+
11
+ export const name = 'exhaustive-deps'
12
+
13
+ export const rule = createRule({
14
+ name,
15
+ meta: {
16
+ type: 'problem',
17
+ docs: {
18
+ description: 'Exhaustive deps rule for useQuery',
19
+ recommended: 'error',
20
+ },
21
+ messages: {
22
+ missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,
23
+ fixTo: 'Fix to {{result}}',
24
+ },
25
+ hasSuggestions: true,
26
+ fixable: 'code',
27
+ schema: [],
28
+ },
29
+ defaultOptions: [],
30
+
31
+ create(context) {
32
+ return {
33
+ Property(node) {
34
+ if (
35
+ node.parent === undefined ||
36
+ !ASTUtils.isObjectExpression(node.parent) ||
37
+ !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)
38
+ ) {
39
+ return
40
+ }
41
+
42
+ const scopeManager = context.getSourceCode().scopeManager
43
+ const queryKey = ASTUtils.findPropertyWithIdentifierKey(
44
+ node.parent.properties,
45
+ QUERY_KEY,
46
+ )
47
+ const queryFn = ASTUtils.findPropertyWithIdentifierKey(
48
+ node.parent.properties,
49
+ QUERY_FN,
50
+ )
51
+
52
+ if (
53
+ scopeManager === null ||
54
+ queryKey === undefined ||
55
+ queryFn === undefined ||
56
+ queryFn.value.type !== AST_NODE_TYPES.ArrowFunctionExpression
57
+ ) {
58
+ return
59
+ }
60
+
61
+ let queryKeyNode = queryKey.value
62
+
63
+ if (
64
+ queryKeyNode.type === AST_NODE_TYPES.TSAsExpression &&
65
+ queryKeyNode.expression.type === AST_NODE_TYPES.ArrayExpression
66
+ ) {
67
+ queryKeyNode = queryKeyNode.expression
68
+ }
69
+
70
+ if (queryKeyNode.type === AST_NODE_TYPES.Identifier) {
71
+ const expression = ASTUtils.getReferencedExpressionByIdentifier({
72
+ context,
73
+ node: queryKeyNode,
74
+ })
75
+
76
+ if (expression?.type === AST_NODE_TYPES.ArrayExpression) {
77
+ queryKeyNode = expression
78
+ }
79
+ }
80
+
81
+ const sourceCode = context.getSourceCode()
82
+ const queryKeyValue = queryKeyNode
83
+ const externalRefs = ASTUtils.getExternalRefs({
84
+ scopeManager,
85
+ sourceCode,
86
+ node: queryFn.value,
87
+ })
88
+
89
+ const relevantRefs = externalRefs.filter((reference) =>
90
+ ExhaustiveDepsUtils.isRelevantReference({
91
+ context,
92
+ reference,
93
+ scopeManager,
94
+ }),
95
+ )
96
+
97
+ const existingKeys = ASTUtils.getNestedIdentifiers(queryKeyValue).map(
98
+ (identifier) => ASTUtils.mapKeyNodeToText(identifier, sourceCode),
99
+ )
100
+
101
+ const missingRefs = relevantRefs
102
+ .map((ref) => ({
103
+ ref: ref,
104
+ text: ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode),
105
+ }))
106
+ .filter(({ ref, text }) => {
107
+ return (
108
+ !ref.isTypeReference &&
109
+ !ASTUtils.isAncestorIsCallee(ref.identifier) &&
110
+ !existingKeys.some((existingKey) => existingKey === text) &&
111
+ !existingKeys.includes(text.split('.')[0] ?? '')
112
+ )
113
+ })
114
+ .map(({ ref, text }) => ({
115
+ identifier: ref.identifier,
116
+ text: text,
117
+ }))
118
+
119
+ const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text)
120
+
121
+ if (uniqueMissingRefs.length > 0) {
122
+ const missingAsText = uniqueMissingRefs
123
+ .map((ref) => ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode))
124
+ .join(', ')
125
+
126
+ const existingWithMissing = sourceCode
127
+ .getText(queryKeyValue)
128
+ .replace(/\]$/, `, ${missingAsText}]`)
129
+
130
+ const suggestions: TSESLint.ReportSuggestionArray<string> = []
131
+
132
+ if (queryKeyNode.type === AST_NODE_TYPES.ArrayExpression) {
133
+ suggestions.push({
134
+ messageId: 'fixTo',
135
+ data: { result: existingWithMissing },
136
+ fix(fixer) {
137
+ return fixer.replaceText(queryKeyValue, existingWithMissing)
138
+ },
139
+ })
140
+ }
141
+
142
+ context.report({
143
+ node: node,
144
+ messageId: 'missingDeps',
145
+ data: {
146
+ deps: uniqueMissingRefs.map((ref) => ref.text).join(', '),
147
+ },
148
+ suggest: suggestions,
149
+ })
150
+ }
151
+ },
152
+ }
153
+ },
154
+ })