tsl-react 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -410
- package/package.json +9 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as tsl from "tsl";
|
|
2
2
|
|
|
3
3
|
//#region src/rules/no-leaked-conditional-rendering.d.ts
|
|
4
4
|
/**
|
|
@@ -52,6 +52,6 @@ import * as tsl0 from "tsl";
|
|
|
52
52
|
*
|
|
53
53
|
* @since 0.0.0
|
|
54
54
|
*/
|
|
55
|
-
declare const noLeakedConditionalRendering: (options?: "off" | undefined) =>
|
|
55
|
+
declare const noLeakedConditionalRendering: (options?: "off" | undefined) => tsl.Rule<unknown>;
|
|
56
56
|
//#endregion
|
|
57
57
|
export { noLeakedConditionalRendering };
|
package/dist/index.js
CHANGED
|
@@ -1,413 +1,11 @@
|
|
|
1
|
-
import { unit } from "@
|
|
1
|
+
import { unit } from "@local/eff";
|
|
2
2
|
import { isLogicalNegationExpression } from "@react-analyzer/ast";
|
|
3
3
|
import { getAnalyzerOptions, report } from "@react-analyzer/shared";
|
|
4
4
|
import { compare } from "compare-versions";
|
|
5
5
|
import { defineRule } from "tsl";
|
|
6
6
|
import ts, { SyntaxKind } from "typescript";
|
|
7
|
+
import { P, isMatching, match } from "ts-pattern";
|
|
7
8
|
|
|
8
|
-
//#region ../../../node_modules/.pnpm/ts-pattern@5.9.0/node_modules/ts-pattern/dist/index.js
|
|
9
|
-
const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVariadic"), n = "@ts-pattern/anonymous-select-key", r = (t) => Boolean(t && "object" == typeof t), i = (e) => e && !!e[t], o = (n, s, c) => {
|
|
10
|
-
if (i(n)) {
|
|
11
|
-
const { matched: r, selections: i } = n[t]().match(s);
|
|
12
|
-
return r && i && Object.keys(i).forEach((t) => c(t, i[t])), r;
|
|
13
|
-
}
|
|
14
|
-
if (r(n)) {
|
|
15
|
-
if (!r(s)) return !1;
|
|
16
|
-
if (Array.isArray(n)) {
|
|
17
|
-
if (!Array.isArray(s)) return !1;
|
|
18
|
-
let t = [], r = [], u = [];
|
|
19
|
-
for (const o of n.keys()) {
|
|
20
|
-
const s$1 = n[o];
|
|
21
|
-
i(s$1) && s$1[e] ? u.push(s$1) : u.length ? r.push(s$1) : t.push(s$1);
|
|
22
|
-
}
|
|
23
|
-
if (u.length) {
|
|
24
|
-
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
25
|
-
if (s.length < t.length + r.length) return !1;
|
|
26
|
-
const e = s.slice(0, t.length), n$1 = 0 === r.length ? [] : s.slice(-r.length), i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
|
|
27
|
-
return t.every((t$1, n$2) => o(t$1, e[n$2], c)) && r.every((t$1, e$1) => o(t$1, n$1[e$1], c)) && (0 === u.length || o(u[0], i, c));
|
|
28
|
-
}
|
|
29
|
-
return n.length === s.length && n.every((t$1, e) => o(t$1, s[e], c));
|
|
30
|
-
}
|
|
31
|
-
return Reflect.ownKeys(n).every((e) => {
|
|
32
|
-
const r = n[e];
|
|
33
|
-
return (e in s || i(u = r) && "optional" === u[t]().matcherType) && o(r, s[e], c);
|
|
34
|
-
var u;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return Object.is(s, n);
|
|
38
|
-
}, s = (e) => {
|
|
39
|
-
var n, o, u;
|
|
40
|
-
return r(e) ? i(e) ? null != (n = null == (o = (u = e[t]()).getSelectionKeys) ? void 0 : o.call(u)) ? n : [] : Array.isArray(e) ? c(e, s) : c(Object.values(e), s) : [];
|
|
41
|
-
}, c = (t, e) => t.reduce((t$1, n) => t$1.concat(e(n)), []);
|
|
42
|
-
function u(...t) {
|
|
43
|
-
if (1 === t.length) {
|
|
44
|
-
const [e] = t;
|
|
45
|
-
return (t$1) => o(e, t$1, () => {});
|
|
46
|
-
}
|
|
47
|
-
if (2 === t.length) {
|
|
48
|
-
const [e, n] = t;
|
|
49
|
-
return o(e, n, () => {});
|
|
50
|
-
}
|
|
51
|
-
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
52
|
-
}
|
|
53
|
-
function a(t) {
|
|
54
|
-
return Object.assign(t, {
|
|
55
|
-
optional: () => h(t),
|
|
56
|
-
and: (e) => d(t, e),
|
|
57
|
-
or: (e) => y(t, e),
|
|
58
|
-
select: (e) => void 0 === e ? v(t) : v(e, t)
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function l(t) {
|
|
62
|
-
return Object.assign(((t$1) => Object.assign(t$1, { [Symbol.iterator]() {
|
|
63
|
-
let n = 0;
|
|
64
|
-
const r = [{
|
|
65
|
-
value: Object.assign(t$1, { [e]: !0 }),
|
|
66
|
-
done: !1
|
|
67
|
-
}, {
|
|
68
|
-
done: !0,
|
|
69
|
-
value: void 0
|
|
70
|
-
}];
|
|
71
|
-
return { next: () => {
|
|
72
|
-
var t$2;
|
|
73
|
-
return null != (t$2 = r[n++]) ? t$2 : r.at(-1);
|
|
74
|
-
} };
|
|
75
|
-
} }))(t), {
|
|
76
|
-
optional: () => l(h(t)),
|
|
77
|
-
select: (e) => l(void 0 === e ? v(t) : v(e, t))
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function h(e) {
|
|
81
|
-
return a({ [t]: () => ({
|
|
82
|
-
match: (t) => {
|
|
83
|
-
let n = {};
|
|
84
|
-
const r = (t$1, e$1) => {
|
|
85
|
-
n[t$1] = e$1;
|
|
86
|
-
};
|
|
87
|
-
return void 0 === t ? (s(e).forEach((t$1) => r(t$1, void 0)), {
|
|
88
|
-
matched: !0,
|
|
89
|
-
selections: n
|
|
90
|
-
}) : {
|
|
91
|
-
matched: o(e, t, r),
|
|
92
|
-
selections: n
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
getSelectionKeys: () => s(e),
|
|
96
|
-
matcherType: "optional"
|
|
97
|
-
}) });
|
|
98
|
-
}
|
|
99
|
-
const f = (t, e) => {
|
|
100
|
-
for (const n of t) if (!e(n)) return !1;
|
|
101
|
-
return !0;
|
|
102
|
-
}, g = (t, e) => {
|
|
103
|
-
for (const [n, r] of t.entries()) if (!e(r, n)) return !1;
|
|
104
|
-
return !0;
|
|
105
|
-
}, m = (t, e) => {
|
|
106
|
-
const n = Reflect.ownKeys(t);
|
|
107
|
-
for (const r of n) if (!e(r, t[r])) return !1;
|
|
108
|
-
return !0;
|
|
109
|
-
};
|
|
110
|
-
function d(...e) {
|
|
111
|
-
return a({ [t]: () => ({
|
|
112
|
-
match: (t) => {
|
|
113
|
-
let n = {};
|
|
114
|
-
const r = (t$1, e$1) => {
|
|
115
|
-
n[t$1] = e$1;
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
matched: e.every((e$1) => o(e$1, t, r)),
|
|
119
|
-
selections: n
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
getSelectionKeys: () => c(e, s),
|
|
123
|
-
matcherType: "and"
|
|
124
|
-
}) });
|
|
125
|
-
}
|
|
126
|
-
function y(...e) {
|
|
127
|
-
return a({ [t]: () => ({
|
|
128
|
-
match: (t) => {
|
|
129
|
-
let n = {};
|
|
130
|
-
const r = (t$1, e$1) => {
|
|
131
|
-
n[t$1] = e$1;
|
|
132
|
-
};
|
|
133
|
-
return c(e, s).forEach((t$1) => r(t$1, void 0)), {
|
|
134
|
-
matched: e.some((e$1) => o(e$1, t, r)),
|
|
135
|
-
selections: n
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
getSelectionKeys: () => c(e, s),
|
|
139
|
-
matcherType: "or"
|
|
140
|
-
}) });
|
|
141
|
-
}
|
|
142
|
-
function p(e) {
|
|
143
|
-
return { [t]: () => ({ match: (t) => ({ matched: Boolean(e(t)) }) }) };
|
|
144
|
-
}
|
|
145
|
-
function v(...e) {
|
|
146
|
-
const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
|
|
147
|
-
return a({ [t]: () => ({
|
|
148
|
-
match: (t) => {
|
|
149
|
-
let e$1 = { [null != r ? r : n]: t };
|
|
150
|
-
return {
|
|
151
|
-
matched: void 0 === i || o(i, t, (t$1, n) => {
|
|
152
|
-
e$1[t$1] = n;
|
|
153
|
-
}),
|
|
154
|
-
selections: e$1
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
getSelectionKeys: () => [null != r ? r : n].concat(void 0 === i ? [] : s(i))
|
|
158
|
-
}) });
|
|
159
|
-
}
|
|
160
|
-
function b(t) {
|
|
161
|
-
return !0;
|
|
162
|
-
}
|
|
163
|
-
function w(t) {
|
|
164
|
-
return "number" == typeof t;
|
|
165
|
-
}
|
|
166
|
-
function S(t) {
|
|
167
|
-
return "string" == typeof t;
|
|
168
|
-
}
|
|
169
|
-
function j(t) {
|
|
170
|
-
return "bigint" == typeof t;
|
|
171
|
-
}
|
|
172
|
-
const K = a(p(b)), O = a(p(b)), E = K, x = (t) => Object.assign(a(t), {
|
|
173
|
-
startsWith: (e) => {
|
|
174
|
-
return x(d(t, (n = e, p((t$1) => S(t$1) && t$1.startsWith(n)))));
|
|
175
|
-
var n;
|
|
176
|
-
},
|
|
177
|
-
endsWith: (e) => {
|
|
178
|
-
return x(d(t, (n = e, p((t$1) => S(t$1) && t$1.endsWith(n)))));
|
|
179
|
-
var n;
|
|
180
|
-
},
|
|
181
|
-
minLength: (e) => x(d(t, ((t$1) => p((e$1) => S(e$1) && e$1.length >= t$1))(e))),
|
|
182
|
-
length: (e) => x(d(t, ((t$1) => p((e$1) => S(e$1) && e$1.length === t$1))(e))),
|
|
183
|
-
maxLength: (e) => x(d(t, ((t$1) => p((e$1) => S(e$1) && e$1.length <= t$1))(e))),
|
|
184
|
-
includes: (e) => {
|
|
185
|
-
return x(d(t, (n = e, p((t$1) => S(t$1) && t$1.includes(n)))));
|
|
186
|
-
var n;
|
|
187
|
-
},
|
|
188
|
-
regex: (e) => {
|
|
189
|
-
return x(d(t, (n = e, p((t$1) => S(t$1) && Boolean(t$1.match(n))))));
|
|
190
|
-
var n;
|
|
191
|
-
}
|
|
192
|
-
}), A = x(p(S)), N = (t) => Object.assign(a(t), {
|
|
193
|
-
between: (e, n) => N(d(t, ((t$1, e$1) => p((n$1) => w(n$1) && t$1 <= n$1 && e$1 >= n$1))(e, n))),
|
|
194
|
-
lt: (e) => N(d(t, ((t$1) => p((e$1) => w(e$1) && e$1 < t$1))(e))),
|
|
195
|
-
gt: (e) => N(d(t, ((t$1) => p((e$1) => w(e$1) && e$1 > t$1))(e))),
|
|
196
|
-
lte: (e) => N(d(t, ((t$1) => p((e$1) => w(e$1) && e$1 <= t$1))(e))),
|
|
197
|
-
gte: (e) => N(d(t, ((t$1) => p((e$1) => w(e$1) && e$1 >= t$1))(e))),
|
|
198
|
-
int: () => N(d(t, p((t$1) => w(t$1) && Number.isInteger(t$1)))),
|
|
199
|
-
finite: () => N(d(t, p((t$1) => w(t$1) && Number.isFinite(t$1)))),
|
|
200
|
-
positive: () => N(d(t, p((t$1) => w(t$1) && t$1 > 0))),
|
|
201
|
-
negative: () => N(d(t, p((t$1) => w(t$1) && t$1 < 0)))
|
|
202
|
-
}), P = N(p(w)), k = (t) => Object.assign(a(t), {
|
|
203
|
-
between: (e, n) => k(d(t, ((t$1, e$1) => p((n$1) => j(n$1) && t$1 <= n$1 && e$1 >= n$1))(e, n))),
|
|
204
|
-
lt: (e) => k(d(t, ((t$1) => p((e$1) => j(e$1) && e$1 < t$1))(e))),
|
|
205
|
-
gt: (e) => k(d(t, ((t$1) => p((e$1) => j(e$1) && e$1 > t$1))(e))),
|
|
206
|
-
lte: (e) => k(d(t, ((t$1) => p((e$1) => j(e$1) && e$1 <= t$1))(e))),
|
|
207
|
-
gte: (e) => k(d(t, ((t$1) => p((e$1) => j(e$1) && e$1 >= t$1))(e))),
|
|
208
|
-
positive: () => k(d(t, p((t$1) => j(t$1) && t$1 > 0))),
|
|
209
|
-
negative: () => k(d(t, p((t$1) => j(t$1) && t$1 < 0)))
|
|
210
|
-
});
|
|
211
|
-
var z = {
|
|
212
|
-
__proto__: null,
|
|
213
|
-
matcher: t,
|
|
214
|
-
optional: h,
|
|
215
|
-
array: function(...e) {
|
|
216
|
-
return l({ [t]: () => ({
|
|
217
|
-
match: (t) => {
|
|
218
|
-
if (!Array.isArray(t)) return { matched: !1 };
|
|
219
|
-
if (0 === e.length) return { matched: !0 };
|
|
220
|
-
const n = e[0];
|
|
221
|
-
let r = {};
|
|
222
|
-
if (0 === t.length) return s(n).forEach((t$1) => {
|
|
223
|
-
r[t$1] = [];
|
|
224
|
-
}), {
|
|
225
|
-
matched: !0,
|
|
226
|
-
selections: r
|
|
227
|
-
};
|
|
228
|
-
const i = (t$1, e$1) => {
|
|
229
|
-
r[t$1] = (r[t$1] || []).concat([e$1]);
|
|
230
|
-
};
|
|
231
|
-
return {
|
|
232
|
-
matched: t.every((t$1) => o(n, t$1, i)),
|
|
233
|
-
selections: r
|
|
234
|
-
};
|
|
235
|
-
},
|
|
236
|
-
getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
|
|
237
|
-
}) });
|
|
238
|
-
},
|
|
239
|
-
set: function(...e) {
|
|
240
|
-
return a({ [t]: () => ({
|
|
241
|
-
match: (t) => {
|
|
242
|
-
if (!(t instanceof Set)) return { matched: !1 };
|
|
243
|
-
let n = {};
|
|
244
|
-
if (0 === t.size) return {
|
|
245
|
-
matched: !0,
|
|
246
|
-
selections: n
|
|
247
|
-
};
|
|
248
|
-
if (0 === e.length) return { matched: !0 };
|
|
249
|
-
const r = (t$1, e$1) => {
|
|
250
|
-
n[t$1] = (n[t$1] || []).concat([e$1]);
|
|
251
|
-
}, i = e[0];
|
|
252
|
-
return {
|
|
253
|
-
matched: f(t, (t$1) => o(i, t$1, r)),
|
|
254
|
-
selections: n
|
|
255
|
-
};
|
|
256
|
-
},
|
|
257
|
-
getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
|
|
258
|
-
}) });
|
|
259
|
-
},
|
|
260
|
-
map: function(...e) {
|
|
261
|
-
return a({ [t]: () => ({
|
|
262
|
-
match: (t) => {
|
|
263
|
-
if (!(t instanceof Map)) return { matched: !1 };
|
|
264
|
-
let n = {};
|
|
265
|
-
if (0 === t.size) return {
|
|
266
|
-
matched: !0,
|
|
267
|
-
selections: n
|
|
268
|
-
};
|
|
269
|
-
const r = (t$1, e$1) => {
|
|
270
|
-
n[t$1] = (n[t$1] || []).concat([e$1]);
|
|
271
|
-
};
|
|
272
|
-
if (0 === e.length) return { matched: !0 };
|
|
273
|
-
var i;
|
|
274
|
-
if (1 === e.length) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i = e[0]) ? void 0 : i.toString()}`);
|
|
275
|
-
const [s, c] = e;
|
|
276
|
-
return {
|
|
277
|
-
matched: g(t, (t$1, e$1) => {
|
|
278
|
-
const n$1 = o(s, e$1, r), i$1 = o(c, t$1, r);
|
|
279
|
-
return n$1 && i$1;
|
|
280
|
-
}),
|
|
281
|
-
selections: n
|
|
282
|
-
};
|
|
283
|
-
},
|
|
284
|
-
getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
|
|
285
|
-
}) });
|
|
286
|
-
},
|
|
287
|
-
record: function(...e) {
|
|
288
|
-
return a({ [t]: () => ({
|
|
289
|
-
match: (t) => {
|
|
290
|
-
if (null === t || "object" != typeof t || Array.isArray(t)) return { matched: !1 };
|
|
291
|
-
var n;
|
|
292
|
-
if (0 === e.length) throw new Error(`\`P.record\` wasn't given enough arguments. Expected (value) or (key, value), received ${null == (n = e[0]) ? void 0 : n.toString()}`);
|
|
293
|
-
let r = {};
|
|
294
|
-
const i = (t$1, e$1) => {
|
|
295
|
-
r[t$1] = (r[t$1] || []).concat([e$1]);
|
|
296
|
-
}, [s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
297
|
-
return {
|
|
298
|
-
matched: m(t, (t$1, e$1) => {
|
|
299
|
-
const n$1 = "string" != typeof t$1 || Number.isNaN(Number(t$1)) ? null : Number(t$1), r$1 = null !== n$1 && o(s, n$1, i), u = o(s, t$1, i), a = o(c, e$1, i);
|
|
300
|
-
return (u || r$1) && a;
|
|
301
|
-
}),
|
|
302
|
-
selections: r
|
|
303
|
-
};
|
|
304
|
-
},
|
|
305
|
-
getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
|
|
306
|
-
}) });
|
|
307
|
-
},
|
|
308
|
-
intersection: d,
|
|
309
|
-
union: y,
|
|
310
|
-
not: function(e) {
|
|
311
|
-
return a({ [t]: () => ({
|
|
312
|
-
match: (t) => ({ matched: !o(e, t, () => {}) }),
|
|
313
|
-
getSelectionKeys: () => [],
|
|
314
|
-
matcherType: "not"
|
|
315
|
-
}) });
|
|
316
|
-
},
|
|
317
|
-
when: p,
|
|
318
|
-
select: v,
|
|
319
|
-
any: K,
|
|
320
|
-
unknown: O,
|
|
321
|
-
_: E,
|
|
322
|
-
string: A,
|
|
323
|
-
number: P,
|
|
324
|
-
bigint: k(p(j)),
|
|
325
|
-
boolean: a(p(function(t) {
|
|
326
|
-
return "boolean" == typeof t;
|
|
327
|
-
})),
|
|
328
|
-
symbol: a(p(function(t) {
|
|
329
|
-
return "symbol" == typeof t;
|
|
330
|
-
})),
|
|
331
|
-
nullish: a(p(function(t) {
|
|
332
|
-
return null == t;
|
|
333
|
-
})),
|
|
334
|
-
nonNullable: a(p(function(t) {
|
|
335
|
-
return null != t;
|
|
336
|
-
})),
|
|
337
|
-
instanceOf: function(t) {
|
|
338
|
-
return a(p(function(t$1) {
|
|
339
|
-
return (e) => e instanceof t$1;
|
|
340
|
-
}(t)));
|
|
341
|
-
},
|
|
342
|
-
shape: function(t) {
|
|
343
|
-
return a(p(u(t)));
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
var I = class extends Error {
|
|
347
|
-
constructor(t) {
|
|
348
|
-
let e;
|
|
349
|
-
try {
|
|
350
|
-
e = JSON.stringify(t);
|
|
351
|
-
} catch (n) {
|
|
352
|
-
e = t;
|
|
353
|
-
}
|
|
354
|
-
super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
const L = {
|
|
358
|
-
matched: !1,
|
|
359
|
-
value: void 0
|
|
360
|
-
};
|
|
361
|
-
function M(t) {
|
|
362
|
-
return new R(t, L);
|
|
363
|
-
}
|
|
364
|
-
var R = class R {
|
|
365
|
-
constructor(t, e) {
|
|
366
|
-
this.input = void 0, this.state = void 0, this.input = t, this.state = e;
|
|
367
|
-
}
|
|
368
|
-
with(...t) {
|
|
369
|
-
if (this.state.matched) return this;
|
|
370
|
-
const e = t[t.length - 1], r = [t[0]];
|
|
371
|
-
let i;
|
|
372
|
-
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
373
|
-
let s = !1, c = {};
|
|
374
|
-
const u = (t$1, e$1) => {
|
|
375
|
-
s = !0, c[t$1] = e$1;
|
|
376
|
-
}, a = !r.some((t$1) => o(t$1, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
377
|
-
matched: !0,
|
|
378
|
-
value: e(s ? n in c ? c[n] : c : this.input, this.input)
|
|
379
|
-
};
|
|
380
|
-
return new R(this.input, a);
|
|
381
|
-
}
|
|
382
|
-
when(t, e) {
|
|
383
|
-
if (this.state.matched) return this;
|
|
384
|
-
const n = Boolean(t(this.input));
|
|
385
|
-
return new R(this.input, n ? {
|
|
386
|
-
matched: !0,
|
|
387
|
-
value: e(this.input, this.input)
|
|
388
|
-
} : L);
|
|
389
|
-
}
|
|
390
|
-
otherwise(t) {
|
|
391
|
-
return this.state.matched ? this.state.value : t(this.input);
|
|
392
|
-
}
|
|
393
|
-
exhaustive(t = F) {
|
|
394
|
-
return this.state.matched ? this.state.value : t(this.input);
|
|
395
|
-
}
|
|
396
|
-
run() {
|
|
397
|
-
return this.exhaustive();
|
|
398
|
-
}
|
|
399
|
-
returnType() {
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
narrow() {
|
|
403
|
-
return this;
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
function F(t) {
|
|
407
|
-
throw new I(t);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
//#endregion
|
|
411
9
|
//#region src/utils/type-is.ts
|
|
412
10
|
function isFlagSet(allFlags, flag) {
|
|
413
11
|
return (allFlags & flag) !== 0;
|
|
@@ -432,7 +30,7 @@ const isBooleanType = (type) => isTypeFlagSet(type, ts.TypeFlags.BooleanLike);
|
|
|
432
30
|
/** @internal */
|
|
433
31
|
const isEnumType = (type) => isTypeFlagSet(type, ts.TypeFlags.EnumLike);
|
|
434
32
|
/** @internal */
|
|
435
|
-
const isFalsyBigIntType = (type) => type.isLiteral() &&
|
|
33
|
+
const isFalsyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: "0" } }, type);
|
|
436
34
|
/** @internal */
|
|
437
35
|
const isFalsyNumberType = (type) => type.isNumberLiteral() && type.value === 0;
|
|
438
36
|
/** @internal */
|
|
@@ -448,7 +46,7 @@ const isObjectType = (type) => !isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeF
|
|
|
448
46
|
/** @internal */
|
|
449
47
|
const isStringType = (type) => isTypeFlagSet(type, ts.TypeFlags.StringLike);
|
|
450
48
|
/** @internal */
|
|
451
|
-
const isTruthyBigIntType = (type) => type.isLiteral() &&
|
|
49
|
+
const isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: P.not("0") } }, type);
|
|
452
50
|
/** @internal */
|
|
453
51
|
const isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
|
|
454
52
|
/** @internal */
|
|
@@ -480,17 +78,17 @@ function getTypeVariants(types) {
|
|
|
480
78
|
} else if (booleans.length === 2) variants.add("boolean");
|
|
481
79
|
const strings = types.filter(isStringType);
|
|
482
80
|
if (strings.length > 0) {
|
|
483
|
-
const evaluated =
|
|
81
|
+
const evaluated = match(strings).when((types) => types.every(isTruthyStringType), () => "truthy string").when((types) => types.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
|
|
484
82
|
variants.add(evaluated);
|
|
485
83
|
}
|
|
486
84
|
const bigints = types.filter(isBigIntType);
|
|
487
85
|
if (bigints.length > 0) {
|
|
488
|
-
const evaluated =
|
|
86
|
+
const evaluated = match(bigints).when((types) => types.every(isTruthyBigIntType), () => "truthy bigint").when((types) => types.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
|
|
489
87
|
variants.add(evaluated);
|
|
490
88
|
}
|
|
491
89
|
const numbers = types.filter(isNumberType);
|
|
492
90
|
if (numbers.length > 0) {
|
|
493
|
-
const evaluated =
|
|
91
|
+
const evaluated = match(numbers).when((types) => types.every(isTruthyNumberType), () => "truthy number").when((types) => types.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
|
|
494
92
|
variants.add(evaluated);
|
|
495
93
|
}
|
|
496
94
|
if (types.some(isEnumType)) variants.add("enum");
|
|
@@ -503,7 +101,7 @@ function getTypeVariants(types) {
|
|
|
503
101
|
//#endregion
|
|
504
102
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
|
505
103
|
/** @internal */
|
|
506
|
-
const messages = { noLeakedConditionalRendering: (p
|
|
104
|
+
const messages = { noLeakedConditionalRendering: (p) => `Potential leaked value ${p.value} that might cause unintentionally rendered values or rendering crashes.` };
|
|
507
105
|
/**
|
|
508
106
|
* Prevents problematic leaked values from being rendered.
|
|
509
107
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsl-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A unified plugin that combines all individual plugins from the react-analyzer monorepo into one.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"tsl-react-naming-convention"
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"author": "Rel1cx
|
|
15
|
+
"author": "Rel1cx",
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"./package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@let/eff": "npm:@jsr/let__eff@^0.1.2",
|
|
31
30
|
"compare-versions": "^6.1.1",
|
|
32
|
-
"
|
|
33
|
-
"@react-analyzer/
|
|
34
|
-
"@react-analyzer/
|
|
31
|
+
"ts-pattern": "^5.9.0",
|
|
32
|
+
"@react-analyzer/ast": "0.0.10",
|
|
33
|
+
"@react-analyzer/shared": "0.0.10",
|
|
34
|
+
"@local/eff": "0.0.10",
|
|
35
|
+
"@react-analyzer/core": "0.0.10"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"tsdown": "^0.20.
|
|
38
|
-
"@local/configs": "0.0.
|
|
38
|
+
"tsdown": "^0.20.3",
|
|
39
|
+
"@local/configs": "0.0.10"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"tsl": "^1.0.28",
|