@rotki/eslint-plugin 1.3.0 → 1.3.2
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/index.d.mts +72 -60
- package/dist/index.d.ts +72 -60
- package/dist/index.mjs +111 -23
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ interface PluginRuleModule<TOptions extends readonly unknown[] = []> extends Rul
|
|
|
4
4
|
defaultOptions: TOptions;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
type Options$
|
|
7
|
+
type Options$6 = [
|
|
8
8
|
{
|
|
9
9
|
extensions: string[];
|
|
10
10
|
ignoreKeys: string[];
|
|
@@ -12,40 +12,52 @@ type Options$3 = [
|
|
|
12
12
|
}
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
-
type Options$
|
|
15
|
+
type Options$5 = [{
|
|
16
16
|
legacy: boolean;
|
|
17
17
|
}];
|
|
18
18
|
|
|
19
|
-
interface Options$
|
|
19
|
+
interface Options$4 {
|
|
20
20
|
max: number;
|
|
21
21
|
ignoreTypeImports: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
type Options = [{
|
|
24
|
+
type Options$3 = [{
|
|
25
25
|
allowInference: boolean;
|
|
26
26
|
}];
|
|
27
27
|
|
|
28
|
+
type Options$2 = [{
|
|
29
|
+
autofix?: boolean;
|
|
30
|
+
}];
|
|
31
|
+
|
|
32
|
+
type Options$1 = [{
|
|
33
|
+
autofix?: boolean;
|
|
34
|
+
}];
|
|
35
|
+
|
|
36
|
+
type Options = [{
|
|
37
|
+
autofix?: boolean;
|
|
38
|
+
}];
|
|
39
|
+
|
|
28
40
|
declare const plugin: {
|
|
29
41
|
meta: {
|
|
30
42
|
name: string;
|
|
31
43
|
version: string;
|
|
32
44
|
};
|
|
33
45
|
rules: {
|
|
34
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
46
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
35
47
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
36
48
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
37
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
49
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
38
50
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
39
|
-
'composable-return-readonly': PluginRuleModule<
|
|
51
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
40
52
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
41
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
42
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
53
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
54
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
43
55
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
44
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
56
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
45
57
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
46
58
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
47
59
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
48
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
60
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
49
61
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
50
62
|
};
|
|
51
63
|
};
|
|
@@ -56,21 +68,21 @@ declare const _default: {
|
|
|
56
68
|
version: string;
|
|
57
69
|
};
|
|
58
70
|
rules: {
|
|
59
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
71
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
60
72
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
61
73
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
62
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
74
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
63
75
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
64
|
-
'composable-return-readonly': PluginRuleModule<
|
|
76
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
65
77
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
66
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
67
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
78
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
79
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
68
80
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
69
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
81
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
70
82
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
71
83
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
72
84
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
73
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
85
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
74
86
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
75
87
|
};
|
|
76
88
|
} & {
|
|
@@ -83,21 +95,21 @@ declare const _default: {
|
|
|
83
95
|
version: string;
|
|
84
96
|
};
|
|
85
97
|
rules: {
|
|
86
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
98
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
87
99
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
88
100
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
89
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
101
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
90
102
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
91
|
-
'composable-return-readonly': PluginRuleModule<
|
|
103
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
92
104
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
93
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
94
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
105
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
106
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
95
107
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
96
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
108
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
97
109
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
98
110
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
99
111
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
100
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
112
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
101
113
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
102
114
|
};
|
|
103
115
|
};
|
|
@@ -119,21 +131,21 @@ declare const _default: {
|
|
|
119
131
|
version: string;
|
|
120
132
|
};
|
|
121
133
|
rules: {
|
|
122
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
134
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
123
135
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
124
136
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
125
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
137
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
126
138
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
127
|
-
'composable-return-readonly': PluginRuleModule<
|
|
139
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
128
140
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
129
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
130
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
141
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
142
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
131
143
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
132
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
144
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
133
145
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
134
146
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
135
147
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
136
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
148
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
137
149
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
138
150
|
};
|
|
139
151
|
};
|
|
@@ -155,21 +167,21 @@ declare const _default: {
|
|
|
155
167
|
version: string;
|
|
156
168
|
};
|
|
157
169
|
rules: {
|
|
158
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
170
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
159
171
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
160
172
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
161
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
173
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
162
174
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
163
|
-
'composable-return-readonly': PluginRuleModule<
|
|
175
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
164
176
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
165
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
166
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
177
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
178
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
167
179
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
168
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
180
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
169
181
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
170
182
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
171
183
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
172
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
184
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
173
185
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
174
186
|
};
|
|
175
187
|
};
|
|
@@ -191,21 +203,21 @@ declare const _default: {
|
|
|
191
203
|
version: string;
|
|
192
204
|
};
|
|
193
205
|
rules: {
|
|
194
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
206
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
195
207
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
196
208
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
197
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
209
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
198
210
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
199
|
-
'composable-return-readonly': PluginRuleModule<
|
|
211
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
200
212
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
201
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
202
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
213
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
214
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
203
215
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
204
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
216
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
205
217
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
206
218
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
207
219
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
208
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
220
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
209
221
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
210
222
|
};
|
|
211
223
|
};
|
|
@@ -227,21 +239,21 @@ declare const _default: {
|
|
|
227
239
|
version: string;
|
|
228
240
|
};
|
|
229
241
|
rules: {
|
|
230
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
242
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
231
243
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
232
244
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
233
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
245
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
234
246
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
235
|
-
'composable-return-readonly': PluginRuleModule<
|
|
247
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
236
248
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
237
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
238
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
249
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
250
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
239
251
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
240
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
252
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
241
253
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
242
254
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
243
255
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
244
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
256
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
245
257
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
246
258
|
};
|
|
247
259
|
};
|
|
@@ -263,21 +275,21 @@ declare const _default: {
|
|
|
263
275
|
version: string;
|
|
264
276
|
};
|
|
265
277
|
rules: {
|
|
266
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
278
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
267
279
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
268
280
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
269
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
281
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
270
282
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
271
|
-
'composable-return-readonly': PluginRuleModule<
|
|
283
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
272
284
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
273
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
274
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
285
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
286
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
275
287
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
276
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
288
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
277
289
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
278
290
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
279
291
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
280
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
292
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
281
293
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
282
294
|
};
|
|
283
295
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ interface PluginRuleModule<TOptions extends readonly unknown[] = []> extends Rul
|
|
|
4
4
|
defaultOptions: TOptions;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
type Options$
|
|
7
|
+
type Options$6 = [
|
|
8
8
|
{
|
|
9
9
|
extensions: string[];
|
|
10
10
|
ignoreKeys: string[];
|
|
@@ -12,40 +12,52 @@ type Options$3 = [
|
|
|
12
12
|
}
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
-
type Options$
|
|
15
|
+
type Options$5 = [{
|
|
16
16
|
legacy: boolean;
|
|
17
17
|
}];
|
|
18
18
|
|
|
19
|
-
interface Options$
|
|
19
|
+
interface Options$4 {
|
|
20
20
|
max: number;
|
|
21
21
|
ignoreTypeImports: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
type Options = [{
|
|
24
|
+
type Options$3 = [{
|
|
25
25
|
allowInference: boolean;
|
|
26
26
|
}];
|
|
27
27
|
|
|
28
|
+
type Options$2 = [{
|
|
29
|
+
autofix?: boolean;
|
|
30
|
+
}];
|
|
31
|
+
|
|
32
|
+
type Options$1 = [{
|
|
33
|
+
autofix?: boolean;
|
|
34
|
+
}];
|
|
35
|
+
|
|
36
|
+
type Options = [{
|
|
37
|
+
autofix?: boolean;
|
|
38
|
+
}];
|
|
39
|
+
|
|
28
40
|
declare const plugin: {
|
|
29
41
|
meta: {
|
|
30
42
|
name: string;
|
|
31
43
|
version: string;
|
|
32
44
|
};
|
|
33
45
|
rules: {
|
|
34
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
46
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
35
47
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
36
48
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
37
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
49
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
38
50
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
39
|
-
'composable-return-readonly': PluginRuleModule<
|
|
51
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
40
52
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
41
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
42
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
53
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
54
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
43
55
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
44
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
56
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
45
57
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
46
58
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
47
59
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
48
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
60
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
49
61
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
50
62
|
};
|
|
51
63
|
};
|
|
@@ -56,21 +68,21 @@ declare const _default: {
|
|
|
56
68
|
version: string;
|
|
57
69
|
};
|
|
58
70
|
rules: {
|
|
59
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
71
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
60
72
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
61
73
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
62
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
74
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
63
75
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
64
|
-
'composable-return-readonly': PluginRuleModule<
|
|
76
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
65
77
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
66
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
67
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
78
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
79
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
68
80
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
69
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
81
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
70
82
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
71
83
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
72
84
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
73
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
85
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
74
86
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
75
87
|
};
|
|
76
88
|
} & {
|
|
@@ -83,21 +95,21 @@ declare const _default: {
|
|
|
83
95
|
version: string;
|
|
84
96
|
};
|
|
85
97
|
rules: {
|
|
86
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
98
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
87
99
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
88
100
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
89
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
101
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
90
102
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
91
|
-
'composable-return-readonly': PluginRuleModule<
|
|
103
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
92
104
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
93
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
94
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
105
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
106
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
95
107
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
96
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
108
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
97
109
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
98
110
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
99
111
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
100
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
112
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
101
113
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
102
114
|
};
|
|
103
115
|
};
|
|
@@ -119,21 +131,21 @@ declare const _default: {
|
|
|
119
131
|
version: string;
|
|
120
132
|
};
|
|
121
133
|
rules: {
|
|
122
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
134
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
123
135
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
124
136
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
125
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
137
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
126
138
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
127
|
-
'composable-return-readonly': PluginRuleModule<
|
|
139
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
128
140
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
129
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
130
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
141
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
142
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
131
143
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
132
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
144
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
133
145
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
134
146
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
135
147
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
136
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
148
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
137
149
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
138
150
|
};
|
|
139
151
|
};
|
|
@@ -155,21 +167,21 @@ declare const _default: {
|
|
|
155
167
|
version: string;
|
|
156
168
|
};
|
|
157
169
|
rules: {
|
|
158
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
170
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
159
171
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
160
172
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
161
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
173
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
162
174
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
163
|
-
'composable-return-readonly': PluginRuleModule<
|
|
175
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
164
176
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
165
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
166
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
177
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
178
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
167
179
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
168
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
180
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
169
181
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
170
182
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
171
183
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
172
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
184
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
173
185
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
174
186
|
};
|
|
175
187
|
};
|
|
@@ -191,21 +203,21 @@ declare const _default: {
|
|
|
191
203
|
version: string;
|
|
192
204
|
};
|
|
193
205
|
rules: {
|
|
194
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
206
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
195
207
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
196
208
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
197
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
209
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
198
210
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
199
|
-
'composable-return-readonly': PluginRuleModule<
|
|
211
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
200
212
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
201
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
202
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
213
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
214
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
203
215
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
204
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
216
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
205
217
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
206
218
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
207
219
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
208
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
220
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
209
221
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
210
222
|
};
|
|
211
223
|
};
|
|
@@ -227,21 +239,21 @@ declare const _default: {
|
|
|
227
239
|
version: string;
|
|
228
240
|
};
|
|
229
241
|
rules: {
|
|
230
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
242
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
231
243
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
232
244
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
233
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
245
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
234
246
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
235
|
-
'composable-return-readonly': PluginRuleModule<
|
|
247
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
236
248
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
237
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
238
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
249
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
250
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
239
251
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
240
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
252
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
241
253
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
242
254
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
243
255
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
244
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
256
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
245
257
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
246
258
|
};
|
|
247
259
|
};
|
|
@@ -263,21 +275,21 @@ declare const _default: {
|
|
|
263
275
|
version: string;
|
|
264
276
|
};
|
|
265
277
|
rules: {
|
|
266
|
-
'composable-input-flexibility': PluginRuleModule<
|
|
278
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
267
279
|
'composable-naming-convention': PluginRuleModule<[]>;
|
|
268
280
|
'composable-no-default-export': PluginRuleModule<[]>;
|
|
269
|
-
'composable-prefer-shallowref': PluginRuleModule<
|
|
281
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
270
282
|
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
271
|
-
'composable-return-readonly': PluginRuleModule<
|
|
283
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
272
284
|
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
273
|
-
'consistent-ref-type-annotation': PluginRuleModule<Options>;
|
|
274
|
-
'max-dependencies': PluginRuleModule<[Options$
|
|
285
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
286
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
275
287
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
276
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
288
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
277
289
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
278
290
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
279
291
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
280
|
-
'no-unused-i18n-keys': PluginRuleModule<Options$
|
|
292
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
281
293
|
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
282
294
|
};
|
|
283
295
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { statSync, readFileSync } from 'node:fs';
|
|
|
7
7
|
import { globSync } from 'tinyglobby';
|
|
8
8
|
import { parse } from 'vue-eslint-parser';
|
|
9
9
|
|
|
10
|
-
const version = "1.3.
|
|
10
|
+
const version = "1.3.2";
|
|
11
11
|
const pkg = {
|
|
12
12
|
version: version};
|
|
13
13
|
|
|
@@ -181,6 +181,7 @@ function checkParamForRef(param) {
|
|
|
181
181
|
}
|
|
182
182
|
const composableInputFlexibility = createEslintRule({
|
|
183
183
|
create(context) {
|
|
184
|
+
const autofix = context.options[0]?.autofix ?? false;
|
|
184
185
|
return {
|
|
185
186
|
FunctionDeclaration: (node) => {
|
|
186
187
|
if (!node.id || !isComposableName(node.id.name))
|
|
@@ -200,8 +201,17 @@ const composableInputFlexibility = createEslintRule({
|
|
|
200
201
|
const refType = checkParamForRef(param);
|
|
201
202
|
if (refType) {
|
|
202
203
|
context.report({
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
...autofix ? {
|
|
205
|
+
fix(fixer) {
|
|
206
|
+
return fixer.replaceText(refType.typeName, "MaybeRefOrGetter");
|
|
207
|
+
}
|
|
208
|
+
} : {
|
|
209
|
+
suggest: [{
|
|
210
|
+
fix(fixer) {
|
|
211
|
+
return fixer.replaceText(refType.typeName, "MaybeRefOrGetter");
|
|
212
|
+
},
|
|
213
|
+
messageId: "suggestMaybeRefOrGetter"
|
|
214
|
+
}]
|
|
205
215
|
},
|
|
206
216
|
messageId: "preferMaybeRefOrGetter",
|
|
207
217
|
node: refType
|
|
@@ -210,17 +220,31 @@ const composableInputFlexibility = createEslintRule({
|
|
|
210
220
|
}
|
|
211
221
|
}
|
|
212
222
|
},
|
|
213
|
-
defaultOptions: [],
|
|
223
|
+
defaultOptions: [{ autofix: false }],
|
|
214
224
|
meta: {
|
|
215
225
|
docs: {
|
|
216
226
|
description: "Prefer MaybeRefOrGetter over Ref for composable parameters",
|
|
217
227
|
recommendation: "stylistic"
|
|
218
228
|
},
|
|
219
229
|
fixable: "code",
|
|
230
|
+
hasSuggestions: true,
|
|
220
231
|
messages: {
|
|
221
|
-
preferMaybeRefOrGetter: "Use MaybeRefOrGetter<T> instead of Ref<T> for composable parameters to increase input flexibility."
|
|
232
|
+
preferMaybeRefOrGetter: "Use MaybeRefOrGetter<T> instead of Ref<T> for composable parameters to increase input flexibility.",
|
|
233
|
+
suggestMaybeRefOrGetter: "Replace Ref<T> with MaybeRefOrGetter<T>."
|
|
222
234
|
},
|
|
223
|
-
schema: [
|
|
235
|
+
schema: [
|
|
236
|
+
{
|
|
237
|
+
additionalProperties: false,
|
|
238
|
+
properties: {
|
|
239
|
+
autofix: {
|
|
240
|
+
default: false,
|
|
241
|
+
description: "Enable auto-fix. When disabled, the fix is available as a suggestion.",
|
|
242
|
+
type: "boolean"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
type: "object"
|
|
246
|
+
}
|
|
247
|
+
],
|
|
224
248
|
type: "suggestion"
|
|
225
249
|
},
|
|
226
250
|
name: RULE_NAME$f
|
|
@@ -357,6 +381,7 @@ const composableNoDefaultExport = createEslintRule({
|
|
|
357
381
|
const RULE_NAME$c = "composable-prefer-shallowref";
|
|
358
382
|
const composablePreferShallowref = createEslintRule({
|
|
359
383
|
create(context) {
|
|
384
|
+
const autofix = context.options[0]?.autofix ?? false;
|
|
360
385
|
return {
|
|
361
386
|
CallExpression(node) {
|
|
362
387
|
if (node.callee.type !== AST_NODE_TYPES.Identifier || node.callee.name !== "ref")
|
|
@@ -367,8 +392,17 @@ const composablePreferShallowref = createEslintRule({
|
|
|
367
392
|
if (!arg || arg.type !== AST_NODE_TYPES.Literal)
|
|
368
393
|
return;
|
|
369
394
|
context.report({
|
|
370
|
-
|
|
371
|
-
|
|
395
|
+
...autofix ? {
|
|
396
|
+
fix(fixer) {
|
|
397
|
+
return fixer.replaceText(node.callee, "shallowRef");
|
|
398
|
+
}
|
|
399
|
+
} : {
|
|
400
|
+
suggest: [{
|
|
401
|
+
fix(fixer) {
|
|
402
|
+
return fixer.replaceText(node.callee, "shallowRef");
|
|
403
|
+
},
|
|
404
|
+
messageId: "suggestShallowRef"
|
|
405
|
+
}]
|
|
372
406
|
},
|
|
373
407
|
messageId: "preferShallowRef",
|
|
374
408
|
node
|
|
@@ -376,17 +410,31 @@ const composablePreferShallowref = createEslintRule({
|
|
|
376
410
|
}
|
|
377
411
|
};
|
|
378
412
|
},
|
|
379
|
-
defaultOptions: [],
|
|
413
|
+
defaultOptions: [{ autofix: false }],
|
|
380
414
|
meta: {
|
|
381
415
|
docs: {
|
|
382
416
|
description: "Prefer shallowRef() over ref() for primitive values in composables",
|
|
383
417
|
recommendation: "strict"
|
|
384
418
|
},
|
|
385
419
|
fixable: "code",
|
|
420
|
+
hasSuggestions: true,
|
|
386
421
|
messages: {
|
|
387
|
-
preferShallowRef: "Use shallowRef() instead of ref() for primitive values in composables."
|
|
422
|
+
preferShallowRef: "Use shallowRef() instead of ref() for primitive values in composables.",
|
|
423
|
+
suggestShallowRef: "Replace ref() with shallowRef()."
|
|
388
424
|
},
|
|
389
|
-
schema: [
|
|
425
|
+
schema: [
|
|
426
|
+
{
|
|
427
|
+
additionalProperties: false,
|
|
428
|
+
properties: {
|
|
429
|
+
autofix: {
|
|
430
|
+
default: false,
|
|
431
|
+
description: "Enable auto-fix. When disabled, the fix is available as a suggestion.",
|
|
432
|
+
type: "boolean"
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
type: "object"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
390
438
|
type: "suggestion"
|
|
391
439
|
},
|
|
392
440
|
name: RULE_NAME$c
|
|
@@ -490,11 +538,17 @@ const composableRequireCleanup = createEslintRule({
|
|
|
490
538
|
});
|
|
491
539
|
|
|
492
540
|
const RULE_NAME$a = "composable-return-readonly";
|
|
493
|
-
const REACTIVE_CREATORS = /* @__PURE__ */ new Set(["ref", "shallowRef"
|
|
541
|
+
const REACTIVE_CREATORS = /* @__PURE__ */ new Set(["ref", "shallowRef"]);
|
|
542
|
+
const READONLY_CREATORS = /* @__PURE__ */ new Set(["computed"]);
|
|
543
|
+
function isReadonlyCall(node) {
|
|
544
|
+
return node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "readonly" && node.arguments.length === 1 && node.arguments[0].type === AST_NODE_TYPES.Identifier;
|
|
545
|
+
}
|
|
494
546
|
const composableReturnReadonly = createEslintRule({
|
|
495
547
|
create(context) {
|
|
548
|
+
const autofix = context.options[0]?.autofix ?? false;
|
|
496
549
|
const source = getSourceCode(context);
|
|
497
550
|
const reactiveVars = /* @__PURE__ */ new Set();
|
|
551
|
+
const readonlyVars = /* @__PURE__ */ new Set();
|
|
498
552
|
return {
|
|
499
553
|
ReturnStatement: (node) => {
|
|
500
554
|
if (!getEnclosingComposable(node))
|
|
@@ -504,22 +558,35 @@ const composableReturnReadonly = createEslintRule({
|
|
|
504
558
|
for (const prop of node.argument.properties) {
|
|
505
559
|
if (prop.type !== AST_NODE_TYPES.Property)
|
|
506
560
|
continue;
|
|
561
|
+
const valueNode = prop.shorthand ? null : prop.value;
|
|
562
|
+
if (valueNode && isReadonlyCall(valueNode)) {
|
|
563
|
+
const innerName = valueNode.arguments[0].name;
|
|
564
|
+
if (readonlyVars.has(innerName)) {
|
|
565
|
+
const fixFn = (fixer) => fixer.replaceText(valueNode, innerName);
|
|
566
|
+
context.report({
|
|
567
|
+
data: { name: innerName },
|
|
568
|
+
...autofix ? { fix: fixFn } : { suggest: [{ data: { name: innerName }, fix: fixFn, messageId: "suggestRemoveReadonly" }] },
|
|
569
|
+
messageId: "unnecessaryReadonly",
|
|
570
|
+
node: prop
|
|
571
|
+
});
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
507
575
|
if (prop.shorthand && prop.key.type === AST_NODE_TYPES.Identifier && reactiveVars.has(prop.key.name)) {
|
|
508
576
|
const keyName = prop.key.name;
|
|
577
|
+
const fixFn = (fixer) => fixer.replaceText(prop, `${keyName}: readonly(${keyName})`);
|
|
509
578
|
context.report({
|
|
510
579
|
data: { name: keyName },
|
|
511
|
-
fix
|
|
512
|
-
return fixer.replaceText(prop, `${keyName}: readonly(${keyName})`);
|
|
513
|
-
},
|
|
580
|
+
...autofix ? { fix: fixFn } : { suggest: [{ data: { name: keyName }, fix: fixFn, messageId: "suggestWrapReadonly" }] },
|
|
514
581
|
messageId: "wrapReadonly",
|
|
515
582
|
node: prop
|
|
516
583
|
});
|
|
517
584
|
} else if (!prop.shorthand && prop.value.type === AST_NODE_TYPES.Identifier && reactiveVars.has(prop.value.name)) {
|
|
585
|
+
const valueName = prop.value.name;
|
|
586
|
+
const fixFn = (fixer) => fixer.replaceText(prop.value, `readonly(${prop.value.type === AST_NODE_TYPES.Identifier ? prop.value.name : source.getText(prop.value)})`);
|
|
518
587
|
context.report({
|
|
519
|
-
data: { name:
|
|
520
|
-
fix
|
|
521
|
-
return fixer.replaceText(prop.value, `readonly(${prop.value.type === AST_NODE_TYPES.Identifier ? prop.value.name : source.getText(prop.value)})`);
|
|
522
|
-
},
|
|
588
|
+
data: { name: valueName },
|
|
589
|
+
...autofix ? { fix: fixFn } : { suggest: [{ data: { name: valueName }, fix: fixFn, messageId: "suggestWrapReadonly" }] },
|
|
523
590
|
messageId: "wrapReadonly",
|
|
524
591
|
node: prop
|
|
525
592
|
});
|
|
@@ -531,23 +598,44 @@ const composableReturnReadonly = createEslintRule({
|
|
|
531
598
|
return;
|
|
532
599
|
if (node.id.type !== AST_NODE_TYPES.Identifier)
|
|
533
600
|
return;
|
|
534
|
-
if (node.init?.type === AST_NODE_TYPES.CallExpression && node.init.callee.type === AST_NODE_TYPES.Identifier
|
|
535
|
-
|
|
601
|
+
if (node.init?.type === AST_NODE_TYPES.CallExpression && node.init.callee.type === AST_NODE_TYPES.Identifier) {
|
|
602
|
+
const calleeName = node.init.callee.name;
|
|
603
|
+
if (REACTIVE_CREATORS.has(calleeName)) {
|
|
604
|
+
reactiveVars.add(node.id.name);
|
|
605
|
+
} else if (READONLY_CREATORS.has(calleeName)) {
|
|
606
|
+
readonlyVars.add(node.id.name);
|
|
607
|
+
}
|
|
536
608
|
}
|
|
537
609
|
}
|
|
538
610
|
};
|
|
539
611
|
},
|
|
540
|
-
defaultOptions: [],
|
|
612
|
+
defaultOptions: [{ autofix: false }],
|
|
541
613
|
meta: {
|
|
542
614
|
docs: {
|
|
543
615
|
description: "Require returned refs from composables to be wrapped with readonly()",
|
|
544
616
|
recommendation: "strict"
|
|
545
617
|
},
|
|
546
618
|
fixable: "code",
|
|
619
|
+
hasSuggestions: true,
|
|
547
620
|
messages: {
|
|
621
|
+
suggestRemoveReadonly: "Remove unnecessary readonly() from '{{ name }}'.",
|
|
622
|
+
suggestWrapReadonly: "Wrap '{{ name }}' with readonly().",
|
|
623
|
+
unnecessaryReadonly: "Computed ref '{{ name }}' is already readonly and does not need readonly() wrapping.",
|
|
548
624
|
wrapReadonly: "Returned ref '{{ name }}' should be wrapped with readonly()."
|
|
549
625
|
},
|
|
550
|
-
schema: [
|
|
626
|
+
schema: [
|
|
627
|
+
{
|
|
628
|
+
additionalProperties: false,
|
|
629
|
+
properties: {
|
|
630
|
+
autofix: {
|
|
631
|
+
default: false,
|
|
632
|
+
description: "Enable auto-fix. When disabled, the fix is available as a suggestion.",
|
|
633
|
+
type: "boolean"
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
type: "object"
|
|
637
|
+
}
|
|
638
|
+
],
|
|
551
639
|
type: "suggestion"
|
|
552
640
|
},
|
|
553
641
|
name: RULE_NAME$a
|