@pobammer-ts/eslint-cease-nonsense-rules 1.7.1 → 1.9.1
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/README.md +227 -0
- package/dist/build-metadata.json +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1792 -1215
- package/dist/index.js.map +27 -22
- package/dist/oxfmt-sync.d.ts +2 -1
- package/dist/oxfmt-sync.d.ts.map +1 -1
- package/dist/oxfmt-worker.d.ts +1 -0
- package/dist/oxfmt-worker.d.ts.map +1 -1
- package/dist/oxfmt-worker.js +17 -172731
- package/dist/oxfmt-worker.js.map +4 -21
- package/dist/recognizers/code-recognizer.d.ts +0 -18
- package/dist/recognizers/code-recognizer.d.ts.map +1 -1
- package/dist/rules/ban-instances.d.ts.map +1 -1
- package/dist/rules/ban-react-fc.d.ts.map +1 -1
- package/dist/rules/enforce-ianitor-check-type.d.ts.map +1 -1
- package/dist/rules/no-god-components.d.ts.map +1 -1
- package/dist/rules/no-identity-map.d.ts.map +1 -1
- package/dist/rules/prefer-class-properties.d.ts +6 -0
- package/dist/rules/prefer-class-properties.d.ts.map +1 -0
- package/dist/rules/prefer-early-return.d.ts +8 -0
- package/dist/rules/prefer-early-return.d.ts.map +1 -0
- package/dist/rules/prefer-module-scope-constants.d.ts +5 -0
- package/dist/rules/prefer-module-scope-constants.d.ts.map +1 -0
- package/dist/rules/prefer-pascal-case-enums.d.ts +5 -0
- package/dist/rules/prefer-pascal-case-enums.d.ts.map +1 -0
- package/dist/rules/prefer-singular-enums.d.ts +5 -0
- package/dist/rules/prefer-singular-enums.d.ts.map +1 -0
- package/dist/rules/prefer-udim2-shorthand.d.ts.map +1 -1
- package/dist/rules/react-hooks-strict-return.d.ts +5 -0
- package/dist/rules/react-hooks-strict-return.d.ts.map +1 -0
- package/dist/rules/require-paired-calls.d.ts +0 -1
- package/dist/rules/require-paired-calls.d.ts.map +1 -1
- package/dist/rules/strict-component-boundaries.d.ts +9 -0
- package/dist/rules/strict-component-boundaries.d.ts.map +1 -0
- package/dist/rules/use-exhaustive-dependencies.d.ts +1 -42
- package/dist/rules/use-exhaustive-dependencies.d.ts.map +1 -1
- package/dist/rules/use-hook-at-top-level.d.ts.map +1 -1
- package/dist/utilities/casing-utilities.d.ts +2 -0
- package/dist/utilities/casing-utilities.d.ts.map +1 -0
- package/dist/utilities/format-utilities.d.ts +2 -3
- package/dist/utilities/format-utilities.d.ts.map +1 -1
- package/dist/utilities/resolve-import.d.ts +16 -0
- package/dist/utilities/resolve-import.d.ts.map +1 -0
- package/package.json +15 -2
- package/dist/types/oxfmt.d.ts +0 -88
- package/dist/types/oxfmt.d.ts.map +0 -1
- package/dist/utilities/error-utilities.d.ts +0 -25
- package/dist/utilities/error-utilities.d.ts.map +0 -1
- package/dist/utilities/typebox-utilities.d.ts +0 -4
- package/dist/utilities/typebox-utilities.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -25,9 +25,732 @@ var __export = (target, all) => {
|
|
|
25
25
|
set: (newValue) => all[name] = () => newValue
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
28
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
29
|
|
|
30
|
+
// node_modules/fast-diff/diff.js
|
|
31
|
+
var require_diff = __commonJS((exports, module3) => {
|
|
32
|
+
var DIFF_DELETE = -1;
|
|
33
|
+
var DIFF_INSERT = 1;
|
|
34
|
+
var DIFF_EQUAL = 0;
|
|
35
|
+
function diff_main(text1, text2, cursor_pos, cleanup, _fix_unicode) {
|
|
36
|
+
if (text1 === text2) {
|
|
37
|
+
if (text1) {
|
|
38
|
+
return [[DIFF_EQUAL, text1]];
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (cursor_pos != null) {
|
|
43
|
+
var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
|
|
44
|
+
if (editdiff) {
|
|
45
|
+
return editdiff;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var commonlength = diff_commonPrefix(text1, text2);
|
|
49
|
+
var commonprefix = text1.substring(0, commonlength);
|
|
50
|
+
text1 = text1.substring(commonlength);
|
|
51
|
+
text2 = text2.substring(commonlength);
|
|
52
|
+
commonlength = diff_commonSuffix(text1, text2);
|
|
53
|
+
var commonsuffix = text1.substring(text1.length - commonlength);
|
|
54
|
+
text1 = text1.substring(0, text1.length - commonlength);
|
|
55
|
+
text2 = text2.substring(0, text2.length - commonlength);
|
|
56
|
+
var diffs = diff_compute_(text1, text2);
|
|
57
|
+
if (commonprefix) {
|
|
58
|
+
diffs.unshift([DIFF_EQUAL, commonprefix]);
|
|
59
|
+
}
|
|
60
|
+
if (commonsuffix) {
|
|
61
|
+
diffs.push([DIFF_EQUAL, commonsuffix]);
|
|
62
|
+
}
|
|
63
|
+
diff_cleanupMerge(diffs, _fix_unicode);
|
|
64
|
+
if (cleanup) {
|
|
65
|
+
diff_cleanupSemantic(diffs);
|
|
66
|
+
}
|
|
67
|
+
return diffs;
|
|
68
|
+
}
|
|
69
|
+
function diff_compute_(text1, text2) {
|
|
70
|
+
var diffs;
|
|
71
|
+
if (!text1) {
|
|
72
|
+
return [[DIFF_INSERT, text2]];
|
|
73
|
+
}
|
|
74
|
+
if (!text2) {
|
|
75
|
+
return [[DIFF_DELETE, text1]];
|
|
76
|
+
}
|
|
77
|
+
var longtext = text1.length > text2.length ? text1 : text2;
|
|
78
|
+
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
79
|
+
var i = longtext.indexOf(shorttext);
|
|
80
|
+
if (i !== -1) {
|
|
81
|
+
diffs = [
|
|
82
|
+
[DIFF_INSERT, longtext.substring(0, i)],
|
|
83
|
+
[DIFF_EQUAL, shorttext],
|
|
84
|
+
[DIFF_INSERT, longtext.substring(i + shorttext.length)]
|
|
85
|
+
];
|
|
86
|
+
if (text1.length > text2.length) {
|
|
87
|
+
diffs[0][0] = diffs[2][0] = DIFF_DELETE;
|
|
88
|
+
}
|
|
89
|
+
return diffs;
|
|
90
|
+
}
|
|
91
|
+
if (shorttext.length === 1) {
|
|
92
|
+
return [
|
|
93
|
+
[DIFF_DELETE, text1],
|
|
94
|
+
[DIFF_INSERT, text2]
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
var hm = diff_halfMatch_(text1, text2);
|
|
98
|
+
if (hm) {
|
|
99
|
+
var text1_a = hm[0];
|
|
100
|
+
var text1_b = hm[1];
|
|
101
|
+
var text2_a = hm[2];
|
|
102
|
+
var text2_b = hm[3];
|
|
103
|
+
var mid_common = hm[4];
|
|
104
|
+
var diffs_a = diff_main(text1_a, text2_a);
|
|
105
|
+
var diffs_b = diff_main(text1_b, text2_b);
|
|
106
|
+
return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
|
|
107
|
+
}
|
|
108
|
+
return diff_bisect_(text1, text2);
|
|
109
|
+
}
|
|
110
|
+
function diff_bisect_(text1, text2) {
|
|
111
|
+
var text1_length = text1.length;
|
|
112
|
+
var text2_length = text2.length;
|
|
113
|
+
var max_d = Math.ceil((text1_length + text2_length) / 2);
|
|
114
|
+
var v_offset = max_d;
|
|
115
|
+
var v_length = 2 * max_d;
|
|
116
|
+
var v1 = new Array(v_length);
|
|
117
|
+
var v2 = new Array(v_length);
|
|
118
|
+
for (var x3 = 0;x3 < v_length; x3++) {
|
|
119
|
+
v1[x3] = -1;
|
|
120
|
+
v2[x3] = -1;
|
|
121
|
+
}
|
|
122
|
+
v1[v_offset + 1] = 0;
|
|
123
|
+
v2[v_offset + 1] = 0;
|
|
124
|
+
var delta2 = text1_length - text2_length;
|
|
125
|
+
var front = delta2 % 2 !== 0;
|
|
126
|
+
var k1start = 0;
|
|
127
|
+
var k1end = 0;
|
|
128
|
+
var k2start = 0;
|
|
129
|
+
var k2end = 0;
|
|
130
|
+
for (var d2 = 0;d2 < max_d; d2++) {
|
|
131
|
+
for (var k1 = -d2 + k1start;k1 <= d2 - k1end; k1 += 2) {
|
|
132
|
+
var k1_offset = v_offset + k1;
|
|
133
|
+
var x1;
|
|
134
|
+
if (k1 === -d2 || k1 !== d2 && v1[k1_offset - 1] < v1[k1_offset + 1]) {
|
|
135
|
+
x1 = v1[k1_offset + 1];
|
|
136
|
+
} else {
|
|
137
|
+
x1 = v1[k1_offset - 1] + 1;
|
|
138
|
+
}
|
|
139
|
+
var y1 = x1 - k1;
|
|
140
|
+
while (x1 < text1_length && y1 < text2_length && text1.charAt(x1) === text2.charAt(y1)) {
|
|
141
|
+
x1++;
|
|
142
|
+
y1++;
|
|
143
|
+
}
|
|
144
|
+
v1[k1_offset] = x1;
|
|
145
|
+
if (x1 > text1_length) {
|
|
146
|
+
k1end += 2;
|
|
147
|
+
} else if (y1 > text2_length) {
|
|
148
|
+
k1start += 2;
|
|
149
|
+
} else if (front) {
|
|
150
|
+
var k2_offset = v_offset + delta2 - k1;
|
|
151
|
+
if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] !== -1) {
|
|
152
|
+
var x22 = text1_length - v2[k2_offset];
|
|
153
|
+
if (x1 >= x22) {
|
|
154
|
+
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (var k2 = -d2 + k2start;k2 <= d2 - k2end; k2 += 2) {
|
|
160
|
+
var k2_offset = v_offset + k2;
|
|
161
|
+
var x22;
|
|
162
|
+
if (k2 === -d2 || k2 !== d2 && v2[k2_offset - 1] < v2[k2_offset + 1]) {
|
|
163
|
+
x22 = v2[k2_offset + 1];
|
|
164
|
+
} else {
|
|
165
|
+
x22 = v2[k2_offset - 1] + 1;
|
|
166
|
+
}
|
|
167
|
+
var y2 = x22 - k2;
|
|
168
|
+
while (x22 < text1_length && y2 < text2_length && text1.charAt(text1_length - x22 - 1) === text2.charAt(text2_length - y2 - 1)) {
|
|
169
|
+
x22++;
|
|
170
|
+
y2++;
|
|
171
|
+
}
|
|
172
|
+
v2[k2_offset] = x22;
|
|
173
|
+
if (x22 > text1_length) {
|
|
174
|
+
k2end += 2;
|
|
175
|
+
} else if (y2 > text2_length) {
|
|
176
|
+
k2start += 2;
|
|
177
|
+
} else if (!front) {
|
|
178
|
+
var k1_offset = v_offset + delta2 - k2;
|
|
179
|
+
if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] !== -1) {
|
|
180
|
+
var x1 = v1[k1_offset];
|
|
181
|
+
var y1 = v_offset + x1 - k1_offset;
|
|
182
|
+
x22 = text1_length - x22;
|
|
183
|
+
if (x1 >= x22) {
|
|
184
|
+
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [
|
|
191
|
+
[DIFF_DELETE, text1],
|
|
192
|
+
[DIFF_INSERT, text2]
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
function diff_bisectSplit_(text1, text2, x3, y) {
|
|
196
|
+
var text1a = text1.substring(0, x3);
|
|
197
|
+
var text2a = text2.substring(0, y);
|
|
198
|
+
var text1b = text1.substring(x3);
|
|
199
|
+
var text2b = text2.substring(y);
|
|
200
|
+
var diffs = diff_main(text1a, text2a);
|
|
201
|
+
var diffsb = diff_main(text1b, text2b);
|
|
202
|
+
return diffs.concat(diffsb);
|
|
203
|
+
}
|
|
204
|
+
function diff_commonPrefix(text1, text2) {
|
|
205
|
+
if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
var pointermin = 0;
|
|
209
|
+
var pointermax = Math.min(text1.length, text2.length);
|
|
210
|
+
var pointermid = pointermax;
|
|
211
|
+
var pointerstart = 0;
|
|
212
|
+
while (pointermin < pointermid) {
|
|
213
|
+
if (text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid)) {
|
|
214
|
+
pointermin = pointermid;
|
|
215
|
+
pointerstart = pointermin;
|
|
216
|
+
} else {
|
|
217
|
+
pointermax = pointermid;
|
|
218
|
+
}
|
|
219
|
+
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
220
|
+
}
|
|
221
|
+
if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
|
|
222
|
+
pointermid--;
|
|
223
|
+
}
|
|
224
|
+
return pointermid;
|
|
225
|
+
}
|
|
226
|
+
function diff_commonOverlap_(text1, text2) {
|
|
227
|
+
var text1_length = text1.length;
|
|
228
|
+
var text2_length = text2.length;
|
|
229
|
+
if (text1_length == 0 || text2_length == 0) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
if (text1_length > text2_length) {
|
|
233
|
+
text1 = text1.substring(text1_length - text2_length);
|
|
234
|
+
} else if (text1_length < text2_length) {
|
|
235
|
+
text2 = text2.substring(0, text1_length);
|
|
236
|
+
}
|
|
237
|
+
var text_length = Math.min(text1_length, text2_length);
|
|
238
|
+
if (text1 == text2) {
|
|
239
|
+
return text_length;
|
|
240
|
+
}
|
|
241
|
+
var best = 0;
|
|
242
|
+
var length = 1;
|
|
243
|
+
while (true) {
|
|
244
|
+
var pattern4 = text1.substring(text_length - length);
|
|
245
|
+
var found = text2.indexOf(pattern4);
|
|
246
|
+
if (found == -1) {
|
|
247
|
+
return best;
|
|
248
|
+
}
|
|
249
|
+
length += found;
|
|
250
|
+
if (found == 0 || text1.substring(text_length - length) == text2.substring(0, length)) {
|
|
251
|
+
best = length;
|
|
252
|
+
length++;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function diff_commonSuffix(text1, text2) {
|
|
257
|
+
if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
var pointermin = 0;
|
|
261
|
+
var pointermax = Math.min(text1.length, text2.length);
|
|
262
|
+
var pointermid = pointermax;
|
|
263
|
+
var pointerend = 0;
|
|
264
|
+
while (pointermin < pointermid) {
|
|
265
|
+
if (text1.substring(text1.length - pointermid, text1.length - pointerend) == text2.substring(text2.length - pointermid, text2.length - pointerend)) {
|
|
266
|
+
pointermin = pointermid;
|
|
267
|
+
pointerend = pointermin;
|
|
268
|
+
} else {
|
|
269
|
+
pointermax = pointermid;
|
|
270
|
+
}
|
|
271
|
+
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
272
|
+
}
|
|
273
|
+
if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
|
|
274
|
+
pointermid--;
|
|
275
|
+
}
|
|
276
|
+
return pointermid;
|
|
277
|
+
}
|
|
278
|
+
function diff_halfMatch_(text1, text2) {
|
|
279
|
+
var longtext = text1.length > text2.length ? text1 : text2;
|
|
280
|
+
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
281
|
+
if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
function diff_halfMatchI_(longtext2, shorttext2, i) {
|
|
285
|
+
var seed = longtext2.substring(i, i + Math.floor(longtext2.length / 4));
|
|
286
|
+
var j = -1;
|
|
287
|
+
var best_common = "";
|
|
288
|
+
var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
|
|
289
|
+
while ((j = shorttext2.indexOf(seed, j + 1)) !== -1) {
|
|
290
|
+
var prefixLength = diff_commonPrefix(longtext2.substring(i), shorttext2.substring(j));
|
|
291
|
+
var suffixLength = diff_commonSuffix(longtext2.substring(0, i), shorttext2.substring(0, j));
|
|
292
|
+
if (best_common.length < suffixLength + prefixLength) {
|
|
293
|
+
best_common = shorttext2.substring(j - suffixLength, j) + shorttext2.substring(j, j + prefixLength);
|
|
294
|
+
best_longtext_a = longtext2.substring(0, i - suffixLength);
|
|
295
|
+
best_longtext_b = longtext2.substring(i + prefixLength);
|
|
296
|
+
best_shorttext_a = shorttext2.substring(0, j - suffixLength);
|
|
297
|
+
best_shorttext_b = shorttext2.substring(j + prefixLength);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (best_common.length * 2 >= longtext2.length) {
|
|
301
|
+
return [
|
|
302
|
+
best_longtext_a,
|
|
303
|
+
best_longtext_b,
|
|
304
|
+
best_shorttext_a,
|
|
305
|
+
best_shorttext_b,
|
|
306
|
+
best_common
|
|
307
|
+
];
|
|
308
|
+
} else {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4));
|
|
313
|
+
var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
|
|
314
|
+
var hm;
|
|
315
|
+
if (!hm1 && !hm2) {
|
|
316
|
+
return null;
|
|
317
|
+
} else if (!hm2) {
|
|
318
|
+
hm = hm1;
|
|
319
|
+
} else if (!hm1) {
|
|
320
|
+
hm = hm2;
|
|
321
|
+
} else {
|
|
322
|
+
hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
|
|
323
|
+
}
|
|
324
|
+
var text1_a, text1_b, text2_a, text2_b;
|
|
325
|
+
if (text1.length > text2.length) {
|
|
326
|
+
text1_a = hm[0];
|
|
327
|
+
text1_b = hm[1];
|
|
328
|
+
text2_a = hm[2];
|
|
329
|
+
text2_b = hm[3];
|
|
330
|
+
} else {
|
|
331
|
+
text2_a = hm[0];
|
|
332
|
+
text2_b = hm[1];
|
|
333
|
+
text1_a = hm[2];
|
|
334
|
+
text1_b = hm[3];
|
|
335
|
+
}
|
|
336
|
+
var mid_common = hm[4];
|
|
337
|
+
return [text1_a, text1_b, text2_a, text2_b, mid_common];
|
|
338
|
+
}
|
|
339
|
+
function diff_cleanupSemantic(diffs) {
|
|
340
|
+
var changes = false;
|
|
341
|
+
var equalities = [];
|
|
342
|
+
var equalitiesLength = 0;
|
|
343
|
+
var lastequality = null;
|
|
344
|
+
var pointer4 = 0;
|
|
345
|
+
var length_insertions1 = 0;
|
|
346
|
+
var length_deletions1 = 0;
|
|
347
|
+
var length_insertions2 = 0;
|
|
348
|
+
var length_deletions2 = 0;
|
|
349
|
+
while (pointer4 < diffs.length) {
|
|
350
|
+
if (diffs[pointer4][0] == DIFF_EQUAL) {
|
|
351
|
+
equalities[equalitiesLength++] = pointer4;
|
|
352
|
+
length_insertions1 = length_insertions2;
|
|
353
|
+
length_deletions1 = length_deletions2;
|
|
354
|
+
length_insertions2 = 0;
|
|
355
|
+
length_deletions2 = 0;
|
|
356
|
+
lastequality = diffs[pointer4][1];
|
|
357
|
+
} else {
|
|
358
|
+
if (diffs[pointer4][0] == DIFF_INSERT) {
|
|
359
|
+
length_insertions2 += diffs[pointer4][1].length;
|
|
360
|
+
} else {
|
|
361
|
+
length_deletions2 += diffs[pointer4][1].length;
|
|
362
|
+
}
|
|
363
|
+
if (lastequality && lastequality.length <= Math.max(length_insertions1, length_deletions1) && lastequality.length <= Math.max(length_insertions2, length_deletions2)) {
|
|
364
|
+
diffs.splice(equalities[equalitiesLength - 1], 0, [
|
|
365
|
+
DIFF_DELETE,
|
|
366
|
+
lastequality
|
|
367
|
+
]);
|
|
368
|
+
diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
|
|
369
|
+
equalitiesLength--;
|
|
370
|
+
equalitiesLength--;
|
|
371
|
+
pointer4 = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
|
|
372
|
+
length_insertions1 = 0;
|
|
373
|
+
length_deletions1 = 0;
|
|
374
|
+
length_insertions2 = 0;
|
|
375
|
+
length_deletions2 = 0;
|
|
376
|
+
lastequality = null;
|
|
377
|
+
changes = true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
pointer4++;
|
|
381
|
+
}
|
|
382
|
+
if (changes) {
|
|
383
|
+
diff_cleanupMerge(diffs);
|
|
384
|
+
}
|
|
385
|
+
diff_cleanupSemanticLossless(diffs);
|
|
386
|
+
pointer4 = 1;
|
|
387
|
+
while (pointer4 < diffs.length) {
|
|
388
|
+
if (diffs[pointer4 - 1][0] == DIFF_DELETE && diffs[pointer4][0] == DIFF_INSERT) {
|
|
389
|
+
var deletion = diffs[pointer4 - 1][1];
|
|
390
|
+
var insertion = diffs[pointer4][1];
|
|
391
|
+
var overlap_length1 = diff_commonOverlap_(deletion, insertion);
|
|
392
|
+
var overlap_length2 = diff_commonOverlap_(insertion, deletion);
|
|
393
|
+
if (overlap_length1 >= overlap_length2) {
|
|
394
|
+
if (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) {
|
|
395
|
+
diffs.splice(pointer4, 0, [
|
|
396
|
+
DIFF_EQUAL,
|
|
397
|
+
insertion.substring(0, overlap_length1)
|
|
398
|
+
]);
|
|
399
|
+
diffs[pointer4 - 1][1] = deletion.substring(0, deletion.length - overlap_length1);
|
|
400
|
+
diffs[pointer4 + 1][1] = insertion.substring(overlap_length1);
|
|
401
|
+
pointer4++;
|
|
402
|
+
}
|
|
403
|
+
} else {
|
|
404
|
+
if (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) {
|
|
405
|
+
diffs.splice(pointer4, 0, [
|
|
406
|
+
DIFF_EQUAL,
|
|
407
|
+
deletion.substring(0, overlap_length2)
|
|
408
|
+
]);
|
|
409
|
+
diffs[pointer4 - 1][0] = DIFF_INSERT;
|
|
410
|
+
diffs[pointer4 - 1][1] = insertion.substring(0, insertion.length - overlap_length2);
|
|
411
|
+
diffs[pointer4 + 1][0] = DIFF_DELETE;
|
|
412
|
+
diffs[pointer4 + 1][1] = deletion.substring(overlap_length2);
|
|
413
|
+
pointer4++;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
pointer4++;
|
|
417
|
+
}
|
|
418
|
+
pointer4++;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
var nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/;
|
|
422
|
+
var whitespaceRegex_ = /\s/;
|
|
423
|
+
var linebreakRegex_ = /[\r\n]/;
|
|
424
|
+
var blanklineEndRegex_ = /\n\r?\n$/;
|
|
425
|
+
var blanklineStartRegex_ = /^\r?\n\r?\n/;
|
|
426
|
+
function diff_cleanupSemanticLossless(diffs) {
|
|
427
|
+
function diff_cleanupSemanticScore_(one, two) {
|
|
428
|
+
if (!one || !two) {
|
|
429
|
+
return 6;
|
|
430
|
+
}
|
|
431
|
+
var char1 = one.charAt(one.length - 1);
|
|
432
|
+
var char2 = two.charAt(0);
|
|
433
|
+
var nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_);
|
|
434
|
+
var nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_);
|
|
435
|
+
var whitespace1 = nonAlphaNumeric1 && char1.match(whitespaceRegex_);
|
|
436
|
+
var whitespace2 = nonAlphaNumeric2 && char2.match(whitespaceRegex_);
|
|
437
|
+
var lineBreak1 = whitespace1 && char1.match(linebreakRegex_);
|
|
438
|
+
var lineBreak2 = whitespace2 && char2.match(linebreakRegex_);
|
|
439
|
+
var blankLine1 = lineBreak1 && one.match(blanklineEndRegex_);
|
|
440
|
+
var blankLine2 = lineBreak2 && two.match(blanklineStartRegex_);
|
|
441
|
+
if (blankLine1 || blankLine2) {
|
|
442
|
+
return 5;
|
|
443
|
+
} else if (lineBreak1 || lineBreak2) {
|
|
444
|
+
return 4;
|
|
445
|
+
} else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) {
|
|
446
|
+
return 3;
|
|
447
|
+
} else if (whitespace1 || whitespace2) {
|
|
448
|
+
return 2;
|
|
449
|
+
} else if (nonAlphaNumeric1 || nonAlphaNumeric2) {
|
|
450
|
+
return 1;
|
|
451
|
+
}
|
|
452
|
+
return 0;
|
|
453
|
+
}
|
|
454
|
+
var pointer4 = 1;
|
|
455
|
+
while (pointer4 < diffs.length - 1) {
|
|
456
|
+
if (diffs[pointer4 - 1][0] == DIFF_EQUAL && diffs[pointer4 + 1][0] == DIFF_EQUAL) {
|
|
457
|
+
var equality1 = diffs[pointer4 - 1][1];
|
|
458
|
+
var edit2 = diffs[pointer4][1];
|
|
459
|
+
var equality2 = diffs[pointer4 + 1][1];
|
|
460
|
+
var commonOffset = diff_commonSuffix(equality1, edit2);
|
|
461
|
+
if (commonOffset) {
|
|
462
|
+
var commonString = edit2.substring(edit2.length - commonOffset);
|
|
463
|
+
equality1 = equality1.substring(0, equality1.length - commonOffset);
|
|
464
|
+
edit2 = commonString + edit2.substring(0, edit2.length - commonOffset);
|
|
465
|
+
equality2 = commonString + equality2;
|
|
466
|
+
}
|
|
467
|
+
var bestEquality1 = equality1;
|
|
468
|
+
var bestEdit = edit2;
|
|
469
|
+
var bestEquality2 = equality2;
|
|
470
|
+
var bestScore = diff_cleanupSemanticScore_(equality1, edit2) + diff_cleanupSemanticScore_(edit2, equality2);
|
|
471
|
+
while (edit2.charAt(0) === equality2.charAt(0)) {
|
|
472
|
+
equality1 += edit2.charAt(0);
|
|
473
|
+
edit2 = edit2.substring(1) + equality2.charAt(0);
|
|
474
|
+
equality2 = equality2.substring(1);
|
|
475
|
+
var score = diff_cleanupSemanticScore_(equality1, edit2) + diff_cleanupSemanticScore_(edit2, equality2);
|
|
476
|
+
if (score >= bestScore) {
|
|
477
|
+
bestScore = score;
|
|
478
|
+
bestEquality1 = equality1;
|
|
479
|
+
bestEdit = edit2;
|
|
480
|
+
bestEquality2 = equality2;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (diffs[pointer4 - 1][1] != bestEquality1) {
|
|
484
|
+
if (bestEquality1) {
|
|
485
|
+
diffs[pointer4 - 1][1] = bestEquality1;
|
|
486
|
+
} else {
|
|
487
|
+
diffs.splice(pointer4 - 1, 1);
|
|
488
|
+
pointer4--;
|
|
489
|
+
}
|
|
490
|
+
diffs[pointer4][1] = bestEdit;
|
|
491
|
+
if (bestEquality2) {
|
|
492
|
+
diffs[pointer4 + 1][1] = bestEquality2;
|
|
493
|
+
} else {
|
|
494
|
+
diffs.splice(pointer4 + 1, 1);
|
|
495
|
+
pointer4--;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
pointer4++;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function diff_cleanupMerge(diffs, fix_unicode) {
|
|
503
|
+
diffs.push([DIFF_EQUAL, ""]);
|
|
504
|
+
var pointer4 = 0;
|
|
505
|
+
var count_delete = 0;
|
|
506
|
+
var count_insert = 0;
|
|
507
|
+
var text_delete = "";
|
|
508
|
+
var text_insert = "";
|
|
509
|
+
var commonlength;
|
|
510
|
+
while (pointer4 < diffs.length) {
|
|
511
|
+
if (pointer4 < diffs.length - 1 && !diffs[pointer4][1]) {
|
|
512
|
+
diffs.splice(pointer4, 1);
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
switch (diffs[pointer4][0]) {
|
|
516
|
+
case DIFF_INSERT:
|
|
517
|
+
count_insert++;
|
|
518
|
+
text_insert += diffs[pointer4][1];
|
|
519
|
+
pointer4++;
|
|
520
|
+
break;
|
|
521
|
+
case DIFF_DELETE:
|
|
522
|
+
count_delete++;
|
|
523
|
+
text_delete += diffs[pointer4][1];
|
|
524
|
+
pointer4++;
|
|
525
|
+
break;
|
|
526
|
+
case DIFF_EQUAL:
|
|
527
|
+
var previous_equality = pointer4 - count_insert - count_delete - 1;
|
|
528
|
+
if (fix_unicode) {
|
|
529
|
+
if (previous_equality >= 0 && ends_with_pair_start(diffs[previous_equality][1])) {
|
|
530
|
+
var stray = diffs[previous_equality][1].slice(-1);
|
|
531
|
+
diffs[previous_equality][1] = diffs[previous_equality][1].slice(0, -1);
|
|
532
|
+
text_delete = stray + text_delete;
|
|
533
|
+
text_insert = stray + text_insert;
|
|
534
|
+
if (!diffs[previous_equality][1]) {
|
|
535
|
+
diffs.splice(previous_equality, 1);
|
|
536
|
+
pointer4--;
|
|
537
|
+
var k2 = previous_equality - 1;
|
|
538
|
+
if (diffs[k2] && diffs[k2][0] === DIFF_INSERT) {
|
|
539
|
+
count_insert++;
|
|
540
|
+
text_insert = diffs[k2][1] + text_insert;
|
|
541
|
+
k2--;
|
|
542
|
+
}
|
|
543
|
+
if (diffs[k2] && diffs[k2][0] === DIFF_DELETE) {
|
|
544
|
+
count_delete++;
|
|
545
|
+
text_delete = diffs[k2][1] + text_delete;
|
|
546
|
+
k2--;
|
|
547
|
+
}
|
|
548
|
+
previous_equality = k2;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (starts_with_pair_end(diffs[pointer4][1])) {
|
|
552
|
+
var stray = diffs[pointer4][1].charAt(0);
|
|
553
|
+
diffs[pointer4][1] = diffs[pointer4][1].slice(1);
|
|
554
|
+
text_delete += stray;
|
|
555
|
+
text_insert += stray;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (pointer4 < diffs.length - 1 && !diffs[pointer4][1]) {
|
|
559
|
+
diffs.splice(pointer4, 1);
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
if (text_delete.length > 0 || text_insert.length > 0) {
|
|
563
|
+
if (text_delete.length > 0 && text_insert.length > 0) {
|
|
564
|
+
commonlength = diff_commonPrefix(text_insert, text_delete);
|
|
565
|
+
if (commonlength !== 0) {
|
|
566
|
+
if (previous_equality >= 0) {
|
|
567
|
+
diffs[previous_equality][1] += text_insert.substring(0, commonlength);
|
|
568
|
+
} else {
|
|
569
|
+
diffs.splice(0, 0, [
|
|
570
|
+
DIFF_EQUAL,
|
|
571
|
+
text_insert.substring(0, commonlength)
|
|
572
|
+
]);
|
|
573
|
+
pointer4++;
|
|
574
|
+
}
|
|
575
|
+
text_insert = text_insert.substring(commonlength);
|
|
576
|
+
text_delete = text_delete.substring(commonlength);
|
|
577
|
+
}
|
|
578
|
+
commonlength = diff_commonSuffix(text_insert, text_delete);
|
|
579
|
+
if (commonlength !== 0) {
|
|
580
|
+
diffs[pointer4][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer4][1];
|
|
581
|
+
text_insert = text_insert.substring(0, text_insert.length - commonlength);
|
|
582
|
+
text_delete = text_delete.substring(0, text_delete.length - commonlength);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
var n = count_insert + count_delete;
|
|
586
|
+
if (text_delete.length === 0 && text_insert.length === 0) {
|
|
587
|
+
diffs.splice(pointer4 - n, n);
|
|
588
|
+
pointer4 = pointer4 - n;
|
|
589
|
+
} else if (text_delete.length === 0) {
|
|
590
|
+
diffs.splice(pointer4 - n, n, [DIFF_INSERT, text_insert]);
|
|
591
|
+
pointer4 = pointer4 - n + 1;
|
|
592
|
+
} else if (text_insert.length === 0) {
|
|
593
|
+
diffs.splice(pointer4 - n, n, [DIFF_DELETE, text_delete]);
|
|
594
|
+
pointer4 = pointer4 - n + 1;
|
|
595
|
+
} else {
|
|
596
|
+
diffs.splice(pointer4 - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
|
|
597
|
+
pointer4 = pointer4 - n + 2;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (pointer4 !== 0 && diffs[pointer4 - 1][0] === DIFF_EQUAL) {
|
|
601
|
+
diffs[pointer4 - 1][1] += diffs[pointer4][1];
|
|
602
|
+
diffs.splice(pointer4, 1);
|
|
603
|
+
} else {
|
|
604
|
+
pointer4++;
|
|
605
|
+
}
|
|
606
|
+
count_insert = 0;
|
|
607
|
+
count_delete = 0;
|
|
608
|
+
text_delete = "";
|
|
609
|
+
text_insert = "";
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (diffs[diffs.length - 1][1] === "") {
|
|
614
|
+
diffs.pop();
|
|
615
|
+
}
|
|
616
|
+
var changes = false;
|
|
617
|
+
pointer4 = 1;
|
|
618
|
+
while (pointer4 < diffs.length - 1) {
|
|
619
|
+
if (diffs[pointer4 - 1][0] === DIFF_EQUAL && diffs[pointer4 + 1][0] === DIFF_EQUAL) {
|
|
620
|
+
if (diffs[pointer4][1].substring(diffs[pointer4][1].length - diffs[pointer4 - 1][1].length) === diffs[pointer4 - 1][1]) {
|
|
621
|
+
diffs[pointer4][1] = diffs[pointer4 - 1][1] + diffs[pointer4][1].substring(0, diffs[pointer4][1].length - diffs[pointer4 - 1][1].length);
|
|
622
|
+
diffs[pointer4 + 1][1] = diffs[pointer4 - 1][1] + diffs[pointer4 + 1][1];
|
|
623
|
+
diffs.splice(pointer4 - 1, 1);
|
|
624
|
+
changes = true;
|
|
625
|
+
} else if (diffs[pointer4][1].substring(0, diffs[pointer4 + 1][1].length) == diffs[pointer4 + 1][1]) {
|
|
626
|
+
diffs[pointer4 - 1][1] += diffs[pointer4 + 1][1];
|
|
627
|
+
diffs[pointer4][1] = diffs[pointer4][1].substring(diffs[pointer4 + 1][1].length) + diffs[pointer4 + 1][1];
|
|
628
|
+
diffs.splice(pointer4 + 1, 1);
|
|
629
|
+
changes = true;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
pointer4++;
|
|
633
|
+
}
|
|
634
|
+
if (changes) {
|
|
635
|
+
diff_cleanupMerge(diffs, fix_unicode);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
function is_surrogate_pair_start(charCode) {
|
|
639
|
+
return charCode >= 55296 && charCode <= 56319;
|
|
640
|
+
}
|
|
641
|
+
function is_surrogate_pair_end(charCode) {
|
|
642
|
+
return charCode >= 56320 && charCode <= 57343;
|
|
643
|
+
}
|
|
644
|
+
function starts_with_pair_end(str) {
|
|
645
|
+
return is_surrogate_pair_end(str.charCodeAt(0));
|
|
646
|
+
}
|
|
647
|
+
function ends_with_pair_start(str) {
|
|
648
|
+
return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
|
|
649
|
+
}
|
|
650
|
+
function remove_empty_tuples(tuples) {
|
|
651
|
+
var ret = [];
|
|
652
|
+
for (var i = 0;i < tuples.length; i++) {
|
|
653
|
+
if (tuples[i][1].length > 0) {
|
|
654
|
+
ret.push(tuples[i]);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return ret;
|
|
658
|
+
}
|
|
659
|
+
function make_edit_splice(before, oldMiddle, newMiddle, after) {
|
|
660
|
+
if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
return remove_empty_tuples([
|
|
664
|
+
[DIFF_EQUAL, before],
|
|
665
|
+
[DIFF_DELETE, oldMiddle],
|
|
666
|
+
[DIFF_INSERT, newMiddle],
|
|
667
|
+
[DIFF_EQUAL, after]
|
|
668
|
+
]);
|
|
669
|
+
}
|
|
670
|
+
function find_cursor_edit_diff(oldText, newText, cursor_pos) {
|
|
671
|
+
var oldRange = typeof cursor_pos === "number" ? { index: cursor_pos, length: 0 } : cursor_pos.oldRange;
|
|
672
|
+
var newRange = typeof cursor_pos === "number" ? null : cursor_pos.newRange;
|
|
673
|
+
var oldLength = oldText.length;
|
|
674
|
+
var newLength = newText.length;
|
|
675
|
+
if (oldRange.length === 0 && (newRange === null || newRange.length === 0)) {
|
|
676
|
+
var oldCursor = oldRange.index;
|
|
677
|
+
var oldBefore = oldText.slice(0, oldCursor);
|
|
678
|
+
var oldAfter = oldText.slice(oldCursor);
|
|
679
|
+
var maybeNewCursor = newRange ? newRange.index : null;
|
|
680
|
+
editBefore: {
|
|
681
|
+
var newCursor = oldCursor + newLength - oldLength;
|
|
682
|
+
if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
|
|
683
|
+
break editBefore;
|
|
684
|
+
}
|
|
685
|
+
if (newCursor < 0 || newCursor > newLength) {
|
|
686
|
+
break editBefore;
|
|
687
|
+
}
|
|
688
|
+
var newBefore = newText.slice(0, newCursor);
|
|
689
|
+
var newAfter = newText.slice(newCursor);
|
|
690
|
+
if (newAfter !== oldAfter) {
|
|
691
|
+
break editBefore;
|
|
692
|
+
}
|
|
693
|
+
var prefixLength = Math.min(oldCursor, newCursor);
|
|
694
|
+
var oldPrefix = oldBefore.slice(0, prefixLength);
|
|
695
|
+
var newPrefix = newBefore.slice(0, prefixLength);
|
|
696
|
+
if (oldPrefix !== newPrefix) {
|
|
697
|
+
break editBefore;
|
|
698
|
+
}
|
|
699
|
+
var oldMiddle = oldBefore.slice(prefixLength);
|
|
700
|
+
var newMiddle = newBefore.slice(prefixLength);
|
|
701
|
+
return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
|
|
702
|
+
}
|
|
703
|
+
editAfter: {
|
|
704
|
+
if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
|
|
705
|
+
break editAfter;
|
|
706
|
+
}
|
|
707
|
+
var cursor = oldCursor;
|
|
708
|
+
var newBefore = newText.slice(0, cursor);
|
|
709
|
+
var newAfter = newText.slice(cursor);
|
|
710
|
+
if (newBefore !== oldBefore) {
|
|
711
|
+
break editAfter;
|
|
712
|
+
}
|
|
713
|
+
var suffixLength = Math.min(oldLength - cursor, newLength - cursor);
|
|
714
|
+
var oldSuffix = oldAfter.slice(oldAfter.length - suffixLength);
|
|
715
|
+
var newSuffix = newAfter.slice(newAfter.length - suffixLength);
|
|
716
|
+
if (oldSuffix !== newSuffix) {
|
|
717
|
+
break editAfter;
|
|
718
|
+
}
|
|
719
|
+
var oldMiddle = oldAfter.slice(0, oldAfter.length - suffixLength);
|
|
720
|
+
var newMiddle = newAfter.slice(0, newAfter.length - suffixLength);
|
|
721
|
+
return make_edit_splice(oldBefore, oldMiddle, newMiddle, oldSuffix);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (oldRange.length > 0 && newRange && newRange.length === 0) {
|
|
725
|
+
replaceRange: {
|
|
726
|
+
var oldPrefix = oldText.slice(0, oldRange.index);
|
|
727
|
+
var oldSuffix = oldText.slice(oldRange.index + oldRange.length);
|
|
728
|
+
var prefixLength = oldPrefix.length;
|
|
729
|
+
var suffixLength = oldSuffix.length;
|
|
730
|
+
if (newLength < prefixLength + suffixLength) {
|
|
731
|
+
break replaceRange;
|
|
732
|
+
}
|
|
733
|
+
var newPrefix = newText.slice(0, prefixLength);
|
|
734
|
+
var newSuffix = newText.slice(newLength - suffixLength);
|
|
735
|
+
if (oldPrefix !== newPrefix || oldSuffix !== newSuffix) {
|
|
736
|
+
break replaceRange;
|
|
737
|
+
}
|
|
738
|
+
var oldMiddle = oldText.slice(prefixLength, oldLength - suffixLength);
|
|
739
|
+
var newMiddle = newText.slice(prefixLength, newLength - suffixLength);
|
|
740
|
+
return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldSuffix);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
function diff2(text1, text2, cursor_pos, cleanup) {
|
|
746
|
+
return diff_main(text1, text2, cursor_pos, cleanup, true);
|
|
747
|
+
}
|
|
748
|
+
diff2.INSERT = DIFF_INSERT;
|
|
749
|
+
diff2.DELETE = DIFF_DELETE;
|
|
750
|
+
diff2.EQUAL = DIFF_EQUAL;
|
|
751
|
+
module3.exports = diff2;
|
|
752
|
+
});
|
|
753
|
+
|
|
31
754
|
// node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs
|
|
32
755
|
var require_eslint_visitor_keys = __commonJS((exports) => {
|
|
33
756
|
var KEYS = {
|
|
@@ -6306,11 +7029,11 @@ var require_Visitor = __commonJS((exports) => {
|
|
|
6306
7029
|
var PatternVisitor_1 = require_PatternVisitor();
|
|
6307
7030
|
var VisitorBase_1 = require_VisitorBase();
|
|
6308
7031
|
|
|
6309
|
-
class
|
|
7032
|
+
class Visitor extends VisitorBase_1.VisitorBase {
|
|
6310
7033
|
#options;
|
|
6311
7034
|
constructor(optionsOrVisitor) {
|
|
6312
|
-
super(optionsOrVisitor instanceof
|
|
6313
|
-
this.#options = optionsOrVisitor instanceof
|
|
7035
|
+
super(optionsOrVisitor instanceof Visitor ? optionsOrVisitor.#options : optionsOrVisitor);
|
|
7036
|
+
this.#options = optionsOrVisitor instanceof Visitor ? optionsOrVisitor.#options : optionsOrVisitor;
|
|
6314
7037
|
}
|
|
6315
7038
|
visitPattern(node, callback, options3 = { processRightHandNodes: false }) {
|
|
6316
7039
|
const visitor = new PatternVisitor_1.PatternVisitor(this.#options, node, callback);
|
|
@@ -6320,7 +7043,7 @@ var require_Visitor = __commonJS((exports) => {
|
|
|
6320
7043
|
}
|
|
6321
7044
|
}
|
|
6322
7045
|
}
|
|
6323
|
-
exports.Visitor =
|
|
7046
|
+
exports.Visitor = Visitor;
|
|
6324
7047
|
var VisitorBase_2 = require_VisitorBase();
|
|
6325
7048
|
Object.defineProperty(exports, "VisitorBase", { enumerable: true, get: function() {
|
|
6326
7049
|
return VisitorBase_2.VisitorBase;
|
|
@@ -15435,19 +16158,17 @@ function normalizeConfig(options3) {
|
|
|
15435
16158
|
if (!isOptionsObject.Check(options3))
|
|
15436
16159
|
return { bannedClasses: new Map };
|
|
15437
16160
|
const { bannedInstances } = options3;
|
|
16161
|
+
const bannedClasses = new Map;
|
|
15438
16162
|
if (isArrayConfig.Check(bannedInstances)) {
|
|
15439
|
-
const
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
for (const [className, message] of Object.entries(bannedInstances))
|
|
15447
|
-
map.set(className.toLowerCase(), { message, originalName: className });
|
|
15448
|
-
return { bannedClasses: map };
|
|
16163
|
+
for (const className of bannedInstances) {
|
|
16164
|
+
bannedClasses.set(className.toLowerCase(), { message: undefined, originalName: className });
|
|
16165
|
+
}
|
|
16166
|
+
} else if (isObjectConfig.Check(bannedInstances)) {
|
|
16167
|
+
for (const [className, message] of Object.entries(bannedInstances)) {
|
|
16168
|
+
bannedClasses.set(className.toLowerCase(), { message, originalName: className });
|
|
16169
|
+
}
|
|
15449
16170
|
}
|
|
15450
|
-
return { bannedClasses
|
|
16171
|
+
return { bannedClasses };
|
|
15451
16172
|
}
|
|
15452
16173
|
var docs = {
|
|
15453
16174
|
description: "Ban specified Roblox Instance classes in new Instance() calls and JSX elements.",
|
|
@@ -15554,10 +16275,11 @@ var banReactFC = {
|
|
|
15554
16275
|
return;
|
|
15555
16276
|
const { typeName } = inner;
|
|
15556
16277
|
let isBannedFc = false;
|
|
15557
|
-
if (typeName.type === TSESTree2.AST_NODE_TYPES.Identifier)
|
|
16278
|
+
if (typeName.type === TSESTree2.AST_NODE_TYPES.Identifier) {
|
|
15558
16279
|
isBannedFc = BANNED_FC_NAMES.has(typeName.name);
|
|
15559
|
-
else if (typeName.type === TSESTree2.AST_NODE_TYPES.TSQualifiedName)
|
|
16280
|
+
} else if (typeName.type === TSESTree2.AST_NODE_TYPES.TSQualifiedName) {
|
|
15560
16281
|
isBannedFc = BANNED_FC_NAMES.has(typeName.right.name);
|
|
16282
|
+
}
|
|
15561
16283
|
if (!isBannedFc || node.init?.type !== TSESTree2.AST_NODE_TYPES.ArrowFunctionExpression)
|
|
15562
16284
|
return;
|
|
15563
16285
|
context.report({
|
|
@@ -15592,22 +16314,15 @@ var DEFAULT_CONFIGURATION = {
|
|
|
15592
16314
|
performanceMode: true,
|
|
15593
16315
|
warnThreshold: 15
|
|
15594
16316
|
};
|
|
15595
|
-
var SHOULD_NOT_NOT_RETURN_TYPE = new Set([
|
|
15596
|
-
TSESTree3.AST_NODE_TYPES.FunctionDeclaration,
|
|
15597
|
-
TSESTree3.AST_NODE_TYPES.FunctionExpression
|
|
15598
|
-
]);
|
|
15599
16317
|
function hasTypeAnnotationProperty(node) {
|
|
15600
16318
|
return "typeAnnotation" in node;
|
|
15601
16319
|
}
|
|
15602
16320
|
function hasTypeAnnotation(node) {
|
|
15603
|
-
if (node.type
|
|
15604
|
-
return
|
|
15605
|
-
if (
|
|
15606
|
-
return
|
|
15607
|
-
return
|
|
15608
|
-
}
|
|
15609
|
-
function getTypeName(node) {
|
|
15610
|
-
return node.type === TSESTree3.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === TSESTree3.AST_NODE_TYPES.TSTypeAliasDeclaration ? node.id.name : undefined;
|
|
16321
|
+
if (node.id.type !== TSESTree3.AST_NODE_TYPES.Identifier)
|
|
16322
|
+
return false;
|
|
16323
|
+
if (typeof node.id !== "object" || !hasTypeAnnotationProperty(node.id))
|
|
16324
|
+
return false;
|
|
16325
|
+
return Boolean(node.id.typeAnnotation);
|
|
15611
16326
|
}
|
|
15612
16327
|
function isIanitorValidator(node) {
|
|
15613
16328
|
return node.type === TSESTree3.AST_NODE_TYPES.CallExpression && node.callee?.type === TSESTree3.AST_NODE_TYPES.MemberExpression && node.callee.object?.type === TSESTree3.AST_NODE_TYPES.Identifier && node.callee.object.name === "Ianitor";
|
|
@@ -15620,9 +16335,10 @@ function extractIanitorStaticVariable(typeAnnotation) {
|
|
|
15620
16335
|
if (currentType.type !== TSESTree3.AST_NODE_TYPES.TSTypeReference)
|
|
15621
16336
|
return;
|
|
15622
16337
|
const { typeName, typeArguments } = currentType;
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
16338
|
+
if (typeName.type === TSESTree3.AST_NODE_TYPES.TSQualifiedName && typeName.left.type === TSESTree3.AST_NODE_TYPES.Identifier && typeName.left.name === "Ianitor" && typeName.right.type === TSESTree3.AST_NODE_TYPES.Identifier && typeName.right.name === "Static") {
|
|
16339
|
+
const first = typeArguments?.params[0];
|
|
16340
|
+
const name = first?.type === TSESTree3.AST_NODE_TYPES.TSTypeQuery && first.exprName.type === TSESTree3.AST_NODE_TYPES.Identifier ? first.exprName.name : undefined;
|
|
16341
|
+
return name;
|
|
15626
16342
|
}
|
|
15627
16343
|
return;
|
|
15628
16344
|
}
|
|
@@ -15728,8 +16444,9 @@ var enforceIanitorCheckType = createRule({
|
|
|
15728
16444
|
score = addScore(score, body.length * 2);
|
|
15729
16445
|
for (const member of body) {
|
|
15730
16446
|
const typeAnnotation = "typeAnnotation" in member ? member.typeAnnotation : undefined;
|
|
15731
|
-
if (typeAnnotation)
|
|
16447
|
+
if (typeAnnotation !== undefined) {
|
|
15732
16448
|
score = addScore(score, calculateStructuralComplexity(typeAnnotation.typeAnnotation, nextDepth));
|
|
16449
|
+
}
|
|
15733
16450
|
}
|
|
15734
16451
|
break;
|
|
15735
16452
|
}
|
|
@@ -15738,8 +16455,9 @@ var enforceIanitorCheckType = createRule({
|
|
|
15738
16455
|
score = 2 + members.length * 0.5;
|
|
15739
16456
|
for (const member of members) {
|
|
15740
16457
|
const typeAnnotation = "typeAnnotation" in member ? member.typeAnnotation : undefined;
|
|
15741
|
-
if (typeAnnotation)
|
|
16458
|
+
if (typeAnnotation !== undefined) {
|
|
15742
16459
|
score = addScore(score, calculateStructuralComplexity(typeAnnotation.typeAnnotation, nextDepth));
|
|
16460
|
+
}
|
|
15743
16461
|
}
|
|
15744
16462
|
break;
|
|
15745
16463
|
}
|
|
@@ -15764,9 +16482,10 @@ var enforceIanitorCheckType = createRule({
|
|
|
15764
16482
|
const { elementTypes } = node;
|
|
15765
16483
|
score = 1;
|
|
15766
16484
|
for (const element of elementTypes) {
|
|
15767
|
-
const
|
|
15768
|
-
if (
|
|
16485
|
+
const { type: type3 } = element;
|
|
16486
|
+
if (type3 !== "TSRestType" && type3 !== "TSOptionalType") {
|
|
15769
16487
|
score = addScore(score, calculateStructuralComplexity(element, nextDepth));
|
|
16488
|
+
}
|
|
15770
16489
|
}
|
|
15771
16490
|
score = addScore(score, 1.5 * elementTypes.length);
|
|
15772
16491
|
break;
|
|
@@ -15774,9 +16493,10 @@ var enforceIanitorCheckType = createRule({
|
|
|
15774
16493
|
case TSESTree3.AST_NODE_TYPES.TSTypeReference: {
|
|
15775
16494
|
score = 2;
|
|
15776
16495
|
const { typeArguments } = node;
|
|
15777
|
-
if (typeArguments) {
|
|
15778
|
-
for (const
|
|
15779
|
-
score = addScore(score, calculateStructuralComplexity(
|
|
16496
|
+
if (typeArguments !== undefined) {
|
|
16497
|
+
for (const parameter2 of typeArguments.params) {
|
|
16498
|
+
score = addScore(score, calculateStructuralComplexity(parameter2, nextDepth) + 2);
|
|
16499
|
+
}
|
|
15780
16500
|
}
|
|
15781
16501
|
break;
|
|
15782
16502
|
}
|
|
@@ -15790,22 +16510,26 @@ var enforceIanitorCheckType = createRule({
|
|
|
15790
16510
|
}
|
|
15791
16511
|
case TSESTree3.AST_NODE_TYPES.TSMappedType: {
|
|
15792
16512
|
score = 5;
|
|
15793
|
-
if (node
|
|
16513
|
+
if ("constraint" in node) {
|
|
15794
16514
|
score = addScore(score, calculateStructuralComplexity(node.constraint, nextDepth));
|
|
15795
|
-
|
|
16515
|
+
}
|
|
16516
|
+
if (node.typeAnnotation !== undefined) {
|
|
15796
16517
|
score = addScore(score, calculateStructuralComplexity(node.typeAnnotation, nextDepth));
|
|
16518
|
+
}
|
|
15797
16519
|
break;
|
|
15798
16520
|
}
|
|
15799
16521
|
case TSESTree3.AST_NODE_TYPES.TSFunctionType:
|
|
15800
16522
|
case TSESTree3.AST_NODE_TYPES.TSMethodSignature: {
|
|
15801
16523
|
score = 2;
|
|
15802
|
-
for (const
|
|
15803
|
-
const typeAnnotation = "typeAnnotation" in
|
|
15804
|
-
if (typeAnnotation)
|
|
16524
|
+
for (const parameter2 of node.params) {
|
|
16525
|
+
const typeAnnotation = "typeAnnotation" in parameter2 ? parameter2.typeAnnotation : undefined;
|
|
16526
|
+
if (typeAnnotation !== undefined) {
|
|
15805
16527
|
score = addScore(score, calculateStructuralComplexity(typeAnnotation.typeAnnotation, nextDepth));
|
|
16528
|
+
}
|
|
15806
16529
|
}
|
|
15807
|
-
if (node.returnType)
|
|
16530
|
+
if (node.returnType !== undefined) {
|
|
15808
16531
|
score = addScore(score, calculateStructuralComplexity(node.returnType.typeAnnotation, nextDepth));
|
|
16532
|
+
}
|
|
15809
16533
|
break;
|
|
15810
16534
|
}
|
|
15811
16535
|
default:
|
|
@@ -15820,8 +16544,9 @@ var enforceIanitorCheckType = createRule({
|
|
|
15820
16544
|
return {
|
|
15821
16545
|
"Program:exit"() {
|
|
15822
16546
|
for (const [node, data] of variableDeclaratorsToCheck.entries()) {
|
|
15823
|
-
if (node.id.type === TSESTree3.AST_NODE_TYPES.Identifier && ianitorStaticVariables.has(node.id.name))
|
|
16547
|
+
if (node.id.type === TSESTree3.AST_NODE_TYPES.Identifier && ianitorStaticVariables.has(node.id.name)) {
|
|
15824
16548
|
continue;
|
|
16549
|
+
}
|
|
15825
16550
|
context.report({
|
|
15826
16551
|
data: { score: data.complexity.toFixed(1) },
|
|
15827
16552
|
messageId: "missingIanitorCheckType",
|
|
@@ -15831,10 +16556,10 @@ var enforceIanitorCheckType = createRule({
|
|
|
15831
16556
|
},
|
|
15832
16557
|
TSInterfaceDeclaration(node) {
|
|
15833
16558
|
const complexity = calculateStructuralComplexity(node);
|
|
15834
|
-
const name =
|
|
16559
|
+
const { name } = node.id;
|
|
15835
16560
|
if (complexity >= config.interfacePenalty) {
|
|
15836
16561
|
context.report({
|
|
15837
|
-
data: { name
|
|
16562
|
+
data: { name },
|
|
15838
16563
|
messageId: "complexInterfaceNeedsCheck",
|
|
15839
16564
|
node
|
|
15840
16565
|
});
|
|
@@ -15842,7 +16567,7 @@ var enforceIanitorCheckType = createRule({
|
|
|
15842
16567
|
},
|
|
15843
16568
|
TSTypeAliasDeclaration(node) {
|
|
15844
16569
|
const variableName = extractIanitorStaticVariable(node.typeAnnotation);
|
|
15845
|
-
if (variableName)
|
|
16570
|
+
if (variableName !== undefined)
|
|
15846
16571
|
ianitorStaticVariables.add(variableName);
|
|
15847
16572
|
if (hasIanitorStaticType(node.typeAnnotation))
|
|
15848
16573
|
return;
|
|
@@ -16336,23 +17061,29 @@ function h(n, l) {
|
|
|
16336
17061
|
const g = K(n, l?.errors, l);
|
|
16337
17062
|
return N(n, g, l), g;
|
|
16338
17063
|
}
|
|
17064
|
+
// src/utilities/format-utilities.ts
|
|
17065
|
+
var import_fast_diff = __toESM(require_diff(), 1);
|
|
17066
|
+
|
|
16339
17067
|
// src/oxfmt-sync.ts
|
|
16340
17068
|
import { existsSync } from "node:fs";
|
|
16341
17069
|
import { fileURLToPath } from "node:url";
|
|
16342
17070
|
import { MessageChannel, receiveMessageOnPort, Worker } from "node:worker_threads";
|
|
16343
17071
|
var FORMAT_TIMEOUT = 30000;
|
|
16344
17072
|
var workerState;
|
|
16345
|
-
function
|
|
16346
|
-
const jsPath = new URL("./oxfmt-worker.js",
|
|
17073
|
+
function __testingResolveWorkerPath(baseUrl, exists) {
|
|
17074
|
+
const jsPath = new URL("./oxfmt-worker.js", baseUrl);
|
|
16347
17075
|
const jsFilePath = fileURLToPath(jsPath);
|
|
16348
|
-
if (
|
|
17076
|
+
if (exists(jsFilePath))
|
|
16349
17077
|
return jsPath;
|
|
16350
|
-
const tsPath = new URL("./oxfmt-worker.ts",
|
|
17078
|
+
const tsPath = new URL("./oxfmt-worker.ts", baseUrl);
|
|
16351
17079
|
const tsFilePath = fileURLToPath(tsPath);
|
|
16352
|
-
if (
|
|
17080
|
+
if (exists(tsFilePath))
|
|
16353
17081
|
return tsPath;
|
|
16354
17082
|
throw new Error(`Oxfmt worker not found at ${jsFilePath} or ${tsFilePath}. Did you run 'bun run build'?`);
|
|
16355
17083
|
}
|
|
17084
|
+
function resolveWorkerPath() {
|
|
17085
|
+
return __testingResolveWorkerPath(import.meta.url, existsSync);
|
|
17086
|
+
}
|
|
16356
17087
|
function getWorker() {
|
|
16357
17088
|
if (workerState !== undefined)
|
|
16358
17089
|
return workerState;
|
|
@@ -16417,22 +17148,38 @@ function loadOxfmtConfig() {
|
|
|
16417
17148
|
}
|
|
16418
17149
|
}
|
|
16419
17150
|
function getExtension(filePath) {
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16431
|
-
|
|
16432
|
-
|
|
16433
|
-
|
|
16434
|
-
|
|
16435
|
-
|
|
17151
|
+
const { length } = filePath;
|
|
17152
|
+
if (length >= 3 && filePath.codePointAt(length - 3) === 46 /* Period */) {
|
|
17153
|
+
const character1 = filePath.codePointAt(length - 2);
|
|
17154
|
+
const character2 = filePath.codePointAt(length - 1);
|
|
17155
|
+
if (character1 === 116 /* LowerT */ && character2 === 115 /* LowerS */)
|
|
17156
|
+
return ".ts";
|
|
17157
|
+
if (character1 === 106 /* LowerJ */ && character2 === 115 /* LowerS */)
|
|
17158
|
+
return ".js";
|
|
17159
|
+
}
|
|
17160
|
+
if (length >= 4 && filePath.codePointAt(length - 4) === 46 /* Period */) {
|
|
17161
|
+
const character1 = filePath.codePointAt(length - 3);
|
|
17162
|
+
const character2 = filePath.codePointAt(length - 2);
|
|
17163
|
+
const character3 = filePath.codePointAt(length - 1);
|
|
17164
|
+
if (character3 === 120 /* LowerX */) {
|
|
17165
|
+
if (character1 === 116 /* LowerT */ && character2 === 115 /* LowerS */)
|
|
17166
|
+
return ".tsx";
|
|
17167
|
+
if (character1 === 106 /* LowerJ */ && character2 === 115 /* LowerS */)
|
|
17168
|
+
return ".jsx";
|
|
17169
|
+
} else if (character3 === 115 /* LowerS */) {
|
|
17170
|
+
if (character2 === 116 /* LowerT */) {
|
|
17171
|
+
if (character1 === 109 /* LowerM */)
|
|
17172
|
+
return ".mts";
|
|
17173
|
+
if (character1 === 99 /* LowerC */)
|
|
17174
|
+
return ".cts";
|
|
17175
|
+
} else if (character2 === 106 /* LowerJ */) {
|
|
17176
|
+
if (character1 === 109 /* LowerM */)
|
|
17177
|
+
return ".mjs";
|
|
17178
|
+
if (character1 === 99 /* LowerC */)
|
|
17179
|
+
return ".cjs";
|
|
17180
|
+
}
|
|
17181
|
+
}
|
|
17182
|
+
}
|
|
16436
17183
|
return;
|
|
16437
17184
|
}
|
|
16438
17185
|
function formatWithOxfmtSync(source, filePath) {
|
|
@@ -16445,14 +17192,51 @@ function formatWithOxfmtSync(source, filePath) {
|
|
|
16445
17192
|
function generateDifferences(original, formatted) {
|
|
16446
17193
|
if (original === formatted)
|
|
16447
17194
|
return [];
|
|
16448
|
-
|
|
16449
|
-
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
|
|
16453
|
-
|
|
17195
|
+
const diffs = import_fast_diff.default(original, formatted);
|
|
17196
|
+
const differences = new Array;
|
|
17197
|
+
let size = 0;
|
|
17198
|
+
let offset = 0;
|
|
17199
|
+
let index2 = 0;
|
|
17200
|
+
while (index2 < diffs.length) {
|
|
17201
|
+
const diff2 = diffs[index2];
|
|
17202
|
+
if (diff2 === undefined)
|
|
17203
|
+
break;
|
|
17204
|
+
const [type3, text] = diff2;
|
|
17205
|
+
if (type3 === 0) {
|
|
17206
|
+
offset += text.length;
|
|
17207
|
+
index2 += 1;
|
|
17208
|
+
} else if (type3 === -1) {
|
|
17209
|
+
let adjustedOffset = offset;
|
|
17210
|
+
const previous = diffs[index2 - 1];
|
|
17211
|
+
if (previous !== undefined && previous[0] === 0) {
|
|
17212
|
+
const [, prevText] = previous;
|
|
17213
|
+
let shiftCount = 0;
|
|
17214
|
+
while (shiftCount < prevText.length && shiftCount < text.length && prevText[prevText.length - 1 - shiftCount] === text[shiftCount]) {
|
|
17215
|
+
shiftCount += 1;
|
|
17216
|
+
}
|
|
17217
|
+
adjustedOffset -= shiftCount;
|
|
17218
|
+
}
|
|
17219
|
+
const next = diffs[index2 + 1];
|
|
17220
|
+
if (next !== undefined && next[0] === 1) {
|
|
17221
|
+
const [, nextText] = next;
|
|
17222
|
+
differences[size++] = {
|
|
17223
|
+
deleteText: text,
|
|
17224
|
+
insertText: nextText,
|
|
17225
|
+
offset: adjustedOffset,
|
|
17226
|
+
operation: "REPLACE"
|
|
17227
|
+
};
|
|
17228
|
+
index2 += 2;
|
|
17229
|
+
} else {
|
|
17230
|
+
differences[size++] = { deleteText: text, offset: adjustedOffset, operation: "DELETE" };
|
|
17231
|
+
index2 += 1;
|
|
17232
|
+
}
|
|
17233
|
+
offset += text.length;
|
|
17234
|
+
} else {
|
|
17235
|
+
differences[size++] = { insertText: text, offset, operation: "INSERT" };
|
|
17236
|
+
index2 += 1;
|
|
16454
17237
|
}
|
|
16455
|
-
|
|
17238
|
+
}
|
|
17239
|
+
return differences;
|
|
16456
17240
|
}
|
|
16457
17241
|
var MAX_LENGTH = 60;
|
|
16458
17242
|
var SYMBOLS = {
|
|
@@ -16892,955 +17676,68 @@ var no_color3_constructor_default = noColor3Constructor;
|
|
|
16892
17676
|
|
|
16893
17677
|
// src/rules/no-commented-code.ts
|
|
16894
17678
|
import path from "node:path";
|
|
17679
|
+
import { parseSync } from "oxc-parser";
|
|
16895
17680
|
|
|
16896
|
-
//
|
|
16897
|
-
|
|
17681
|
+
// src/recognizers/detector.ts
|
|
17682
|
+
function recognize(detector, line) {
|
|
17683
|
+
const matches = detector.scan(line);
|
|
17684
|
+
if (matches === 0)
|
|
17685
|
+
return 0;
|
|
17686
|
+
return 1 - (1 - detector.probability) ** matches;
|
|
17687
|
+
}
|
|
16898
17688
|
|
|
16899
|
-
//
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
var isMusl = () => {
|
|
16907
|
-
let musl = false;
|
|
16908
|
-
if (process.platform === "linux") {
|
|
16909
|
-
musl = isMuslFromFilesystem();
|
|
16910
|
-
if (musl === null) {
|
|
16911
|
-
musl = isMuslFromReport();
|
|
16912
|
-
}
|
|
16913
|
-
if (musl === null) {
|
|
16914
|
-
musl = isMuslFromChildProcess();
|
|
16915
|
-
}
|
|
16916
|
-
}
|
|
16917
|
-
return musl;
|
|
16918
|
-
};
|
|
16919
|
-
var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
16920
|
-
var isMuslFromFilesystem = () => {
|
|
16921
|
-
try {
|
|
16922
|
-
return readFileSync2("/usr/bin/ldd", "utf-8").includes("musl");
|
|
16923
|
-
} catch {
|
|
16924
|
-
return null;
|
|
16925
|
-
}
|
|
16926
|
-
};
|
|
16927
|
-
var isMuslFromReport = () => {
|
|
16928
|
-
let report = null;
|
|
16929
|
-
if (typeof process.report?.getReport === "function") {
|
|
16930
|
-
process.report.excludeNetwork = true;
|
|
16931
|
-
report = process.report.getReport();
|
|
16932
|
-
}
|
|
16933
|
-
if (!report) {
|
|
16934
|
-
return null;
|
|
16935
|
-
}
|
|
16936
|
-
if (report.header && report.header.glibcVersionRuntime) {
|
|
16937
|
-
return false;
|
|
16938
|
-
}
|
|
16939
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
16940
|
-
if (report.sharedObjects.some(isFileMusl)) {
|
|
16941
|
-
return true;
|
|
16942
|
-
}
|
|
16943
|
-
}
|
|
16944
|
-
return false;
|
|
16945
|
-
};
|
|
16946
|
-
var isMuslFromChildProcess = () => {
|
|
16947
|
-
try {
|
|
16948
|
-
return require2("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
16949
|
-
} catch (e) {
|
|
16950
|
-
return false;
|
|
17689
|
+
// src/recognizers/code-recognizer.ts
|
|
17690
|
+
var PROBABILITY_THRESHOLD = 0.9;
|
|
17691
|
+
function computeProbability(detectors, line) {
|
|
17692
|
+
let probability = 0;
|
|
17693
|
+
for (const detector of detectors) {
|
|
17694
|
+
const detected = recognize(detector, line);
|
|
17695
|
+
probability = 1 - (1 - probability) * (1 - detected);
|
|
16951
17696
|
}
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
const
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17697
|
+
return probability;
|
|
17698
|
+
}
|
|
17699
|
+
function isLikelyCode(detectors, line) {
|
|
17700
|
+
return computeProbability(detectors, line) >= PROBABILITY_THRESHOLD;
|
|
17701
|
+
}
|
|
17702
|
+
function hasCodeLines(detectors, lines) {
|
|
17703
|
+
return lines.some((line) => isLikelyCode(detectors, line));
|
|
17704
|
+
}
|
|
17705
|
+
|
|
17706
|
+
// src/recognizers/camel-case-detector.ts
|
|
17707
|
+
function createCamelCaseDetector(probability) {
|
|
17708
|
+
return {
|
|
17709
|
+
probability,
|
|
17710
|
+
scan(line) {
|
|
17711
|
+
for (let index2 = 0;index2 < line.length - 1; index2 += 1) {
|
|
17712
|
+
const current = line.charAt(index2);
|
|
17713
|
+
const next = line.charAt(index2 + 1);
|
|
17714
|
+
if (current === current.toLowerCase() && next === next.toUpperCase() && next !== next.toLowerCase()) {
|
|
17715
|
+
return 1;
|
|
16972
17716
|
}
|
|
16973
|
-
return binding;
|
|
16974
|
-
} catch (e) {
|
|
16975
|
-
loadErrors.push(e);
|
|
16976
|
-
}
|
|
16977
|
-
} else if (process.arch === "arm") {
|
|
16978
|
-
try {
|
|
16979
|
-
return require2("./parser.android-arm-eabi.node");
|
|
16980
|
-
} catch (e) {
|
|
16981
|
-
loadErrors.push(e);
|
|
16982
17717
|
}
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-gnu/package.json").version;
|
|
17007
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17008
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17009
|
-
}
|
|
17010
|
-
return binding;
|
|
17011
|
-
} catch (e) {
|
|
17012
|
-
loadErrors.push(e);
|
|
17013
|
-
}
|
|
17014
|
-
} else {
|
|
17015
|
-
try {
|
|
17016
|
-
return require2("./parser.win32-x64-msvc.node");
|
|
17017
|
-
} catch (e) {
|
|
17018
|
-
loadErrors.push(e);
|
|
17019
|
-
}
|
|
17020
|
-
try {
|
|
17021
|
-
const binding = require2("@oxc-parser/binding-win32-x64-msvc");
|
|
17022
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-msvc/package.json").version;
|
|
17023
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17024
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17025
|
-
}
|
|
17026
|
-
return binding;
|
|
17027
|
-
} catch (e) {
|
|
17028
|
-
loadErrors.push(e);
|
|
17029
|
-
}
|
|
17030
|
-
}
|
|
17031
|
-
} else if (process.arch === "ia32") {
|
|
17032
|
-
try {
|
|
17033
|
-
return require2("./parser.win32-ia32-msvc.node");
|
|
17034
|
-
} catch (e) {
|
|
17035
|
-
loadErrors.push(e);
|
|
17036
|
-
}
|
|
17037
|
-
try {
|
|
17038
|
-
const binding = require2("@oxc-parser/binding-win32-ia32-msvc");
|
|
17039
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-win32-ia32-msvc/package.json").version;
|
|
17040
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17041
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17042
|
-
}
|
|
17043
|
-
return binding;
|
|
17044
|
-
} catch (e) {
|
|
17045
|
-
loadErrors.push(e);
|
|
17046
|
-
}
|
|
17047
|
-
} else if (process.arch === "arm64") {
|
|
17048
|
-
try {
|
|
17049
|
-
return require2("./parser.win32-arm64-msvc.node");
|
|
17050
|
-
} catch (e) {
|
|
17051
|
-
loadErrors.push(e);
|
|
17052
|
-
}
|
|
17053
|
-
try {
|
|
17054
|
-
const binding = require2("@oxc-parser/binding-win32-arm64-msvc");
|
|
17055
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-win32-arm64-msvc/package.json").version;
|
|
17056
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17057
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17058
|
-
}
|
|
17059
|
-
return binding;
|
|
17060
|
-
} catch (e) {
|
|
17061
|
-
loadErrors.push(e);
|
|
17062
|
-
}
|
|
17063
|
-
} else {
|
|
17064
|
-
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
17065
|
-
}
|
|
17066
|
-
} else if (process.platform === "darwin") {
|
|
17067
|
-
try {
|
|
17068
|
-
return require2("./parser.darwin-universal.node");
|
|
17069
|
-
} catch (e) {
|
|
17070
|
-
loadErrors.push(e);
|
|
17071
|
-
}
|
|
17072
|
-
try {
|
|
17073
|
-
const binding = require2("@oxc-parser/binding-darwin-universal");
|
|
17074
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-universal/package.json").version;
|
|
17075
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17076
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17077
|
-
}
|
|
17078
|
-
return binding;
|
|
17079
|
-
} catch (e) {
|
|
17080
|
-
loadErrors.push(e);
|
|
17081
|
-
}
|
|
17082
|
-
if (process.arch === "x64") {
|
|
17083
|
-
try {
|
|
17084
|
-
return require2("./parser.darwin-x64.node");
|
|
17085
|
-
} catch (e) {
|
|
17086
|
-
loadErrors.push(e);
|
|
17087
|
-
}
|
|
17088
|
-
try {
|
|
17089
|
-
const binding = require2("@oxc-parser/binding-darwin-x64");
|
|
17090
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-x64/package.json").version;
|
|
17091
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17092
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17093
|
-
}
|
|
17094
|
-
return binding;
|
|
17095
|
-
} catch (e) {
|
|
17096
|
-
loadErrors.push(e);
|
|
17097
|
-
}
|
|
17098
|
-
} else if (process.arch === "arm64") {
|
|
17099
|
-
try {
|
|
17100
|
-
return require2("./parser.darwin-arm64.node");
|
|
17101
|
-
} catch (e) {
|
|
17102
|
-
loadErrors.push(e);
|
|
17103
|
-
}
|
|
17104
|
-
try {
|
|
17105
|
-
const binding = require2("@oxc-parser/binding-darwin-arm64");
|
|
17106
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-arm64/package.json").version;
|
|
17107
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17108
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17109
|
-
}
|
|
17110
|
-
return binding;
|
|
17111
|
-
} catch (e) {
|
|
17112
|
-
loadErrors.push(e);
|
|
17113
|
-
}
|
|
17114
|
-
} else {
|
|
17115
|
-
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
17116
|
-
}
|
|
17117
|
-
} else if (process.platform === "freebsd") {
|
|
17118
|
-
if (process.arch === "x64") {
|
|
17119
|
-
try {
|
|
17120
|
-
return require2("./parser.freebsd-x64.node");
|
|
17121
|
-
} catch (e) {
|
|
17122
|
-
loadErrors.push(e);
|
|
17123
|
-
}
|
|
17124
|
-
try {
|
|
17125
|
-
const binding = require2("@oxc-parser/binding-freebsd-x64");
|
|
17126
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-x64/package.json").version;
|
|
17127
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17128
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17129
|
-
}
|
|
17130
|
-
return binding;
|
|
17131
|
-
} catch (e) {
|
|
17132
|
-
loadErrors.push(e);
|
|
17133
|
-
}
|
|
17134
|
-
} else if (process.arch === "arm64") {
|
|
17135
|
-
try {
|
|
17136
|
-
return require2("./parser.freebsd-arm64.node");
|
|
17137
|
-
} catch (e) {
|
|
17138
|
-
loadErrors.push(e);
|
|
17139
|
-
}
|
|
17140
|
-
try {
|
|
17141
|
-
const binding = require2("@oxc-parser/binding-freebsd-arm64");
|
|
17142
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-arm64/package.json").version;
|
|
17143
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17144
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17145
|
-
}
|
|
17146
|
-
return binding;
|
|
17147
|
-
} catch (e) {
|
|
17148
|
-
loadErrors.push(e);
|
|
17149
|
-
}
|
|
17150
|
-
} else {
|
|
17151
|
-
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
17152
|
-
}
|
|
17153
|
-
} else if (process.platform === "linux") {
|
|
17154
|
-
if (process.arch === "x64") {
|
|
17155
|
-
if (isMusl()) {
|
|
17156
|
-
try {
|
|
17157
|
-
return require2("./parser.linux-x64-musl.node");
|
|
17158
|
-
} catch (e) {
|
|
17159
|
-
loadErrors.push(e);
|
|
17160
|
-
}
|
|
17161
|
-
try {
|
|
17162
|
-
const binding = require2("@oxc-parser/binding-linux-x64-musl");
|
|
17163
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-musl/package.json").version;
|
|
17164
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17165
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17166
|
-
}
|
|
17167
|
-
return binding;
|
|
17168
|
-
} catch (e) {
|
|
17169
|
-
loadErrors.push(e);
|
|
17170
|
-
}
|
|
17171
|
-
} else {
|
|
17172
|
-
try {
|
|
17173
|
-
return require2("./parser.linux-x64-gnu.node");
|
|
17174
|
-
} catch (e) {
|
|
17175
|
-
loadErrors.push(e);
|
|
17176
|
-
}
|
|
17177
|
-
try {
|
|
17178
|
-
const binding = require2("@oxc-parser/binding-linux-x64-gnu");
|
|
17179
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-gnu/package.json").version;
|
|
17180
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17181
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17182
|
-
}
|
|
17183
|
-
return binding;
|
|
17184
|
-
} catch (e) {
|
|
17185
|
-
loadErrors.push(e);
|
|
17186
|
-
}
|
|
17187
|
-
}
|
|
17188
|
-
} else if (process.arch === "arm64") {
|
|
17189
|
-
if (isMusl()) {
|
|
17190
|
-
try {
|
|
17191
|
-
return require2("./parser.linux-arm64-musl.node");
|
|
17192
|
-
} catch (e) {
|
|
17193
|
-
loadErrors.push(e);
|
|
17194
|
-
}
|
|
17195
|
-
try {
|
|
17196
|
-
const binding = require2("@oxc-parser/binding-linux-arm64-musl");
|
|
17197
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-musl/package.json").version;
|
|
17198
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17199
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17200
|
-
}
|
|
17201
|
-
return binding;
|
|
17202
|
-
} catch (e) {
|
|
17203
|
-
loadErrors.push(e);
|
|
17204
|
-
}
|
|
17205
|
-
} else {
|
|
17206
|
-
try {
|
|
17207
|
-
return require2("./parser.linux-arm64-gnu.node");
|
|
17208
|
-
} catch (e) {
|
|
17209
|
-
loadErrors.push(e);
|
|
17210
|
-
}
|
|
17211
|
-
try {
|
|
17212
|
-
const binding = require2("@oxc-parser/binding-linux-arm64-gnu");
|
|
17213
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-gnu/package.json").version;
|
|
17214
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17215
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17216
|
-
}
|
|
17217
|
-
return binding;
|
|
17218
|
-
} catch (e) {
|
|
17219
|
-
loadErrors.push(e);
|
|
17220
|
-
}
|
|
17221
|
-
}
|
|
17222
|
-
} else if (process.arch === "arm") {
|
|
17223
|
-
if (isMusl()) {
|
|
17224
|
-
try {
|
|
17225
|
-
return require2("./parser.linux-arm-musleabihf.node");
|
|
17226
|
-
} catch (e) {
|
|
17227
|
-
loadErrors.push(e);
|
|
17228
|
-
}
|
|
17229
|
-
try {
|
|
17230
|
-
const binding = require2("@oxc-parser/binding-linux-arm-musleabihf");
|
|
17231
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-musleabihf/package.json").version;
|
|
17232
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17233
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17234
|
-
}
|
|
17235
|
-
return binding;
|
|
17236
|
-
} catch (e) {
|
|
17237
|
-
loadErrors.push(e);
|
|
17238
|
-
}
|
|
17239
|
-
} else {
|
|
17240
|
-
try {
|
|
17241
|
-
return require2("./parser.linux-arm-gnueabihf.node");
|
|
17242
|
-
} catch (e) {
|
|
17243
|
-
loadErrors.push(e);
|
|
17244
|
-
}
|
|
17245
|
-
try {
|
|
17246
|
-
const binding = require2("@oxc-parser/binding-linux-arm-gnueabihf");
|
|
17247
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-gnueabihf/package.json").version;
|
|
17248
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17249
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17250
|
-
}
|
|
17251
|
-
return binding;
|
|
17252
|
-
} catch (e) {
|
|
17253
|
-
loadErrors.push(e);
|
|
17254
|
-
}
|
|
17255
|
-
}
|
|
17256
|
-
} else if (process.arch === "loong64") {
|
|
17257
|
-
if (isMusl()) {
|
|
17258
|
-
try {
|
|
17259
|
-
return require2("./parser.linux-loong64-musl.node");
|
|
17260
|
-
} catch (e) {
|
|
17261
|
-
loadErrors.push(e);
|
|
17262
|
-
}
|
|
17263
|
-
try {
|
|
17264
|
-
const binding = require2("@oxc-parser/binding-linux-loong64-musl");
|
|
17265
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-musl/package.json").version;
|
|
17266
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17267
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17268
|
-
}
|
|
17269
|
-
return binding;
|
|
17270
|
-
} catch (e) {
|
|
17271
|
-
loadErrors.push(e);
|
|
17272
|
-
}
|
|
17273
|
-
} else {
|
|
17274
|
-
try {
|
|
17275
|
-
return require2("./parser.linux-loong64-gnu.node");
|
|
17276
|
-
} catch (e) {
|
|
17277
|
-
loadErrors.push(e);
|
|
17278
|
-
}
|
|
17279
|
-
try {
|
|
17280
|
-
const binding = require2("@oxc-parser/binding-linux-loong64-gnu");
|
|
17281
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-gnu/package.json").version;
|
|
17282
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17283
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17284
|
-
}
|
|
17285
|
-
return binding;
|
|
17286
|
-
} catch (e) {
|
|
17287
|
-
loadErrors.push(e);
|
|
17288
|
-
}
|
|
17289
|
-
}
|
|
17290
|
-
} else if (process.arch === "riscv64") {
|
|
17291
|
-
if (isMusl()) {
|
|
17292
|
-
try {
|
|
17293
|
-
return require2("./parser.linux-riscv64-musl.node");
|
|
17294
|
-
} catch (e) {
|
|
17295
|
-
loadErrors.push(e);
|
|
17296
|
-
}
|
|
17297
|
-
try {
|
|
17298
|
-
const binding = require2("@oxc-parser/binding-linux-riscv64-musl");
|
|
17299
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-musl/package.json").version;
|
|
17300
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17301
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17302
|
-
}
|
|
17303
|
-
return binding;
|
|
17304
|
-
} catch (e) {
|
|
17305
|
-
loadErrors.push(e);
|
|
17306
|
-
}
|
|
17307
|
-
} else {
|
|
17308
|
-
try {
|
|
17309
|
-
return require2("./parser.linux-riscv64-gnu.node");
|
|
17310
|
-
} catch (e) {
|
|
17311
|
-
loadErrors.push(e);
|
|
17312
|
-
}
|
|
17313
|
-
try {
|
|
17314
|
-
const binding = require2("@oxc-parser/binding-linux-riscv64-gnu");
|
|
17315
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-gnu/package.json").version;
|
|
17316
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17317
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17318
|
-
}
|
|
17319
|
-
return binding;
|
|
17320
|
-
} catch (e) {
|
|
17321
|
-
loadErrors.push(e);
|
|
17322
|
-
}
|
|
17323
|
-
}
|
|
17324
|
-
} else if (process.arch === "ppc64") {
|
|
17325
|
-
try {
|
|
17326
|
-
return require2("./parser.linux-ppc64-gnu.node");
|
|
17327
|
-
} catch (e) {
|
|
17328
|
-
loadErrors.push(e);
|
|
17329
|
-
}
|
|
17330
|
-
try {
|
|
17331
|
-
const binding = require2("@oxc-parser/binding-linux-ppc64-gnu");
|
|
17332
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-ppc64-gnu/package.json").version;
|
|
17333
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17334
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17335
|
-
}
|
|
17336
|
-
return binding;
|
|
17337
|
-
} catch (e) {
|
|
17338
|
-
loadErrors.push(e);
|
|
17339
|
-
}
|
|
17340
|
-
} else if (process.arch === "s390x") {
|
|
17341
|
-
try {
|
|
17342
|
-
return require2("./parser.linux-s390x-gnu.node");
|
|
17343
|
-
} catch (e) {
|
|
17344
|
-
loadErrors.push(e);
|
|
17345
|
-
}
|
|
17346
|
-
try {
|
|
17347
|
-
const binding = require2("@oxc-parser/binding-linux-s390x-gnu");
|
|
17348
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-linux-s390x-gnu/package.json").version;
|
|
17349
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17350
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17351
|
-
}
|
|
17352
|
-
return binding;
|
|
17353
|
-
} catch (e) {
|
|
17354
|
-
loadErrors.push(e);
|
|
17355
|
-
}
|
|
17356
|
-
} else {
|
|
17357
|
-
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
17358
|
-
}
|
|
17359
|
-
} else if (process.platform === "openharmony") {
|
|
17360
|
-
if (process.arch === "arm64") {
|
|
17361
|
-
try {
|
|
17362
|
-
return require2("./parser.openharmony-arm64.node");
|
|
17363
|
-
} catch (e) {
|
|
17364
|
-
loadErrors.push(e);
|
|
17365
|
-
}
|
|
17366
|
-
try {
|
|
17367
|
-
const binding = require2("@oxc-parser/binding-openharmony-arm64");
|
|
17368
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm64/package.json").version;
|
|
17369
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17370
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17371
|
-
}
|
|
17372
|
-
return binding;
|
|
17373
|
-
} catch (e) {
|
|
17374
|
-
loadErrors.push(e);
|
|
17375
|
-
}
|
|
17376
|
-
} else if (process.arch === "x64") {
|
|
17377
|
-
try {
|
|
17378
|
-
return require2("./parser.openharmony-x64.node");
|
|
17379
|
-
} catch (e) {
|
|
17380
|
-
loadErrors.push(e);
|
|
17381
|
-
}
|
|
17382
|
-
try {
|
|
17383
|
-
const binding = require2("@oxc-parser/binding-openharmony-x64");
|
|
17384
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-x64/package.json").version;
|
|
17385
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17386
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17387
|
-
}
|
|
17388
|
-
return binding;
|
|
17389
|
-
} catch (e) {
|
|
17390
|
-
loadErrors.push(e);
|
|
17391
|
-
}
|
|
17392
|
-
} else if (process.arch === "arm") {
|
|
17393
|
-
try {
|
|
17394
|
-
return require2("./parser.openharmony-arm.node");
|
|
17395
|
-
} catch (e) {
|
|
17396
|
-
loadErrors.push(e);
|
|
17397
|
-
}
|
|
17398
|
-
try {
|
|
17399
|
-
const binding = require2("@oxc-parser/binding-openharmony-arm");
|
|
17400
|
-
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm/package.json").version;
|
|
17401
|
-
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
17402
|
-
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
17403
|
-
}
|
|
17404
|
-
return binding;
|
|
17405
|
-
} catch (e) {
|
|
17406
|
-
loadErrors.push(e);
|
|
17407
|
-
}
|
|
17408
|
-
} else {
|
|
17409
|
-
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
|
|
17410
|
-
}
|
|
17411
|
-
} else {
|
|
17412
|
-
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
17413
|
-
}
|
|
17414
|
-
}
|
|
17415
|
-
nativeBinding = requireNative();
|
|
17416
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
17417
|
-
let wasiBinding = null;
|
|
17418
|
-
let wasiBindingError = null;
|
|
17419
|
-
try {
|
|
17420
|
-
wasiBinding = require2("./parser.wasi.cjs");
|
|
17421
|
-
nativeBinding = wasiBinding;
|
|
17422
|
-
} catch (err) {
|
|
17423
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
17424
|
-
wasiBindingError = err;
|
|
17425
|
-
}
|
|
17426
|
-
}
|
|
17427
|
-
if (!nativeBinding) {
|
|
17428
|
-
try {
|
|
17429
|
-
wasiBinding = require2("@oxc-parser/binding-wasm32-wasi");
|
|
17430
|
-
nativeBinding = wasiBinding;
|
|
17431
|
-
} catch (err) {
|
|
17432
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
17433
|
-
wasiBindingError.cause = err;
|
|
17434
|
-
loadErrors.push(err);
|
|
17435
|
-
}
|
|
17436
|
-
}
|
|
17437
|
-
}
|
|
17438
|
-
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
|
|
17439
|
-
const error2 = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
|
|
17440
|
-
error2.cause = wasiBindingError;
|
|
17441
|
-
throw error2;
|
|
17442
|
-
}
|
|
17443
|
-
}
|
|
17444
|
-
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
17445
|
-
try {
|
|
17446
|
-
nativeBinding = require2("./webcontainer-fallback.cjs");
|
|
17447
|
-
} catch (err) {
|
|
17448
|
-
loadErrors.push(err);
|
|
17449
|
-
}
|
|
17450
|
-
}
|
|
17451
|
-
if (!nativeBinding) {
|
|
17452
|
-
if (loadErrors.length > 0) {
|
|
17453
|
-
throw new Error(`Cannot find native binding. ` + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + "Please try `npm i` again after removing both package-lock.json and node_modules directory.", {
|
|
17454
|
-
cause: loadErrors.reduce((err, cur) => {
|
|
17455
|
-
cur.cause = err;
|
|
17456
|
-
return cur;
|
|
17457
|
-
})
|
|
17458
|
-
});
|
|
17459
|
-
}
|
|
17460
|
-
throw new Error(`Failed to load native binding`);
|
|
17461
|
-
}
|
|
17462
|
-
var { Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse: parse3, parseSync, rawTransferSupported } = nativeBinding;
|
|
17463
|
-
|
|
17464
|
-
// node_modules/oxc-parser/src-js/wrap.js
|
|
17465
|
-
function wrap(result) {
|
|
17466
|
-
let program, module3, comments, errors4;
|
|
17467
|
-
return {
|
|
17468
|
-
get program() {
|
|
17469
|
-
if (!program)
|
|
17470
|
-
program = jsonParseAst(result.program);
|
|
17471
|
-
return program;
|
|
17472
|
-
},
|
|
17473
|
-
get module() {
|
|
17474
|
-
if (!module3)
|
|
17475
|
-
module3 = result.module;
|
|
17476
|
-
return module3;
|
|
17477
|
-
},
|
|
17478
|
-
get comments() {
|
|
17479
|
-
if (!comments)
|
|
17480
|
-
comments = result.comments;
|
|
17481
|
-
return comments;
|
|
17482
|
-
},
|
|
17483
|
-
get errors() {
|
|
17484
|
-
if (!errors4)
|
|
17485
|
-
errors4 = result.errors;
|
|
17486
|
-
return errors4;
|
|
17487
|
-
}
|
|
17488
|
-
};
|
|
17489
|
-
}
|
|
17490
|
-
function jsonParseAst(programJson) {
|
|
17491
|
-
const { node: program, fixes } = JSON.parse(programJson);
|
|
17492
|
-
for (const fixPath of fixes) {
|
|
17493
|
-
applyFix(program, fixPath);
|
|
17494
|
-
}
|
|
17495
|
-
return program;
|
|
17496
|
-
}
|
|
17497
|
-
function applyFix(program, fixPath) {
|
|
17498
|
-
let node = program;
|
|
17499
|
-
for (const key of fixPath) {
|
|
17500
|
-
node = node[key];
|
|
17501
|
-
}
|
|
17502
|
-
if (node.bigint) {
|
|
17503
|
-
node.value = BigInt(node.bigint);
|
|
17504
|
-
} else {
|
|
17505
|
-
try {
|
|
17506
|
-
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
17507
|
-
} catch {}
|
|
17508
|
-
}
|
|
17509
|
-
}
|
|
17510
|
-
|
|
17511
|
-
// node_modules/oxc-parser/src-js/generated/visit/keys.js
|
|
17512
|
-
var { freeze } = Object;
|
|
17513
|
-
var $EMPTY = freeze([]);
|
|
17514
|
-
var DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([
|
|
17515
|
-
"decorators",
|
|
17516
|
-
"key",
|
|
17517
|
-
"typeAnnotation",
|
|
17518
|
-
"value"
|
|
17519
|
-
]);
|
|
17520
|
-
var LEFT__RIGHT = freeze(["left", "right"]);
|
|
17521
|
-
var ARGUMENT = freeze(["argument"]);
|
|
17522
|
-
var BODY = freeze(["body"]);
|
|
17523
|
-
var LABEL = freeze(["label"]);
|
|
17524
|
-
var CALLEE__TYPE_ARGUMENTS__ARGUMENTS = freeze(["callee", "typeArguments", "arguments"]);
|
|
17525
|
-
var EXPRESSION = freeze(["expression"]);
|
|
17526
|
-
var DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY = freeze([
|
|
17527
|
-
"decorators",
|
|
17528
|
-
"id",
|
|
17529
|
-
"typeParameters",
|
|
17530
|
-
"superClass",
|
|
17531
|
-
"superTypeArguments",
|
|
17532
|
-
"implements",
|
|
17533
|
-
"body"
|
|
17534
|
-
]);
|
|
17535
|
-
var TEST__CONSEQUENT__ALTERNATE = freeze(["test", "consequent", "alternate"]);
|
|
17536
|
-
var LEFT__RIGHT__BODY = freeze(["left", "right", "body"]);
|
|
17537
|
-
var ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY = freeze([
|
|
17538
|
-
"id",
|
|
17539
|
-
"typeParameters",
|
|
17540
|
-
"params",
|
|
17541
|
-
"returnType",
|
|
17542
|
-
"body"
|
|
17543
|
-
]);
|
|
17544
|
-
var KEY__VALUE = freeze(["key", "value"]);
|
|
17545
|
-
var LOCAL = freeze(["local"]);
|
|
17546
|
-
var OBJECT__PROPERTY = freeze(["object", "property"]);
|
|
17547
|
-
var DECORATORS__KEY__TYPE_ANNOTATION = freeze(["decorators", "key", "typeAnnotation"]);
|
|
17548
|
-
var EXPRESSION__TYPE_ANNOTATION = freeze(["expression", "typeAnnotation"]);
|
|
17549
|
-
var TYPE_PARAMETERS__PARAMS__RETURN_TYPE = freeze(["typeParameters", "params", "returnType"]);
|
|
17550
|
-
var EXPRESSION__TYPE_ARGUMENTS = freeze(["expression", "typeArguments"]);
|
|
17551
|
-
var MEMBERS = freeze(["members"]);
|
|
17552
|
-
var ID__BODY = freeze(["id", "body"]);
|
|
17553
|
-
var TYPES = freeze(["types"]);
|
|
17554
|
-
var TYPE_ANNOTATION = freeze(["typeAnnotation"]);
|
|
17555
|
-
var PARAMS = freeze(["params"]);
|
|
17556
|
-
var keys_default = freeze({
|
|
17557
|
-
DebuggerStatement: $EMPTY,
|
|
17558
|
-
EmptyStatement: $EMPTY,
|
|
17559
|
-
Literal: $EMPTY,
|
|
17560
|
-
PrivateIdentifier: $EMPTY,
|
|
17561
|
-
Super: $EMPTY,
|
|
17562
|
-
TemplateElement: $EMPTY,
|
|
17563
|
-
ThisExpression: $EMPTY,
|
|
17564
|
-
JSXClosingFragment: $EMPTY,
|
|
17565
|
-
JSXEmptyExpression: $EMPTY,
|
|
17566
|
-
JSXIdentifier: $EMPTY,
|
|
17567
|
-
JSXOpeningFragment: $EMPTY,
|
|
17568
|
-
JSXText: $EMPTY,
|
|
17569
|
-
TSAnyKeyword: $EMPTY,
|
|
17570
|
-
TSBigIntKeyword: $EMPTY,
|
|
17571
|
-
TSBooleanKeyword: $EMPTY,
|
|
17572
|
-
TSIntrinsicKeyword: $EMPTY,
|
|
17573
|
-
TSJSDocUnknownType: $EMPTY,
|
|
17574
|
-
TSNeverKeyword: $EMPTY,
|
|
17575
|
-
TSNullKeyword: $EMPTY,
|
|
17576
|
-
TSNumberKeyword: $EMPTY,
|
|
17577
|
-
TSObjectKeyword: $EMPTY,
|
|
17578
|
-
TSStringKeyword: $EMPTY,
|
|
17579
|
-
TSSymbolKeyword: $EMPTY,
|
|
17580
|
-
TSThisType: $EMPTY,
|
|
17581
|
-
TSUndefinedKeyword: $EMPTY,
|
|
17582
|
-
TSUnknownKeyword: $EMPTY,
|
|
17583
|
-
TSVoidKeyword: $EMPTY,
|
|
17584
|
-
AccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
|
|
17585
|
-
ArrayExpression: freeze(["elements"]),
|
|
17586
|
-
ArrayPattern: freeze(["decorators", "elements", "typeAnnotation"]),
|
|
17587
|
-
ArrowFunctionExpression: freeze(["typeParameters", "params", "returnType", "body"]),
|
|
17588
|
-
AssignmentExpression: LEFT__RIGHT,
|
|
17589
|
-
AssignmentPattern: freeze(["decorators", "left", "right", "typeAnnotation"]),
|
|
17590
|
-
AwaitExpression: ARGUMENT,
|
|
17591
|
-
BinaryExpression: LEFT__RIGHT,
|
|
17592
|
-
BlockStatement: BODY,
|
|
17593
|
-
BreakStatement: LABEL,
|
|
17594
|
-
CallExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
|
|
17595
|
-
CatchClause: freeze(["param", "body"]),
|
|
17596
|
-
ChainExpression: EXPRESSION,
|
|
17597
|
-
ClassBody: BODY,
|
|
17598
|
-
ClassDeclaration: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
|
|
17599
|
-
ClassExpression: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
|
|
17600
|
-
ConditionalExpression: TEST__CONSEQUENT__ALTERNATE,
|
|
17601
|
-
ContinueStatement: LABEL,
|
|
17602
|
-
Decorator: EXPRESSION,
|
|
17603
|
-
DoWhileStatement: freeze(["body", "test"]),
|
|
17604
|
-
ExportAllDeclaration: freeze(["exported", "source", "attributes"]),
|
|
17605
|
-
ExportDefaultDeclaration: freeze(["declaration"]),
|
|
17606
|
-
ExportNamedDeclaration: freeze(["declaration", "specifiers", "source", "attributes"]),
|
|
17607
|
-
ExportSpecifier: freeze(["local", "exported"]),
|
|
17608
|
-
ExpressionStatement: EXPRESSION,
|
|
17609
|
-
ForInStatement: LEFT__RIGHT__BODY,
|
|
17610
|
-
ForOfStatement: LEFT__RIGHT__BODY,
|
|
17611
|
-
ForStatement: freeze(["init", "test", "update", "body"]),
|
|
17612
|
-
FunctionDeclaration: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
|
|
17613
|
-
FunctionExpression: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
|
|
17614
|
-
Identifier: freeze(["decorators", "typeAnnotation"]),
|
|
17615
|
-
IfStatement: TEST__CONSEQUENT__ALTERNATE,
|
|
17616
|
-
ImportAttribute: KEY__VALUE,
|
|
17617
|
-
ImportDeclaration: freeze(["specifiers", "source", "attributes"]),
|
|
17618
|
-
ImportDefaultSpecifier: LOCAL,
|
|
17619
|
-
ImportExpression: freeze(["source", "options"]),
|
|
17620
|
-
ImportNamespaceSpecifier: LOCAL,
|
|
17621
|
-
ImportSpecifier: freeze(["imported", "local"]),
|
|
17622
|
-
LabeledStatement: freeze(["label", "body"]),
|
|
17623
|
-
LogicalExpression: LEFT__RIGHT,
|
|
17624
|
-
MemberExpression: OBJECT__PROPERTY,
|
|
17625
|
-
MetaProperty: freeze(["meta", "property"]),
|
|
17626
|
-
MethodDefinition: freeze(["decorators", "key", "value"]),
|
|
17627
|
-
NewExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
|
|
17628
|
-
ObjectExpression: freeze(["properties"]),
|
|
17629
|
-
ObjectPattern: freeze(["decorators", "properties", "typeAnnotation"]),
|
|
17630
|
-
ParenthesizedExpression: EXPRESSION,
|
|
17631
|
-
Program: BODY,
|
|
17632
|
-
Property: KEY__VALUE,
|
|
17633
|
-
PropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
|
|
17634
|
-
RestElement: freeze(["decorators", "argument", "typeAnnotation"]),
|
|
17635
|
-
ReturnStatement: ARGUMENT,
|
|
17636
|
-
SequenceExpression: freeze(["expressions"]),
|
|
17637
|
-
SpreadElement: ARGUMENT,
|
|
17638
|
-
StaticBlock: BODY,
|
|
17639
|
-
SwitchCase: freeze(["test", "consequent"]),
|
|
17640
|
-
SwitchStatement: freeze(["discriminant", "cases"]),
|
|
17641
|
-
TaggedTemplateExpression: freeze(["tag", "typeArguments", "quasi"]),
|
|
17642
|
-
TemplateLiteral: freeze(["quasis", "expressions"]),
|
|
17643
|
-
ThrowStatement: ARGUMENT,
|
|
17644
|
-
TryStatement: freeze(["block", "handler", "finalizer"]),
|
|
17645
|
-
UnaryExpression: ARGUMENT,
|
|
17646
|
-
UpdateExpression: ARGUMENT,
|
|
17647
|
-
V8IntrinsicExpression: freeze(["name", "arguments"]),
|
|
17648
|
-
VariableDeclaration: freeze(["declarations"]),
|
|
17649
|
-
VariableDeclarator: freeze(["id", "init"]),
|
|
17650
|
-
WhileStatement: freeze(["test", "body"]),
|
|
17651
|
-
WithStatement: freeze(["object", "body"]),
|
|
17652
|
-
YieldExpression: ARGUMENT,
|
|
17653
|
-
JSXAttribute: freeze(["name", "value"]),
|
|
17654
|
-
JSXClosingElement: freeze(["name"]),
|
|
17655
|
-
JSXElement: freeze(["openingElement", "children", "closingElement"]),
|
|
17656
|
-
JSXExpressionContainer: EXPRESSION,
|
|
17657
|
-
JSXFragment: freeze(["openingFragment", "children", "closingFragment"]),
|
|
17658
|
-
JSXMemberExpression: OBJECT__PROPERTY,
|
|
17659
|
-
JSXNamespacedName: freeze(["namespace", "name"]),
|
|
17660
|
-
JSXOpeningElement: freeze(["name", "typeArguments", "attributes"]),
|
|
17661
|
-
JSXSpreadAttribute: ARGUMENT,
|
|
17662
|
-
JSXSpreadChild: EXPRESSION,
|
|
17663
|
-
TSAbstractAccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION,
|
|
17664
|
-
TSAbstractMethodDefinition: KEY__VALUE,
|
|
17665
|
-
TSAbstractPropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION,
|
|
17666
|
-
TSArrayType: freeze(["elementType"]),
|
|
17667
|
-
TSAsExpression: EXPRESSION__TYPE_ANNOTATION,
|
|
17668
|
-
TSCallSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
|
|
17669
|
-
TSClassImplements: EXPRESSION__TYPE_ARGUMENTS,
|
|
17670
|
-
TSConditionalType: freeze(["checkType", "extendsType", "trueType", "falseType"]),
|
|
17671
|
-
TSConstructSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
|
|
17672
|
-
TSConstructorType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
|
|
17673
|
-
TSDeclareFunction: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
|
|
17674
|
-
TSEmptyBodyFunctionExpression: freeze(["id", "typeParameters", "params", "returnType"]),
|
|
17675
|
-
TSEnumBody: MEMBERS,
|
|
17676
|
-
TSEnumDeclaration: ID__BODY,
|
|
17677
|
-
TSEnumMember: freeze(["id", "initializer"]),
|
|
17678
|
-
TSExportAssignment: EXPRESSION,
|
|
17679
|
-
TSExternalModuleReference: EXPRESSION,
|
|
17680
|
-
TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
|
|
17681
|
-
TSImportEqualsDeclaration: freeze(["id", "moduleReference"]),
|
|
17682
|
-
TSImportType: freeze(["source", "options", "qualifier", "typeArguments"]),
|
|
17683
|
-
TSIndexSignature: freeze(["parameters", "typeAnnotation"]),
|
|
17684
|
-
TSIndexedAccessType: freeze(["objectType", "indexType"]),
|
|
17685
|
-
TSInferType: freeze(["typeParameter"]),
|
|
17686
|
-
TSInstantiationExpression: EXPRESSION__TYPE_ARGUMENTS,
|
|
17687
|
-
TSInterfaceBody: BODY,
|
|
17688
|
-
TSInterfaceDeclaration: freeze(["id", "typeParameters", "extends", "body"]),
|
|
17689
|
-
TSInterfaceHeritage: EXPRESSION__TYPE_ARGUMENTS,
|
|
17690
|
-
TSIntersectionType: TYPES,
|
|
17691
|
-
TSJSDocNonNullableType: TYPE_ANNOTATION,
|
|
17692
|
-
TSJSDocNullableType: TYPE_ANNOTATION,
|
|
17693
|
-
TSLiteralType: freeze(["literal"]),
|
|
17694
|
-
TSMappedType: freeze(["key", "constraint", "nameType", "typeAnnotation"]),
|
|
17695
|
-
TSMethodSignature: freeze(["key", "typeParameters", "params", "returnType"]),
|
|
17696
|
-
TSModuleBlock: BODY,
|
|
17697
|
-
TSModuleDeclaration: ID__BODY,
|
|
17698
|
-
TSNamedTupleMember: freeze(["label", "elementType"]),
|
|
17699
|
-
TSNamespaceExportDeclaration: freeze(["id"]),
|
|
17700
|
-
TSNonNullExpression: EXPRESSION,
|
|
17701
|
-
TSOptionalType: TYPE_ANNOTATION,
|
|
17702
|
-
TSParameterProperty: freeze(["decorators", "parameter"]),
|
|
17703
|
-
TSParenthesizedType: TYPE_ANNOTATION,
|
|
17704
|
-
TSPropertySignature: freeze(["key", "typeAnnotation"]),
|
|
17705
|
-
TSQualifiedName: LEFT__RIGHT,
|
|
17706
|
-
TSRestType: TYPE_ANNOTATION,
|
|
17707
|
-
TSSatisfiesExpression: EXPRESSION__TYPE_ANNOTATION,
|
|
17708
|
-
TSTemplateLiteralType: freeze(["quasis", "types"]),
|
|
17709
|
-
TSTupleType: freeze(["elementTypes"]),
|
|
17710
|
-
TSTypeAliasDeclaration: freeze(["id", "typeParameters", "typeAnnotation"]),
|
|
17711
|
-
TSTypeAnnotation: TYPE_ANNOTATION,
|
|
17712
|
-
TSTypeAssertion: freeze(["typeAnnotation", "expression"]),
|
|
17713
|
-
TSTypeLiteral: MEMBERS,
|
|
17714
|
-
TSTypeOperator: TYPE_ANNOTATION,
|
|
17715
|
-
TSTypeParameter: freeze(["name", "constraint", "default"]),
|
|
17716
|
-
TSTypeParameterDeclaration: PARAMS,
|
|
17717
|
-
TSTypeParameterInstantiation: PARAMS,
|
|
17718
|
-
TSTypePredicate: freeze(["parameterName", "typeAnnotation"]),
|
|
17719
|
-
TSTypeQuery: freeze(["exprName", "typeArguments"]),
|
|
17720
|
-
TSTypeReference: freeze(["typeName", "typeArguments"]),
|
|
17721
|
-
TSUnionType: TYPES
|
|
17722
|
-
});
|
|
17723
|
-
// node_modules/oxc-parser/src-js/visit/index.js
|
|
17724
|
-
import { createRequire as createRequire3 } from "node:module";
|
|
17725
|
-
var walkProgram = null;
|
|
17726
|
-
var addVisitorToCompiled;
|
|
17727
|
-
var createCompiledVisitor;
|
|
17728
|
-
var finalizeCompiledVisitor;
|
|
17729
|
-
|
|
17730
|
-
class Visitor {
|
|
17731
|
-
#compiledVisitor = null;
|
|
17732
|
-
constructor(visitor) {
|
|
17733
|
-
if (walkProgram === null) {
|
|
17734
|
-
const require3 = createRequire3(import.meta.url);
|
|
17735
|
-
({ walkProgram } = require3("../generated/visit/walk.js"));
|
|
17736
|
-
({
|
|
17737
|
-
addVisitorToCompiled,
|
|
17738
|
-
createCompiledVisitor,
|
|
17739
|
-
finalizeCompiledVisitor
|
|
17740
|
-
} = require3("./visitor.js"));
|
|
17741
|
-
}
|
|
17742
|
-
const compiledVisitor = createCompiledVisitor();
|
|
17743
|
-
addVisitorToCompiled(visitor);
|
|
17744
|
-
const needsVisit = finalizeCompiledVisitor();
|
|
17745
|
-
if (needsVisit)
|
|
17746
|
-
this.#compiledVisitor = compiledVisitor;
|
|
17747
|
-
}
|
|
17748
|
-
visit(program) {
|
|
17749
|
-
const compiledVisitor = this.#compiledVisitor;
|
|
17750
|
-
if (compiledVisitor !== null)
|
|
17751
|
-
walkProgram(program, compiledVisitor);
|
|
17752
|
-
}
|
|
17753
|
-
}
|
|
17754
|
-
|
|
17755
|
-
// node_modules/oxc-parser/src-js/index.js
|
|
17756
|
-
var require3 = createRequire4(import.meta.url);
|
|
17757
|
-
var parseSyncRaw = null;
|
|
17758
|
-
var parseRaw;
|
|
17759
|
-
var parseSyncLazy = null;
|
|
17760
|
-
var parseLazy;
|
|
17761
|
-
var LazyVisitor;
|
|
17762
|
-
function loadRawTransfer() {
|
|
17763
|
-
if (parseSyncRaw === null) {
|
|
17764
|
-
({ parseSyncRaw, parse: parseRaw } = require3("./raw-transfer/eager.js"));
|
|
17765
|
-
}
|
|
17766
|
-
}
|
|
17767
|
-
function loadRawTransferLazy() {
|
|
17768
|
-
if (parseSyncLazy === null) {
|
|
17769
|
-
({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require3("./raw-transfer/lazy.js"));
|
|
17770
|
-
}
|
|
17771
|
-
}
|
|
17772
|
-
function parseSync2(filename, sourceText, options3) {
|
|
17773
|
-
if (options3?.experimentalRawTransfer) {
|
|
17774
|
-
loadRawTransfer();
|
|
17775
|
-
return parseSyncRaw(filename, sourceText, options3);
|
|
17776
|
-
}
|
|
17777
|
-
if (options3?.experimentalLazy) {
|
|
17778
|
-
loadRawTransferLazy();
|
|
17779
|
-
return parseSyncLazy(filename, sourceText, options3);
|
|
17780
|
-
}
|
|
17781
|
-
return wrap(parseSync(filename, sourceText, options3));
|
|
17782
|
-
}
|
|
17783
|
-
|
|
17784
|
-
// src/recognizers/detector.ts
|
|
17785
|
-
function recognize(detector, line) {
|
|
17786
|
-
const matches = detector.scan(line);
|
|
17787
|
-
if (matches === 0)
|
|
17788
|
-
return 0;
|
|
17789
|
-
return 1 - (1 - detector.probability) ** matches;
|
|
17790
|
-
}
|
|
17791
|
-
|
|
17792
|
-
// src/recognizers/code-recognizer.ts
|
|
17793
|
-
var PROBABILITY_THRESHOLD = 0.9;
|
|
17794
|
-
function computeProbability(detectors, line) {
|
|
17795
|
-
let probability = 0;
|
|
17796
|
-
for (const detector of detectors) {
|
|
17797
|
-
const detected = recognize(detector, line);
|
|
17798
|
-
probability = 1 - (1 - probability) * (1 - detected);
|
|
17799
|
-
}
|
|
17800
|
-
return probability;
|
|
17801
|
-
}
|
|
17802
|
-
function isLikelyCode(detectors, line) {
|
|
17803
|
-
return computeProbability(detectors, line) >= PROBABILITY_THRESHOLD;
|
|
17804
|
-
}
|
|
17805
|
-
function hasCodeLines(detectors, lines) {
|
|
17806
|
-
return lines.some((line) => isLikelyCode(detectors, line));
|
|
17807
|
-
}
|
|
17808
|
-
|
|
17809
|
-
// src/recognizers/camel-case-detector.ts
|
|
17810
|
-
function createCamelCaseDetector(probability) {
|
|
17811
|
-
return {
|
|
17812
|
-
probability,
|
|
17813
|
-
scan(line) {
|
|
17814
|
-
for (let index2 = 0;index2 < line.length - 1; index2 += 1) {
|
|
17815
|
-
const current = line.charAt(index2);
|
|
17816
|
-
const next = line.charAt(index2 + 1);
|
|
17817
|
-
if (current === current.toLowerCase() && next === next.toUpperCase() && next !== next.toLowerCase()) {
|
|
17818
|
-
return 1;
|
|
17819
|
-
}
|
|
17820
|
-
}
|
|
17821
|
-
return 0;
|
|
17822
|
-
}
|
|
17823
|
-
};
|
|
17824
|
-
}
|
|
17825
|
-
|
|
17826
|
-
// src/recognizers/contains-detector.ts
|
|
17827
|
-
var WHITESPACE_GLOBAL_REGEX = regex2("\\s+", "g");
|
|
17828
|
-
var ESCAPE = regex2("[-/\\^$*+?.()|[\\]{}]", "g");
|
|
17829
|
-
function escapeForRegex(value) {
|
|
17830
|
-
return value.replaceAll(ESCAPE, String.raw`\$&`);
|
|
17831
|
-
}
|
|
17832
|
-
function createContainsDetector(probability, patterns2) {
|
|
17833
|
-
const compiledPatterns = patterns2.map((pattern4) => typeof pattern4 === "string" ? new RegExp(escapeForRegex(pattern4), "g") : new RegExp(pattern4.source, "g"));
|
|
17834
|
-
return {
|
|
17835
|
-
probability,
|
|
17836
|
-
scan(line) {
|
|
17837
|
-
const compressed = line.replace(WHITESPACE_GLOBAL_REGEX, "");
|
|
17838
|
-
let total = 0;
|
|
17839
|
-
for (const pattern4 of compiledPatterns) {
|
|
17840
|
-
pattern4.lastIndex = 0;
|
|
17841
|
-
const matches = compressed.match(pattern4);
|
|
17842
|
-
if (matches)
|
|
17843
|
-
total += matches.length;
|
|
17718
|
+
return 0;
|
|
17719
|
+
}
|
|
17720
|
+
};
|
|
17721
|
+
}
|
|
17722
|
+
|
|
17723
|
+
// src/recognizers/contains-detector.ts
|
|
17724
|
+
var WHITESPACE_GLOBAL_REGEX = regex2("\\s+", "g");
|
|
17725
|
+
var ESCAPE = regex2("[-/\\^$*+?.()|[\\]{}]", "g");
|
|
17726
|
+
function escapeForRegex(value) {
|
|
17727
|
+
return value.replaceAll(ESCAPE, String.raw`\$&`);
|
|
17728
|
+
}
|
|
17729
|
+
function createContainsDetector(probability, patterns2) {
|
|
17730
|
+
const compiledPatterns = patterns2.map((pattern4) => typeof pattern4 === "string" ? new RegExp(escapeForRegex(pattern4), "g") : new RegExp(pattern4.source, "g"));
|
|
17731
|
+
return {
|
|
17732
|
+
probability,
|
|
17733
|
+
scan(line) {
|
|
17734
|
+
const compressed = line.replace(WHITESPACE_GLOBAL_REGEX, "");
|
|
17735
|
+
let total = 0;
|
|
17736
|
+
for (const pattern4 of compiledPatterns) {
|
|
17737
|
+
pattern4.lastIndex = 0;
|
|
17738
|
+
const matches = compressed.match(pattern4);
|
|
17739
|
+
if (matches)
|
|
17740
|
+
total += matches.length;
|
|
17844
17741
|
}
|
|
17845
17742
|
return total;
|
|
17846
17743
|
}
|
|
@@ -18099,11 +17996,11 @@ function isValidParseResult(result) {
|
|
|
18099
17996
|
function tryParse(value, filename) {
|
|
18100
17997
|
const ext = path.extname(filename);
|
|
18101
17998
|
const parseFilename = `file${ext || ".js"}`;
|
|
18102
|
-
const result =
|
|
17999
|
+
const result = parseSync(parseFilename, value);
|
|
18103
18000
|
if (isValidParseResult(result))
|
|
18104
18001
|
return result;
|
|
18105
18002
|
if (ext !== ".tsx" && ext !== ".jsx") {
|
|
18106
|
-
const jsxResult =
|
|
18003
|
+
const jsxResult = parseSync("file.tsx", value);
|
|
18107
18004
|
if (isValidParseResult(jsxResult))
|
|
18108
18005
|
return jsxResult;
|
|
18109
18006
|
}
|
|
@@ -18112,15 +18009,11 @@ function tryParse(value, filename) {
|
|
|
18112
18009
|
function containsCode(value, filename) {
|
|
18113
18010
|
if (!couldBeJsCode(value))
|
|
18114
18011
|
return false;
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
if (!result)
|
|
18118
|
-
return false;
|
|
18119
|
-
const statements = toParsedStatements(result.program.body);
|
|
18120
|
-
return !isExclusion(statements, value);
|
|
18121
|
-
} catch {
|
|
18012
|
+
const result = tryParse(value, filename);
|
|
18013
|
+
if (!result)
|
|
18122
18014
|
return false;
|
|
18123
|
-
|
|
18015
|
+
const statements = toParsedStatements(result.program.body);
|
|
18016
|
+
return !isExclusion(statements, value);
|
|
18124
18017
|
}
|
|
18125
18018
|
var noCommentedCode = {
|
|
18126
18019
|
create(context) {
|
|
@@ -18181,24 +18074,17 @@ var FUNCTION_BOUNDARIES = new Set([
|
|
|
18181
18074
|
TSESTree5.AST_NODE_TYPES.FunctionExpression,
|
|
18182
18075
|
TSESTree5.AST_NODE_TYPES.ArrowFunctionExpression
|
|
18183
18076
|
]);
|
|
18184
|
-
var RUNTIME_TS_WRAPPERS = new Set([
|
|
18185
|
-
"ParenthesizedExpression",
|
|
18186
|
-
"TSAsExpression",
|
|
18187
|
-
"TSSatisfiesExpression",
|
|
18188
|
-
"TSTypeAssertion",
|
|
18189
|
-
"TSNonNullExpression",
|
|
18190
|
-
"TSInstantiationExpression",
|
|
18191
|
-
"ChainExpression"
|
|
18192
|
-
]);
|
|
18193
18077
|
function isComponentName(name) {
|
|
18194
18078
|
return COMPONENT_NAME_PATTERN.test(name);
|
|
18195
18079
|
}
|
|
18196
18080
|
function isReactComponentHOC(callExpr) {
|
|
18197
18081
|
const { callee } = callExpr;
|
|
18198
|
-
if (callee.type === TSESTree5.AST_NODE_TYPES.Identifier)
|
|
18082
|
+
if (callee.type === TSESTree5.AST_NODE_TYPES.Identifier) {
|
|
18199
18083
|
return callee.name === "forwardRef" || callee.name === "memo";
|
|
18200
|
-
|
|
18084
|
+
}
|
|
18085
|
+
if (callee.type === TSESTree5.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree5.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree5.AST_NODE_TYPES.Identifier) {
|
|
18201
18086
|
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
18087
|
+
}
|
|
18202
18088
|
return false;
|
|
18203
18089
|
}
|
|
18204
18090
|
function getComponentNameFromFunction(node) {
|
|
@@ -18231,13 +18117,14 @@ function getComponentNameFromCallParent(callExpr) {
|
|
|
18231
18117
|
if (parent.type === TSESTree5.AST_NODE_TYPES.AssignmentExpression && parent.left.type === TSESTree5.AST_NODE_TYPES.Identifier && isComponentName(parent.left.name)) {
|
|
18232
18118
|
return parent.left.name;
|
|
18233
18119
|
}
|
|
18120
|
+
let nameFromExportDefault;
|
|
18234
18121
|
if (parent.type === TSESTree5.AST_NODE_TYPES.ExportDefaultDeclaration && callExpr.arguments.length > 0) {
|
|
18235
18122
|
const [firstArg] = callExpr.arguments;
|
|
18236
18123
|
if (firstArg && firstArg.type === TSESTree5.AST_NODE_TYPES.FunctionExpression && firstArg.id && isComponentName(firstArg.id.name)) {
|
|
18237
|
-
|
|
18124
|
+
nameFromExportDefault = firstArg.id.name;
|
|
18238
18125
|
}
|
|
18239
18126
|
}
|
|
18240
|
-
return;
|
|
18127
|
+
return nameFromExportDefault;
|
|
18241
18128
|
}
|
|
18242
18129
|
function getHookName(callExpression) {
|
|
18243
18130
|
const { callee } = callExpression;
|
|
@@ -18270,11 +18157,7 @@ function isTypeOnlyNullLiteral(node) {
|
|
|
18270
18157
|
const { parent } = node;
|
|
18271
18158
|
if (parent === null || parent === undefined)
|
|
18272
18159
|
return false;
|
|
18273
|
-
|
|
18274
|
-
return true;
|
|
18275
|
-
if (parent.type === TSESTree5.AST_NODE_TYPES.TSLiteralType)
|
|
18276
|
-
return true;
|
|
18277
|
-
return false;
|
|
18160
|
+
return parent.type === TSESTree5.AST_NODE_TYPES.TSLiteralType;
|
|
18278
18161
|
}
|
|
18279
18162
|
function analyzeComponentBody(functionNode, sourceCode, stateHooks) {
|
|
18280
18163
|
let maxJsxDepth = 0;
|
|
@@ -18300,14 +18183,10 @@ function analyzeComponentBody(functionNode, sourceCode, stateHooks) {
|
|
|
18300
18183
|
nullLiterals.push(literalNode);
|
|
18301
18184
|
}
|
|
18302
18185
|
function getVisitorKeysForNodeType(nodeType) {
|
|
18303
|
-
const visitorKeysUnknown = sourceCode.visitorKeys;
|
|
18304
|
-
if (visitorKeysUnknown === null || visitorKeysUnknown === undefined || typeof visitorKeysUnknown !== "object")
|
|
18305
|
-
return [];
|
|
18306
|
-
const visitorKeysRecord = visitorKeysUnknown;
|
|
18307
|
-
const keysUnknown = visitorKeysRecord[nodeType];
|
|
18308
|
-
if (!Array.isArray(keysUnknown))
|
|
18309
|
-
return [];
|
|
18310
18186
|
const keys3 = new Array;
|
|
18187
|
+
const keysUnknown = sourceCode.visitorKeys[nodeType];
|
|
18188
|
+
if (!Array.isArray(keysUnknown))
|
|
18189
|
+
return keys3;
|
|
18311
18190
|
for (const key of keysUnknown)
|
|
18312
18191
|
if (typeof key === "string")
|
|
18313
18192
|
keys3.push(key);
|
|
@@ -18319,9 +18198,10 @@ function analyzeComponentBody(functionNode, sourceCode, stateHooks) {
|
|
|
18319
18198
|
const value = currentRecord[key];
|
|
18320
18199
|
if (Array.isArray(value)) {
|
|
18321
18200
|
for (const item of value) {
|
|
18322
|
-
if (typeof item
|
|
18201
|
+
if (typeof item !== "object" || item === null)
|
|
18202
|
+
continue;
|
|
18203
|
+
if ("type" in item)
|
|
18323
18204
|
visit(item, nextDepth);
|
|
18324
|
-
}
|
|
18325
18205
|
}
|
|
18326
18206
|
continue;
|
|
18327
18207
|
}
|
|
@@ -18548,41 +18428,35 @@ function isBlockReturningIdentity(body, paramName) {
|
|
|
18548
18428
|
return statement.argument.name === paramName;
|
|
18549
18429
|
}
|
|
18550
18430
|
function isIdentityCallback(callback) {
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
|
|
18563
|
-
if (callback.body.type === AST_NODE_TYPES2.BlockStatement) {
|
|
18564
|
-
return isBlockReturningIdentity(callback.body, paramName);
|
|
18431
|
+
let isIdentity = false;
|
|
18432
|
+
if (callback.type === AST_NODE_TYPES2.ArrowFunctionExpression && callback.params.length === 1) {
|
|
18433
|
+
const [parameter2] = callback.params;
|
|
18434
|
+
if (parameter2 !== undefined) {
|
|
18435
|
+
const name = getParameterName(parameter2);
|
|
18436
|
+
if (name !== undefined) {
|
|
18437
|
+
const { body } = callback;
|
|
18438
|
+
if (body.type === AST_NODE_TYPES2.Identifier)
|
|
18439
|
+
isIdentity = body.name === name;
|
|
18440
|
+
if (body.type === AST_NODE_TYPES2.BlockStatement)
|
|
18441
|
+
isIdentity = isBlockReturningIdentity(body, name);
|
|
18442
|
+
}
|
|
18565
18443
|
}
|
|
18566
|
-
return false;
|
|
18567
18444
|
}
|
|
18568
|
-
if (callback.type === AST_NODE_TYPES2.FunctionExpression) {
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
18572
|
-
|
|
18573
|
-
|
|
18574
|
-
|
|
18575
|
-
if (paramName === undefined || paramName === "")
|
|
18576
|
-
return false;
|
|
18577
|
-
return isBlockReturningIdentity(callback.body, paramName);
|
|
18445
|
+
if (callback.type === AST_NODE_TYPES2.FunctionExpression && callback.params.length === 1) {
|
|
18446
|
+
const [parameter2] = callback.params;
|
|
18447
|
+
if (parameter2 !== undefined) {
|
|
18448
|
+
const name = getParameterName(parameter2);
|
|
18449
|
+
if (name !== undefined)
|
|
18450
|
+
isIdentity = isBlockReturningIdentity(callback.body, name);
|
|
18451
|
+
}
|
|
18578
18452
|
}
|
|
18579
|
-
return
|
|
18453
|
+
return isIdentity;
|
|
18580
18454
|
}
|
|
18581
18455
|
function findVariable(context, identifier3) {
|
|
18582
18456
|
let scope = context.sourceCode.getScope(identifier3);
|
|
18583
18457
|
while (scope) {
|
|
18584
18458
|
const variable = scope.set.get(identifier3.name);
|
|
18585
|
-
if (variable)
|
|
18459
|
+
if (variable !== undefined)
|
|
18586
18460
|
return variable;
|
|
18587
18461
|
scope = scope.upper ?? undefined;
|
|
18588
18462
|
}
|
|
@@ -18590,9 +18464,8 @@ function findVariable(context, identifier3) {
|
|
|
18590
18464
|
}
|
|
18591
18465
|
function getHookName2(node) {
|
|
18592
18466
|
const { callee } = node;
|
|
18593
|
-
if (callee.type === AST_NODE_TYPES2.Identifier)
|
|
18467
|
+
if (callee.type === AST_NODE_TYPES2.Identifier)
|
|
18594
18468
|
return callee.name;
|
|
18595
|
-
}
|
|
18596
18469
|
if (callee.type === AST_NODE_TYPES2.MemberExpression && callee.property.type === AST_NODE_TYPES2.Identifier) {
|
|
18597
18470
|
return callee.property.name;
|
|
18598
18471
|
}
|
|
@@ -18600,9 +18473,8 @@ function getHookName2(node) {
|
|
|
18600
18473
|
}
|
|
18601
18474
|
function isJoinBindingsCall(node) {
|
|
18602
18475
|
const { callee } = node;
|
|
18603
|
-
if (callee.type === AST_NODE_TYPES2.Identifier)
|
|
18476
|
+
if (callee.type === AST_NODE_TYPES2.Identifier)
|
|
18604
18477
|
return callee.name === "joinBindings";
|
|
18605
|
-
}
|
|
18606
18478
|
if (callee.type === AST_NODE_TYPES2.MemberExpression && callee.property.type === AST_NODE_TYPES2.Identifier) {
|
|
18607
18479
|
return callee.property.name === "joinBindings";
|
|
18608
18480
|
}
|
|
@@ -18616,9 +18488,7 @@ function isBindingInitialization(variable) {
|
|
|
18616
18488
|
if (!init || init.type !== AST_NODE_TYPES2.CallExpression)
|
|
18617
18489
|
continue;
|
|
18618
18490
|
const hookName = getHookName2(init);
|
|
18619
|
-
if (hookName === "useBinding")
|
|
18620
|
-
return true;
|
|
18621
|
-
if (isJoinBindingsCall(init))
|
|
18491
|
+
if (hookName === "useBinding" || isJoinBindingsCall(init))
|
|
18622
18492
|
return true;
|
|
18623
18493
|
if (init.callee.type === AST_NODE_TYPES2.MemberExpression && init.callee.property.type === AST_NODE_TYPES2.Identifier && init.callee.property.name === "map") {
|
|
18624
18494
|
return true;
|
|
@@ -18630,26 +18500,21 @@ function isLikelyBinding(context, callee, patterns2) {
|
|
|
18630
18500
|
const { object: object3 } = callee;
|
|
18631
18501
|
if (object3.type === AST_NODE_TYPES2.Identifier) {
|
|
18632
18502
|
const lowerName = object3.name.toLowerCase();
|
|
18633
|
-
for (const pattern4 of patterns2)
|
|
18503
|
+
for (const pattern4 of patterns2)
|
|
18634
18504
|
if (lowerName.includes(pattern4.toLowerCase()))
|
|
18635
18505
|
return true;
|
|
18636
|
-
}
|
|
18637
18506
|
const variable = findVariable(context, object3);
|
|
18638
|
-
if (variable && isBindingInitialization(variable))
|
|
18507
|
+
if (variable !== undefined && isBindingInitialization(variable))
|
|
18639
18508
|
return true;
|
|
18640
18509
|
}
|
|
18641
18510
|
if (object3.type === AST_NODE_TYPES2.CallExpression && object3.callee.type === AST_NODE_TYPES2.MemberExpression && object3.callee.property.type === AST_NODE_TYPES2.Identifier && object3.callee.property.name === "map") {
|
|
18642
18511
|
return true;
|
|
18643
18512
|
}
|
|
18644
|
-
|
|
18645
|
-
return true;
|
|
18646
|
-
}
|
|
18647
|
-
return false;
|
|
18513
|
+
return object3.type === AST_NODE_TYPES2.CallExpression && isJoinBindingsCall(object3);
|
|
18648
18514
|
}
|
|
18649
18515
|
var noIdentityMap = {
|
|
18650
18516
|
create(context) {
|
|
18651
|
-
const [
|
|
18652
|
-
const patterns2 = rawOptions?.bindingPatterns ?? DEFAULT_BINDING_PATTERNS;
|
|
18517
|
+
const [{ bindingPatterns = DEFAULT_BINDING_PATTERNS } = {}] = context.options;
|
|
18653
18518
|
return {
|
|
18654
18519
|
CallExpression(node) {
|
|
18655
18520
|
const { callee } = node;
|
|
@@ -18668,7 +18533,7 @@ var noIdentityMap = {
|
|
|
18668
18533
|
return;
|
|
18669
18534
|
if (!isIdentityCallback(callback))
|
|
18670
18535
|
return;
|
|
18671
|
-
const isBinding = isLikelyBinding(context, callee,
|
|
18536
|
+
const isBinding = isLikelyBinding(context, callee, bindingPatterns);
|
|
18672
18537
|
context.report({
|
|
18673
18538
|
fix(fixer) {
|
|
18674
18539
|
const objectText = context.sourceCode.getText(callee.object);
|
|
@@ -19396,31 +19261,226 @@ var noUselessUseSpring = {
|
|
|
19396
19261
|
defaultOptions: [DEFAULT_OPTION_VALUES],
|
|
19397
19262
|
meta: {
|
|
19398
19263
|
docs: {
|
|
19399
|
-
description: "Disallow useSpring hooks whose config and dependencies are entirely static"
|
|
19264
|
+
description: "Disallow useSpring hooks whose config and dependencies are entirely static"
|
|
19265
|
+
},
|
|
19266
|
+
messages: {
|
|
19267
|
+
uselessSpring: "useSpring call has only static inputs and non-updating dependencies; replace it with a constant or remove the hook."
|
|
19268
|
+
},
|
|
19269
|
+
schema: [
|
|
19270
|
+
{
|
|
19271
|
+
additionalProperties: false,
|
|
19272
|
+
properties: {
|
|
19273
|
+
springHooks: {
|
|
19274
|
+
description: "Hook identifiers that should be treated as spring hooks",
|
|
19275
|
+
items: { type: "string" },
|
|
19276
|
+
type: "array"
|
|
19277
|
+
},
|
|
19278
|
+
staticGlobalFactories: {
|
|
19279
|
+
default: [...DEFAULT_STATIC_GLOBAL_FACTORIES],
|
|
19280
|
+
description: "Global factory identifiers that are treated as static constructors",
|
|
19281
|
+
items: { type: "string" },
|
|
19282
|
+
type: "array"
|
|
19283
|
+
},
|
|
19284
|
+
treatEmptyDepsAsViolation: {
|
|
19285
|
+
default: true,
|
|
19286
|
+
description: "Treat static config with an empty dependency array as a violation",
|
|
19287
|
+
type: "boolean"
|
|
19288
|
+
}
|
|
19289
|
+
},
|
|
19290
|
+
type: "object"
|
|
19291
|
+
}
|
|
19292
|
+
],
|
|
19293
|
+
type: "suggestion"
|
|
19294
|
+
}
|
|
19295
|
+
};
|
|
19296
|
+
var no_useless_use_spring_default = noUselessUseSpring;
|
|
19297
|
+
|
|
19298
|
+
// src/rules/no-warn.ts
|
|
19299
|
+
var noWarn = {
|
|
19300
|
+
create(context) {
|
|
19301
|
+
return {
|
|
19302
|
+
'CallExpression[callee.type="Identifier"][callee.name="warn"]'(node) {
|
|
19303
|
+
context.report({
|
|
19304
|
+
messageId: "useLog",
|
|
19305
|
+
node
|
|
19306
|
+
});
|
|
19307
|
+
}
|
|
19308
|
+
};
|
|
19309
|
+
},
|
|
19310
|
+
meta: {
|
|
19311
|
+
docs: {
|
|
19312
|
+
description: "Ban warn() function calls. Use Log instead.",
|
|
19313
|
+
recommended: false
|
|
19314
|
+
},
|
|
19315
|
+
messages: {
|
|
19316
|
+
useLog: "Use Log instead of warn()"
|
|
19317
|
+
},
|
|
19318
|
+
schema: [],
|
|
19319
|
+
type: "problem"
|
|
19320
|
+
}
|
|
19321
|
+
};
|
|
19322
|
+
var no_warn_default = noWarn;
|
|
19323
|
+
|
|
19324
|
+
// src/rules/prefer-class-properties.ts
|
|
19325
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES5 } from "@typescript-eslint/utils";
|
|
19326
|
+
function isExpression(node) {
|
|
19327
|
+
return node.type !== AST_NODE_TYPES5.AssignmentPattern && node.type !== AST_NODE_TYPES5.TSEmptyBodyFunctionExpression;
|
|
19328
|
+
}
|
|
19329
|
+
function isSimpleLiteralProperty({ computed, value }) {
|
|
19330
|
+
return !computed && isExpression(value) && isSimpleLiteral(value);
|
|
19331
|
+
}
|
|
19332
|
+
function isSimpleLiteral(node) {
|
|
19333
|
+
if (!node)
|
|
19334
|
+
return false;
|
|
19335
|
+
switch (node.type) {
|
|
19336
|
+
case AST_NODE_TYPES5.Literal:
|
|
19337
|
+
return true;
|
|
19338
|
+
case AST_NODE_TYPES5.MemberExpression:
|
|
19339
|
+
return isSimpleLiteral(node.object);
|
|
19340
|
+
case AST_NODE_TYPES5.CallExpression:
|
|
19341
|
+
return node.callee.type === AST_NODE_TYPES5.MemberExpression && isSimpleLiteral(node.callee.object);
|
|
19342
|
+
case AST_NODE_TYPES5.ArrayExpression:
|
|
19343
|
+
return node.elements.every((element) => {
|
|
19344
|
+
if (element === null)
|
|
19345
|
+
return true;
|
|
19346
|
+
if (element.type === AST_NODE_TYPES5.SpreadElement)
|
|
19347
|
+
return false;
|
|
19348
|
+
return isSimpleLiteral(element);
|
|
19349
|
+
});
|
|
19350
|
+
case AST_NODE_TYPES5.ObjectExpression:
|
|
19351
|
+
return node.properties.every((property) => property.type === AST_NODE_TYPES5.SpreadElement || property.type !== AST_NODE_TYPES5.Property ? false : isSimpleLiteralProperty(property));
|
|
19352
|
+
default:
|
|
19353
|
+
return false;
|
|
19354
|
+
}
|
|
19355
|
+
}
|
|
19356
|
+
function isStaticMemberExpression(node) {
|
|
19357
|
+
let current = node;
|
|
19358
|
+
while (current.type === AST_NODE_TYPES5.MemberExpression) {
|
|
19359
|
+
if (current.computed && current.property.type !== AST_NODE_TYPES5.Literal)
|
|
19360
|
+
return false;
|
|
19361
|
+
current = current.object;
|
|
19362
|
+
}
|
|
19363
|
+
return true;
|
|
19364
|
+
}
|
|
19365
|
+
function isConstructor(node) {
|
|
19366
|
+
return node.type === AST_NODE_TYPES5.MethodDefinition && node.kind === "constructor" && node.key.type === AST_NODE_TYPES5.Identifier && node.key.name === "constructor";
|
|
19367
|
+
}
|
|
19368
|
+
var preferClassProperties = {
|
|
19369
|
+
create(context) {
|
|
19370
|
+
const option = context.options[0] ?? "always";
|
|
19371
|
+
if (option === "never") {
|
|
19372
|
+
return {
|
|
19373
|
+
PropertyDefinition(node) {
|
|
19374
|
+
if (node.static)
|
|
19375
|
+
return;
|
|
19376
|
+
context.report({
|
|
19377
|
+
messageId: "unexpectedClassProperty",
|
|
19378
|
+
node
|
|
19379
|
+
});
|
|
19380
|
+
}
|
|
19381
|
+
};
|
|
19382
|
+
}
|
|
19383
|
+
return {
|
|
19384
|
+
ClassDeclaration(node) {
|
|
19385
|
+
checkClass(node.body);
|
|
19386
|
+
},
|
|
19387
|
+
ClassExpression(node) {
|
|
19388
|
+
checkClass(node.body);
|
|
19389
|
+
}
|
|
19390
|
+
};
|
|
19391
|
+
function checkClass(body) {
|
|
19392
|
+
for (const member of body.body) {
|
|
19393
|
+
if (!isConstructor(member))
|
|
19394
|
+
continue;
|
|
19395
|
+
if (member.type !== AST_NODE_TYPES5.MethodDefinition)
|
|
19396
|
+
continue;
|
|
19397
|
+
if (!member.value || member.value.type !== AST_NODE_TYPES5.FunctionExpression)
|
|
19398
|
+
continue;
|
|
19399
|
+
for (const statement of member.value.body.body) {
|
|
19400
|
+
if (statement.type !== AST_NODE_TYPES5.ExpressionStatement)
|
|
19401
|
+
continue;
|
|
19402
|
+
const { expression } = statement;
|
|
19403
|
+
if (expression.type !== AST_NODE_TYPES5.AssignmentExpression)
|
|
19404
|
+
continue;
|
|
19405
|
+
if (expression.left.type !== AST_NODE_TYPES5.MemberExpression)
|
|
19406
|
+
continue;
|
|
19407
|
+
if (expression.left.object.type !== AST_NODE_TYPES5.ThisExpression)
|
|
19408
|
+
continue;
|
|
19409
|
+
if ((expression.left.property.type === AST_NODE_TYPES5.Identifier || expression.left.property.type === AST_NODE_TYPES5.Literal) && isSimpleLiteral(expression.right) && isStaticMemberExpression(expression.left)) {
|
|
19410
|
+
context.report({
|
|
19411
|
+
messageId: "unexpectedAssignment",
|
|
19412
|
+
node: expression
|
|
19413
|
+
});
|
|
19414
|
+
}
|
|
19415
|
+
}
|
|
19416
|
+
}
|
|
19417
|
+
}
|
|
19418
|
+
},
|
|
19419
|
+
defaultOptions: ["always"],
|
|
19420
|
+
meta: {
|
|
19421
|
+
docs: {
|
|
19422
|
+
description: "Prefer class properties to assignment of literals in constructors."
|
|
19423
|
+
},
|
|
19424
|
+
messages: {
|
|
19425
|
+
unexpectedAssignment: "Unexpected assignment of literal instance member.",
|
|
19426
|
+
unexpectedClassProperty: "Unexpected class property."
|
|
19427
|
+
},
|
|
19428
|
+
schema: [{ enum: ["always", "never"], type: "string" }],
|
|
19429
|
+
type: "suggestion"
|
|
19430
|
+
}
|
|
19431
|
+
};
|
|
19432
|
+
var prefer_class_properties_default = preferClassProperties;
|
|
19433
|
+
|
|
19434
|
+
// src/rules/prefer-early-return.ts
|
|
19435
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
|
|
19436
|
+
var DEFAULT_MAXIMUM_STATEMENTS = 1;
|
|
19437
|
+
function isLonelyIfStatement(statement) {
|
|
19438
|
+
return statement.alternate === null;
|
|
19439
|
+
}
|
|
19440
|
+
function isOffendingConsequent(consequent, maxStatements) {
|
|
19441
|
+
return consequent.type === AST_NODE_TYPES6.ExpressionStatement && maxStatements === 0 || consequent.type === AST_NODE_TYPES6.BlockStatement && consequent.body.length > maxStatements;
|
|
19442
|
+
}
|
|
19443
|
+
function canSimplifyConditionalBody(body, maxStatements) {
|
|
19444
|
+
if (body.body.length !== 1)
|
|
19445
|
+
return false;
|
|
19446
|
+
const [statement] = body.body;
|
|
19447
|
+
if (statement === undefined || statement.type !== AST_NODE_TYPES6.IfStatement || !isLonelyIfStatement(statement)) {
|
|
19448
|
+
return false;
|
|
19449
|
+
}
|
|
19450
|
+
return isOffendingConsequent(statement.consequent, maxStatements);
|
|
19451
|
+
}
|
|
19452
|
+
var preferEarlyReturn = {
|
|
19453
|
+
create(context) {
|
|
19454
|
+
const options3 = context.options[0] ?? {};
|
|
19455
|
+
const maxStatements = options3.maximumStatements ?? DEFAULT_MAXIMUM_STATEMENTS;
|
|
19456
|
+
function checkFunctionBody(node) {
|
|
19457
|
+
const { body } = node;
|
|
19458
|
+
if (body.type !== AST_NODE_TYPES6.BlockStatement || !canSimplifyConditionalBody(body, maxStatements))
|
|
19459
|
+
return;
|
|
19460
|
+
context.report({
|
|
19461
|
+
messageId: "preferEarlyReturn",
|
|
19462
|
+
node: body
|
|
19463
|
+
});
|
|
19464
|
+
}
|
|
19465
|
+
return {
|
|
19466
|
+
ArrowFunctionExpression: checkFunctionBody,
|
|
19467
|
+
FunctionDeclaration: checkFunctionBody,
|
|
19468
|
+
FunctionExpression: checkFunctionBody
|
|
19469
|
+
};
|
|
19470
|
+
},
|
|
19471
|
+
defaultOptions: [{}],
|
|
19472
|
+
meta: {
|
|
19473
|
+
docs: {
|
|
19474
|
+
description: "Prefer early returns over full-body conditional wrapping in function declarations."
|
|
19400
19475
|
},
|
|
19401
19476
|
messages: {
|
|
19402
|
-
|
|
19477
|
+
preferEarlyReturn: "Prefer an early return to a conditionally-wrapped function body"
|
|
19403
19478
|
},
|
|
19404
19479
|
schema: [
|
|
19405
19480
|
{
|
|
19406
19481
|
additionalProperties: false,
|
|
19407
19482
|
properties: {
|
|
19408
|
-
|
|
19409
|
-
description: "Hook identifiers that should be treated as spring hooks",
|
|
19410
|
-
items: { type: "string" },
|
|
19411
|
-
type: "array"
|
|
19412
|
-
},
|
|
19413
|
-
staticGlobalFactories: {
|
|
19414
|
-
default: [...DEFAULT_STATIC_GLOBAL_FACTORIES],
|
|
19415
|
-
description: "Global factory identifiers that are treated as static constructors",
|
|
19416
|
-
items: { type: "string" },
|
|
19417
|
-
type: "array"
|
|
19418
|
-
},
|
|
19419
|
-
treatEmptyDepsAsViolation: {
|
|
19420
|
-
default: true,
|
|
19421
|
-
description: "Treat static config with an empty dependency array as a violation",
|
|
19422
|
-
type: "boolean"
|
|
19423
|
-
}
|
|
19483
|
+
maximumStatements: { type: "integer" }
|
|
19424
19484
|
},
|
|
19425
19485
|
type: "object"
|
|
19426
19486
|
}
|
|
@@ -19428,42 +19488,162 @@ var noUselessUseSpring = {
|
|
|
19428
19488
|
type: "suggestion"
|
|
19429
19489
|
}
|
|
19430
19490
|
};
|
|
19431
|
-
var
|
|
19432
|
-
|
|
19433
|
-
// src/rules/
|
|
19434
|
-
var
|
|
19491
|
+
var prefer_early_return_default = preferEarlyReturn;
|
|
19492
|
+
|
|
19493
|
+
// src/rules/prefer-module-scope-constants.ts
|
|
19494
|
+
var import_scope_manager3 = __toESM(require_dist2(), 1);
|
|
19495
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES7 } from "@typescript-eslint/utils";
|
|
19496
|
+
var SCREAMING_SNAKE_CASE = /^[A-Z][A-Z0-9_]*$/;
|
|
19497
|
+
function isTopScope(scope) {
|
|
19498
|
+
const { type: type3 } = scope;
|
|
19499
|
+
if (type3 === import_scope_manager3.ScopeType.module || type3 === import_scope_manager3.ScopeType.global)
|
|
19500
|
+
return true;
|
|
19501
|
+
if (scope.upper?.type === import_scope_manager3.ScopeType.global) {
|
|
19502
|
+
const { block } = scope.upper;
|
|
19503
|
+
if (block.type === AST_NODE_TYPES7.Program && block.sourceType === "script")
|
|
19504
|
+
return true;
|
|
19505
|
+
}
|
|
19506
|
+
return false;
|
|
19507
|
+
}
|
|
19508
|
+
var preferModuleScopeConstants = {
|
|
19435
19509
|
create(context) {
|
|
19510
|
+
let inConstDeclaration = false;
|
|
19436
19511
|
return {
|
|
19437
|
-
|
|
19512
|
+
VariableDeclaration(node) {
|
|
19513
|
+
inConstDeclaration = node.kind === "const";
|
|
19514
|
+
},
|
|
19515
|
+
"VariableDeclaration:exit"() {
|
|
19516
|
+
inConstDeclaration = false;
|
|
19517
|
+
},
|
|
19518
|
+
VariableDeclarator(node) {
|
|
19519
|
+
const { id: id2 } = node;
|
|
19520
|
+
if (id2.type !== AST_NODE_TYPES7.Identifier || !SCREAMING_SNAKE_CASE.test(id2.name))
|
|
19521
|
+
return;
|
|
19522
|
+
if (!inConstDeclaration) {
|
|
19523
|
+
context.report({
|
|
19524
|
+
messageId: "mustUseConst",
|
|
19525
|
+
node
|
|
19526
|
+
});
|
|
19527
|
+
return;
|
|
19528
|
+
}
|
|
19529
|
+
const scope = context.sourceCode.getScope(node);
|
|
19530
|
+
if (isTopScope(scope))
|
|
19531
|
+
return;
|
|
19438
19532
|
context.report({
|
|
19439
|
-
messageId: "
|
|
19533
|
+
messageId: "mustBeModuleScope",
|
|
19440
19534
|
node
|
|
19441
19535
|
});
|
|
19442
19536
|
}
|
|
19443
19537
|
};
|
|
19444
19538
|
},
|
|
19539
|
+
defaultOptions: [],
|
|
19445
19540
|
meta: {
|
|
19446
19541
|
docs: {
|
|
19447
|
-
description: "
|
|
19448
|
-
recommended: false
|
|
19542
|
+
description: "Prefer that screaming snake case variables always be defined using `const`, and always appear at module scope."
|
|
19449
19543
|
},
|
|
19450
19544
|
messages: {
|
|
19451
|
-
|
|
19545
|
+
mustBeModuleScope: "You must place screaming snake case at module scope. If this is not meant to be a module-scoped variable, use camelcase instead.",
|
|
19546
|
+
mustUseConst: "You must use `const` when defining screaming snake case variables. If this is not a constant, use camelcase instead."
|
|
19452
19547
|
},
|
|
19453
19548
|
schema: [],
|
|
19454
|
-
type: "
|
|
19549
|
+
type: "suggestion"
|
|
19455
19550
|
}
|
|
19456
19551
|
};
|
|
19457
|
-
var
|
|
19552
|
+
var prefer_module_scope_constants_default = preferModuleScopeConstants;
|
|
19553
|
+
|
|
19554
|
+
// src/rules/prefer-pascal-case-enums.ts
|
|
19555
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES8 } from "@typescript-eslint/utils";
|
|
19556
|
+
|
|
19557
|
+
// src/utilities/casing-utilities.ts
|
|
19558
|
+
var SPLIT_LOWER_TO_UPPER = regex2("([\\p{Ll}\\d])(\\p{Lu})", "gu");
|
|
19559
|
+
var SPLIT_UPPER_TO_UPPER = regex2("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
|
|
19560
|
+
var SPLIT_MARKER = "\x00";
|
|
19561
|
+
var SPLIT_REPLACE_VALUE = `$1${SPLIT_MARKER}$2`;
|
|
19562
|
+
function toPascalCase(value) {
|
|
19563
|
+
const trimmed = value.trim();
|
|
19564
|
+
if (trimmed.length === 0)
|
|
19565
|
+
return "";
|
|
19566
|
+
const marked = trimmed.replace(SPLIT_LOWER_TO_UPPER, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_TO_UPPER, SPLIT_REPLACE_VALUE);
|
|
19567
|
+
let start = 0;
|
|
19568
|
+
let { length } = marked;
|
|
19569
|
+
while (marked.charCodeAt(start) === 0)
|
|
19570
|
+
start += 1;
|
|
19571
|
+
if (start === length)
|
|
19572
|
+
return "";
|
|
19573
|
+
while (marked.charCodeAt(length - 1) === 0)
|
|
19574
|
+
length -= 1;
|
|
19575
|
+
let result = "";
|
|
19576
|
+
let wordStart = start;
|
|
19577
|
+
for (let index2 = start;index2 <= length; index2 += 1) {
|
|
19578
|
+
if (index2 !== length && marked.charCodeAt(index2) !== 0)
|
|
19579
|
+
continue;
|
|
19580
|
+
if (index2 > wordStart) {
|
|
19581
|
+
const word = marked.slice(wordStart, index2);
|
|
19582
|
+
const firstByte = word.charCodeAt(0);
|
|
19583
|
+
if (result.length > 0 && firstByte >= 48 && firstByte <= 57)
|
|
19584
|
+
result += "_";
|
|
19585
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
19586
|
+
}
|
|
19587
|
+
wordStart = index2 + 1;
|
|
19588
|
+
}
|
|
19589
|
+
return result;
|
|
19590
|
+
}
|
|
19591
|
+
|
|
19592
|
+
// src/rules/prefer-pascal-case-enums.ts
|
|
19593
|
+
var STARTS_WITH_DIGIT = regex2("^\\d");
|
|
19594
|
+
function getIdentifierName(node) {
|
|
19595
|
+
if (node.type === AST_NODE_TYPES8.Identifier)
|
|
19596
|
+
return node.name;
|
|
19597
|
+
if (node.type !== AST_NODE_TYPES8.Literal || typeof node.value !== "string")
|
|
19598
|
+
return;
|
|
19599
|
+
return STARTS_WITH_DIGIT.test(node.value) ? undefined : node.value;
|
|
19600
|
+
}
|
|
19601
|
+
var preferPascalCaseEnums = {
|
|
19602
|
+
create(context) {
|
|
19603
|
+
function report(node, identifier3) {
|
|
19604
|
+
context.report({
|
|
19605
|
+
data: { identifier: identifier3 },
|
|
19606
|
+
messageId: "notPascalCase",
|
|
19607
|
+
node
|
|
19608
|
+
});
|
|
19609
|
+
}
|
|
19610
|
+
return {
|
|
19611
|
+
TSEnumDeclaration(node) {
|
|
19612
|
+
const { name } = node.id;
|
|
19613
|
+
if (toPascalCase(name) === name)
|
|
19614
|
+
return;
|
|
19615
|
+
report(node.id, name);
|
|
19616
|
+
},
|
|
19617
|
+
TSEnumMember(node) {
|
|
19618
|
+
const name = getIdentifierName(node.id);
|
|
19619
|
+
if (name === undefined || toPascalCase(name) === name)
|
|
19620
|
+
return;
|
|
19621
|
+
report(node.id, name);
|
|
19622
|
+
}
|
|
19623
|
+
};
|
|
19624
|
+
},
|
|
19625
|
+
defaultOptions: [],
|
|
19626
|
+
meta: {
|
|
19627
|
+
docs: {
|
|
19628
|
+
description: "Enforce Pascal case when naming enums."
|
|
19629
|
+
},
|
|
19630
|
+
messages: {
|
|
19631
|
+
notPascalCase: "Enum '{{ identifier }}' should use Pascal case."
|
|
19632
|
+
},
|
|
19633
|
+
schema: [],
|
|
19634
|
+
type: "suggestion"
|
|
19635
|
+
}
|
|
19636
|
+
};
|
|
19637
|
+
var prefer_pascal_case_enums_default = preferPascalCaseEnums;
|
|
19458
19638
|
|
|
19459
19639
|
// src/rules/prefer-sequence-overloads.ts
|
|
19460
|
-
import { AST_NODE_TYPES as
|
|
19640
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9 } from "@typescript-eslint/types";
|
|
19461
19641
|
var sequenceDescriptors = [
|
|
19462
19642
|
{ keypointName: "ColorSequenceKeypoint", sequenceName: "ColorSequence" },
|
|
19463
19643
|
{ keypointName: "NumberSequenceKeypoint", sequenceName: "NumberSequence" }
|
|
19464
19644
|
];
|
|
19465
19645
|
function isSequenceIdentifier(node) {
|
|
19466
|
-
if (node.type !==
|
|
19646
|
+
if (node.type !== AST_NODE_TYPES9.Identifier)
|
|
19467
19647
|
return false;
|
|
19468
19648
|
for (const { sequenceName } of sequenceDescriptors)
|
|
19469
19649
|
if (sequenceName === node.name)
|
|
@@ -19477,16 +19657,16 @@ function findDescriptor(sequenceName) {
|
|
|
19477
19657
|
return;
|
|
19478
19658
|
}
|
|
19479
19659
|
var isNumericLiteral = Compile(build_default.Object({
|
|
19480
|
-
type: build_default.Literal(
|
|
19660
|
+
type: build_default.Literal(AST_NODE_TYPES9.Literal),
|
|
19481
19661
|
value: build_default.Number()
|
|
19482
19662
|
}));
|
|
19483
19663
|
function isExpressionArgument(argument) {
|
|
19484
|
-
return argument !== undefined && argument.type !==
|
|
19664
|
+
return argument !== undefined && argument.type !== AST_NODE_TYPES9.SpreadElement;
|
|
19485
19665
|
}
|
|
19486
19666
|
function extractKeypoint(element, descriptor) {
|
|
19487
|
-
if (element === undefined || element.type !==
|
|
19667
|
+
if (element === undefined || element.type !== AST_NODE_TYPES9.NewExpression)
|
|
19488
19668
|
return;
|
|
19489
|
-
if (element.callee.type !==
|
|
19669
|
+
if (element.callee.type !== AST_NODE_TYPES9.Identifier || element.callee.name !== descriptor.keypointName)
|
|
19490
19670
|
return;
|
|
19491
19671
|
if (element.arguments.length !== 2)
|
|
19492
19672
|
return;
|
|
@@ -19516,7 +19696,7 @@ var preferSequenceOverloads = {
|
|
|
19516
19696
|
if (descriptor === undefined || node.arguments.length !== 1)
|
|
19517
19697
|
return;
|
|
19518
19698
|
const [argument] = node.arguments;
|
|
19519
|
-
if (argument === undefined || argument.type !==
|
|
19699
|
+
if (argument === undefined || argument.type !== AST_NODE_TYPES9.ArrayExpression || argument.elements.length !== 2)
|
|
19520
19700
|
return;
|
|
19521
19701
|
const firstElement = argument.elements[0] ?? undefined;
|
|
19522
19702
|
const secondElement = argument.elements[1] ?? undefined;
|
|
@@ -19562,6 +19742,147 @@ var preferSequenceOverloads = {
|
|
|
19562
19742
|
};
|
|
19563
19743
|
var prefer_sequence_overloads_default = preferSequenceOverloads;
|
|
19564
19744
|
|
|
19745
|
+
// src/rules/prefer-singular-enums.ts
|
|
19746
|
+
var IRREGULAR_PLURALS = new Set([
|
|
19747
|
+
"children",
|
|
19748
|
+
"dice",
|
|
19749
|
+
"feet",
|
|
19750
|
+
"geese",
|
|
19751
|
+
"men",
|
|
19752
|
+
"mice",
|
|
19753
|
+
"people",
|
|
19754
|
+
"teeth",
|
|
19755
|
+
"women",
|
|
19756
|
+
"criteria",
|
|
19757
|
+
"data",
|
|
19758
|
+
"media",
|
|
19759
|
+
"phenomena",
|
|
19760
|
+
"indices",
|
|
19761
|
+
"matrices",
|
|
19762
|
+
"vertices",
|
|
19763
|
+
"axes",
|
|
19764
|
+
"alumni",
|
|
19765
|
+
"cacti",
|
|
19766
|
+
"fungi",
|
|
19767
|
+
"octopi"
|
|
19768
|
+
]);
|
|
19769
|
+
var SINGULAR_EXCEPTIONS = new Set([
|
|
19770
|
+
"news",
|
|
19771
|
+
"status",
|
|
19772
|
+
"alias",
|
|
19773
|
+
"analysis",
|
|
19774
|
+
"basis",
|
|
19775
|
+
"thesis",
|
|
19776
|
+
"crisis",
|
|
19777
|
+
"axis",
|
|
19778
|
+
"class",
|
|
19779
|
+
"glass",
|
|
19780
|
+
"series",
|
|
19781
|
+
"species",
|
|
19782
|
+
"business"
|
|
19783
|
+
]);
|
|
19784
|
+
var PROGRAMMING_PLURALS = new Set([
|
|
19785
|
+
"args",
|
|
19786
|
+
"params",
|
|
19787
|
+
"parameters",
|
|
19788
|
+
"options",
|
|
19789
|
+
"settings",
|
|
19790
|
+
"props",
|
|
19791
|
+
"components",
|
|
19792
|
+
"hooks",
|
|
19793
|
+
"types",
|
|
19794
|
+
"enums",
|
|
19795
|
+
"services",
|
|
19796
|
+
"controllers",
|
|
19797
|
+
"models",
|
|
19798
|
+
"repositories",
|
|
19799
|
+
"dto",
|
|
19800
|
+
"dtos",
|
|
19801
|
+
"vo",
|
|
19802
|
+
"vos",
|
|
19803
|
+
"keys",
|
|
19804
|
+
"values",
|
|
19805
|
+
"entries",
|
|
19806
|
+
"items",
|
|
19807
|
+
"orders",
|
|
19808
|
+
"pages"
|
|
19809
|
+
]);
|
|
19810
|
+
var SINGULAR_ENUM_REGEX = regex2("[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\\d+", "g");
|
|
19811
|
+
function tokenizeIdentifier(name) {
|
|
19812
|
+
const parts = name.split("_");
|
|
19813
|
+
const tokens = new Array;
|
|
19814
|
+
for (const part of parts) {
|
|
19815
|
+
const matches = part.match(SINGULAR_ENUM_REGEX);
|
|
19816
|
+
if (matches)
|
|
19817
|
+
tokens.push(...matches);
|
|
19818
|
+
}
|
|
19819
|
+
return tokens;
|
|
19820
|
+
}
|
|
19821
|
+
var INTEGER_REGEXP = regex2("^\\d+$");
|
|
19822
|
+
function getLastAlphaToken(name) {
|
|
19823
|
+
const tokens = tokenizeIdentifier(name);
|
|
19824
|
+
let alphaToken;
|
|
19825
|
+
for (let index2 = tokens.length - 1;index2 >= 0; index2 -= 1) {
|
|
19826
|
+
const token = tokens[index2];
|
|
19827
|
+
if (token === undefined || INTEGER_REGEXP.test(token))
|
|
19828
|
+
continue;
|
|
19829
|
+
alphaToken = { lower: token.toLowerCase(), original: token };
|
|
19830
|
+
break;
|
|
19831
|
+
}
|
|
19832
|
+
return alphaToken;
|
|
19833
|
+
}
|
|
19834
|
+
var ACRONYM_REGEXP = regex2("^[A-Z]{2,}[sS]$");
|
|
19835
|
+
function isAcronymPlural(original) {
|
|
19836
|
+
return ACRONYM_REGEXP.test(original);
|
|
19837
|
+
}
|
|
19838
|
+
var ES_VOWELS_REGEXP = regex2("((ch|sh|x|z|ss|o)es|xes|zes|ches|shes|sses|oes)$");
|
|
19839
|
+
function isPluralWord(lower, original) {
|
|
19840
|
+
if (IRREGULAR_PLURALS.has(lower) || PROGRAMMING_PLURALS.has(lower))
|
|
19841
|
+
return true;
|
|
19842
|
+
if (SINGULAR_EXCEPTIONS.has(lower))
|
|
19843
|
+
return false;
|
|
19844
|
+
if (isAcronymPlural(original) || lower.endsWith("ies") || lower.endsWith("ves") || ES_VOWELS_REGEXP.test(lower) || lower.endsWith("es")) {
|
|
19845
|
+
return true;
|
|
19846
|
+
}
|
|
19847
|
+
if (lower.endsWith("s"))
|
|
19848
|
+
return !(lower.endsWith("ss") || lower.endsWith("us") || lower.endsWith("is"));
|
|
19849
|
+
return false;
|
|
19850
|
+
}
|
|
19851
|
+
function isPlural(name) {
|
|
19852
|
+
if (ACRONYM_REGEXP.test(name))
|
|
19853
|
+
return true;
|
|
19854
|
+
const last = getLastAlphaToken(name);
|
|
19855
|
+
return last ? isPluralWord(last.lower, last.original) : false;
|
|
19856
|
+
}
|
|
19857
|
+
var preferSingularEnums = {
|
|
19858
|
+
create(context) {
|
|
19859
|
+
return {
|
|
19860
|
+
TSEnumDeclaration(node) {
|
|
19861
|
+
const { name } = node.id;
|
|
19862
|
+
if (!isPlural(name))
|
|
19863
|
+
return;
|
|
19864
|
+
context.report({
|
|
19865
|
+
data: { name },
|
|
19866
|
+
messageId: "notSingular",
|
|
19867
|
+
node
|
|
19868
|
+
});
|
|
19869
|
+
}
|
|
19870
|
+
};
|
|
19871
|
+
},
|
|
19872
|
+
defaultOptions: [],
|
|
19873
|
+
meta: {
|
|
19874
|
+
docs: {
|
|
19875
|
+
description: "Prefer singular TypeScript enums."
|
|
19876
|
+
},
|
|
19877
|
+
messages: {
|
|
19878
|
+
notSingular: "Enum '{{ name }}' should be singular."
|
|
19879
|
+
},
|
|
19880
|
+
schema: [],
|
|
19881
|
+
type: "suggestion"
|
|
19882
|
+
}
|
|
19883
|
+
};
|
|
19884
|
+
var prefer_singular_enums_default = preferSingularEnums;
|
|
19885
|
+
|
|
19565
19886
|
// src/rules/prefer-udim2-shorthand.ts
|
|
19566
19887
|
import { TSESTree as TSESTree7 } from "@typescript-eslint/utils";
|
|
19567
19888
|
function isNumber(value) {
|
|
@@ -19576,83 +19897,79 @@ function hasTypeProperty(object3) {
|
|
|
19576
19897
|
var OPERATORS2 = new Set(["+", "-", "*", "/", "%"]);
|
|
19577
19898
|
function reconstructText(node) {
|
|
19578
19899
|
const nodeType = node.type;
|
|
19900
|
+
let text;
|
|
19579
19901
|
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
19580
19902
|
const { value } = node;
|
|
19581
|
-
|
|
19903
|
+
text = isNumber(value) ? String(value) : undefined;
|
|
19582
19904
|
}
|
|
19583
19905
|
if (nodeType === TSESTree7.AST_NODE_TYPES.Identifier) {
|
|
19584
19906
|
const { name } = node;
|
|
19585
|
-
|
|
19907
|
+
text = typeof name === "string" ? name : undefined;
|
|
19586
19908
|
}
|
|
19587
19909
|
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
19588
19910
|
const { operator } = node;
|
|
19589
|
-
if (typeof operator
|
|
19590
|
-
|
|
19591
|
-
|
|
19592
|
-
|
|
19593
|
-
|
|
19594
|
-
|
|
19595
|
-
|
|
19911
|
+
if (typeof operator === "string") {
|
|
19912
|
+
const { argument } = node;
|
|
19913
|
+
if (isRecord3(argument)) {
|
|
19914
|
+
const argumentText = reconstructText(argument);
|
|
19915
|
+
if (argumentText !== undefined)
|
|
19916
|
+
text = `${operator}${argumentText}`;
|
|
19917
|
+
}
|
|
19918
|
+
}
|
|
19596
19919
|
}
|
|
19597
19920
|
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
19598
19921
|
const { operator } = node;
|
|
19599
|
-
if (typeof operator
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19922
|
+
if (typeof operator === "string" && OPERATORS2.has(operator)) {
|
|
19923
|
+
const { left, right } = node;
|
|
19924
|
+
if (isRecord3(left) && isRecord3(right)) {
|
|
19925
|
+
const leftText = reconstructText(left);
|
|
19926
|
+
const rightText = reconstructText(right);
|
|
19927
|
+
if (leftText !== undefined && rightText !== undefined)
|
|
19928
|
+
text = `${leftText} ${operator} ${rightText}`;
|
|
19929
|
+
}
|
|
19930
|
+
}
|
|
19607
19931
|
}
|
|
19608
|
-
return;
|
|
19932
|
+
return text;
|
|
19609
19933
|
}
|
|
19610
19934
|
function evaluateExpression(node) {
|
|
19611
19935
|
if (!isRecord3(node))
|
|
19612
19936
|
return;
|
|
19613
19937
|
const nodeType = node.type;
|
|
19938
|
+
let value;
|
|
19614
19939
|
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
19615
|
-
const { value } = node;
|
|
19616
|
-
|
|
19940
|
+
const { value: literalValue } = node;
|
|
19941
|
+
value = isNumber(literalValue) ? literalValue : undefined;
|
|
19617
19942
|
}
|
|
19618
19943
|
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
19619
19944
|
const { argument, operator } = node;
|
|
19620
|
-
if (
|
|
19621
|
-
const
|
|
19622
|
-
if (
|
|
19623
|
-
|
|
19624
|
-
if (operator === "
|
|
19625
|
-
|
|
19626
|
-
if (operator === "+")
|
|
19627
|
-
return value;
|
|
19945
|
+
if (isRecord3(argument)) {
|
|
19946
|
+
const argumentValue = evaluateExpression(argument);
|
|
19947
|
+
if (operator === "-" && argumentValue !== undefined)
|
|
19948
|
+
value = -argumentValue;
|
|
19949
|
+
if (operator === "+" && argumentValue !== undefined)
|
|
19950
|
+
value = argumentValue;
|
|
19628
19951
|
}
|
|
19629
|
-
return;
|
|
19630
19952
|
}
|
|
19631
19953
|
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
19632
19954
|
const { right, left, operator } = node;
|
|
19633
|
-
if (
|
|
19955
|
+
if (isRecord3(left) && isRecord3(right) && typeof operator === "string" && OPERATORS2.has(operator)) {
|
|
19634
19956
|
const leftValue = evaluateExpression(left);
|
|
19635
19957
|
const rightValue = evaluateExpression(right);
|
|
19636
|
-
if (leftValue
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
19644
|
-
|
|
19645
|
-
|
|
19646
|
-
|
|
19647
|
-
case "%":
|
|
19648
|
-
return rightValue === 0 ? undefined : leftValue % rightValue;
|
|
19649
|
-
default:
|
|
19650
|
-
return;
|
|
19958
|
+
if (leftValue !== undefined && rightValue !== undefined) {
|
|
19959
|
+
if (operator === "+")
|
|
19960
|
+
value = leftValue + rightValue;
|
|
19961
|
+
if (operator === "-")
|
|
19962
|
+
value = leftValue - rightValue;
|
|
19963
|
+
if (operator === "*")
|
|
19964
|
+
value = leftValue * rightValue;
|
|
19965
|
+
if (operator === "/")
|
|
19966
|
+
value = rightValue === 0 ? undefined : leftValue / rightValue;
|
|
19967
|
+
if (operator === "%")
|
|
19968
|
+
value = rightValue === 0 ? undefined : leftValue % rightValue;
|
|
19651
19969
|
}
|
|
19652
19970
|
}
|
|
19653
|
-
return;
|
|
19654
19971
|
}
|
|
19655
|
-
return;
|
|
19972
|
+
return value;
|
|
19656
19973
|
}
|
|
19657
19974
|
function collectArguments(_context2, parameters3) {
|
|
19658
19975
|
if (parameters3.length !== 4)
|
|
@@ -19724,6 +20041,145 @@ var preferUDim2Shorthand = {
|
|
|
19724
20041
|
};
|
|
19725
20042
|
var prefer_udim2_shorthand_default = preferUDim2Shorthand;
|
|
19726
20043
|
|
|
20044
|
+
// src/rules/react-hooks-strict-return.ts
|
|
20045
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES10 } from "@typescript-eslint/utils";
|
|
20046
|
+
var MAX_RETURN_ELEMENTS = 2;
|
|
20047
|
+
var HOOK_PATTERN = /^use[A-Z0-9].*$/;
|
|
20048
|
+
function isHookNode(node) {
|
|
20049
|
+
let name;
|
|
20050
|
+
if (node.type === AST_NODE_TYPES10.VariableDeclarator && node.id.type === AST_NODE_TYPES10.Identifier) {
|
|
20051
|
+
({ name } = node.id);
|
|
20052
|
+
} else if (node.type === AST_NODE_TYPES10.FunctionDeclaration && node.id)
|
|
20053
|
+
({ name } = node.id);
|
|
20054
|
+
else if (node.type === AST_NODE_TYPES10.FunctionExpression && node.id)
|
|
20055
|
+
({ name } = node.id);
|
|
20056
|
+
return name !== undefined && HOOK_PATTERN.test(name);
|
|
20057
|
+
}
|
|
20058
|
+
function getVariableByName(scope, name) {
|
|
20059
|
+
let current = scope;
|
|
20060
|
+
while (current) {
|
|
20061
|
+
const variable = current.set.get(name);
|
|
20062
|
+
if (variable)
|
|
20063
|
+
return variable;
|
|
20064
|
+
current = current.upper;
|
|
20065
|
+
}
|
|
20066
|
+
return;
|
|
20067
|
+
}
|
|
20068
|
+
function getArrayElementsFromVariable(scope, name) {
|
|
20069
|
+
const variable = getVariableByName(scope, name);
|
|
20070
|
+
if (!variable)
|
|
20071
|
+
return [];
|
|
20072
|
+
const elements = new Array;
|
|
20073
|
+
for (const ref6 of variable.references) {
|
|
20074
|
+
const { identifier: identifier3 } = ref6;
|
|
20075
|
+
if (!identifier3.parent)
|
|
20076
|
+
continue;
|
|
20077
|
+
const { parent } = identifier3;
|
|
20078
|
+
if (parent.type !== AST_NODE_TYPES10.VariableDeclarator)
|
|
20079
|
+
continue;
|
|
20080
|
+
if (!parent.init || parent.init.type !== AST_NODE_TYPES10.ArrayExpression)
|
|
20081
|
+
continue;
|
|
20082
|
+
elements.push(...parent.init.elements);
|
|
20083
|
+
}
|
|
20084
|
+
return elements;
|
|
20085
|
+
}
|
|
20086
|
+
function countReturnElements(argument, scope) {
|
|
20087
|
+
if (argument.type === AST_NODE_TYPES10.Identifier)
|
|
20088
|
+
return getArrayElementsFromVariable(scope, argument.name).length;
|
|
20089
|
+
if (argument.type !== AST_NODE_TYPES10.ArrayExpression)
|
|
20090
|
+
return 0;
|
|
20091
|
+
let count = 0;
|
|
20092
|
+
for (const element of argument.elements) {
|
|
20093
|
+
if (element === null)
|
|
20094
|
+
count += 1;
|
|
20095
|
+
else if (element.type === AST_NODE_TYPES10.SpreadElement) {
|
|
20096
|
+
if (element.argument.type === AST_NODE_TYPES10.Identifier) {
|
|
20097
|
+
count += getArrayElementsFromVariable(scope, element.argument.name).length;
|
|
20098
|
+
} else if (element.argument.type === AST_NODE_TYPES10.ArrayExpression) {
|
|
20099
|
+
count += element.argument.elements.length;
|
|
20100
|
+
} else
|
|
20101
|
+
count += 1;
|
|
20102
|
+
} else
|
|
20103
|
+
count += 1;
|
|
20104
|
+
}
|
|
20105
|
+
return count;
|
|
20106
|
+
}
|
|
20107
|
+
function exceedsMaxReturnProperties(node, scope) {
|
|
20108
|
+
const { argument } = node;
|
|
20109
|
+
if (argument === null)
|
|
20110
|
+
return false;
|
|
20111
|
+
if (argument.type === AST_NODE_TYPES10.ObjectExpression)
|
|
20112
|
+
return false;
|
|
20113
|
+
if (argument.type === AST_NODE_TYPES10.Identifier) {
|
|
20114
|
+
const variable = getVariableByName(scope, argument.name);
|
|
20115
|
+
if (variable) {
|
|
20116
|
+
for (const { identifier: identifier3 } of variable.references) {
|
|
20117
|
+
const { parent } = identifier3;
|
|
20118
|
+
if (parent?.type === AST_NODE_TYPES10.VariableDeclarator && parent.init?.type === AST_NODE_TYPES10.ObjectExpression) {
|
|
20119
|
+
return false;
|
|
20120
|
+
}
|
|
20121
|
+
}
|
|
20122
|
+
}
|
|
20123
|
+
}
|
|
20124
|
+
return countReturnElements(argument, scope) > MAX_RETURN_ELEMENTS;
|
|
20125
|
+
}
|
|
20126
|
+
var reactHooksStrictReturn = {
|
|
20127
|
+
create(context) {
|
|
20128
|
+
let hookDepth = 0;
|
|
20129
|
+
function enterHook(node) {
|
|
20130
|
+
if (isHookNode(node))
|
|
20131
|
+
hookDepth += 1;
|
|
20132
|
+
}
|
|
20133
|
+
function exitHook(node) {
|
|
20134
|
+
if (isHookNode(node))
|
|
20135
|
+
hookDepth -= 1;
|
|
20136
|
+
}
|
|
20137
|
+
return {
|
|
20138
|
+
ArrowFunctionExpression(node) {
|
|
20139
|
+
const { parent } = node;
|
|
20140
|
+
if (parent?.type === AST_NODE_TYPES10.VariableDeclarator && parent.id.type === AST_NODE_TYPES10.Identifier && HOOK_PATTERN.test(parent.id.name)) {
|
|
20141
|
+
hookDepth += 1;
|
|
20142
|
+
}
|
|
20143
|
+
},
|
|
20144
|
+
"ArrowFunctionExpression:exit"(node) {
|
|
20145
|
+
const { parent } = node;
|
|
20146
|
+
if (parent?.type === AST_NODE_TYPES10.VariableDeclarator && parent.id.type === AST_NODE_TYPES10.Identifier && HOOK_PATTERN.test(parent.id.name)) {
|
|
20147
|
+
hookDepth -= 1;
|
|
20148
|
+
}
|
|
20149
|
+
},
|
|
20150
|
+
FunctionDeclaration: enterHook,
|
|
20151
|
+
"FunctionDeclaration:exit": exitHook,
|
|
20152
|
+
FunctionExpression: enterHook,
|
|
20153
|
+
"FunctionExpression:exit": exitHook,
|
|
20154
|
+
ReturnStatement(node) {
|
|
20155
|
+
if (hookDepth === 0)
|
|
20156
|
+
return;
|
|
20157
|
+
const scope = context.sourceCode.getScope(node);
|
|
20158
|
+
if (exceedsMaxReturnProperties(node, scope)) {
|
|
20159
|
+
context.report({
|
|
20160
|
+
messageId: "hooksStrictReturn",
|
|
20161
|
+
node
|
|
20162
|
+
});
|
|
20163
|
+
}
|
|
20164
|
+
},
|
|
20165
|
+
VariableDeclarator: enterHook,
|
|
20166
|
+
"VariableDeclarator:exit": exitHook
|
|
20167
|
+
};
|
|
20168
|
+
},
|
|
20169
|
+
defaultOptions: [],
|
|
20170
|
+
meta: {
|
|
20171
|
+
docs: {
|
|
20172
|
+
description: "Restrict the number of returned items from React hooks."
|
|
20173
|
+
},
|
|
20174
|
+
messages: {
|
|
20175
|
+
hooksStrictReturn: "React hooks must return a tuple of two or fewer values or a single object."
|
|
20176
|
+
},
|
|
20177
|
+
schema: [],
|
|
20178
|
+
type: "suggestion"
|
|
20179
|
+
}
|
|
20180
|
+
};
|
|
20181
|
+
var react_hooks_strict_return_default = reactHooksStrictReturn;
|
|
20182
|
+
|
|
19727
20183
|
// src/rules/require-named-effect-functions.ts
|
|
19728
20184
|
import { TSESTree as TSESTree8 } from "@typescript-eslint/types";
|
|
19729
20185
|
var DEFAULT_HOOKS = [
|
|
@@ -20057,7 +20513,7 @@ var requireNamedEffectFunctions = {
|
|
|
20057
20513
|
var require_named_effect_functions_default = requireNamedEffectFunctions;
|
|
20058
20514
|
|
|
20059
20515
|
// src/rules/require-paired-calls.ts
|
|
20060
|
-
import { AST_NODE_TYPES as
|
|
20516
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11 } from "@typescript-eslint/types";
|
|
20061
20517
|
var isStringArray = Compile(build_default.Readonly(build_default.Array(build_default.String())));
|
|
20062
20518
|
var isPairConfiguration = Compile(build_default.Readonly(build_default.Object({
|
|
20063
20519
|
alternatives: build_default.Optional(isStringArray),
|
|
@@ -20075,20 +20531,20 @@ var isRuleOptions3 = Compile(build_default.Partial(build_default.Readonly(build_
|
|
|
20075
20531
|
pairs: build_default.Readonly(build_default.Array(isPairConfiguration))
|
|
20076
20532
|
}))));
|
|
20077
20533
|
var LOOP_NODE_TYPES = new Set([
|
|
20078
|
-
|
|
20079
|
-
|
|
20080
|
-
|
|
20081
|
-
|
|
20082
|
-
|
|
20534
|
+
AST_NODE_TYPES11.DoWhileStatement,
|
|
20535
|
+
AST_NODE_TYPES11.ForInStatement,
|
|
20536
|
+
AST_NODE_TYPES11.ForOfStatement,
|
|
20537
|
+
AST_NODE_TYPES11.ForStatement,
|
|
20538
|
+
AST_NODE_TYPES11.WhileStatement
|
|
20083
20539
|
]);
|
|
20084
20540
|
var DEFAULT_ROBLOX_YIELDING_FUNCTIONS = ["task.wait", "wait", "*.WaitForChild", "*.*Async"];
|
|
20085
20541
|
function getCallName(node) {
|
|
20086
20542
|
const { callee } = node;
|
|
20087
|
-
if (callee.type ===
|
|
20543
|
+
if (callee.type === AST_NODE_TYPES11.Identifier)
|
|
20088
20544
|
return callee.name;
|
|
20089
|
-
if (callee.type ===
|
|
20090
|
-
const object3 = callee.object.type ===
|
|
20091
|
-
const property = callee.property.type ===
|
|
20545
|
+
if (callee.type === AST_NODE_TYPES11.MemberExpression) {
|
|
20546
|
+
const object3 = callee.object.type === AST_NODE_TYPES11.Identifier ? callee.object.name : undefined;
|
|
20547
|
+
const property = callee.property.type === AST_NODE_TYPES11.Identifier ? callee.property.name : undefined;
|
|
20092
20548
|
if (object3 !== undefined && property !== undefined)
|
|
20093
20549
|
return `${object3}.${property}`;
|
|
20094
20550
|
}
|
|
@@ -20124,12 +20580,12 @@ function isLoopLikeStatement(node) {
|
|
|
20124
20580
|
return LOOP_NODE_TYPES.has(node.type);
|
|
20125
20581
|
}
|
|
20126
20582
|
function isSwitchStatement(node) {
|
|
20127
|
-
return node?.type ===
|
|
20583
|
+
return node?.type === AST_NODE_TYPES11.SwitchStatement;
|
|
20128
20584
|
}
|
|
20129
20585
|
function findLabeledStatementBody(label, startingNode) {
|
|
20130
20586
|
let current = startingNode;
|
|
20131
20587
|
while (current) {
|
|
20132
|
-
if (current.type ===
|
|
20588
|
+
if (current.type === AST_NODE_TYPES11.LabeledStatement && current.label.name === label.name)
|
|
20133
20589
|
return current.body;
|
|
20134
20590
|
current = current.parent ?? undefined;
|
|
20135
20591
|
}
|
|
@@ -20382,7 +20838,7 @@ var rule = {
|
|
|
20382
20838
|
function onIfConsequentExit(node) {
|
|
20383
20839
|
const consequentNode = node;
|
|
20384
20840
|
const { parent } = consequentNode;
|
|
20385
|
-
if (parent?.type ===
|
|
20841
|
+
if (parent?.type === AST_NODE_TYPES11.IfStatement) {
|
|
20386
20842
|
const branches = branchStacks.get(parent) ?? [];
|
|
20387
20843
|
branches.push(cloneStack());
|
|
20388
20844
|
branchStacks.set(parent, branches);
|
|
@@ -20397,7 +20853,7 @@ var rule = {
|
|
|
20397
20853
|
function onIfAlternateExit(node) {
|
|
20398
20854
|
const alternateNode = node;
|
|
20399
20855
|
const { parent } = alternateNode;
|
|
20400
|
-
if (parent?.type ===
|
|
20856
|
+
if (parent?.type === AST_NODE_TYPES11.IfStatement) {
|
|
20401
20857
|
const branches = branchStacks.get(parent) ?? [];
|
|
20402
20858
|
branches.push(cloneStack());
|
|
20403
20859
|
branchStacks.set(parent, branches);
|
|
@@ -20446,7 +20902,7 @@ var rule = {
|
|
|
20446
20902
|
function onTryBlockExit(node) {
|
|
20447
20903
|
const blockNode = node;
|
|
20448
20904
|
const { parent } = blockNode;
|
|
20449
|
-
if (parent?.type ===
|
|
20905
|
+
if (parent?.type === AST_NODE_TYPES11.TryStatement) {
|
|
20450
20906
|
const branches = branchStacks.get(parent) ?? [];
|
|
20451
20907
|
branches.push(cloneStack());
|
|
20452
20908
|
branchStacks.set(parent, branches);
|
|
@@ -20465,7 +20921,7 @@ var rule = {
|
|
|
20465
20921
|
function onCatchClauseExit(node) {
|
|
20466
20922
|
const catchNode = node;
|
|
20467
20923
|
const { parent } = catchNode;
|
|
20468
|
-
if (parent?.type ===
|
|
20924
|
+
if (parent?.type === AST_NODE_TYPES11.TryStatement) {
|
|
20469
20925
|
const branches = branchStacks.get(parent) ?? [];
|
|
20470
20926
|
branches.push(cloneStack());
|
|
20471
20927
|
branchStacks.set(parent, branches);
|
|
@@ -20528,7 +20984,7 @@ var rule = {
|
|
|
20528
20984
|
function onSwitchCaseExit(node) {
|
|
20529
20985
|
const caseNode = node;
|
|
20530
20986
|
const { parent } = caseNode;
|
|
20531
|
-
if (parent?.type ===
|
|
20987
|
+
if (parent?.type === AST_NODE_TYPES11.SwitchStatement) {
|
|
20532
20988
|
const branches = branchStacks.get(parent) ?? [];
|
|
20533
20989
|
branches.push(cloneStack());
|
|
20534
20990
|
branchStacks.set(parent, branches);
|
|
@@ -20559,7 +21015,7 @@ var rule = {
|
|
|
20559
21015
|
for (const { opener, config, node: node2 } of openerStack) {
|
|
20560
21016
|
const validClosers = getValidClosers(config);
|
|
20561
21017
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
20562
|
-
const statementType = statementNode.type ===
|
|
21018
|
+
const statementType = statementNode.type === AST_NODE_TYPES11.ReturnStatement ? "return" : "throw";
|
|
20563
21019
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
20564
21020
|
context.report({
|
|
20565
21021
|
data: {
|
|
@@ -20576,7 +21032,7 @@ var rule = {
|
|
|
20576
21032
|
const statementNode = node;
|
|
20577
21033
|
if (openerStack.length === 0)
|
|
20578
21034
|
return;
|
|
20579
|
-
const targetLoop = statementNode.type ===
|
|
21035
|
+
const targetLoop = statementNode.type === AST_NODE_TYPES11.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
|
|
20580
21036
|
if (!targetLoop)
|
|
20581
21037
|
return;
|
|
20582
21038
|
for (const { node: openerNode, config, opener, loopAncestors } of openerStack) {
|
|
@@ -20584,7 +21040,7 @@ var rule = {
|
|
|
20584
21040
|
continue;
|
|
20585
21041
|
const validClosers = getValidClosers(config);
|
|
20586
21042
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
20587
|
-
const statementType = statementNode.type ===
|
|
21043
|
+
const statementType = statementNode.type === AST_NODE_TYPES11.BreakStatement ? "break" : "continue";
|
|
20588
21044
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
20589
21045
|
context.report({
|
|
20590
21046
|
data: {
|
|
@@ -20722,7 +21178,7 @@ var rule = {
|
|
|
20722
21178
|
continue;
|
|
20723
21179
|
const validClosers = getValidClosers(config);
|
|
20724
21180
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
20725
|
-
const asyncType = asyncNode.type ===
|
|
21181
|
+
const asyncType = asyncNode.type === AST_NODE_TYPES11.AwaitExpression ? "await" : "yield";
|
|
20726
21182
|
context.report({
|
|
20727
21183
|
data: { asyncType, closer, opener },
|
|
20728
21184
|
messageId: "asyncViolation",
|
|
@@ -21244,6 +21700,116 @@ var requireReactComponentKeys = {
|
|
|
21244
21700
|
};
|
|
21245
21701
|
var require_react_component_keys_default = requireReactComponentKeys;
|
|
21246
21702
|
|
|
21703
|
+
// src/rules/strict-component-boundaries.ts
|
|
21704
|
+
import { basename, extname, relative } from "node:path";
|
|
21705
|
+
|
|
21706
|
+
// src/utilities/resolve-import.ts
|
|
21707
|
+
import { dirname } from "node:path";
|
|
21708
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
21709
|
+
var resolver = new ResolverFactory({
|
|
21710
|
+
extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json", ".node"]
|
|
21711
|
+
});
|
|
21712
|
+
function resolveRelativeImport(importSource, sourceFile) {
|
|
21713
|
+
if (!importSource.startsWith("."))
|
|
21714
|
+
return { found: false };
|
|
21715
|
+
const { path: path2 } = resolver.sync(dirname(sourceFile), importSource);
|
|
21716
|
+
if (path2 === undefined || path2 === "")
|
|
21717
|
+
return { found: false };
|
|
21718
|
+
return { found: true, path: path2 };
|
|
21719
|
+
}
|
|
21720
|
+
|
|
21721
|
+
// src/rules/strict-component-boundaries.ts
|
|
21722
|
+
function toRegExp(pattern4) {
|
|
21723
|
+
return new RegExp(pattern4, "i");
|
|
21724
|
+
}
|
|
21725
|
+
function pathSegmentsFromSource(source) {
|
|
21726
|
+
return source.split("/").filter((part) => !part.startsWith("."));
|
|
21727
|
+
}
|
|
21728
|
+
function countParentTraversals(pathDiff) {
|
|
21729
|
+
return pathDiff.split("/").filter((part) => part === "..").length;
|
|
21730
|
+
}
|
|
21731
|
+
function hasAnotherComponentInPath(pathParts) {
|
|
21732
|
+
return pathParts.some((part) => part === toPascalCase(part) && !part.includes("."));
|
|
21733
|
+
}
|
|
21734
|
+
function hasDirectoryInPath(pathParts, directory) {
|
|
21735
|
+
return pathParts.includes(directory);
|
|
21736
|
+
}
|
|
21737
|
+
function isIndexFile(filePath) {
|
|
21738
|
+
return basename(filePath, extname(filePath)) === "index";
|
|
21739
|
+
}
|
|
21740
|
+
function isValidFixtureImport(pathParts) {
|
|
21741
|
+
if (!hasDirectoryInPath(pathParts, "fixtures"))
|
|
21742
|
+
return false;
|
|
21743
|
+
const fixtureIndex = pathParts.indexOf("fixtures");
|
|
21744
|
+
const partsBeforeFixture = pathParts.slice(0, fixtureIndex);
|
|
21745
|
+
return !hasAnotherComponentInPath(partsBeforeFixture);
|
|
21746
|
+
}
|
|
21747
|
+
var strictComponentBoundaries = {
|
|
21748
|
+
create(context) {
|
|
21749
|
+
const [{ allow = [], maxDepth = 1 } = {}] = context.options;
|
|
21750
|
+
const allowPatterns = allow.map(toRegExp);
|
|
21751
|
+
return {
|
|
21752
|
+
ImportDeclaration(node) {
|
|
21753
|
+
const importSource = node.source.value;
|
|
21754
|
+
if (typeof importSource !== "string" || !importSource.startsWith("."))
|
|
21755
|
+
return;
|
|
21756
|
+
if (allowPatterns.some((regexp) => regexp.test(importSource)))
|
|
21757
|
+
return;
|
|
21758
|
+
const filename = context.filename ?? "";
|
|
21759
|
+
if (filename === "")
|
|
21760
|
+
return;
|
|
21761
|
+
const resolved = resolveRelativeImport(importSource, filename);
|
|
21762
|
+
if (!resolved.found)
|
|
21763
|
+
return;
|
|
21764
|
+
const pathDifference = relative(filename, resolved.path);
|
|
21765
|
+
const pathParts = pathSegmentsFromSource(pathDifference);
|
|
21766
|
+
const traversals = countParentTraversals(pathDifference);
|
|
21767
|
+
const isDescendingOnly = traversals <= 1;
|
|
21768
|
+
const hasComponentsDir = hasDirectoryInPath(pathParts, "components");
|
|
21769
|
+
if ((!isDescendingOnly || hasComponentsDir) && hasAnotherComponentInPath(pathParts) && pathParts.length > maxDepth && !isIndexFile(pathDifference) && !isValidFixtureImport(pathParts)) {
|
|
21770
|
+
context.report({
|
|
21771
|
+
messageId: "noReachingIntoComponent",
|
|
21772
|
+
node
|
|
21773
|
+
});
|
|
21774
|
+
return;
|
|
21775
|
+
}
|
|
21776
|
+
if (hasDirectoryInPath(pathParts, "components") && pathParts.length > maxDepth + 1 && !isValidFixtureImport(pathParts)) {
|
|
21777
|
+
context.report({
|
|
21778
|
+
messageId: "noReachingIntoComponent",
|
|
21779
|
+
node
|
|
21780
|
+
});
|
|
21781
|
+
}
|
|
21782
|
+
}
|
|
21783
|
+
};
|
|
21784
|
+
},
|
|
21785
|
+
defaultOptions: [{}],
|
|
21786
|
+
meta: {
|
|
21787
|
+
docs: {
|
|
21788
|
+
description: "Prevent module imports between components."
|
|
21789
|
+
},
|
|
21790
|
+
messages: {
|
|
21791
|
+
noReachingIntoComponent: "Do not reach into an individual component's folder for nested modules. Import from the closest shared components folder instead."
|
|
21792
|
+
},
|
|
21793
|
+
schema: [
|
|
21794
|
+
{
|
|
21795
|
+
additionalProperties: false,
|
|
21796
|
+
properties: {
|
|
21797
|
+
allow: {
|
|
21798
|
+
items: { type: "string" },
|
|
21799
|
+
type: "array"
|
|
21800
|
+
},
|
|
21801
|
+
maxDepth: {
|
|
21802
|
+
type: "integer"
|
|
21803
|
+
}
|
|
21804
|
+
},
|
|
21805
|
+
type: "object"
|
|
21806
|
+
}
|
|
21807
|
+
],
|
|
21808
|
+
type: "problem"
|
|
21809
|
+
}
|
|
21810
|
+
};
|
|
21811
|
+
var strict_component_boundaries_default = strictComponentBoundaries;
|
|
21812
|
+
|
|
21247
21813
|
// src/rules/use-exhaustive-dependencies.ts
|
|
21248
21814
|
import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
|
|
21249
21815
|
var FUNCTION_DECLARATIONS = new Set([
|
|
@@ -21988,7 +22554,7 @@ function isComponentOrHook(node) {
|
|
|
21988
22554
|
}
|
|
21989
22555
|
if (node.type === TSESTree11.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree11.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
21990
22556
|
const { parent } = node;
|
|
21991
|
-
if (
|
|
22557
|
+
if (parent === undefined)
|
|
21992
22558
|
return false;
|
|
21993
22559
|
if (parent.type === TSESTree11.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
21994
22560
|
const { name } = parent.id;
|
|
@@ -22021,21 +22587,24 @@ var FUNCTION_BOUNDARIES2 = new Set([
|
|
|
22021
22587
|
function isInFinallyBlock(node) {
|
|
22022
22588
|
let current = node.parent;
|
|
22023
22589
|
const maxDepth = 20;
|
|
22590
|
+
let inFinallyBlock = false;
|
|
22024
22591
|
for (let depth = 0;depth < maxDepth && current; depth += 1) {
|
|
22025
22592
|
if (FUNCTION_BOUNDARIES2.has(current.type))
|
|
22026
|
-
|
|
22593
|
+
break;
|
|
22027
22594
|
if (current.type === TSESTree11.AST_NODE_TYPES.TryStatement) {
|
|
22028
22595
|
let checkNode = node;
|
|
22029
22596
|
while (checkNode && checkNode !== current) {
|
|
22030
|
-
if (checkNode === current.finalizer)
|
|
22031
|
-
|
|
22597
|
+
if (checkNode === current.finalizer) {
|
|
22598
|
+
inFinallyBlock = true;
|
|
22599
|
+
break;
|
|
22600
|
+
}
|
|
22032
22601
|
checkNode = checkNode.parent;
|
|
22033
22602
|
}
|
|
22034
|
-
|
|
22603
|
+
break;
|
|
22035
22604
|
}
|
|
22036
22605
|
current = current.parent;
|
|
22037
22606
|
}
|
|
22038
|
-
return
|
|
22607
|
+
return inFinallyBlock;
|
|
22039
22608
|
}
|
|
22040
22609
|
function isRecursiveCall(node, functionName) {
|
|
22041
22610
|
if (!functionName)
|
|
@@ -22094,8 +22663,9 @@ var useHookAtTopLevel = {
|
|
|
22094
22663
|
const current = getCurrentContext();
|
|
22095
22664
|
const depth = current ? current.functionDepth + 1 : 0;
|
|
22096
22665
|
const isComponentOrHookFlag = isComponentOrHook(functionNode);
|
|
22097
|
-
if (functionNode.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && functionNode.id)
|
|
22666
|
+
if (functionNode.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && functionNode.id) {
|
|
22098
22667
|
currentFunctionName = functionNode.id.name;
|
|
22668
|
+
}
|
|
22099
22669
|
if (current?.isComponentOrHook) {
|
|
22100
22670
|
pushContext({
|
|
22101
22671
|
afterEarlyReturn: false,
|
|
@@ -22423,11 +22993,18 @@ var rules = {
|
|
|
22423
22993
|
"no-shorthand-names": no_shorthand_names_default,
|
|
22424
22994
|
"no-useless-use-spring": no_useless_use_spring_default,
|
|
22425
22995
|
"no-warn": no_warn_default,
|
|
22996
|
+
"prefer-class-properties": prefer_class_properties_default,
|
|
22997
|
+
"prefer-early-return": prefer_early_return_default,
|
|
22998
|
+
"prefer-module-scope-constants": prefer_module_scope_constants_default,
|
|
22999
|
+
"prefer-pascal-case-enums": prefer_pascal_case_enums_default,
|
|
22426
23000
|
"prefer-sequence-overloads": prefer_sequence_overloads_default,
|
|
23001
|
+
"prefer-singular-enums": prefer_singular_enums_default,
|
|
22427
23002
|
"prefer-udim2-shorthand": prefer_udim2_shorthand_default,
|
|
23003
|
+
"react-hooks-strict-return": react_hooks_strict_return_default,
|
|
22428
23004
|
"require-named-effect-functions": require_named_effect_functions_default,
|
|
22429
23005
|
"require-paired-calls": require_paired_calls_default,
|
|
22430
23006
|
"require-react-component-keys": require_react_component_keys_default,
|
|
23007
|
+
"strict-component-boundaries": strict_component_boundaries_default,
|
|
22431
23008
|
"use-exhaustive-dependencies": use_exhaustive_dependencies_default,
|
|
22432
23009
|
"use-hook-at-top-level": use_hook_at_top_level_default
|
|
22433
23010
|
};
|
|
@@ -22478,4 +23055,4 @@ export {
|
|
|
22478
23055
|
createBanInstancesOptions
|
|
22479
23056
|
};
|
|
22480
23057
|
|
|
22481
|
-
//# debugId=
|
|
23058
|
+
//# debugId=C1BEC810E1B754DD64756E2164756E21
|