@tanstack/eslint-plugin-query 5.0.0-beta.0 → 5.0.0-beta.14

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 (82) hide show
  1. package/build/legacy/__tests__/configs.test.cjs +21 -0
  2. package/build/legacy/__tests__/configs.test.cjs.map +1 -0
  3. package/build/legacy/__tests__/configs.test.d.cts +2 -0
  4. package/build/legacy/__tests__/configs.test.d.ts +2 -0
  5. package/build/legacy/__tests__/configs.test.js +19 -0
  6. package/build/legacy/__tests__/configs.test.js.map +1 -0
  7. package/build/legacy/__tests__/exhaustive-deps.test.cjs +722 -0
  8. package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +1 -0
  9. package/build/legacy/__tests__/exhaustive-deps.test.d.cts +2 -0
  10. package/build/legacy/__tests__/exhaustive-deps.test.d.ts +2 -0
  11. package/build/legacy/__tests__/exhaustive-deps.test.js +720 -0
  12. package/build/legacy/__tests__/exhaustive-deps.test.js.map +1 -0
  13. package/build/legacy/configs.cjs +46 -0
  14. package/build/legacy/configs.cjs.map +1 -0
  15. package/build/legacy/configs.d.cts +8 -0
  16. package/build/legacy/configs.d.ts +8 -0
  17. package/build/legacy/configs.js +21 -0
  18. package/build/legacy/configs.js.map +1 -0
  19. package/build/legacy/index.d.cts +3 -14
  20. package/build/legacy/index.d.ts +3 -14
  21. package/build/legacy/rules/exhaustive-deps.rule.cjs +141 -0
  22. package/build/legacy/rules/exhaustive-deps.rule.cjs.map +1 -0
  23. package/build/legacy/rules/exhaustive-deps.rule.d.cts +6 -0
  24. package/build/legacy/rules/exhaustive-deps.rule.d.ts +6 -0
  25. package/build/legacy/rules/exhaustive-deps.rule.js +115 -0
  26. package/build/legacy/rules/exhaustive-deps.rule.js.map +1 -0
  27. package/build/legacy/rules/exhaustive-deps.utils.cjs +52 -0
  28. package/build/legacy/rules/exhaustive-deps.utils.cjs.map +1 -0
  29. package/build/legacy/rules/exhaustive-deps.utils.d.cts +12 -0
  30. package/build/legacy/rules/exhaustive-deps.utils.d.ts +12 -0
  31. package/build/legacy/rules/exhaustive-deps.utils.js +27 -0
  32. package/build/legacy/rules/exhaustive-deps.utils.js.map +1 -0
  33. package/build/legacy/rules.cjs +44 -0
  34. package/build/legacy/rules.cjs.map +1 -0
  35. package/build/legacy/rules.d.cts +7 -0
  36. package/build/legacy/rules.d.ts +7 -0
  37. package/build/legacy/rules.js +9 -0
  38. package/build/legacy/rules.js.map +1 -0
  39. package/build/legacy/utils/ast-utils.cjs +247 -0
  40. package/build/legacy/utils/ast-utils.cjs.map +1 -0
  41. package/build/legacy/utils/ast-utils.d.cts +41 -0
  42. package/build/legacy/utils/ast-utils.d.ts +41 -0
  43. package/build/legacy/utils/ast-utils.js +222 -0
  44. package/build/legacy/utils/ast-utils.js.map +1 -0
  45. package/build/legacy/utils/create-rule.cjs +39 -0
  46. package/build/legacy/utils/create-rule.cjs.map +1 -0
  47. package/build/legacy/utils/create-rule.d.cts +10 -0
  48. package/build/legacy/utils/create-rule.d.ts +10 -0
  49. package/build/legacy/utils/create-rule.js +14 -0
  50. package/build/legacy/utils/create-rule.js.map +1 -0
  51. package/build/legacy/utils/detect-react-query-imports.cjs +70 -0
  52. package/build/legacy/utils/detect-react-query-imports.cjs.map +1 -0
  53. package/build/legacy/utils/detect-react-query-imports.d.cts +12 -0
  54. package/build/legacy/utils/detect-react-query-imports.d.ts +12 -0
  55. package/build/legacy/utils/detect-react-query-imports.js +45 -0
  56. package/build/legacy/utils/detect-react-query-imports.js.map +1 -0
  57. package/build/legacy/utils/object-utils.cjs +33 -0
  58. package/build/legacy/utils/object-utils.cjs.map +1 -0
  59. package/build/legacy/utils/object-utils.d.cts +3 -0
  60. package/build/legacy/utils/object-utils.d.ts +3 -0
  61. package/build/legacy/utils/object-utils.js +8 -0
  62. package/build/legacy/utils/object-utils.js.map +1 -0
  63. package/build/legacy/utils/test-utils.cjs +36 -0
  64. package/build/legacy/utils/test-utils.cjs.map +1 -0
  65. package/build/legacy/utils/test-utils.d.cts +3 -0
  66. package/build/legacy/utils/test-utils.d.ts +3 -0
  67. package/build/legacy/utils/test-utils.js +11 -0
  68. package/build/legacy/utils/test-utils.js.map +1 -0
  69. package/build/legacy/utils/unique-by.cjs +33 -0
  70. package/build/legacy/utils/unique-by.cjs.map +1 -0
  71. package/build/legacy/utils/unique-by.d.cts +3 -0
  72. package/build/legacy/utils/unique-by.d.ts +3 -0
  73. package/build/legacy/utils/unique-by.js +8 -0
  74. package/build/legacy/utils/unique-by.js.map +1 -0
  75. package/package.json +7 -3
  76. package/src/{configs/index.test.ts → __tests__/configs.test.ts} +1 -1
  77. package/src/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.ts +2 -2
  78. package/src/{configs/index.ts → configs.ts} +1 -1
  79. package/src/rules/{exhaustive-deps/exhaustive-deps.rule.ts → exhaustive-deps.rule.ts} +3 -3
  80. package/src/rules/{exhaustive-deps/exhaustive-deps.utils.ts → exhaustive-deps.utils.ts} +1 -1
  81. package/src/rules.ts +5 -0
  82. package/src/rules/index.ts +0 -5
@@ -0,0 +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 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,SA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,eAAe,QAAQ,KAAK,cAAc,MAAM;AAClD,YAAM,QAAQ,KAAK,SAAS,IACxB,KAAK,UAAU,QAAQ,CAAC,MAAM;AAC5B,yBAAiB,KAAK,GAAG,SAAS,0BAA0B,CAAC,CAAC;AAAA,MAChE,CAAC,IACD,iBAAiB;AAAA,QACf,GAAG,SAAS,0BAA0B,KAAK,SAAS;AAAA,MACtD;AAAA,IACN;AAEA,QAAI,WAAW,MAAM;AACnB,WAAK,MAAM,QAAQ,CAAC,MAAM;AACxB,yBAAiB,KAAK,GAAG,SAAS,0BAA0B,CAAC,CAAC;AAAA,MAChE,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,MAAM;AACnB,uBAAiB,KAAK,GAAG,SAAS,0BAA0B,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":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/create-rule.ts
21
+ var create_rule_exports = {};
22
+ __export(create_rule_exports, {
23
+ createRule: () => createRule
24
+ });
25
+ module.exports = __toCommonJS(create_rule_exports);
26
+ var import_utils = require("@typescript-eslint/utils");
27
+ var import_detect_react_query_imports = require("./detect-react-query-imports.cjs");
28
+ var getDocsUrl = (ruleName) => `https://tanstack.com/query/v4/docs/eslint/${ruleName}`;
29
+ function createRule({ create, ...rest }) {
30
+ return import_utils.ESLintUtils.RuleCreator(getDocsUrl)({
31
+ ...rest,
32
+ create: (0, import_detect_react_query_imports.detectTanstackQueryImports)(create)
33
+ });
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ createRule
38
+ });
39
+ //# sourceMappingURL=create-rule.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/create-rule.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { detectTanstackQueryImports } from './detect-react-query-imports'\nimport type { EnhancedCreate } 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAC5B,wCAA2C;AAG3C,IAAM,aAAa,CAAC,aAClB,6CAA6C,QAAQ;AAShD,SAAS,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAe;AAC1D,SAAO,yBAAY,YAAY,UAAU,EAAE;AAAA,IACzC,GAAG;AAAA,IACH,YAAQ,8DAA2B,MAAM;AAAA,EAC3C,CAAC;AACH;","names":[]}
@@ -0,0 +1,10 @@
1
+ import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
3
+ import { EnhancedCreate } from './detect-react-query-imports.cjs';
4
+
5
+ type EslintRule = Omit<Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0], 'create'> & {
6
+ create: EnhancedCreate;
7
+ };
8
+ declare function createRule({ create, ...rest }: EslintRule): _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
9
+
10
+ export { createRule };
@@ -0,0 +1,10 @@
1
+ import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
3
+ import { EnhancedCreate } from './detect-react-query-imports.js';
4
+
5
+ type EslintRule = Omit<Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0], 'create'> & {
6
+ create: EnhancedCreate;
7
+ };
8
+ declare function createRule({ create, ...rest }: EslintRule): _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
9
+
10
+ export { createRule };
@@ -0,0 +1,14 @@
1
+ // src/utils/create-rule.ts
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ import { detectTanstackQueryImports } from "./detect-react-query-imports.js";
4
+ var getDocsUrl = (ruleName) => `https://tanstack.com/query/v4/docs/eslint/${ruleName}`;
5
+ function createRule({ create, ...rest }) {
6
+ return ESLintUtils.RuleCreator(getDocsUrl)({
7
+ ...rest,
8
+ create: detectTanstackQueryImports(create)
9
+ });
10
+ }
11
+ export {
12
+ createRule
13
+ };
14
+ //# sourceMappingURL=create-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/create-rule.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { detectTanstackQueryImports } from './detect-react-query-imports'\nimport type { EnhancedCreate } 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"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,kCAAkC;AAG3C,IAAM,aAAa,CAAC,aAClB,6CAA6C,QAAQ;AAShD,SAAS,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAe;AAC1D,SAAO,YAAY,YAAY,UAAU,EAAE;AAAA,IACzC,GAAG;AAAA,IACH,QAAQ,2BAA2B,MAAM;AAAA,EAC3C,CAAC;AACH;","names":[]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/detect-react-query-imports.ts
21
+ var detect_react_query_imports_exports = {};
22
+ __export(detect_react_query_imports_exports, {
23
+ detectTanstackQueryImports: () => detectTanstackQueryImports
24
+ });
25
+ module.exports = __toCommonJS(detect_react_query_imports_exports);
26
+ function detectTanstackQueryImports(create) {
27
+ return (context, optionsWithDefault) => {
28
+ const tanstackQueryImportSpecifiers = [];
29
+ const helpers = {
30
+ isTanstackQueryImport(node) {
31
+ return !!tanstackQueryImportSpecifiers.find((specifier) => {
32
+ if (specifier.type === "ImportSpecifier") {
33
+ return node.name === specifier.local.name;
34
+ }
35
+ return false;
36
+ });
37
+ }
38
+ };
39
+ const detectionInstructions = {
40
+ ImportDeclaration(node) {
41
+ if (node.specifiers.length > 0 && node.importKind === "value" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-query")) {
42
+ tanstackQueryImportSpecifiers.push(...node.specifiers);
43
+ }
44
+ }
45
+ };
46
+ const ruleInstructions = create(context, optionsWithDefault, helpers);
47
+ const enhancedRuleInstructions = {};
48
+ const allKeys = new Set(
49
+ Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
50
+ );
51
+ allKeys.forEach((instruction) => {
52
+ enhancedRuleInstructions[instruction] = (node) => {
53
+ var _a, _b;
54
+ if (instruction in detectionInstructions) {
55
+ (_a = detectionInstructions[instruction]) == null ? void 0 : _a.call(detectionInstructions, node);
56
+ }
57
+ if (ruleInstructions[instruction]) {
58
+ return (_b = ruleInstructions[instruction]) == null ? void 0 : _b.call(ruleInstructions, node);
59
+ }
60
+ return void 0;
61
+ };
62
+ });
63
+ return enhancedRuleInstructions;
64
+ };
65
+ }
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ detectTanstackQueryImports
69
+ });
70
+ //# sourceMappingURL=detect-react-query-imports.cjs.map
@@ -0,0 +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":[]}
@@ -0,0 +1,12 @@
1
+ import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
2
+
3
+ type Create = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]['create'];
4
+ type Context = Parameters<Create>[0];
5
+ type Options = Parameters<Create>[1];
6
+ type Helpers = {
7
+ isTanstackQueryImport: (node: TSESTree.Identifier) => boolean;
8
+ };
9
+ type EnhancedCreate = (context: Context, options: Options, helpers: Helpers) => ReturnType<Create>;
10
+ declare function detectTanstackQueryImports(create: EnhancedCreate): Create;
11
+
12
+ export { EnhancedCreate, detectTanstackQueryImports };
@@ -0,0 +1,12 @@
1
+ import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
2
+
3
+ type Create = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]['create'];
4
+ type Context = Parameters<Create>[0];
5
+ type Options = Parameters<Create>[1];
6
+ type Helpers = {
7
+ isTanstackQueryImport: (node: TSESTree.Identifier) => boolean;
8
+ };
9
+ type EnhancedCreate = (context: Context, options: Options, helpers: Helpers) => ReturnType<Create>;
10
+ declare function detectTanstackQueryImports(create: EnhancedCreate): Create;
11
+
12
+ export { EnhancedCreate, detectTanstackQueryImports };
@@ -0,0 +1,45 @@
1
+ // src/utils/detect-react-query-imports.ts
2
+ function detectTanstackQueryImports(create) {
3
+ return (context, optionsWithDefault) => {
4
+ const tanstackQueryImportSpecifiers = [];
5
+ const helpers = {
6
+ isTanstackQueryImport(node) {
7
+ return !!tanstackQueryImportSpecifiers.find((specifier) => {
8
+ if (specifier.type === "ImportSpecifier") {
9
+ return node.name === specifier.local.name;
10
+ }
11
+ return false;
12
+ });
13
+ }
14
+ };
15
+ const detectionInstructions = {
16
+ ImportDeclaration(node) {
17
+ if (node.specifiers.length > 0 && node.importKind === "value" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-query")) {
18
+ tanstackQueryImportSpecifiers.push(...node.specifiers);
19
+ }
20
+ }
21
+ };
22
+ const ruleInstructions = create(context, optionsWithDefault, helpers);
23
+ const enhancedRuleInstructions = {};
24
+ const allKeys = new Set(
25
+ Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
26
+ );
27
+ allKeys.forEach((instruction) => {
28
+ enhancedRuleInstructions[instruction] = (node) => {
29
+ var _a, _b;
30
+ if (instruction in detectionInstructions) {
31
+ (_a = detectionInstructions[instruction]) == null ? void 0 : _a.call(detectionInstructions, node);
32
+ }
33
+ if (ruleInstructions[instruction]) {
34
+ return (_b = ruleInstructions[instruction]) == null ? void 0 : _b.call(ruleInstructions, node);
35
+ }
36
+ return void 0;
37
+ };
38
+ });
39
+ return enhancedRuleInstructions;
40
+ };
41
+ }
42
+ export {
43
+ detectTanstackQueryImports
44
+ };
45
+ //# sourceMappingURL=detect-react-query-imports.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/object-utils.ts
21
+ var object_utils_exports = {};
22
+ __export(object_utils_exports, {
23
+ objectKeys: () => objectKeys
24
+ });
25
+ module.exports = __toCommonJS(object_utils_exports);
26
+ function objectKeys(obj) {
27
+ return Object.keys(obj);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ objectKeys
32
+ });
33
+ //# sourceMappingURL=object-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/object-utils.ts"],"sourcesContent":["export function objectKeys<T extends Record<string, unknown>>(\n obj: T,\n): Array<keyof T> {\n return Object.keys(obj) as Array<keyof T>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,WACd,KACgB;AAChB,SAAO,OAAO,KAAK,GAAG;AACxB;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function objectKeys<T extends Record<string, unknown>>(obj: T): Array<keyof T>;
2
+
3
+ export { objectKeys };
@@ -0,0 +1,3 @@
1
+ declare function objectKeys<T extends Record<string, unknown>>(obj: T): Array<keyof T>;
2
+
3
+ export { objectKeys };
@@ -0,0 +1,8 @@
1
+ // src/utils/object-utils.ts
2
+ function objectKeys(obj) {
3
+ return Object.keys(obj);
4
+ }
5
+ export {
6
+ objectKeys
7
+ };
8
+ //# sourceMappingURL=object-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/object-utils.ts"],"sourcesContent":["export function objectKeys<T extends Record<string, unknown>>(\n obj: T,\n): Array<keyof T> {\n return Object.keys(obj) as Array<keyof T>\n}\n"],"mappings":";AAAO,SAAS,WACd,KACgB;AAChB,SAAO,OAAO,KAAK,GAAG;AACxB;","names":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/test-utils.ts
21
+ var test_utils_exports = {};
22
+ __export(test_utils_exports, {
23
+ normalizeIndent: () => normalizeIndent
24
+ });
25
+ module.exports = __toCommonJS(test_utils_exports);
26
+ function normalizeIndent(template) {
27
+ var _a, _b, _c;
28
+ const codeLines = ((_a = template[0]) == null ? void 0 : _a.split("\n")) ?? [""];
29
+ const leftPadding = ((_c = (_b = codeLines[1]) == null ? void 0 : _b.match(/\s+/)) == null ? void 0 : _c[0]) ?? "";
30
+ return codeLines.map((line) => line.slice(leftPadding.length)).join("\n");
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ normalizeIndent
35
+ });
36
+ //# sourceMappingURL=test-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/test-utils.ts"],"sourcesContent":["export function normalizeIndent(template: TemplateStringsArray) {\n const codeLines = template[0]?.split('\\n') ?? ['']\n const leftPadding = codeLines[1]?.match(/\\s+/)?.[0] ?? ''\n return codeLines.map((line) => line.slice(leftPadding.length)).join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,gBAAgB,UAAgC;AAAhE;AACE,QAAM,cAAY,cAAS,CAAC,MAAV,mBAAa,MAAM,UAAS,CAAC,EAAE;AACjD,QAAM,gBAAc,qBAAU,CAAC,MAAX,mBAAc,MAAM,WAApB,mBAA6B,OAAM;AACvD,SAAO,UAAU,IAAI,CAAC,SAAS,KAAK,MAAM,YAAY,MAAM,CAAC,EAAE,KAAK,IAAI;AAC1E;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function normalizeIndent(template: TemplateStringsArray): string;
2
+
3
+ export { normalizeIndent };
@@ -0,0 +1,3 @@
1
+ declare function normalizeIndent(template: TemplateStringsArray): string;
2
+
3
+ export { normalizeIndent };
@@ -0,0 +1,11 @@
1
+ // src/utils/test-utils.ts
2
+ function normalizeIndent(template) {
3
+ var _a, _b, _c;
4
+ const codeLines = ((_a = template[0]) == null ? void 0 : _a.split("\n")) ?? [""];
5
+ const leftPadding = ((_c = (_b = codeLines[1]) == null ? void 0 : _b.match(/\s+/)) == null ? void 0 : _c[0]) ?? "";
6
+ return codeLines.map((line) => line.slice(leftPadding.length)).join("\n");
7
+ }
8
+ export {
9
+ normalizeIndent
10
+ };
11
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/test-utils.ts"],"sourcesContent":["export function normalizeIndent(template: TemplateStringsArray) {\n const codeLines = template[0]?.split('\\n') ?? ['']\n const leftPadding = codeLines[1]?.match(/\\s+/)?.[0] ?? ''\n return codeLines.map((line) => line.slice(leftPadding.length)).join('\\n')\n}\n"],"mappings":";AAAO,SAAS,gBAAgB,UAAgC;AAAhE;AACE,QAAM,cAAY,cAAS,CAAC,MAAV,mBAAa,MAAM,UAAS,CAAC,EAAE;AACjD,QAAM,gBAAc,qBAAU,CAAC,MAAX,mBAAc,MAAM,WAApB,mBAA6B,OAAM;AACvD,SAAO,UAAU,IAAI,CAAC,SAAS,KAAK,MAAM,YAAY,MAAM,CAAC,EAAE,KAAK,IAAI;AAC1E;","names":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/unique-by.ts
21
+ var unique_by_exports = {};
22
+ __export(unique_by_exports, {
23
+ uniqueBy: () => uniqueBy
24
+ });
25
+ module.exports = __toCommonJS(unique_by_exports);
26
+ function uniqueBy(arr, fn) {
27
+ return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ uniqueBy
32
+ });
33
+ //# sourceMappingURL=unique-by.cjs.map
@@ -0,0 +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":[]}
@@ -0,0 +1,3 @@
1
+ declare function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[];
2
+
3
+ export { uniqueBy };
@@ -0,0 +1,3 @@
1
+ declare function uniqueBy<T>(arr: T[], fn: (x: T) => unknown): T[];
2
+
3
+ export { uniqueBy };
@@ -0,0 +1,8 @@
1
+ // src/utils/unique-by.ts
2
+ function uniqueBy(arr, fn) {
3
+ return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
4
+ }
5
+ export {
6
+ uniqueBy
7
+ };
8
+ //# sourceMappingURL=unique-by.js.map
@@ -0,0 +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":[]}
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@tanstack/eslint-plugin-query",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.14",
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",
@@ -47,7 +51,7 @@
47
51
  "test:types": "tsc",
48
52
  "test:lib": "vitest run --coverage",
49
53
  "test:lib:dev": "pnpm run test:lib --watch",
50
- "test:build": "publint --strict && attw --pack",
54
+ "test:build": "publint --strict",
51
55
  "build": "tsup"
52
56
  }
53
57
  }
@@ -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,5 +1,5 @@
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 = {
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
+ }
@@ -1,5 +0,0 @@
1
- import * as exhaustiveDeps from './exhaustive-deps/exhaustive-deps.rule'
2
-
3
- export const rules = {
4
- [exhaustiveDeps.name]: exhaustiveDeps.rule,
5
- }