@tanstack/eslint-plugin-query 5.17.7 → 5.17.22

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 (168) 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/{build/legacy → dist/cjs}/index.d.cts +0 -1
  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/{build/legacy → dist/esm}/index.d.ts +0 -1
  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/src/utils/create-rule.ts +1 -1
  81. package/build/legacy/__tests__/configs.test.cjs +0 -24
  82. package/build/legacy/__tests__/configs.test.cjs.map +0 -1
  83. package/build/legacy/__tests__/configs.test.d.cts +0 -2
  84. package/build/legacy/__tests__/configs.test.d.ts +0 -2
  85. package/build/legacy/__tests__/configs.test.js +0 -22
  86. package/build/legacy/__tests__/configs.test.js.map +0 -1
  87. package/build/legacy/__tests__/exhaustive-deps.test.cjs +0 -722
  88. package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +0 -1
  89. package/build/legacy/__tests__/exhaustive-deps.test.d.cts +0 -2
  90. package/build/legacy/__tests__/exhaustive-deps.test.d.ts +0 -2
  91. package/build/legacy/__tests__/exhaustive-deps.test.js +0 -720
  92. package/build/legacy/__tests__/exhaustive-deps.test.js.map +0 -1
  93. package/build/legacy/configs.cjs +0 -49
  94. package/build/legacy/configs.cjs.map +0 -1
  95. package/build/legacy/configs.d.cts +0 -8
  96. package/build/legacy/configs.d.ts +0 -8
  97. package/build/legacy/configs.js.map +0 -1
  98. package/build/legacy/index.cjs +0 -34
  99. package/build/legacy/index.cjs.map +0 -1
  100. package/build/legacy/index.js.map +0 -1
  101. package/build/legacy/rules/exhaustive-deps.rule.cjs +0 -141
  102. package/build/legacy/rules/exhaustive-deps.rule.cjs.map +0 -1
  103. package/build/legacy/rules/exhaustive-deps.rule.d.cts +0 -6
  104. package/build/legacy/rules/exhaustive-deps.rule.d.ts +0 -6
  105. package/build/legacy/rules/exhaustive-deps.rule.js.map +0 -1
  106. package/build/legacy/rules/exhaustive-deps.utils.cjs +0 -52
  107. package/build/legacy/rules/exhaustive-deps.utils.cjs.map +0 -1
  108. package/build/legacy/rules/exhaustive-deps.utils.js.map +0 -1
  109. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs +0 -87
  110. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs.map +0 -1
  111. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.cts +0 -6
  112. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.ts +0 -6
  113. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.js.map +0 -1
  114. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs +0 -197
  115. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs.map +0 -1
  116. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.cts +0 -2
  117. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.ts +0 -2
  118. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js +0 -195
  119. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js.map +0 -1
  120. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs +0 -39
  121. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs.map +0 -1
  122. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.cts +0 -7
  123. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.ts +0 -7
  124. package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.js.map +0 -1
  125. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs +0 -93
  126. package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs.map +0 -1
  127. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.cts +0 -6
  128. package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.ts +0 -6
  129. package/build/legacy/rules/stable-query-client/stable-query-client.rule.js.map +0 -1
  130. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs +0 -197
  131. package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs.map +0 -1
  132. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.cts +0 -2
  133. package/build/legacy/rules/stable-query-client/stable-query-client.test.d.ts +0 -2
  134. package/build/legacy/rules/stable-query-client/stable-query-client.test.js +0 -195
  135. package/build/legacy/rules/stable-query-client/stable-query-client.test.js.map +0 -1
  136. package/build/legacy/rules.cjs +0 -48
  137. package/build/legacy/rules.cjs.map +0 -1
  138. package/build/legacy/rules.d.cts +0 -9
  139. package/build/legacy/rules.d.ts +0 -9
  140. package/build/legacy/rules.js +0 -13
  141. package/build/legacy/rules.js.map +0 -1
  142. package/build/legacy/utils/ast-utils.cjs.map +0 -1
  143. package/build/legacy/utils/ast-utils.js.map +0 -1
  144. package/build/legacy/utils/create-rule.cjs +0 -39
  145. package/build/legacy/utils/create-rule.cjs.map +0 -1
  146. package/build/legacy/utils/create-rule.d.cts +0 -10
  147. package/build/legacy/utils/create-rule.d.ts +0 -10
  148. package/build/legacy/utils/create-rule.js.map +0 -1
  149. package/build/legacy/utils/detect-react-query-imports.cjs.map +0 -1
  150. package/build/legacy/utils/detect-react-query-imports.js.map +0 -1
  151. package/build/legacy/utils/object-utils.cjs +0 -33
  152. package/build/legacy/utils/object-utils.cjs.map +0 -1
  153. package/build/legacy/utils/object-utils.d.cts +0 -3
  154. package/build/legacy/utils/object-utils.d.ts +0 -3
  155. package/build/legacy/utils/object-utils.js +0 -8
  156. package/build/legacy/utils/object-utils.js.map +0 -1
  157. package/build/legacy/utils/test-utils.cjs +0 -36
  158. package/build/legacy/utils/test-utils.cjs.map +0 -1
  159. package/build/legacy/utils/test-utils.d.cts +0 -3
  160. package/build/legacy/utils/test-utils.d.ts +0 -3
  161. package/build/legacy/utils/test-utils.js +0 -11
  162. package/build/legacy/utils/test-utils.js.map +0 -1
  163. package/build/legacy/utils/unique-by.cjs +0 -33
  164. package/build/legacy/utils/unique-by.cjs.map +0 -1
  165. package/build/legacy/utils/unique-by.d.cts +0 -3
  166. package/build/legacy/utils/unique-by.d.ts +0 -3
  167. package/build/legacy/utils/unique-by.js.map +0 -1
  168. package/src/utils/object-utils.ts +0 -5
@@ -1,197 +0,0 @@
1
- "use strict";
2
-
3
- // src/rules/no-rest-desctructuring/no-rest-destructuring.test.ts
4
- var import_utils = require("@typescript-eslint/utils");
5
- var import_test_utils = require("../../utils/test-utils.cjs");
6
- var import_no_rest_destructuring = require("./no-rest-destructuring.rule.cjs");
7
- var ruleTester = new import_utils.ESLintUtils.RuleTester({
8
- parser: "@typescript-eslint/parser",
9
- settings: {}
10
- });
11
- ruleTester.run("no-rest-desctructuring", import_no_rest_destructuring.rule, {
12
- valid: [
13
- {
14
- name: "useQuery is not captured",
15
- code: import_test_utils.normalizeIndent`
16
- import { useQuery } from '@tanstack/react-query'
17
-
18
- function Component() {
19
- useQuery()
20
- return
21
- }
22
- `
23
- },
24
- {
25
- name: "useQuery is not destructured",
26
- code: import_test_utils.normalizeIndent`
27
- import { useQuery } from '@tanstack/react-query'
28
-
29
- function Component() {
30
- const query = useQuery()
31
- return
32
- }
33
- `
34
- },
35
- {
36
- name: "useQuery is destructured without rest",
37
- code: import_test_utils.normalizeIndent`
38
- import { useQuery } from '@tanstack/react-query'
39
-
40
- function Component() {
41
- const { data, isLoading, isError } = useQuery()
42
- return
43
- }
44
- `
45
- },
46
- {
47
- name: "useInfiniteQuery is not captured",
48
- code: import_test_utils.normalizeIndent`
49
- import { useInfiniteQuery } from '@tanstack/react-query'
50
-
51
- function Component() {
52
- useInfiniteQuery()
53
- return
54
- }
55
- `
56
- },
57
- {
58
- name: "useInfiniteQuery is not destructured",
59
- code: import_test_utils.normalizeIndent`
60
- import { useInfiniteQuery } from '@tanstack/react-query'
61
-
62
- function Component() {
63
- const query = useInfiniteQuery()
64
- return
65
- }
66
- `
67
- },
68
- {
69
- name: "useInfiniteQuery is destructured without rest",
70
- code: import_test_utils.normalizeIndent`
71
- import { useInfiniteQuery } from '@tanstack/react-query'
72
-
73
- function Component() {
74
- const { data, isLoading, isError } = useInfiniteQuery()
75
- return
76
- }
77
- `
78
- },
79
- {
80
- name: "useQueries is not captured",
81
- code: import_test_utils.normalizeIndent`
82
- import { useQueries } from '@tanstack/react-query'
83
-
84
- function Component() {
85
- useQueries([])
86
- return
87
- }
88
- `
89
- },
90
- {
91
- name: "useQueries is not destructured",
92
- code: import_test_utils.normalizeIndent`
93
- import { useQueries } from '@tanstack/react-query'
94
-
95
- function Component() {
96
- const queries = useQueries([])
97
- return
98
- }
99
- `
100
- },
101
- {
102
- name: "useQueries array has no rest destructured element",
103
- code: import_test_utils.normalizeIndent`
104
- import { useQueries } from '@tanstack/react-query'
105
-
106
- function Component() {
107
- const [query1, { data, isLoading },, ...others] = useQueries([
108
- { queryKey: ['key1'], queryFn: () => {} },
109
- { queryKey: ['key2'], queryFn: () => {} },
110
- { queryKey: ['key3'], queryFn: () => {} },
111
- { queryKey: ['key4'], queryFn: () => {} },
112
- { queryKey: ['key5'], queryFn: () => {} },
113
- ])
114
- return
115
- }
116
- `
117
- },
118
- {
119
- name: "useQuery is destructured with rest but not from tanstack query",
120
- code: import_test_utils.normalizeIndent`
121
- import { useQuery } from 'other-package'
122
-
123
- function Component() {
124
- const { data, ...rest } = useQuery()
125
- return
126
- }
127
- `
128
- },
129
- {
130
- name: "useInfiniteQuery is destructured with rest but not from tanstack query",
131
- code: import_test_utils.normalizeIndent`
132
- import { useInfiniteQuery } from 'other-package'
133
-
134
- function Component() {
135
- const { data, ...rest } = useInfiniteQuery()
136
- return
137
- }
138
- `
139
- },
140
- {
141
- name: "useQueries array has rest destructured element but not from tanstack query",
142
- code: import_test_utils.normalizeIndent`
143
- import { useQueries } from 'other-package'
144
-
145
- function Component() {
146
- const [query1, { data, ...rest }] = useQueries([
147
- { queryKey: ['key1'], queryFn: () => {} },
148
- { queryKey: ['key2'], queryFn: () => {} },
149
- ])
150
- return
151
- }
152
- `
153
- }
154
- ],
155
- invalid: [
156
- {
157
- name: "useQuery is destructured with rest",
158
- code: import_test_utils.normalizeIndent`
159
- import { useQuery } from '@tanstack/react-query'
160
-
161
- function Component() {
162
- const { data, ...rest } = useQuery()
163
- return
164
- }
165
- `,
166
- errors: [{ messageId: "objectRestDestructure" }]
167
- },
168
- {
169
- name: "useInfiniteQuery is destructured with rest",
170
- code: import_test_utils.normalizeIndent`
171
- import { useInfiniteQuery } from '@tanstack/react-query'
172
-
173
- function Component() {
174
- const { data, ...rest } = useInfiniteQuery()
175
- return
176
- }
177
- `,
178
- errors: [{ messageId: "objectRestDestructure" }]
179
- },
180
- {
181
- name: "useQueries array has rest destructured element",
182
- code: import_test_utils.normalizeIndent`
183
- import { useQueries } from '@tanstack/react-query'
184
-
185
- function Component() {
186
- const [query1, { data, ...rest }] = useQueries([
187
- { queryKey: ['key1'], queryFn: () => {} },
188
- { queryKey: ['key2'], queryFn: () => {} },
189
- ])
190
- return
191
- }
192
- `,
193
- errors: [{ messageId: "objectRestDestructure" }]
194
- }
195
- ]
196
- });
197
- //# sourceMappingURL=no-rest-destructuring.test.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/no-rest-desctructuring/no-rest-destructuring.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './no-rest-destructuring.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('no-rest-desctructuring', rule, {\n valid: [\n {\n name: 'useQuery is not captured',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n useQuery()\n return\n }\n `,\n },\n {\n name: 'useQuery is not destructured',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const query = useQuery()\n return\n }\n `,\n },\n {\n name: 'useQuery is destructured without rest',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, isLoading, isError } = useQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is not captured',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is not destructured',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const query = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is destructured without rest',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, isLoading, isError } = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useQueries is not captured',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n useQueries([])\n return\n }\n `,\n },\n {\n name: 'useQueries is not destructured',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const queries = useQueries([])\n return\n }\n `,\n },\n {\n name: 'useQueries array has no rest destructured element',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const [query1, { data, isLoading },, ...others] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n { queryKey: ['key3'], queryFn: () => {} },\n { queryKey: ['key4'], queryFn: () => {} },\n { queryKey: ['key5'], queryFn: () => {} },\n ])\n return\n }\n `,\n },\n {\n name: 'useQuery is destructured with rest but not from tanstack query',\n code: normalizeIndent`\n import { useQuery } from 'other-package'\n\n function Component() {\n const { data, ...rest } = useQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is destructured with rest but not from tanstack query',\n code: normalizeIndent`\n import { useInfiniteQuery } from 'other-package'\n\n function Component() {\n const { data, ...rest } = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useQueries array has rest destructured element but not from tanstack query',\n code: normalizeIndent`\n import { useQueries } from 'other-package'\n\n function Component() {\n const [query1, { data, ...rest }] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n ])\n return\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'useQuery is destructured with rest',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, ...rest } = useQuery()\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\n },\n {\n name: 'useInfiniteQuery is destructured with rest',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, ...rest } = useInfiniteQuery()\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\n },\n {\n name: 'useQueries array has rest destructured element',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const [query1, { data, ...rest }] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n ])\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\n },\n ],\n})\n"],"mappings":";;;AAAA,mBAA4B;AAC5B,wBAAgC;AAChC,mCAAqB;AAErB,IAAM,aAAa,IAAI,yBAAY,WAAW;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU,CAAC;AACb,CAAC;AAED,WAAW,IAAI,0BAA0B,mCAAM;AAAA,EAC7C,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,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;AAAA;AAAA;AAAA;AAAA;AAAA,IAcR;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;AAAA;AAAA,IAWR;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAWN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -1,195 +0,0 @@
1
- // src/rules/no-rest-desctructuring/no-rest-destructuring.test.ts
2
- import { ESLintUtils } from "@typescript-eslint/utils";
3
- import { normalizeIndent } from "../../utils/test-utils.js";
4
- import { rule } from "./no-rest-destructuring.rule.js";
5
- var ruleTester = new ESLintUtils.RuleTester({
6
- parser: "@typescript-eslint/parser",
7
- settings: {}
8
- });
9
- ruleTester.run("no-rest-desctructuring", rule, {
10
- valid: [
11
- {
12
- name: "useQuery is not captured",
13
- code: normalizeIndent`
14
- import { useQuery } from '@tanstack/react-query'
15
-
16
- function Component() {
17
- useQuery()
18
- return
19
- }
20
- `
21
- },
22
- {
23
- name: "useQuery is not destructured",
24
- code: normalizeIndent`
25
- import { useQuery } from '@tanstack/react-query'
26
-
27
- function Component() {
28
- const query = useQuery()
29
- return
30
- }
31
- `
32
- },
33
- {
34
- name: "useQuery is destructured without rest",
35
- code: normalizeIndent`
36
- import { useQuery } from '@tanstack/react-query'
37
-
38
- function Component() {
39
- const { data, isLoading, isError } = useQuery()
40
- return
41
- }
42
- `
43
- },
44
- {
45
- name: "useInfiniteQuery is not captured",
46
- code: normalizeIndent`
47
- import { useInfiniteQuery } from '@tanstack/react-query'
48
-
49
- function Component() {
50
- useInfiniteQuery()
51
- return
52
- }
53
- `
54
- },
55
- {
56
- name: "useInfiniteQuery is not destructured",
57
- code: normalizeIndent`
58
- import { useInfiniteQuery } from '@tanstack/react-query'
59
-
60
- function Component() {
61
- const query = useInfiniteQuery()
62
- return
63
- }
64
- `
65
- },
66
- {
67
- name: "useInfiniteQuery is destructured without rest",
68
- code: normalizeIndent`
69
- import { useInfiniteQuery } from '@tanstack/react-query'
70
-
71
- function Component() {
72
- const { data, isLoading, isError } = useInfiniteQuery()
73
- return
74
- }
75
- `
76
- },
77
- {
78
- name: "useQueries is not captured",
79
- code: normalizeIndent`
80
- import { useQueries } from '@tanstack/react-query'
81
-
82
- function Component() {
83
- useQueries([])
84
- return
85
- }
86
- `
87
- },
88
- {
89
- name: "useQueries is not destructured",
90
- code: normalizeIndent`
91
- import { useQueries } from '@tanstack/react-query'
92
-
93
- function Component() {
94
- const queries = useQueries([])
95
- return
96
- }
97
- `
98
- },
99
- {
100
- name: "useQueries array has no rest destructured element",
101
- code: normalizeIndent`
102
- import { useQueries } from '@tanstack/react-query'
103
-
104
- function Component() {
105
- const [query1, { data, isLoading },, ...others] = useQueries([
106
- { queryKey: ['key1'], queryFn: () => {} },
107
- { queryKey: ['key2'], queryFn: () => {} },
108
- { queryKey: ['key3'], queryFn: () => {} },
109
- { queryKey: ['key4'], queryFn: () => {} },
110
- { queryKey: ['key5'], queryFn: () => {} },
111
- ])
112
- return
113
- }
114
- `
115
- },
116
- {
117
- name: "useQuery is destructured with rest but not from tanstack query",
118
- code: normalizeIndent`
119
- import { useQuery } from 'other-package'
120
-
121
- function Component() {
122
- const { data, ...rest } = useQuery()
123
- return
124
- }
125
- `
126
- },
127
- {
128
- name: "useInfiniteQuery is destructured with rest but not from tanstack query",
129
- code: normalizeIndent`
130
- import { useInfiniteQuery } from 'other-package'
131
-
132
- function Component() {
133
- const { data, ...rest } = useInfiniteQuery()
134
- return
135
- }
136
- `
137
- },
138
- {
139
- name: "useQueries array has rest destructured element but not from tanstack query",
140
- code: normalizeIndent`
141
- import { useQueries } from 'other-package'
142
-
143
- function Component() {
144
- const [query1, { data, ...rest }] = useQueries([
145
- { queryKey: ['key1'], queryFn: () => {} },
146
- { queryKey: ['key2'], queryFn: () => {} },
147
- ])
148
- return
149
- }
150
- `
151
- }
152
- ],
153
- invalid: [
154
- {
155
- name: "useQuery is destructured with rest",
156
- code: normalizeIndent`
157
- import { useQuery } from '@tanstack/react-query'
158
-
159
- function Component() {
160
- const { data, ...rest } = useQuery()
161
- return
162
- }
163
- `,
164
- errors: [{ messageId: "objectRestDestructure" }]
165
- },
166
- {
167
- name: "useInfiniteQuery is destructured with rest",
168
- code: normalizeIndent`
169
- import { useInfiniteQuery } from '@tanstack/react-query'
170
-
171
- function Component() {
172
- const { data, ...rest } = useInfiniteQuery()
173
- return
174
- }
175
- `,
176
- errors: [{ messageId: "objectRestDestructure" }]
177
- },
178
- {
179
- name: "useQueries array has rest destructured element",
180
- code: normalizeIndent`
181
- import { useQueries } from '@tanstack/react-query'
182
-
183
- function Component() {
184
- const [query1, { data, ...rest }] = useQueries([
185
- { queryKey: ['key1'], queryFn: () => {} },
186
- { queryKey: ['key2'], queryFn: () => {} },
187
- ])
188
- return
189
- }
190
- `,
191
- errors: [{ messageId: "objectRestDestructure" }]
192
- }
193
- ]
194
- });
195
- //# sourceMappingURL=no-rest-destructuring.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/no-rest-desctructuring/no-rest-destructuring.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../../utils/test-utils'\nimport { rule } from './no-rest-destructuring.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('no-rest-desctructuring', rule, {\n valid: [\n {\n name: 'useQuery is not captured',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n useQuery()\n return\n }\n `,\n },\n {\n name: 'useQuery is not destructured',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const query = useQuery()\n return\n }\n `,\n },\n {\n name: 'useQuery is destructured without rest',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, isLoading, isError } = useQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is not captured',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is not destructured',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const query = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is destructured without rest',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, isLoading, isError } = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useQueries is not captured',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n useQueries([])\n return\n }\n `,\n },\n {\n name: 'useQueries is not destructured',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const queries = useQueries([])\n return\n }\n `,\n },\n {\n name: 'useQueries array has no rest destructured element',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const [query1, { data, isLoading },, ...others] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n { queryKey: ['key3'], queryFn: () => {} },\n { queryKey: ['key4'], queryFn: () => {} },\n { queryKey: ['key5'], queryFn: () => {} },\n ])\n return\n }\n `,\n },\n {\n name: 'useQuery is destructured with rest but not from tanstack query',\n code: normalizeIndent`\n import { useQuery } from 'other-package'\n\n function Component() {\n const { data, ...rest } = useQuery()\n return\n }\n `,\n },\n {\n name: 'useInfiniteQuery is destructured with rest but not from tanstack query',\n code: normalizeIndent`\n import { useInfiniteQuery } from 'other-package'\n\n function Component() {\n const { data, ...rest } = useInfiniteQuery()\n return\n }\n `,\n },\n {\n name: 'useQueries array has rest destructured element but not from tanstack query',\n code: normalizeIndent`\n import { useQueries } from 'other-package'\n\n function Component() {\n const [query1, { data, ...rest }] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n ])\n return\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'useQuery is destructured with rest',\n code: normalizeIndent`\n import { useQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, ...rest } = useQuery()\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\n },\n {\n name: 'useInfiniteQuery is destructured with rest',\n code: normalizeIndent`\n import { useInfiniteQuery } from '@tanstack/react-query'\n\n function Component() {\n const { data, ...rest } = useInfiniteQuery()\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\n },\n {\n name: 'useQueries array has rest destructured element',\n code: normalizeIndent`\n import { useQueries } from '@tanstack/react-query'\n\n function Component() {\n const [query1, { data, ...rest }] = useQueries([\n { queryKey: ['key1'], queryFn: () => {} },\n { queryKey: ['key2'], queryFn: () => {} },\n ])\n return\n }\n `,\n errors: [{ messageId: 'objectRestDestructure' }],\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,0BAA0B,MAAM;AAAA,EAC7C,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,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;AAAA;AAAA;AAAA;AAAA;AAAA,IAcR;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;AAAA;AAAA,IAWR;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAWN,QAAQ,CAAC,EAAE,WAAW,wBAAwB,CAAC;AAAA,IACjD;AAAA,EACF;AACF,CAAC;","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/rules/no-rest-desctructuring/no-rest-destructuring.utils.ts
21
- var no_rest_destructuring_utils_exports = {};
22
- __export(no_rest_destructuring_utils_exports, {
23
- NoRestDestructuringUtils: () => NoRestDestructuringUtils
24
- });
25
- module.exports = __toCommonJS(no_rest_destructuring_utils_exports);
26
- var import_utils = require("@typescript-eslint/utils");
27
- var NoRestDestructuringUtils = {
28
- isObjectRestDestructuring(node) {
29
- if (node.type !== import_utils.AST_NODE_TYPES.ObjectPattern) {
30
- return false;
31
- }
32
- return node.properties.some((p) => p.type === import_utils.AST_NODE_TYPES.RestElement);
33
- }
34
- };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- NoRestDestructuringUtils
38
- });
39
- //# sourceMappingURL=no-rest-destructuring.utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/no-rest-desctructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement)\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAGxB,IAAM,2BAA2B;AAAA,EACtC,0BAA0B,MAA8B;AACtD,QAAI,KAAK,SAAS,4BAAe,eAAe;AAC9C,aAAO;AAAA,IACT;AACA,WAAO,KAAK,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,4BAAe,WAAW;AAAA,EAC1E;AACF;","names":[]}
@@ -1,7 +0,0 @@
1
- import { TSESTree } from '@typescript-eslint/utils';
2
-
3
- declare const NoRestDestructuringUtils: {
4
- isObjectRestDestructuring(node: TSESTree.Node): boolean;
5
- };
6
-
7
- export { NoRestDestructuringUtils };
@@ -1,7 +0,0 @@
1
- import { TSESTree } from '@typescript-eslint/utils';
2
-
3
- declare const NoRestDestructuringUtils: {
4
- isObjectRestDestructuring(node: TSESTree.Node): boolean;
5
- };
6
-
7
- export { NoRestDestructuringUtils };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/rules/no-rest-desctructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement)\n },\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAGxB,IAAM,2BAA2B;AAAA,EACtC,0BAA0B,MAA8B;AACtD,QAAI,KAAK,SAAS,eAAe,eAAe;AAC9C,aAAO;AAAA,IACT;AACA,WAAO,KAAK,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,eAAe,WAAW;AAAA,EAC1E;AACF;","names":[]}
@@ -1,93 +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 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
@@ -1 +0,0 @@
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;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,4BAAe,cACpC,KAAK,OAAO,SAAS,mBACrB,UAAK,WAAL,mBAAa,UAAS,4BAAe,sBACrC,CAAC,QAAQ;AAAA,UACP,KAAK;AAAA,UACL;AAAA,QACF,GACA;AACA;AAAA,QACF;AAEA,cAAM,aAAa,0BAAS,oBAAoB,OAAO;AACvD,cAAM,0BAAyB,yCAAY,WAAU;AAErD,YACE,CAAC,0BAAS,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,4BAAe,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":[]}
@@ -1,6 +0,0 @@
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 };
@@ -1,6 +0,0 @@
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 };
@@ -1 +0,0 @@
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":[]}