@tanstack/eslint-plugin-query 5.0.0-rc.1 → 5.0.0-rc.5

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 (41) hide show
  1. package/build/legacy/__tests__/configs.test.cjs +1 -0
  2. package/build/legacy/__tests__/configs.test.cjs.map +1 -1
  3. package/build/legacy/__tests__/configs.test.js +1 -0
  4. package/build/legacy/__tests__/configs.test.js.map +1 -1
  5. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs +93 -0
  6. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs.map +1 -0
  7. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.cts +6 -0
  8. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.ts +6 -0
  9. package/build/legacy/rules/stable-query-client/stable-query-client.rule.js +67 -0
  10. package/build/legacy/rules/stable-query-client/stable-query-client.rule.js.map +1 -0
  11. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs +197 -0
  12. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs.map +1 -0
  13. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.cts +2 -0
  14. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.ts +2 -0
  15. package/build/legacy/rules/stable-query-client/stable-query-client.test.js +195 -0
  16. package/build/legacy/rules/stable-query-client/stable-query-client.test.js.map +1 -0
  17. package/build/legacy/rules.cjs +5 -3
  18. package/build/legacy/rules.cjs.map +1 -1
  19. package/build/legacy/rules.d.cts +1 -0
  20. package/build/legacy/rules.d.ts +1 -0
  21. package/build/legacy/rules.js +3 -1
  22. package/build/legacy/rules.js.map +1 -1
  23. package/build/legacy/utils/ast-utils.cjs +21 -8
  24. package/build/legacy/utils/ast-utils.cjs.map +1 -1
  25. package/build/legacy/utils/ast-utils.d.cts +3 -2
  26. package/build/legacy/utils/ast-utils.d.ts +3 -2
  27. package/build/legacy/utils/ast-utils.js +21 -8
  28. package/build/legacy/utils/ast-utils.js.map +1 -1
  29. package/build/legacy/utils/detect-react-query-imports.cjs +11 -1
  30. package/build/legacy/utils/detect-react-query-imports.cjs.map +1 -1
  31. package/build/legacy/utils/detect-react-query-imports.d.cts +1 -0
  32. package/build/legacy/utils/detect-react-query-imports.d.ts +1 -0
  33. package/build/legacy/utils/detect-react-query-imports.js +11 -1
  34. package/build/legacy/utils/detect-react-query-imports.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/__tests__/configs.test.ts +1 -0
  37. package/src/rules/stable-query-client/stable-query-client.rule.ts +78 -0
  38. package/src/rules/stable-query-client/stable-query-client.test.ts +195 -0
  39. package/src/rules.ts +2 -0
  40. package/src/utils/ast-utils.ts +37 -11
  41. package/src/utils/detect-react-query-imports.ts +21 -2
@@ -12,6 +12,7 @@ describe("configs", () => {
12
12
  ],
13
13
  "rules": {
14
14
  "@tanstack/query/exhaustive-deps": "error",
15
+ "@tanstack/query/stable-query-client": "error",
15
16
  },
16
17
  },
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/__tests__/configs.test.ts"],"sourcesContent":["import { configs } from '../configs'\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,qBAAwB;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,yBAAyB,MAAM;AAChC,WAAO,sBAAO,EAAE,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWrC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/__tests__/configs.test.ts"],"sourcesContent":["import { configs } from '../configs'\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 \"@tanstack/query/stable-query-client\": \"error\",\n },\n },\n }\n `)\n })\n})\n"],"mappings":";;;AAAA,qBAAwB;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,yBAAyB,MAAM;AAChC,WAAO,sBAAO,EAAE,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAYrC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -10,6 +10,7 @@ describe("configs", () => {
10
10
  ],
11
11
  "rules": {
12
12
  "@tanstack/query/exhaustive-deps": "error",
13
+ "@tanstack/query/stable-query-client": "error",
13
14
  },
14
15
  },
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/__tests__/configs.test.ts"],"sourcesContent":["import { configs } from '../configs'\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
+ {"version":3,"sources":["../../../src/__tests__/configs.test.ts"],"sourcesContent":["import { configs } from '../configs'\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 \"@tanstack/query/stable-query-client\": \"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;AAAA,KAYrC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/rules/stable-query-client/stable-query-client.rule.ts
21
+ var stable_query_client_rule_exports = {};
22
+ __export(stable_query_client_rule_exports, {
23
+ name: () => name,
24
+ rule: () => rule
25
+ });
26
+ module.exports = __toCommonJS(stable_query_client_rule_exports);
27
+ var import_utils = require("@typescript-eslint/utils");
28
+ var import_ast_utils = require("../../utils/ast-utils.cjs");
29
+ var import_create_rule = require("../../utils/create-rule.cjs");
30
+ var name = "stable-query-client";
31
+ var rule = (0, import_create_rule.createRule)({
32
+ name,
33
+ meta: {
34
+ type: "problem",
35
+ docs: {
36
+ description: "Makes sure that QueryClient is stable",
37
+ recommended: "error"
38
+ },
39
+ messages: {
40
+ unstable: [
41
+ "QueryClient is not stable. It should be either extracted from the component or wrapped in React.useState.",
42
+ "See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable"
43
+ ].join("\n"),
44
+ fixTo: "Fix to {{result}}"
45
+ },
46
+ hasSuggestions: true,
47
+ fixable: "code",
48
+ schema: []
49
+ },
50
+ defaultOptions: [],
51
+ create(context, _, helpers) {
52
+ return {
53
+ NewExpression(node) {
54
+ var _a;
55
+ if (node.callee.type !== import_utils.AST_NODE_TYPES.Identifier || node.callee.name !== "QueryClient" || ((_a = node.parent) == null ? void 0 : _a.type) !== import_utils.AST_NODE_TYPES.VariableDeclarator || !helpers.isSpecificTanstackQueryImport(
56
+ node.callee,
57
+ "@tanstack/react-query"
58
+ )) {
59
+ return;
60
+ }
61
+ const fnAncestor = import_ast_utils.ASTUtils.getFunctionAncestor(context);
62
+ const isReactServerComponent = (fnAncestor == null ? void 0 : fnAncestor.async) === true;
63
+ if (!import_ast_utils.ASTUtils.isValidReactComponentOrHookName(fnAncestor == null ? void 0 : fnAncestor.id) || isReactServerComponent) {
64
+ return;
65
+ }
66
+ context.report({
67
+ node: node.parent,
68
+ messageId: "unstable",
69
+ fix: (() => {
70
+ const { parent } = node;
71
+ if (parent.id.type !== import_utils.AST_NODE_TYPES.Identifier) {
72
+ return;
73
+ }
74
+ const nodeText = context.getSourceCode().getText(node);
75
+ const variableName = parent.id.name;
76
+ return (fixer) => {
77
+ return fixer.replaceTextRange(
78
+ [parent.range[0], parent.range[1]],
79
+ `[${variableName}] = React.useState(() => ${nodeText})`
80
+ );
81
+ };
82
+ })()
83
+ });
84
+ }
85
+ };
86
+ }
87
+ });
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ name,
91
+ rule
92
+ });
93
+ //# sourceMappingURL=stable-query-client.rule.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/rules/stable-query-client/stable-query-client.rule.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport { createRule } from '../../utils/create-rule'\nimport type { TSESLint } from '@typescript-eslint/utils'\n\nexport const name = 'stable-query-client'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Makes sure that QueryClient is stable',\n recommended: 'error',\n },\n messages: {\n unstable: [\n 'QueryClient is not stable. It should be either extracted from the component or wrapped in React.useState.',\n 'See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable',\n ].join('\\n'),\n fixTo: 'Fix to {{result}}',\n },\n hasSuggestions: true,\n fixable: 'code',\n schema: [],\n },\n defaultOptions: [],\n\n create(context, _, helpers) {\n return {\n NewExpression(node) {\n if (\n node.callee.type !== AST_NODE_TYPES.Identifier ||\n node.callee.name !== 'QueryClient' ||\n node.parent?.type !== AST_NODE_TYPES.VariableDeclarator ||\n !helpers.isSpecificTanstackQueryImport(\n node.callee,\n '@tanstack/react-query',\n )\n ) {\n return\n }\n\n const fnAncestor = ASTUtils.getFunctionAncestor(context)\n const isReactServerComponent = fnAncestor?.async === true\n\n if (\n !ASTUtils.isValidReactComponentOrHookName(fnAncestor?.id) ||\n isReactServerComponent\n ) {\n return\n }\n\n context.report({\n node: node.parent,\n messageId: 'unstable',\n fix: (() => {\n const { parent } = node\n\n if (parent.id.type !== AST_NODE_TYPES.Identifier) {\n return\n }\n\n const nodeText = context.getSourceCode().getText(node)\n const variableName = parent.id.name\n\n return (fixer: TSESLint.RuleFixer) => {\n return fixer.replaceTextRange(\n [parent.range[0], parent.range[1]],\n `[${variableName}] = React.useState(() => ${nodeText})`,\n )\n }\n })(),\n })\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAAyB;AACzB,yBAA2B;AAGpB,IAAM,OAAO;AAEb,IAAM,WAAO,+BAAW;AAAA,EAC7B;AAAA,EACA,MAAM;A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,6 @@
1
+ import { TSESLint } from '@typescript-eslint/utils';
2
+
3
+ declare const name = "stable-query-client";
4
+ declare const rule: TSESLint.RuleModule<string, readonly unknown[], TSESLint.RuleListener>;
5
+
6
+ export { name, rule };
@@ -0,0 +1,6 @@
1
+ import { TSESLint } from '@typescript-eslint/utils';
2
+
3
+ declare const name = "stable-query-client";
4
+ declare const rule: TSESLint.RuleModule<string, readonly unknown[], TSESLint.RuleListener>;
5
+
6
+ export { name, rule };
@@ -0,0 +1,67 @@
1
+ // src/rules/stable-query-client/stable-query-client.rule.ts
2
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
3
+ import { ASTUtils } from "../../utils/ast-utils.js";
4
+ import { createRule } from "../../utils/create-rule.js";
5
+ var name = "stable-query-client";
6
+ var rule = createRule({
7
+ name,
8
+ meta: {
9
+ type: "problem",
10
+ docs: {
11
+ description: "Makes sure that QueryClient is stable",
12
+ recommended: "error"
13
+ },
14
+ messages: {
15
+ unstable: [
16
+ "QueryClient is not stable. It should be either extracted from the component or wrapped in React.useState.",
17
+ "See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable"
18
+ ].join("\n"),
19
+ fixTo: "Fix to {{result}}"
20
+ },
21
+ hasSuggestions: true,
22
+ fixable: "code",
23
+ schema: []
24
+ },
25
+ defaultOptions: [],
26
+ create(context, _, helpers) {
27
+ return {
28
+ NewExpression(node) {
29
+ var _a;
30
+ if (node.callee.type !== AST_NODE_TYPES.Identifier || node.callee.name !== "QueryClient" || ((_a = node.parent) == null ? void 0 : _a.type) !== AST_NODE_TYPES.VariableDeclarator || !helpers.isSpecificTanstackQueryImport(
31
+ node.callee,
32
+ "@tanstack/react-query"
33
+ )) {
34
+ return;
35
+ }
36
+ const fnAncestor = ASTUtils.getFunctionAncestor(context);
37
+ const isReactServerComponent = (fnAncestor == null ? void 0 : fnAncestor.async) === true;
38
+ if (!ASTUtils.isValidReactComponentOrHookName(fnAncestor == null ? void 0 : fnAncestor.id) || isReactServerComponent) {
39
+ return;
40
+ }
41
+ context.report({
42
+ node: node.parent,
43
+ messageId: "unstable",
44
+ fix: (() => {
45
+ const { parent } = node;
46
+ if (parent.id.type !== AST_NODE_TYPES.Identifier) {
47
+ return;
48
+ }
49
+ const nodeText = context.getSourceCode().getText(node);
50
+ const variableName = parent.id.name;
51
+ return (fixer) => {
52
+ return fixer.replaceTextRange(
53
+ [parent.range[0], parent.range[1]],
54
+ `[${variableName}] = React.useState(() => ${nodeText})`
55
+ );
56
+ };
57
+ })()
58
+ });
59
+ }
60
+ };
61
+ }
62
+ });
63
+ export {
64
+ name,
65
+ rule
66
+ };
67
+ //# sourceMappingURL=stable-query-client.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/rules/stable-query-client/stable-query-client.rule.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport { ASTUtils } from '../../utils/ast-utils'\nimport { createRule } from '../../utils/create-rule'\nimport type { TSESLint } from '@typescript-eslint/utils'\n\nexport const name = 'stable-query-client'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Makes sure that QueryClient is stable',\n recommended: 'error',\n },\n messages: {\n unstable: [\n 'QueryClient is not stable. It should be either extracted from the component or wrapped in React.useState.',\n 'See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable',\n ].join('\\n'),\n fixTo: 'Fix to {{result}}',\n },\n hasSuggestions: true,\n fixable: 'code',\n schema: [],\n },\n defaultOptions: [],\n\n create(context, _, helpers) {\n return {\n NewExpression(node) {\n if (\n node.callee.type !== AST_NODE_TYPES.Identifier ||\n node.callee.name !== 'QueryClient' ||\n node.parent?.type !== AST_NODE_TYPES.VariableDeclarator ||\n !helpers.isSpecificTanstackQueryImport(\n node.callee,\n '@tanstack/react-query',\n )\n ) {\n return\n }\n\n const fnAncestor = ASTUtils.getFunctionAncestor(context)\n const isReactServerComponent = fnAncestor?.async === true\n\n if (\n !ASTUtils.isValidReactComponentOrHookName(fnAncestor?.id) ||\n isReactServerComponent\n ) {\n return\n }\n\n context.report({\n node: node.parent,\n messageId: 'unstable',\n fix: (() => {\n const { parent } = node\n\n if (parent.id.type !== AST_NODE_TYPES.Identifier) {\n return\n }\n\n const nodeText = context.getSourceCode().getText(node)\n const variableName = parent.id.name\n\n return (fixer: TSESLint.RuleFixer) => {\n return fixer.replaceTextRange(\n [parent.range[0], parent.range[1]],\n `[${variableName}] = React.useState(() => ${nodeText})`,\n )\n }\n })(),\n })\n },\n }\n },\n})\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAGpB,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,UAAU;AAAA,QACR;AAAA,QACA;AAAA,MACF,EAAE,KAAK,IAAI;AAAA,MACX,OAAO;AAAA,IACT;AAAA,IACA,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,QAAQ,CAAC;AAAA,EACX;AAAA,EACA,gBAAgB,CAAC;AAAA,EAEjB,OAAO,SAAS,GAAG,SAAS;AAC1B,WAAO;AAAA,MACL,cAAc,MAAM;AA9B1B;AA+BQ,YACE,KAAK,OAAO,SAAS,eAAe,cACpC,KAAK,OAAO,SAAS,mBACrB,UAAK,WAAL,mBAAa,UAAS,eAAe,sBACrC,CAAC,QAAQ;AAAA,UACP,KAAK;AAAA,UACL;AAAA,QACF,GACA;AACA;AAAA,QACF;AAEA,cAAM,aAAa,SAAS,oBAAoB,OAAO;AACvD,cAAM,0BAAyB,yCAAY,WAAU;AAErD,YACE,CAAC,SAAS,gCAAgC,yCAAY,EAAE,KACxD,wBACA;AACA;AAAA,QACF;AAEA,gBAAQ,OAAO;AAAA,UACb,MAAM,KAAK;AAAA,UACX,WAAW;AAAA,UACX,MAAM,MAAM;AACV,kBAAM,EAAE,OAAO,IAAI;AAEnB,gBAAI,OAAO,GAAG,SAAS,eAAe,YAAY;AAChD;AAAA,YACF;AAEA,kBAAM,WAAW,QAAQ,cAAc,EAAE,QAAQ,IAAI;AACrD,kBAAM,eAAe,OAAO,GAAG;AAE/B,mBAAO,CAAC,UAA8B;AACpC,qBAAO,MAAM;AAAA,gBACX,CAAC,OAAO,MAAM,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC;AAAA,gBACjC,IAAI,YAAY,4BAA4B,QAAQ;AAAA,cACtD;AAAA,YACF;AAAA,UACF,GAAG;AAAA,QACL,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ // src/rules/stable-query-client/stable-query-client.test.ts
4
+ var import_utils = require("@typescript-eslint/utils");
5
+ var import_test_utils = require("../../utils/test-utils.cjs");
6
+ var import_stable_query_client = require("./stable-query-client.rule.cjs");
7
+ var ruleTester = new import_utils.ESLintUtils.RuleTester({
8
+ parser: "@typescript-eslint/parser",
9
+ settings: {}
10
+ });
11
+ ruleTester.run("stable-query-client", import_stable_query_client.rule, {
12
+ valid: [
13
+ {
14
+ name: "QueryClient is stable when wrapped in React.useState",
15
+ code: import_test_utils.normalizeIndent`
16
+ import { QueryClient } from "@tanstack/react-query";
17
+
18
+ function Component() {
19
+ const [queryClient] = React.useState(() => new QueryClient());
20
+ return;
21
+ }
22
+ `
23
+ },
24
+ {
25
+ name: "QueryClient is stable when wrapped in useState",
26
+ code: import_test_utils.normalizeIndent`
27
+ import { QueryClient } from "@tanstack/react-query";
28
+
29
+ function Component() {
30
+ const [queryClient] = useState(() => new QueryClient());
31
+ return;
32
+ }
33
+ `
34
+ },
35
+ {
36
+ name: "QueryClient is stable when wrapped in React.useMemo",
37
+ code: import_test_utils.normalizeIndent`
38
+ import { QueryClient } from "@tanstack/react-query";
39
+
40
+ function Component() {
41
+ const [queryClient] = React.useMemo(() => new QueryClient(), []);
42
+ return;
43
+ }
44
+ `
45
+ },
46
+ {
47
+ name: "QueryClient is stable when wrapped in useAnything",
48
+ code: import_test_utils.normalizeIndent`
49
+ import { QueryClient } from "@tanstack/react-query";
50
+
51
+ function Component() {
52
+ const [queryClient] = useAnything(() => new QueryClient());
53
+ return;
54
+ }
55
+ `
56
+ },
57
+ {
58
+ name: "QueryClient is imported from a non-tanstack package",
59
+ code: import_test_utils.normalizeIndent`
60
+ import { QueryClient } from "other-library";
61
+
62
+ function Component() {
63
+ const queryClient = new QueryClient();
64
+ return;
65
+ }
66
+ `
67
+ },
68
+ {
69
+ name: "QueryClient is not imported from @tanstack/react-query",
70
+ code: import_test_utils.normalizeIndent`
71
+ import { QueryClient } from "@tanstack/solid-query";
72
+
73
+ function Component() {
74
+ const queryClient = new QueryClient();
75
+ return;
76
+ }
77
+ `
78
+ },
79
+ {
80
+ name: "QueryClient is invoked outside of a function",
81
+ code: import_test_utils.normalizeIndent`
82
+ import { QueryClient } from "@tanstack/solid-query";
83
+
84
+ const queryClient = new QueryClient();
85
+
86
+ function Component() {
87
+ return;
88
+ }
89
+ `
90
+ },
91
+ {
92
+ name: "QueryClient is invoked in a non-component function",
93
+ code: import_test_utils.normalizeIndent`
94
+ import { QueryClient } from "@tanstack/solid-query";
95
+
96
+ function someFn() {
97
+ const queryClient = new QueryClient();
98
+ return;
99
+ }
100
+ `
101
+ },
102
+ {
103
+ name: "QueryClient is invoked in an async (react server) component",
104
+ code: import_test_utils.normalizeIndent`
105
+ import { QueryClient } from "@tanstack/solid-query";
106
+
107
+ async function AsyncComponent() {
108
+ const queryClient = new QueryClient();
109
+ return;
110
+ }
111
+ `
112
+ }
113
+ ],
114
+ invalid: [
115
+ {
116
+ name: "QueryClient is not stable when it is not wrapped in React.useState in component",
117
+ code: import_test_utils.normalizeIndent`
118
+ import { QueryClient } from "@tanstack/react-query";
119
+
120
+ function Component() {
121
+ const queryClient = new QueryClient();
122
+ return;
123
+ }
124
+ `,
125
+ output: import_test_utils.normalizeIndent`
126
+ import { QueryClient } from "@tanstack/react-query";
127
+
128
+ function Component() {
129
+ const [queryClient] = React.useState(() => new QueryClient());
130
+ return;
131
+ }
132
+ `,
133
+ errors: [{ messageId: "unstable" }]
134
+ },
135
+ {
136
+ name: "QueryClient is not stable when it is not wrapped in React.useState in custom hook",
137
+ code: import_test_utils.normalizeIndent`
138
+ import { QueryClient } from "@tanstack/react-query";
139
+
140
+ function useHook() {
141
+ const queryClient = new QueryClient();
142
+ return;
143
+ }
144
+ `,
145
+ output: import_test_utils.normalizeIndent`
146
+ import { QueryClient } from "@tanstack/react-query";
147
+
148
+ function useHook() {
149
+ const [queryClient] = React.useState(() => new QueryClient());
150
+ return;
151
+ }
152
+ `,
153
+ errors: [{ messageId: "unstable" }]
154
+ },
155
+ {
156
+ name: "preserve QueryClient options",
157
+ code: import_test_utils.normalizeIndent`
158
+ import { QueryClient } from "@tanstack/react-query";
159
+
160
+ function Component() {
161
+ const queryClient = new QueryClient({ defaultOptions: { /* */ } });
162
+ return;
163
+ }
164
+ `,
165
+ output: import_test_utils.normalizeIndent`
166
+ import { QueryClient } from "@tanstack/react-query";
167
+
168
+ function Component() {
169
+ const [queryClient] = React.useState(() => new QueryClient({ defaultOptions: { /* */ } }));
170
+ return;
171
+ }
172
+ `,
173
+ errors: [{ messageId: "unstable" }]
174
+ },
175
+ {
176
+ name: "preserve QueryClient variable declarator name",
177
+ code: import_test_utils.normalizeIndent`
178
+ import { QueryClient } from "@tanstack/react-query";
179
+
180
+ function Component() {
181
+ const customName = new QueryClient();
182
+ return;
183
+ }
184
+ `,
185
+ output: import_test_utils.normalizeIndent`
186
+ import { QueryClient } from "@tanstack/react-query";
187
+
188
+ function Component() {
189
+ const [customName] = React.useState(() => new QueryClient());
190
+ return;
191
+ }
192
+ `,
193
+ errors: [{ messageId: "unstable" }]
194
+ }
195
+ ]
196
+ });
197
+ //# sourceMappingURL=stable-query-client.test.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/rules/stable-query-client/stable-query-client.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './stable-query-client.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('stable-query-client', rule, {\n valid: [\n {\n name: 'QueryClient is stable when wrapped in React.useState',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in useState',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = useState(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in React.useMemo',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n \n function Component() {\n const [queryClient] = React.useMemo(() => new QueryClient(), []);\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in useAnything',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n \n function Component() {\n const [queryClient] = useAnything(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is imported from a non-tanstack package',\n code: normalizeIndent`\n import { QueryClient } from \"other-library\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is not imported from @tanstack/react-query',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked outside of a function',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n const queryClient = new QueryClient();\n\n function Component() {\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked in a non-component function',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n function someFn() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked in an async (react server) component',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n async function AsyncComponent() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'QueryClient is not stable when it is not wrapped in React.useState in component',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'QueryClient is not stable when it is not wrapped in React.useState in custom hook',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function useHook() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function useHook() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'preserve QueryClient options',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const queryClient = new QueryClient({ defaultOptions: { /* */ } });\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient({ defaultOptions: { /* */ } }));\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'preserve QueryClient variable declarator name',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const customName = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [customName] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n ],\n})\n"],"mappings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AAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQR,QAAQ,CAAC,EAAE,WAAW,WAAW,CAAC;AAAA,IACpC;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQR,QAAQ,CAAC,EAAE,WAAW,WAAW,CAAC;AAAA,IACpC;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQR,QAAQ,CAAC,EAAE,WAAW,WAAW,CAAC;AAAA,IACpC;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQR,QAAQ,CAAC,EAAE,WAAW,WAAW,CAAC;AAAA,IACpC;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,195 @@
1
+ // src/rules/stable-query-client/stable-query-client.test.ts
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ import { normalizeIndent } from "../../utils/test-utils.js";
4
+ import { rule } from "./stable-query-client.rule.js";
5
+ var ruleTester = new ESLintUtils.RuleTester({
6
+ parser: "@typescript-eslint/parser",
7
+ settings: {}
8
+ });
9
+ ruleTester.run("stable-query-client", rule, {
10
+ valid: [
11
+ {
12
+ name: "QueryClient is stable when wrapped in React.useState",
13
+ code: normalizeIndent`
14
+ import { QueryClient } from "@tanstack/react-query";
15
+
16
+ function Component() {
17
+ const [queryClient] = React.useState(() => new QueryClient());
18
+ return;
19
+ }
20
+ `
21
+ },
22
+ {
23
+ name: "QueryClient is stable when wrapped in useState",
24
+ code: normalizeIndent`
25
+ import { QueryClient } from "@tanstack/react-query";
26
+
27
+ function Component() {
28
+ const [queryClient] = useState(() => new QueryClient());
29
+ return;
30
+ }
31
+ `
32
+ },
33
+ {
34
+ name: "QueryClient is stable when wrapped in React.useMemo",
35
+ code: normalizeIndent`
36
+ import { QueryClient } from "@tanstack/react-query";
37
+
38
+ function Component() {
39
+ const [queryClient] = React.useMemo(() => new QueryClient(), []);
40
+ return;
41
+ }
42
+ `
43
+ },
44
+ {
45
+ name: "QueryClient is stable when wrapped in useAnything",
46
+ code: normalizeIndent`
47
+ import { QueryClient } from "@tanstack/react-query";
48
+
49
+ function Component() {
50
+ const [queryClient] = useAnything(() => new QueryClient());
51
+ return;
52
+ }
53
+ `
54
+ },
55
+ {
56
+ name: "QueryClient is imported from a non-tanstack package",
57
+ code: normalizeIndent`
58
+ import { QueryClient } from "other-library";
59
+
60
+ function Component() {
61
+ const queryClient = new QueryClient();
62
+ return;
63
+ }
64
+ `
65
+ },
66
+ {
67
+ name: "QueryClient is not imported from @tanstack/react-query",
68
+ code: normalizeIndent`
69
+ import { QueryClient } from "@tanstack/solid-query";
70
+
71
+ function Component() {
72
+ const queryClient = new QueryClient();
73
+ return;
74
+ }
75
+ `
76
+ },
77
+ {
78
+ name: "QueryClient is invoked outside of a function",
79
+ code: normalizeIndent`
80
+ import { QueryClient } from "@tanstack/solid-query";
81
+
82
+ const queryClient = new QueryClient();
83
+
84
+ function Component() {
85
+ return;
86
+ }
87
+ `
88
+ },
89
+ {
90
+ name: "QueryClient is invoked in a non-component function",
91
+ code: normalizeIndent`
92
+ import { QueryClient } from "@tanstack/solid-query";
93
+
94
+ function someFn() {
95
+ const queryClient = new QueryClient();
96
+ return;
97
+ }
98
+ `
99
+ },
100
+ {
101
+ name: "QueryClient is invoked in an async (react server) component",
102
+ code: normalizeIndent`
103
+ import { QueryClient } from "@tanstack/solid-query";
104
+
105
+ async function AsyncComponent() {
106
+ const queryClient = new QueryClient();
107
+ return;
108
+ }
109
+ `
110
+ }
111
+ ],
112
+ invalid: [
113
+ {
114
+ name: "QueryClient is not stable when it is not wrapped in React.useState in component",
115
+ code: normalizeIndent`
116
+ import { QueryClient } from "@tanstack/react-query";
117
+
118
+ function Component() {
119
+ const queryClient = new QueryClient();
120
+ return;
121
+ }
122
+ `,
123
+ output: normalizeIndent`
124
+ import { QueryClient } from "@tanstack/react-query";
125
+
126
+ function Component() {
127
+ const [queryClient] = React.useState(() => new QueryClient());
128
+ return;
129
+ }
130
+ `,
131
+ errors: [{ messageId: "unstable" }]
132
+ },
133
+ {
134
+ name: "QueryClient is not stable when it is not wrapped in React.useState in custom hook",
135
+ code: normalizeIndent`
136
+ import { QueryClient } from "@tanstack/react-query";
137
+
138
+ function useHook() {
139
+ const queryClient = new QueryClient();
140
+ return;
141
+ }
142
+ `,
143
+ output: normalizeIndent`
144
+ import { QueryClient } from "@tanstack/react-query";
145
+
146
+ function useHook() {
147
+ const [queryClient] = React.useState(() => new QueryClient());
148
+ return;
149
+ }
150
+ `,
151
+ errors: [{ messageId: "unstable" }]
152
+ },
153
+ {
154
+ name: "preserve QueryClient options",
155
+ code: normalizeIndent`
156
+ import { QueryClient } from "@tanstack/react-query";
157
+
158
+ function Component() {
159
+ const queryClient = new QueryClient({ defaultOptions: { /* */ } });
160
+ return;
161
+ }
162
+ `,
163
+ output: normalizeIndent`
164
+ import { QueryClient } from "@tanstack/react-query";
165
+
166
+ function Component() {
167
+ const [queryClient] = React.useState(() => new QueryClient({ defaultOptions: { /* */ } }));
168
+ return;
169
+ }
170
+ `,
171
+ errors: [{ messageId: "unstable" }]
172
+ },
173
+ {
174
+ name: "preserve QueryClient variable declarator name",
175
+ code: normalizeIndent`
176
+ import { QueryClient } from "@tanstack/react-query";
177
+
178
+ function Component() {
179
+ const customName = new QueryClient();
180
+ return;
181
+ }
182
+ `,
183
+ output: normalizeIndent`
184
+ import { QueryClient } from "@tanstack/react-query";
185
+
186
+ function Component() {
187
+ const [customName] = React.useState(() => new QueryClient());
188
+ return;
189
+ }
190
+ `,
191
+ errors: [{ messageId: "unstable" }]
192
+ }
193
+ ]
194
+ });
195
+ //# sourceMappingURL=stable-query-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/rules/stable-query-client/stable-query-client.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './stable-query-client.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('stable-query-client', rule, {\n valid: [\n {\n name: 'QueryClient is stable when wrapped in React.useState',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in useState',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = useState(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in React.useMemo',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n \n function Component() {\n const [queryClient] = React.useMemo(() => new QueryClient(), []);\n return;\n }\n `,\n },\n {\n name: 'QueryClient is stable when wrapped in useAnything',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n \n function Component() {\n const [queryClient] = useAnything(() => new QueryClient());\n return;\n }\n `,\n },\n {\n name: 'QueryClient is imported from a non-tanstack package',\n code: normalizeIndent`\n import { QueryClient } from \"other-library\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is not imported from @tanstack/react-query',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked outside of a function',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n const queryClient = new QueryClient();\n\n function Component() {\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked in a non-component function',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n function someFn() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n {\n name: 'QueryClient is invoked in an async (react server) component',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/solid-query\";\n\n async function AsyncComponent() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'QueryClient is not stable when it is not wrapped in React.useState in component',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'QueryClient is not stable when it is not wrapped in React.useState in custom hook',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function useHook() {\n const queryClient = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function useHook() {\n const [queryClient] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'preserve QueryClient options',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const queryClient = new QueryClient({ defaultOptions: { /* */ } });\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [queryClient] = React.useState(() => new QueryClient({ defaultOptions: { /* */ } }));\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\n },\n {\n name: 'preserve QueryClient variable declarator name',\n code: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const customName = new QueryClient();\n return;\n }\n `,\n output: normalizeIndent`\n import { QueryClient } from \"@tanstack/react-query\";\n\n function Component() {\n const [customName] = React.useState(() => new QueryClient());\n return;\n }\n `,\n errors: [{ messageId: 'unstable' }],\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,uBAAuB,MAAM;AAAA,EAC1C,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQR;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP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