tsl-react 0.0.8 → 0.0.9
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 +75 -75
- package/package.json +6 -6
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
|
@@ -17,16 +17,16 @@ const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVaria
|
|
|
17
17
|
if (!Array.isArray(s)) return !1;
|
|
18
18
|
let t = [], r = [], u = [];
|
|
19
19
|
for (const o of n.keys()) {
|
|
20
|
-
const s
|
|
21
|
-
i(s
|
|
20
|
+
const s = n[o];
|
|
21
|
+
i(s) && s[e] ? u.push(s) : u.length ? r.push(s) : t.push(s);
|
|
22
22
|
}
|
|
23
23
|
if (u.length) {
|
|
24
24
|
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
25
25
|
if (s.length < t.length + r.length) return !1;
|
|
26
|
-
const e = s.slice(0, t.length), n
|
|
27
|
-
return t.every((t
|
|
26
|
+
const e = s.slice(0, t.length), n = 0 === r.length ? [] : s.slice(-r.length), i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
|
|
27
|
+
return t.every((t, n) => o(t, e[n], c)) && r.every((t, e) => o(t, n[e], c)) && (0 === u.length || o(u[0], i, c));
|
|
28
28
|
}
|
|
29
|
-
return n.length === s.length && n.every((t
|
|
29
|
+
return n.length === s.length && n.every((t, e) => o(t, s[e], c));
|
|
30
30
|
}
|
|
31
31
|
return Reflect.ownKeys(n).every((e) => {
|
|
32
32
|
const r = n[e];
|
|
@@ -38,11 +38,11 @@ const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVaria
|
|
|
38
38
|
}, s = (e) => {
|
|
39
39
|
var n, o, u;
|
|
40
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
|
|
41
|
+
}, c = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
|
|
42
42
|
function u(...t) {
|
|
43
43
|
if (1 === t.length) {
|
|
44
44
|
const [e] = t;
|
|
45
|
-
return (t
|
|
45
|
+
return (t) => o(e, t, () => {});
|
|
46
46
|
}
|
|
47
47
|
if (2 === t.length) {
|
|
48
48
|
const [e, n] = t;
|
|
@@ -59,18 +59,18 @@ function a(t) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
function l(t) {
|
|
62
|
-
return Object.assign(((t
|
|
62
|
+
return Object.assign(((t) => Object.assign(t, { [Symbol.iterator]() {
|
|
63
63
|
let n = 0;
|
|
64
64
|
const r = [{
|
|
65
|
-
value: Object.assign(t
|
|
65
|
+
value: Object.assign(t, { [e]: !0 }),
|
|
66
66
|
done: !1
|
|
67
67
|
}, {
|
|
68
68
|
done: !0,
|
|
69
69
|
value: void 0
|
|
70
70
|
}];
|
|
71
71
|
return { next: () => {
|
|
72
|
-
var t
|
|
73
|
-
return null != (t
|
|
72
|
+
var t;
|
|
73
|
+
return null != (t = r[n++]) ? t : r.at(-1);
|
|
74
74
|
} };
|
|
75
75
|
} }))(t), {
|
|
76
76
|
optional: () => l(h(t)),
|
|
@@ -81,10 +81,10 @@ function h(e) {
|
|
|
81
81
|
return a({ [t]: () => ({
|
|
82
82
|
match: (t) => {
|
|
83
83
|
let n = {};
|
|
84
|
-
const r = (t
|
|
85
|
-
n[t
|
|
84
|
+
const r = (t, e) => {
|
|
85
|
+
n[t] = e;
|
|
86
86
|
};
|
|
87
|
-
return void 0 === t ? (s(e).forEach((t
|
|
87
|
+
return void 0 === t ? (s(e).forEach((t) => r(t, void 0)), {
|
|
88
88
|
matched: !0,
|
|
89
89
|
selections: n
|
|
90
90
|
}) : {
|
|
@@ -111,11 +111,11 @@ function d(...e) {
|
|
|
111
111
|
return a({ [t]: () => ({
|
|
112
112
|
match: (t) => {
|
|
113
113
|
let n = {};
|
|
114
|
-
const r = (t
|
|
115
|
-
n[t
|
|
114
|
+
const r = (t, e) => {
|
|
115
|
+
n[t] = e;
|
|
116
116
|
};
|
|
117
117
|
return {
|
|
118
|
-
matched: e.every((e
|
|
118
|
+
matched: e.every((e) => o(e, t, r)),
|
|
119
119
|
selections: n
|
|
120
120
|
};
|
|
121
121
|
},
|
|
@@ -127,11 +127,11 @@ function y(...e) {
|
|
|
127
127
|
return a({ [t]: () => ({
|
|
128
128
|
match: (t) => {
|
|
129
129
|
let n = {};
|
|
130
|
-
const r = (t
|
|
131
|
-
n[t
|
|
130
|
+
const r = (t, e) => {
|
|
131
|
+
n[t] = e;
|
|
132
132
|
};
|
|
133
|
-
return c(e, s).forEach((t
|
|
134
|
-
matched: e.some((e
|
|
133
|
+
return c(e, s).forEach((t) => r(t, void 0)), {
|
|
134
|
+
matched: e.some((e) => o(e, t, r)),
|
|
135
135
|
selections: n
|
|
136
136
|
};
|
|
137
137
|
},
|
|
@@ -146,12 +146,12 @@ function v(...e) {
|
|
|
146
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
147
|
return a({ [t]: () => ({
|
|
148
148
|
match: (t) => {
|
|
149
|
-
let e
|
|
149
|
+
let e = { [null != r ? r : n]: t };
|
|
150
150
|
return {
|
|
151
|
-
matched: void 0 === i || o(i, t, (t
|
|
152
|
-
e
|
|
151
|
+
matched: void 0 === i || o(i, t, (t, n) => {
|
|
152
|
+
e[t] = n;
|
|
153
153
|
}),
|
|
154
|
-
selections: e
|
|
154
|
+
selections: e
|
|
155
155
|
};
|
|
156
156
|
},
|
|
157
157
|
getSelectionKeys: () => [null != r ? r : n].concat(void 0 === i ? [] : s(i))
|
|
@@ -171,42 +171,42 @@ function j(t) {
|
|
|
171
171
|
}
|
|
172
172
|
const K = a(p(b)), O = a(p(b)), E = K, x = (t) => Object.assign(a(t), {
|
|
173
173
|
startsWith: (e) => {
|
|
174
|
-
return x(d(t, (n = e, p((t
|
|
174
|
+
return x(d(t, (n = e, p((t) => S(t) && t.startsWith(n)))));
|
|
175
175
|
var n;
|
|
176
176
|
},
|
|
177
177
|
endsWith: (e) => {
|
|
178
|
-
return x(d(t, (n = e, p((t
|
|
178
|
+
return x(d(t, (n = e, p((t) => S(t) && t.endsWith(n)))));
|
|
179
179
|
var n;
|
|
180
180
|
},
|
|
181
|
-
minLength: (e) => x(d(t, ((t
|
|
182
|
-
length: (e) => x(d(t, ((t
|
|
183
|
-
maxLength: (e) => x(d(t, ((t
|
|
181
|
+
minLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length >= t))(e))),
|
|
182
|
+
length: (e) => x(d(t, ((t) => p((e) => S(e) && e.length === t))(e))),
|
|
183
|
+
maxLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length <= t))(e))),
|
|
184
184
|
includes: (e) => {
|
|
185
|
-
return x(d(t, (n = e, p((t
|
|
185
|
+
return x(d(t, (n = e, p((t) => S(t) && t.includes(n)))));
|
|
186
186
|
var n;
|
|
187
187
|
},
|
|
188
188
|
regex: (e) => {
|
|
189
|
-
return x(d(t, (n = e, p((t
|
|
189
|
+
return x(d(t, (n = e, p((t) => S(t) && Boolean(t.match(n))))));
|
|
190
190
|
var n;
|
|
191
191
|
}
|
|
192
192
|
}), A = x(p(S)), N = (t) => Object.assign(a(t), {
|
|
193
|
-
between: (e, n) => N(d(t, ((t
|
|
194
|
-
lt: (e) => N(d(t, ((t
|
|
195
|
-
gt: (e) => N(d(t, ((t
|
|
196
|
-
lte: (e) => N(d(t, ((t
|
|
197
|
-
gte: (e) => N(d(t, ((t
|
|
198
|
-
int: () => N(d(t, p((t
|
|
199
|
-
finite: () => N(d(t, p((t
|
|
200
|
-
positive: () => N(d(t, p((t
|
|
201
|
-
negative: () => N(d(t, p((t
|
|
193
|
+
between: (e, n) => N(d(t, ((t, e) => p((n) => w(n) && t <= n && e >= n))(e, n))),
|
|
194
|
+
lt: (e) => N(d(t, ((t) => p((e) => w(e) && e < t))(e))),
|
|
195
|
+
gt: (e) => N(d(t, ((t) => p((e) => w(e) && e > t))(e))),
|
|
196
|
+
lte: (e) => N(d(t, ((t) => p((e) => w(e) && e <= t))(e))),
|
|
197
|
+
gte: (e) => N(d(t, ((t) => p((e) => w(e) && e >= t))(e))),
|
|
198
|
+
int: () => N(d(t, p((t) => w(t) && Number.isInteger(t)))),
|
|
199
|
+
finite: () => N(d(t, p((t) => w(t) && Number.isFinite(t)))),
|
|
200
|
+
positive: () => N(d(t, p((t) => w(t) && t > 0))),
|
|
201
|
+
negative: () => N(d(t, p((t) => w(t) && t < 0)))
|
|
202
202
|
}), P = N(p(w)), k = (t) => Object.assign(a(t), {
|
|
203
|
-
between: (e, n) => k(d(t, ((t
|
|
204
|
-
lt: (e) => k(d(t, ((t
|
|
205
|
-
gt: (e) => k(d(t, ((t
|
|
206
|
-
lte: (e) => k(d(t, ((t
|
|
207
|
-
gte: (e) => k(d(t, ((t
|
|
208
|
-
positive: () => k(d(t, p((t
|
|
209
|
-
negative: () => k(d(t, p((t
|
|
203
|
+
between: (e, n) => k(d(t, ((t, e) => p((n) => j(n) && t <= n && e >= n))(e, n))),
|
|
204
|
+
lt: (e) => k(d(t, ((t) => p((e) => j(e) && e < t))(e))),
|
|
205
|
+
gt: (e) => k(d(t, ((t) => p((e) => j(e) && e > t))(e))),
|
|
206
|
+
lte: (e) => k(d(t, ((t) => p((e) => j(e) && e <= t))(e))),
|
|
207
|
+
gte: (e) => k(d(t, ((t) => p((e) => j(e) && e >= t))(e))),
|
|
208
|
+
positive: () => k(d(t, p((t) => j(t) && t > 0))),
|
|
209
|
+
negative: () => k(d(t, p((t) => j(t) && t < 0)))
|
|
210
210
|
});
|
|
211
211
|
var z = {
|
|
212
212
|
__proto__: null,
|
|
@@ -219,17 +219,17 @@ var z = {
|
|
|
219
219
|
if (0 === e.length) return { matched: !0 };
|
|
220
220
|
const n = e[0];
|
|
221
221
|
let r = {};
|
|
222
|
-
if (0 === t.length) return s(n).forEach((t
|
|
223
|
-
r[t
|
|
222
|
+
if (0 === t.length) return s(n).forEach((t) => {
|
|
223
|
+
r[t] = [];
|
|
224
224
|
}), {
|
|
225
225
|
matched: !0,
|
|
226
226
|
selections: r
|
|
227
227
|
};
|
|
228
|
-
const i = (t
|
|
229
|
-
r[t
|
|
228
|
+
const i = (t, e) => {
|
|
229
|
+
r[t] = (r[t] || []).concat([e]);
|
|
230
230
|
};
|
|
231
231
|
return {
|
|
232
|
-
matched: t.every((t
|
|
232
|
+
matched: t.every((t) => o(n, t, i)),
|
|
233
233
|
selections: r
|
|
234
234
|
};
|
|
235
235
|
},
|
|
@@ -246,11 +246,11 @@ var z = {
|
|
|
246
246
|
selections: n
|
|
247
247
|
};
|
|
248
248
|
if (0 === e.length) return { matched: !0 };
|
|
249
|
-
const r = (t
|
|
250
|
-
n[t
|
|
249
|
+
const r = (t, e) => {
|
|
250
|
+
n[t] = (n[t] || []).concat([e]);
|
|
251
251
|
}, i = e[0];
|
|
252
252
|
return {
|
|
253
|
-
matched: f(t, (t
|
|
253
|
+
matched: f(t, (t) => o(i, t, r)),
|
|
254
254
|
selections: n
|
|
255
255
|
};
|
|
256
256
|
},
|
|
@@ -266,17 +266,17 @@ var z = {
|
|
|
266
266
|
matched: !0,
|
|
267
267
|
selections: n
|
|
268
268
|
};
|
|
269
|
-
const r = (t
|
|
270
|
-
n[t
|
|
269
|
+
const r = (t, e) => {
|
|
270
|
+
n[t] = (n[t] || []).concat([e]);
|
|
271
271
|
};
|
|
272
272
|
if (0 === e.length) return { matched: !0 };
|
|
273
273
|
var i;
|
|
274
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
275
|
const [s, c] = e;
|
|
276
276
|
return {
|
|
277
|
-
matched: g(t, (t
|
|
278
|
-
const n
|
|
279
|
-
return n
|
|
277
|
+
matched: g(t, (t, e) => {
|
|
278
|
+
const n = o(s, e, r), i = o(c, t, r);
|
|
279
|
+
return n && i;
|
|
280
280
|
}),
|
|
281
281
|
selections: n
|
|
282
282
|
};
|
|
@@ -291,13 +291,13 @@ var z = {
|
|
|
291
291
|
var n;
|
|
292
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
293
|
let r = {};
|
|
294
|
-
const i = (t
|
|
295
|
-
r[t
|
|
294
|
+
const i = (t, e) => {
|
|
295
|
+
r[t] = (r[t] || []).concat([e]);
|
|
296
296
|
}, [s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
297
297
|
return {
|
|
298
|
-
matched: m(t, (t
|
|
299
|
-
const n
|
|
300
|
-
return (u || r
|
|
298
|
+
matched: m(t, (t, e) => {
|
|
299
|
+
const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t), r = null !== n && o(s, n, i), u = o(s, t, i), a = o(c, e, i);
|
|
300
|
+
return (u || r) && a;
|
|
301
301
|
}),
|
|
302
302
|
selections: r
|
|
303
303
|
};
|
|
@@ -335,8 +335,8 @@ var z = {
|
|
|
335
335
|
return null != t;
|
|
336
336
|
})),
|
|
337
337
|
instanceOf: function(t) {
|
|
338
|
-
return a(p(function(t
|
|
339
|
-
return (e) => e instanceof t
|
|
338
|
+
return a(p(function(t) {
|
|
339
|
+
return (e) => e instanceof t;
|
|
340
340
|
}(t)));
|
|
341
341
|
},
|
|
342
342
|
shape: function(t) {
|
|
@@ -371,9 +371,9 @@ var R = class R {
|
|
|
371
371
|
let i;
|
|
372
372
|
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
373
373
|
let s = !1, c = {};
|
|
374
|
-
const u = (t
|
|
375
|
-
s = !0, c[t
|
|
376
|
-
}, a = !r.some((t
|
|
374
|
+
const u = (t, e) => {
|
|
375
|
+
s = !0, c[t] = e;
|
|
376
|
+
}, a = !r.some((t) => o(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
377
377
|
matched: !0,
|
|
378
378
|
value: e(s ? n in c ? c[n] : c : this.input, this.input)
|
|
379
379
|
};
|
|
@@ -480,17 +480,17 @@ function getTypeVariants(types) {
|
|
|
480
480
|
} else if (booleans.length === 2) variants.add("boolean");
|
|
481
481
|
const strings = types.filter(isStringType);
|
|
482
482
|
if (strings.length > 0) {
|
|
483
|
-
const evaluated = M(strings).when((types
|
|
483
|
+
const evaluated = M(strings).when((types) => types.every(isTruthyStringType), () => "truthy string").when((types) => types.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
|
|
484
484
|
variants.add(evaluated);
|
|
485
485
|
}
|
|
486
486
|
const bigints = types.filter(isBigIntType);
|
|
487
487
|
if (bigints.length > 0) {
|
|
488
|
-
const evaluated = M(bigints).when((types
|
|
488
|
+
const evaluated = M(bigints).when((types) => types.every(isTruthyBigIntType), () => "truthy bigint").when((types) => types.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
|
|
489
489
|
variants.add(evaluated);
|
|
490
490
|
}
|
|
491
491
|
const numbers = types.filter(isNumberType);
|
|
492
492
|
if (numbers.length > 0) {
|
|
493
|
-
const evaluated = M(numbers).when((types
|
|
493
|
+
const evaluated = M(numbers).when((types) => types.every(isTruthyNumberType), () => "truthy number").when((types) => types.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
|
|
494
494
|
variants.add(evaluated);
|
|
495
495
|
}
|
|
496
496
|
if (types.some(isEnumType)) variants.add("enum");
|
|
@@ -503,7 +503,7 @@ function getTypeVariants(types) {
|
|
|
503
503
|
//#endregion
|
|
504
504
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
|
505
505
|
/** @internal */
|
|
506
|
-
const messages = { noLeakedConditionalRendering: (p
|
|
506
|
+
const messages = { noLeakedConditionalRendering: (p) => `Potential leaked value ${p.value} that might cause unintentionally rendered values or rendering crashes.` };
|
|
507
507
|
/**
|
|
508
508
|
* Prevents problematic leaked values from being rendered.
|
|
509
509
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsl-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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": {
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@let/eff": "npm:@jsr/let__eff@^0.1.2",
|
|
31
31
|
"compare-versions": "^6.1.1",
|
|
32
|
-
"@react-analyzer/
|
|
33
|
-
"@react-analyzer/
|
|
34
|
-
"@react-analyzer/
|
|
32
|
+
"@react-analyzer/core": "0.0.9",
|
|
33
|
+
"@react-analyzer/ast": "0.0.9",
|
|
34
|
+
"@react-analyzer/shared": "0.0.9"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"tsdown": "^0.20.
|
|
37
|
+
"tsdown": "^0.20.3",
|
|
38
38
|
"@local/configs": "0.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|