@tanstack/eslint-plugin-query 5.17.1 → 5.17.20

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 (169) hide show
  1. package/dist/cjs/configs.cjs +23 -0
  2. package/dist/cjs/configs.cjs.map +1 -0
  3. package/dist/cjs/configs.d.cts +6 -0
  4. package/dist/cjs/index.cjs +7 -0
  5. package/dist/cjs/index.cjs.map +1 -0
  6. package/dist/cjs/index.d.cts +2 -0
  7. package/dist/cjs/rules/exhaustive-deps.rule.cjs +114 -0
  8. package/dist/cjs/rules/exhaustive-deps.rule.cjs.map +1 -0
  9. package/dist/cjs/rules/exhaustive-deps.rule.d.cts +3 -0
  10. package/dist/cjs/rules/exhaustive-deps.utils.cjs +26 -0
  11. package/dist/cjs/rules/exhaustive-deps.utils.cjs.map +1 -0
  12. package/{build/legacy → dist/cjs}/rules/exhaustive-deps.utils.d.cts +2 -5
  13. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs +60 -0
  14. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs.map +1 -0
  15. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.cts +2 -0
  16. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.test.d.cts +1 -0
  17. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs +13 -0
  18. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs.map +1 -0
  19. package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.cts +4 -0
  20. package/dist/cjs/rules/stable-query-client/stable-query-client.rule.cjs +66 -0
  21. package/dist/cjs/rules/stable-query-client/stable-query-client.rule.cjs.map +1 -0
  22. package/dist/cjs/rules/stable-query-client/stable-query-client.rule.d.cts +3 -0
  23. package/dist/cjs/rules/stable-query-client/stable-query-client.test.d.cts +1 -0
  24. package/dist/cjs/rules.cjs +12 -0
  25. package/dist/cjs/rules.cjs.map +1 -0
  26. package/dist/cjs/rules.d.cts +5 -0
  27. package/{build/legacy → dist/cjs}/utils/ast-utils.cjs +31 -57
  28. package/dist/cjs/utils/ast-utils.cjs.map +1 -0
  29. package/{build/legacy → dist/cjs}/utils/ast-utils.d.cts +4 -6
  30. package/dist/cjs/utils/create-rule.cjs +13 -0
  31. package/dist/cjs/utils/create-rule.cjs.map +1 -0
  32. package/dist/cjs/utils/create-rule.d.cts +7 -0
  33. package/{build/legacy → dist/cjs}/utils/detect-react-query-imports.cjs +6 -32
  34. package/dist/cjs/utils/detect-react-query-imports.cjs.map +1 -0
  35. package/{build/legacy → dist/cjs}/utils/detect-react-query-imports.d.cts +5 -6
  36. package/dist/cjs/utils/test-utils.d.cts +1 -0
  37. package/dist/cjs/utils/unique-by.cjs +7 -0
  38. package/dist/cjs/utils/unique-by.cjs.map +1 -0
  39. package/dist/cjs/utils/unique-by.d.cts +1 -0
  40. package/dist/esm/configs.d.ts +6 -0
  41. package/{build/legacy → dist/esm}/configs.js +2 -3
  42. package/dist/esm/configs.js.map +1 -0
  43. package/dist/esm/index.d.ts +2 -0
  44. package/{build/legacy → dist/esm}/index.js +1 -2
  45. package/dist/esm/index.js.map +1 -0
  46. package/dist/esm/rules/exhaustive-deps.rule.d.ts +3 -0
  47. package/{build/legacy → dist/esm}/rules/exhaustive-deps.rule.js +5 -6
  48. package/dist/esm/rules/exhaustive-deps.rule.js.map +1 -0
  49. package/{build/legacy → dist/esm}/rules/exhaustive-deps.utils.d.ts +2 -5
  50. package/{build/legacy → dist/esm}/rules/exhaustive-deps.utils.js +2 -3
  51. package/dist/esm/rules/exhaustive-deps.utils.js.map +1 -0
  52. package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.ts +2 -0
  53. package/{build/legacy → dist/esm}/rules/no-rest-desctructuring/no-rest-destructuring.rule.js +4 -5
  54. package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.rule.js.map +1 -0
  55. package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.test.d.ts +1 -0
  56. package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.ts +4 -0
  57. package/{build/legacy → dist/esm}/rules/no-rest-desctructuring/no-rest-destructuring.utils.js +2 -3
  58. package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.utils.js.map +1 -0
  59. package/dist/esm/rules/stable-query-client/stable-query-client.rule.d.ts +3 -0
  60. package/{build/legacy → dist/esm}/rules/stable-query-client/stable-query-client.rule.js +3 -4
  61. package/dist/esm/rules/stable-query-client/stable-query-client.rule.js.map +1 -0
  62. package/dist/esm/rules/stable-query-client/stable-query-client.test.d.ts +1 -0
  63. package/dist/esm/rules.d.ts +5 -0
  64. package/dist/esm/rules.js +12 -0
  65. package/dist/esm/rules.js.map +1 -0
  66. package/{build/legacy → dist/esm}/utils/ast-utils.d.ts +4 -6
  67. package/{build/legacy → dist/esm}/utils/ast-utils.js +2 -3
  68. package/dist/esm/utils/ast-utils.js.map +1 -0
  69. package/dist/esm/utils/create-rule.d.ts +7 -0
  70. package/{build/legacy → dist/esm}/utils/create-rule.js +2 -3
  71. package/dist/esm/utils/create-rule.js.map +1 -0
  72. package/{build/legacy → dist/esm}/utils/detect-react-query-imports.d.ts +5 -6
  73. package/{build/legacy → dist/esm}/utils/detect-react-query-imports.js +1 -2
  74. package/dist/esm/utils/detect-react-query-imports.js.map +1 -0
  75. package/dist/esm/utils/test-utils.d.ts +1 -0
  76. package/dist/esm/utils/unique-by.d.ts +1 -0
  77. package/{build/legacy → dist/esm}/utils/unique-by.js +1 -2
  78. package/dist/esm/utils/unique-by.js.map +1 -0
  79. package/package.json +11 -12
  80. package/build/legacy/__tests__/configs.test.cjs +0 -24
  81. package/build/legacy/__tests__/configs.test.cjs.map +0 -1
  82. package/build/legacy/__tests__/configs.test.d.cts +0 -2
  83. package/build/legacy/__tests__/configs.test.d.ts +0 -2
  84. package/build/legacy/__tests__/configs.test.js +0 -22
  85. package/build/legacy/__tests__/configs.test.js.map +0 -1
  86. package/build/legacy/__tests__/exhaustive-deps.test.cjs +0 -722
  87. package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +0 -1
  88. package/build/legacy/__tests__/exhaustive-deps.test.d.cts +0 -2
  89. package/build/legacy/__tests__/exhaustive-deps.test.d.ts +0 -2
  90. package/build/legacy/__tests__/exhaustive-deps.test.js +0 -720
  91. package/build/legacy/__tests__/exhaustive-deps.test.js.map +0 -1
  92. package/build/legacy/configs.cjs +0 -49
  93. package/build/legacy/configs.cjs.map +0 -1
  94. package/build/legacy/configs.d.cts +0 -8
  95. package/build/legacy/configs.d.ts +0 -8
  96. package/build/legacy/configs.js.map +0 -1
  97. package/build/legacy/index.cjs +0 -34
  98. package/build/legacy/index.cjs.map +0 -1
  99. package/build/legacy/index.d.cts +0 -3
  100. package/build/legacy/index.d.ts +0 -3
  101. package/build/legacy/index.js.map +0 -1
  102. package/build/legacy/rules/exhaustive-deps.rule.cjs +0 -141
  103. package/build/legacy/rules/exhaustive-deps.rule.cjs.map +0 -1
  104. package/build/legacy/rules/exhaustive-deps.rule.d.cts +0 -6
  105. package/build/legacy/rules/exhaustive-deps.rule.d.ts +0 -6
  106. package/build/legacy/rules/exhaustive-deps.rule.js.map +0 -1
  107. package/build/legacy/rules/exhaustive-deps.utils.cjs +0 -52
  108. package/build/legacy/rules/exhaustive-deps.utils.cjs.map +0 -1
  109. package/build/legacy/rules/exhaustive-deps.utils.js.map +0 -1
  110. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs +0 -87
  111. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs.map +0 -1
  112. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.cts +0 -6
  113. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.ts +0 -6
  114. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.js.map +0 -1
  115. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs +0 -197
  116. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs.map +0 -1
  117. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.cts +0 -2
  118. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.ts +0 -2
  119. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js +0 -195
  120. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js.map +0 -1
  121. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs +0 -39
  122. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs.map +0 -1
  123. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.cts +0 -7
  124. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.ts +0 -7
  125. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.js.map +0 -1
  126. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs +0 -93
  127. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs.map +0 -1
  128. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.cts +0 -6
  129. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.ts +0 -6
  130. package/build/legacy/rules/stable-query-client/stable-query-client.rule.js.map +0 -1
  131. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs +0 -197
  132. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs.map +0 -1
  133. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.cts +0 -2
  134. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.ts +0 -2
  135. package/build/legacy/rules/stable-query-client/stable-query-client.test.js +0 -195
  136. package/build/legacy/rules/stable-query-client/stable-query-client.test.js.map +0 -1
  137. package/build/legacy/rules.cjs +0 -48
  138. package/build/legacy/rules.cjs.map +0 -1
  139. package/build/legacy/rules.d.cts +0 -9
  140. package/build/legacy/rules.d.ts +0 -9
  141. package/build/legacy/rules.js +0 -13
  142. package/build/legacy/rules.js.map +0 -1
  143. package/build/legacy/utils/ast-utils.cjs.map +0 -1
  144. package/build/legacy/utils/ast-utils.js.map +0 -1
  145. package/build/legacy/utils/create-rule.cjs +0 -39
  146. package/build/legacy/utils/create-rule.cjs.map +0 -1
  147. package/build/legacy/utils/create-rule.d.cts +0 -10
  148. package/build/legacy/utils/create-rule.d.ts +0 -10
  149. package/build/legacy/utils/create-rule.js.map +0 -1
  150. package/build/legacy/utils/detect-react-query-imports.cjs.map +0 -1
  151. package/build/legacy/utils/detect-react-query-imports.js.map +0 -1
  152. package/build/legacy/utils/object-utils.cjs +0 -33
  153. package/build/legacy/utils/object-utils.cjs.map +0 -1
  154. package/build/legacy/utils/object-utils.d.cts +0 -3
  155. package/build/legacy/utils/object-utils.d.ts +0 -3
  156. package/build/legacy/utils/object-utils.js +0 -8
  157. package/build/legacy/utils/object-utils.js.map +0 -1
  158. package/build/legacy/utils/test-utils.cjs +0 -36
  159. package/build/legacy/utils/test-utils.cjs.map +0 -1
  160. package/build/legacy/utils/test-utils.d.cts +0 -3
  161. package/build/legacy/utils/test-utils.d.ts +0 -3
  162. package/build/legacy/utils/test-utils.js +0 -11
  163. package/build/legacy/utils/test-utils.js.map +0 -1
  164. package/build/legacy/utils/unique-by.cjs +0 -33
  165. package/build/legacy/utils/unique-by.cjs.map +0 -1
  166. package/build/legacy/utils/unique-by.d.cts +0 -3
  167. package/build/legacy/utils/unique-by.d.ts +0 -3
  168. package/build/legacy/utils/unique-by.js.map +0 -1
  169. package/src/utils/object-utils.ts +0 -5
@@ -1,197 +0,0 @@
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
@@ -1 +0,0 @@
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,mBAA4B;AAC5B,wBAAgC;AAChC,iCAAqB;AAErB,IAAM,aAAa,IAAI,yBAAY,WAAW;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU,CAAC;AACb,CAAC;AAED,WAAW,IAAI,uBAAuB,iCAAM;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;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,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":[]}
@@ -1,195 +0,0 @@
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
@@ -1 +0,0 @@
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;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,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":[]}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name4 in all)
10
- __defProp(target, name4, { get: all[name4], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/rules.ts
31
- var rules_exports = {};
32
- __export(rules_exports, {
33
- rules: () => rules
34
- });
35
- module.exports = __toCommonJS(rules_exports);
36
- var exhaustiveDeps = __toESM(require("./rules/exhaustive-deps.rule.cjs"), 1);
37
- var stableQueryClient = __toESM(require("./rules/stable-query-client/stable-query-client.rule.cjs"), 1);
38
- var noRestDestructuring = __toESM(require("./rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs"), 1);
39
- var rules = {
40
- [exhaustiveDeps.name]: exhaustiveDeps.rule,
41
- [stableQueryClient.name]: stableQueryClient.rule,
42
- [noRestDestructuring.name]: noRestDestructuring.rule
43
- };
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- rules
47
- });
48
- //# sourceMappingURL=rules.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules.ts"],"sourcesContent":["import * as exhaustiveDeps from './rules/exhaustive-deps.rule'\nimport * as stableQueryClient from './rules/stable-query-client/stable-query-client.rule'\nimport * as noRestDestructuring from './rules/no-rest-desctructuring/no-rest-destructuring.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n [stableQueryClient.name]: stableQueryClient.rule,\n [noRestDestructuring.name]: noRestDestructuring.rule,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgC;AAChC,wBAAmC;AACnC,0BAAqC;AAE9B,IAAM,QAAQ;AAAA,EACnB,CAAgB,mBAAI,GAAkB;AAAA,EACtC,CAAmB,sBAAI,GAAqB;AAAA,EAC5C,CAAqB,wBAAI,GAAuB;AAClD;","names":[]}
@@ -1,9 +0,0 @@
1
- import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
2
-
3
- declare const rules: {
4
- "exhaustive-deps": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
5
- "stable-query-client": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
6
- "no-rest-destructuring": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
7
- };
8
-
9
- export { rules };
@@ -1,9 +0,0 @@
1
- import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
2
-
3
- declare const rules: {
4
- "exhaustive-deps": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
5
- "stable-query-client": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
6
- "no-rest-destructuring": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<string, readonly unknown[], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
7
- };
8
-
9
- export { rules };
@@ -1,13 +0,0 @@
1
- // src/rules.ts
2
- import * as exhaustiveDeps from "./rules/exhaustive-deps.rule.js";
3
- import * as stableQueryClient from "./rules/stable-query-client/stable-query-client.rule.js";
4
- import * as noRestDestructuring from "./rules/no-rest-desctructuring/no-rest-destructuring.rule.js";
5
- var rules = {
6
- [exhaustiveDeps.name]: exhaustiveDeps.rule,
7
- [stableQueryClient.name]: stableQueryClient.rule,
8
- [noRestDestructuring.name]: noRestDestructuring.rule
9
- };
10
- export {
11
- rules
12
- };
13
- //# sourceMappingURL=rules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules.ts"],"sourcesContent":["import * as exhaustiveDeps from './rules/exhaustive-deps.rule'\nimport * as stableQueryClient from './rules/stable-query-client/stable-query-client.rule'\nimport * as noRestDestructuring from './rules/no-rest-desctructuring/no-rest-destructuring.rule'\n\nexport const rules = {\n [exhaustiveDeps.name]: exhaustiveDeps.rule,\n [stableQueryClient.name]: stableQueryClient.rule,\n [noRestDestructuring.name]: noRestDestructuring.rule,\n}\n"],"mappings":";AAAA,YAAY,oBAAoB;AAChC,YAAY,uBAAuB;AACnC,YAAY,yBAAyB;AAE9B,IAAM,QAAQ;AAAA,EACnB,CAAgB,mBAAI,GAAkB;AAAA,EACtC,CAAmB,sBAAI,GAAqB;AAAA,EAC5C,CAAqB,wBAAI,GAAuB;AAClD;","names":[]}
@@ -1 +0,0 @@
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 { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\n\nexport const ASTUtils = {\n isNodeOfOneOf<T extends AST_NODE_TYPES>(\n node: TSESTree.Node,\n types: ReadonlyArray<T>,\n ): node is TSESTree.Node & { type: T } {\n return types.includes(node.type as T)\n },\n isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier {\n return node.type === AST_NODE_TYPES.Identifier\n },\n isIdentifierWithName(\n node: TSESTree.Node,\n name: string,\n ): node is TSESTree.Identifier {\n return ASTUtils.isIdentifier(node) && node.name === name\n },\n isIdentifierWithOneOfNames<T extends Array<string>>(\n node: TSESTree.Node,\n name: T,\n ): node is TSESTree.Identifier & { name: T[number] } {\n return ASTUtils.isIdentifier(node) && name.includes(node.name)\n },\n isProperty(node: TSESTree.Node): node is TSESTree.Property {\n return node.type === AST_NODE_TYPES.Property\n },\n isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression {\n return node.type === AST_NODE_TYPES.ObjectExpression\n },\n isPropertyWithIdentifierKey(\n node: TSESTree.Node,\n key: string,\n ): node is TSESTree.Property {\n return (\n ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key)\n )\n },\n findPropertyWithIdentifierKey(\n properties: Array<TSESTree.ObjectLiteralElement>,\n key: string,\n ): TSESTree.Property | undefined {\n return properties.find((x) =>\n ASTUtils.isPropertyWithIdentifierKey(x, key),\n ) as TSESTree.Property | undefined\n },\n getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier> {\n const identifiers: Array<TSESTree.Identifier> = []\n\n if (ASTUtils.isIdentifier(node)) {\n identifiers.push(node)\n }\n\n if ('arguments' in node) {\n node.arguments.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('elements' in node) {\n node.elements.forEach((x) => {\n if (x !== null) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n }\n })\n }\n\n if ('properties' in node) {\n node.properties.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('expressions' in node) {\n node.expressions.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if (node.type === AST_NODE_TYPES.Property) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.value))\n }\n\n if (node.type === AST_NODE_TYPES.SpreadElement) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.MemberExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.object))\n }\n\n if (node.type === AST_NODE_TYPES.UnaryExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.ChainExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n if (node.type === AST_NODE_TYPES.TSNonNullExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n return identifiers\n },\n isAncestorIsCallee(identifier: TSESTree.Node) {\n let previousNode = identifier\n let currentNode = identifier.parent\n\n while (currentNode !== undefined) {\n if (\n currentNode.type === AST_NODE_TYPES.CallExpression &&\n currentNode.callee === previousNode\n ) {\n return true\n }\n\n if (currentNode.type !== AST_NODE_TYPES.MemberExpression) {\n return false\n }\n\n previousNode = currentNode\n currentNode = currentNode.parent\n }\n\n return false\n },\n traverseUpOnly(\n identifier: TSESTree.Node,\n allowedNodeTypes: Array<AST_NODE_TYPES>,\n ): TSESTree.Node {\n const parent = identifier.parent\n\n if (parent !== undefined && allowedNodeTypes.includes(parent.type)) {\n return ASTUtils.traverseUpOnly(parent, allowedNodeTypes)\n }\n\n return identifier\n },\n isDeclaredInNode(params: {\n functionNode: TSESTree.Node\n reference: TSESLint.Scope.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { functionNode, reference, scopeManager } = params\n const scope = scopeManager.acquire(functionNode)\n\n if (scope === null) {\n return false\n }\n\n return scope.set.has(reference.identifier.name)\n },\n getExternalRefs(params: {\n scopeManager: TSESLint.Scope.ScopeManager\n sourceCode: Readonly<TSESLint.SourceCode>\n node: TSESTree.Node\n }): Array<TSESLint.Scope.Reference> {\n const { scopeManager, sourceCode, node } = params\n const scope = scopeManager.acquire(node)\n\n if (scope === null) {\n return []\n }\n\n const references = scope.references\n .filter((x) => x.isRead() && !scope.set.has(x.identifier.name))\n .map((x) => {\n const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ])\n\n return {\n variable: x,\n node: referenceNode,\n text: sourceCode.getText(referenceNode),\n }\n })\n\n const localRefIds = new Set(\n [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0])),\n )\n\n const externalRefs = references.filter(\n (x) => x.variable.resolved === null || !localRefIds.has(x.text),\n )\n\n return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)\n },\n mapKeyNodeToText(\n node: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n ) {\n return sourceCode.getText(\n ASTUtils.traverseUpOnly(node, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ]),\n )\n },\n isValidReactComponentOrHookName(\n identifier: TSESTree.Identifier | null | undefined,\n ) {\n return (\n identifier !== null &&\n identifier !== undefined &&\n /^(use|[A-Z])/.test(identifier.name)\n )\n },\n getFunctionAncestor(\n context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>,\n ) {\n for (const ancestor of context.getAncestors()) {\n if (ancestor.type === AST_NODE_TYPES.FunctionDeclaration) {\n return ancestor\n }\n\n if (\n ancestor.parent?.type === AST_NODE_TYPES.VariableDeclarator &&\n ancestor.parent.id.type === AST_NODE_TYPES.Identifier &&\n ASTUtils.isNodeOfOneOf(ancestor, [\n AST_NODE_TYPES.FunctionDeclaration,\n AST_NODE_TYPES.FunctionExpression,\n AST_NODE_TYPES.ArrowFunctionExpression,\n ])\n ) {\n return ancestor\n }\n }\n\n return undefined\n },\n getReferencedExpressionByIdentifier(params: {\n node: TSESTree.Node\n context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>\n }) {\n const { node, context } = params\n\n const resolvedNode = context\n .getScope()\n .references.find((ref) => ref.identifier === node)?.resolved?.defs[0]\n ?.node\n\n if (resolvedNode?.type !== AST_NODE_TYPES.VariableDeclarator) {\n return null\n }\n\n return resolvedNode.init\n },\n getClosestVariableDeclarator(node: TSESTree.Node) {\n let currentNode: TSESTree.Node | undefined = node\n\n while (\n currentNode !== undefined &&\n currentNode.type !== AST_NODE_TYPES.Program\n ) {\n if (currentNode.type === AST_NODE_TYPES.VariableDeclarator) {\n return currentNode\n }\n\n currentNode = currentNode.parent\n }\n\n return undefined\n },\n getNestedReturnStatements(\n node: TSESTree.Node,\n ): Array<TSESTree.ReturnStatement> {\n const returnStatements: Array<TSESTree.ReturnStatement> = []\n\n if (node.type === AST_NODE_TYPES.ReturnStatement) {\n returnStatements.push(node)\n }\n\n if ('body' in node && node.body !== undefined && node.body !== null) {\n Array.isArray(node.body)\n ? node.body.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.body),\n )\n }\n\n if ('consequent' in node) {\n Array.isArray(node.consequent)\n ? node.consequent.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.consequent),\n )\n }\n\n if ('alternate' in node && node.alternate !== null) {\n Array.isArray(node.alternate)\n ? node.alternate.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.alternate),\n )\n }\n\n if ('cases' in node) {\n node.cases.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n }\n\n if ('block' in node) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block))\n }\n\n if ('handler' in node && node.handler !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler))\n }\n\n if ('finalizer' in node && node.finalizer !== null) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.finalizer),\n )\n }\n\n if (\n 'expression' in node &&\n node.expression !== true &&\n node.expression !== false\n ) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.expression),\n )\n }\n\n if ('test' in node && node.test !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test))\n }\n\n return returnStatements\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAAyB;AAIlB,IAAM,WAAW;AAAA,EACtB,cACE,MACA,OACqC;AACrC,WAAO,MAAM,SAAS,KAAK,IAAS;AAAA,EACtC;AAAA,EACA,aAAa,MAAkD;AAC7D,WAAO,KAAK,SAAS,4BAAe;AAAA,EACtC;AAAA,EACA,qBACE,MACA,MAC6B;AAC7B,WAAO,SAAS,aAAa,IAAI,KAAK,KAAK,SAAS;AAAA,EACtD;AAAA,EACA,2BACE,MACA,MACmD;AACnD,WAAO,SAAS,aAAa,IAAI,KAAK,KAAK,SAAS,KAAK,IAAI;AAAA,EAC/D;AAAA,EACA,WAAW,MAAgD;AACzD,WAAO,KAAK,SAAS,4BAAe;AAAA,EACtC;AAAA,EACA,mBAAmB,MAAwD;AACzE,WAAO,KAAK,SAAS,4BAAe;AAAA,EACtC;AAAA,EACA,4BACE,MACA,KAC2B;AAC3B,WACE,SAAS,WAAW,IAAI,KAAK,SAAS,qBAAqB,KAAK,KAAK,GAAG;AAAA,EAE5E;AAAA,EACA,8BACE,YACA,KAC+B;AAC/B,WAAO,WAAW;AAAA,MAAK,CAAC,MACtB,SAAS,4BAA4B,GAAG,GAAG;AAAA,IAC7C;AAAA,EACF;AAAA,EACA,qBAAqB,MAAiD;AACpE,UAAM,cAA0C,CAAC;AAEjD,QAAI,SAAS,aAAa,IAAI,GAAG;AAC/B,kBAAY,KAAK,IAAI;AAAA,IACvB;AAEA,QAAI,eAAe,MAAM;AACvB,WAAK,UAAU,QAAQ,CAAC,MAAM;AAC5B,oBAAY,KAAK,GAAG,SAAS,qBAAqB,CAAC,CAAC;AAAA,MACtD,CAAC;AAAA,IACH;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,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":[]}
@@ -1 +0,0 @@
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 { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'\n\nexport const ASTUtils = {\n isNodeOfOneOf<T extends AST_NODE_TYPES>(\n node: TSESTree.Node,\n types: ReadonlyArray<T>,\n ): node is TSESTree.Node & { type: T } {\n return types.includes(node.type as T)\n },\n isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier {\n return node.type === AST_NODE_TYPES.Identifier\n },\n isIdentifierWithName(\n node: TSESTree.Node,\n name: string,\n ): node is TSESTree.Identifier {\n return ASTUtils.isIdentifier(node) && node.name === name\n },\n isIdentifierWithOneOfNames<T extends Array<string>>(\n node: TSESTree.Node,\n name: T,\n ): node is TSESTree.Identifier & { name: T[number] } {\n return ASTUtils.isIdentifier(node) && name.includes(node.name)\n },\n isProperty(node: TSESTree.Node): node is TSESTree.Property {\n return node.type === AST_NODE_TYPES.Property\n },\n isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression {\n return node.type === AST_NODE_TYPES.ObjectExpression\n },\n isPropertyWithIdentifierKey(\n node: TSESTree.Node,\n key: string,\n ): node is TSESTree.Property {\n return (\n ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key)\n )\n },\n findPropertyWithIdentifierKey(\n properties: Array<TSESTree.ObjectLiteralElement>,\n key: string,\n ): TSESTree.Property | undefined {\n return properties.find((x) =>\n ASTUtils.isPropertyWithIdentifierKey(x, key),\n ) as TSESTree.Property | undefined\n },\n getNestedIdentifiers(node: TSESTree.Node): Array<TSESTree.Identifier> {\n const identifiers: Array<TSESTree.Identifier> = []\n\n if (ASTUtils.isIdentifier(node)) {\n identifiers.push(node)\n }\n\n if ('arguments' in node) {\n node.arguments.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('elements' in node) {\n node.elements.forEach((x) => {\n if (x !== null) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n }\n })\n }\n\n if ('properties' in node) {\n node.properties.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if ('expressions' in node) {\n node.expressions.forEach((x) => {\n identifiers.push(...ASTUtils.getNestedIdentifiers(x))\n })\n }\n\n if (node.type === AST_NODE_TYPES.Property) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.value))\n }\n\n if (node.type === AST_NODE_TYPES.SpreadElement) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.MemberExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.object))\n }\n\n if (node.type === AST_NODE_TYPES.UnaryExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))\n }\n\n if (node.type === AST_NODE_TYPES.ChainExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n if (node.type === AST_NODE_TYPES.TSNonNullExpression) {\n identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))\n }\n\n return identifiers\n },\n isAncestorIsCallee(identifier: TSESTree.Node) {\n let previousNode = identifier\n let currentNode = identifier.parent\n\n while (currentNode !== undefined) {\n if (\n currentNode.type === AST_NODE_TYPES.CallExpression &&\n currentNode.callee === previousNode\n ) {\n return true\n }\n\n if (currentNode.type !== AST_NODE_TYPES.MemberExpression) {\n return false\n }\n\n previousNode = currentNode\n currentNode = currentNode.parent\n }\n\n return false\n },\n traverseUpOnly(\n identifier: TSESTree.Node,\n allowedNodeTypes: Array<AST_NODE_TYPES>,\n ): TSESTree.Node {\n const parent = identifier.parent\n\n if (parent !== undefined && allowedNodeTypes.includes(parent.type)) {\n return ASTUtils.traverseUpOnly(parent, allowedNodeTypes)\n }\n\n return identifier\n },\n isDeclaredInNode(params: {\n functionNode: TSESTree.Node\n reference: TSESLint.Scope.Reference\n scopeManager: TSESLint.Scope.ScopeManager\n }) {\n const { functionNode, reference, scopeManager } = params\n const scope = scopeManager.acquire(functionNode)\n\n if (scope === null) {\n return false\n }\n\n return scope.set.has(reference.identifier.name)\n },\n getExternalRefs(params: {\n scopeManager: TSESLint.Scope.ScopeManager\n sourceCode: Readonly<TSESLint.SourceCode>\n node: TSESTree.Node\n }): Array<TSESLint.Scope.Reference> {\n const { scopeManager, sourceCode, node } = params\n const scope = scopeManager.acquire(node)\n\n if (scope === null) {\n return []\n }\n\n const references = scope.references\n .filter((x) => x.isRead() && !scope.set.has(x.identifier.name))\n .map((x) => {\n const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ])\n\n return {\n variable: x,\n node: referenceNode,\n text: sourceCode.getText(referenceNode),\n }\n })\n\n const localRefIds = new Set(\n [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0])),\n )\n\n const externalRefs = references.filter(\n (x) => x.variable.resolved === null || !localRefIds.has(x.text),\n )\n\n return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)\n },\n mapKeyNodeToText(\n node: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n ) {\n return sourceCode.getText(\n ASTUtils.traverseUpOnly(node, [\n AST_NODE_TYPES.MemberExpression,\n AST_NODE_TYPES.Identifier,\n ]),\n )\n },\n isValidReactComponentOrHookName(\n identifier: TSESTree.Identifier | null | undefined,\n ) {\n return (\n identifier !== null &&\n identifier !== undefined &&\n /^(use|[A-Z])/.test(identifier.name)\n )\n },\n getFunctionAncestor(\n context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>,\n ) {\n for (const ancestor of context.getAncestors()) {\n if (ancestor.type === AST_NODE_TYPES.FunctionDeclaration) {\n return ancestor\n }\n\n if (\n ancestor.parent?.type === AST_NODE_TYPES.VariableDeclarator &&\n ancestor.parent.id.type === AST_NODE_TYPES.Identifier &&\n ASTUtils.isNodeOfOneOf(ancestor, [\n AST_NODE_TYPES.FunctionDeclaration,\n AST_NODE_TYPES.FunctionExpression,\n AST_NODE_TYPES.ArrowFunctionExpression,\n ])\n ) {\n return ancestor\n }\n }\n\n return undefined\n },\n getReferencedExpressionByIdentifier(params: {\n node: TSESTree.Node\n context: Readonly<RuleContext<string, ReadonlyArray<unknown>>>\n }) {\n const { node, context } = params\n\n const resolvedNode = context\n .getScope()\n .references.find((ref) => ref.identifier === node)?.resolved?.defs[0]\n ?.node\n\n if (resolvedNode?.type !== AST_NODE_TYPES.VariableDeclarator) {\n return null\n }\n\n return resolvedNode.init\n },\n getClosestVariableDeclarator(node: TSESTree.Node) {\n let currentNode: TSESTree.Node | undefined = node\n\n while (\n currentNode !== undefined &&\n currentNode.type !== AST_NODE_TYPES.Program\n ) {\n if (currentNode.type === AST_NODE_TYPES.VariableDeclarator) {\n return currentNode\n }\n\n currentNode = currentNode.parent\n }\n\n return undefined\n },\n getNestedReturnStatements(\n node: TSESTree.Node,\n ): Array<TSESTree.ReturnStatement> {\n const returnStatements: Array<TSESTree.ReturnStatement> = []\n\n if (node.type === AST_NODE_TYPES.ReturnStatement) {\n returnStatements.push(node)\n }\n\n if ('body' in node && node.body !== undefined && node.body !== null) {\n Array.isArray(node.body)\n ? node.body.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.body),\n )\n }\n\n if ('consequent' in node) {\n Array.isArray(node.consequent)\n ? node.consequent.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.consequent),\n )\n }\n\n if ('alternate' in node && node.alternate !== null) {\n Array.isArray(node.alternate)\n ? node.alternate.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n : returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.alternate),\n )\n }\n\n if ('cases' in node) {\n node.cases.forEach((x) => {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(x))\n })\n }\n\n if ('block' in node) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block))\n }\n\n if ('handler' in node && node.handler !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler))\n }\n\n if ('finalizer' in node && node.finalizer !== null) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.finalizer),\n )\n }\n\n if (\n 'expression' in node &&\n node.expression !== true &&\n node.expression !== false\n ) {\n returnStatements.push(\n ...ASTUtils.getNestedReturnStatements(node.expression),\n )\n }\n\n if ('test' in node && node.test !== null) {\n returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test))\n }\n\n return returnStatements\n },\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAIlB,IAAM,WAAW;AAAA,EACtB,cACE,MACA,OACqC;AACrC,WAAO,MAAM,SAAS,K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E,gBAAgB,QAChB,KAAK,eAAe,QACpB,KAAK,eAAe,OACpB;AACA,uBAAiB;AAAA,QACf,GAAG,SAAS,0BAA0B,KAAK,UAAU;AAAA,MACvD;AAAA,IACF;AAEA,QAAI,UAAU,QAAQ,KAAK,SAAS,MAAM;AACxC,uBAAiB,KAAK,GAAG,SAAS,0BAA0B,KAAK,IAAI,CAAC;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,39 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}