@tanstack/eslint-plugin-query 5.17.7 → 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.
- package/dist/cjs/configs.cjs +23 -0
- package/dist/cjs/configs.cjs.map +1 -0
- package/dist/cjs/configs.d.cts +6 -0
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +2 -0
- package/dist/cjs/rules/exhaustive-deps.rule.cjs +114 -0
- package/dist/cjs/rules/exhaustive-deps.rule.cjs.map +1 -0
- package/dist/cjs/rules/exhaustive-deps.rule.d.cts +3 -0
- package/dist/cjs/rules/exhaustive-deps.utils.cjs +26 -0
- package/dist/cjs/rules/exhaustive-deps.utils.cjs.map +1 -0
- package/{build/legacy → dist/cjs}/rules/exhaustive-deps.utils.d.cts +2 -5
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs +60 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs.map +1 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.cts +2 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.test.d.cts +1 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs +13 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs.map +1 -0
- package/dist/cjs/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.cts +4 -0
- package/dist/cjs/rules/stable-query-client/stable-query-client.rule.cjs +66 -0
- package/dist/cjs/rules/stable-query-client/stable-query-client.rule.cjs.map +1 -0
- package/dist/cjs/rules/stable-query-client/stable-query-client.rule.d.cts +3 -0
- package/dist/cjs/rules/stable-query-client/stable-query-client.test.d.cts +1 -0
- package/dist/cjs/rules.cjs +12 -0
- package/dist/cjs/rules.cjs.map +1 -0
- package/dist/cjs/rules.d.cts +5 -0
- package/{build/legacy → dist/cjs}/utils/ast-utils.cjs +31 -57
- package/dist/cjs/utils/ast-utils.cjs.map +1 -0
- package/{build/legacy → dist/cjs}/utils/ast-utils.d.cts +4 -6
- package/dist/cjs/utils/create-rule.cjs +13 -0
- package/dist/cjs/utils/create-rule.cjs.map +1 -0
- package/dist/cjs/utils/create-rule.d.cts +7 -0
- package/{build/legacy → dist/cjs}/utils/detect-react-query-imports.cjs +6 -32
- package/dist/cjs/utils/detect-react-query-imports.cjs.map +1 -0
- package/{build/legacy → dist/cjs}/utils/detect-react-query-imports.d.cts +5 -6
- package/dist/cjs/utils/test-utils.d.cts +1 -0
- package/dist/cjs/utils/unique-by.cjs +7 -0
- package/dist/cjs/utils/unique-by.cjs.map +1 -0
- package/dist/cjs/utils/unique-by.d.cts +1 -0
- package/dist/esm/configs.d.ts +6 -0
- package/{build/legacy → dist/esm}/configs.js +2 -3
- package/dist/esm/configs.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/{build/legacy → dist/esm}/index.js +1 -2
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/rules/exhaustive-deps.rule.d.ts +3 -0
- package/{build/legacy → dist/esm}/rules/exhaustive-deps.rule.js +5 -6
- package/dist/esm/rules/exhaustive-deps.rule.js.map +1 -0
- package/{build/legacy → dist/esm}/rules/exhaustive-deps.utils.d.ts +2 -5
- package/{build/legacy → dist/esm}/rules/exhaustive-deps.utils.js +2 -3
- package/dist/esm/rules/exhaustive-deps.utils.js.map +1 -0
- package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.ts +2 -0
- package/{build/legacy → dist/esm}/rules/no-rest-desctructuring/no-rest-destructuring.rule.js +4 -5
- package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.rule.js.map +1 -0
- package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.test.d.ts +1 -0
- package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.ts +4 -0
- package/{build/legacy → dist/esm}/rules/no-rest-desctructuring/no-rest-destructuring.utils.js +2 -3
- package/dist/esm/rules/no-rest-desctructuring/no-rest-destructuring.utils.js.map +1 -0
- package/dist/esm/rules/stable-query-client/stable-query-client.rule.d.ts +3 -0
- package/{build/legacy → dist/esm}/rules/stable-query-client/stable-query-client.rule.js +3 -4
- package/dist/esm/rules/stable-query-client/stable-query-client.rule.js.map +1 -0
- package/dist/esm/rules/stable-query-client/stable-query-client.test.d.ts +1 -0
- package/dist/esm/rules.d.ts +5 -0
- package/dist/esm/rules.js +12 -0
- package/dist/esm/rules.js.map +1 -0
- package/{build/legacy → dist/esm}/utils/ast-utils.d.ts +4 -6
- package/{build/legacy → dist/esm}/utils/ast-utils.js +2 -3
- package/dist/esm/utils/ast-utils.js.map +1 -0
- package/dist/esm/utils/create-rule.d.ts +7 -0
- package/{build/legacy → dist/esm}/utils/create-rule.js +2 -3
- package/dist/esm/utils/create-rule.js.map +1 -0
- package/{build/legacy → dist/esm}/utils/detect-react-query-imports.d.ts +5 -6
- package/{build/legacy → dist/esm}/utils/detect-react-query-imports.js +1 -2
- package/dist/esm/utils/detect-react-query-imports.js.map +1 -0
- package/dist/esm/utils/test-utils.d.ts +1 -0
- package/dist/esm/utils/unique-by.d.ts +1 -0
- package/{build/legacy → dist/esm}/utils/unique-by.js +1 -2
- package/dist/esm/utils/unique-by.js.map +1 -0
- package/package.json +11 -12
- package/build/legacy/__tests__/configs.test.cjs +0 -24
- package/build/legacy/__tests__/configs.test.cjs.map +0 -1
- package/build/legacy/__tests__/configs.test.d.cts +0 -2
- package/build/legacy/__tests__/configs.test.d.ts +0 -2
- package/build/legacy/__tests__/configs.test.js +0 -22
- package/build/legacy/__tests__/configs.test.js.map +0 -1
- package/build/legacy/__tests__/exhaustive-deps.test.cjs +0 -722
- package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +0 -1
- package/build/legacy/__tests__/exhaustive-deps.test.d.cts +0 -2
- package/build/legacy/__tests__/exhaustive-deps.test.d.ts +0 -2
- package/build/legacy/__tests__/exhaustive-deps.test.js +0 -720
- package/build/legacy/__tests__/exhaustive-deps.test.js.map +0 -1
- package/build/legacy/configs.cjs +0 -49
- package/build/legacy/configs.cjs.map +0 -1
- package/build/legacy/configs.d.cts +0 -8
- package/build/legacy/configs.d.ts +0 -8
- package/build/legacy/configs.js.map +0 -1
- package/build/legacy/index.cjs +0 -34
- package/build/legacy/index.cjs.map +0 -1
- package/build/legacy/index.d.cts +0 -3
- package/build/legacy/index.d.ts +0 -3
- package/build/legacy/index.js.map +0 -1
- package/build/legacy/rules/exhaustive-deps.rule.cjs +0 -141
- package/build/legacy/rules/exhaustive-deps.rule.cjs.map +0 -1
- package/build/legacy/rules/exhaustive-deps.rule.d.cts +0 -6
- package/build/legacy/rules/exhaustive-deps.rule.d.ts +0 -6
- package/build/legacy/rules/exhaustive-deps.rule.js.map +0 -1
- package/build/legacy/rules/exhaustive-deps.utils.cjs +0 -52
- package/build/legacy/rules/exhaustive-deps.utils.cjs.map +0 -1
- package/build/legacy/rules/exhaustive-deps.utils.js.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs +0 -87
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.cjs.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.cts +0 -6
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.d.ts +0 -6
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.rule.js.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs +0 -197
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.cjs.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.cts +0 -2
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.d.ts +0 -2
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js +0 -195
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.test.js.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs +0 -39
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.cjs.map +0 -1
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.cts +0 -7
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.d.ts +0 -7
- package/build/legacy/rules/no-rest-desctructuring/no-rest-destructuring.utils.js.map +0 -1
- package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs +0 -93
- package/build/legacy/rules/stable-query-client/stable-query-client.rule.cjs.map +0 -1
- package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.cts +0 -6
- package/build/legacy/rules/stable-query-client/stable-query-client.rule.d.ts +0 -6
- package/build/legacy/rules/stable-query-client/stable-query-client.rule.js.map +0 -1
- package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs +0 -197
- package/build/legacy/rules/stable-query-client/stable-query-client.test.cjs.map +0 -1
- package/build/legacy/rules/stable-query-client/stable-query-client.test.d.cts +0 -2
- package/build/legacy/rules/stable-query-client/stable-query-client.test.d.ts +0 -2
- package/build/legacy/rules/stable-query-client/stable-query-client.test.js +0 -195
- package/build/legacy/rules/stable-query-client/stable-query-client.test.js.map +0 -1
- package/build/legacy/rules.cjs +0 -48
- package/build/legacy/rules.cjs.map +0 -1
- package/build/legacy/rules.d.cts +0 -9
- package/build/legacy/rules.d.ts +0 -9
- package/build/legacy/rules.js +0 -13
- package/build/legacy/rules.js.map +0 -1
- package/build/legacy/utils/ast-utils.cjs.map +0 -1
- package/build/legacy/utils/ast-utils.js.map +0 -1
- package/build/legacy/utils/create-rule.cjs +0 -39
- package/build/legacy/utils/create-rule.cjs.map +0 -1
- package/build/legacy/utils/create-rule.d.cts +0 -10
- package/build/legacy/utils/create-rule.d.ts +0 -10
- package/build/legacy/utils/create-rule.js.map +0 -1
- package/build/legacy/utils/detect-react-query-imports.cjs.map +0 -1
- package/build/legacy/utils/detect-react-query-imports.js.map +0 -1
- package/build/legacy/utils/object-utils.cjs +0 -33
- package/build/legacy/utils/object-utils.cjs.map +0 -1
- package/build/legacy/utils/object-utils.d.cts +0 -3
- package/build/legacy/utils/object-utils.d.ts +0 -3
- package/build/legacy/utils/object-utils.js +0 -8
- package/build/legacy/utils/object-utils.js.map +0 -1
- package/build/legacy/utils/test-utils.cjs +0 -36
- package/build/legacy/utils/test-utils.cjs.map +0 -1
- package/build/legacy/utils/test-utils.d.cts +0 -3
- package/build/legacy/utils/test-utils.d.ts +0 -3
- package/build/legacy/utils/test-utils.js +0 -11
- package/build/legacy/utils/test-utils.js.map +0 -1
- package/build/legacy/utils/unique-by.cjs +0 -33
- package/build/legacy/utils/unique-by.cjs.map +0 -1
- package/build/legacy/utils/unique-by.d.cts +0 -3
- package/build/legacy/utils/unique-by.d.ts +0 -3
- package/build/legacy/utils/unique-by.js.map +0 -1
- 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 +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 +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":[]}
|