@eslint-react/jsx 0.6.2 → 0.7.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/dist/index.cjs +284 -58
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +284 -58
- package/dist/index.mjs +284 -58
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('@typescript-eslint/scope-manager');
|
|
3
|
+
var scopeManager = require('@typescript-eslint/scope-manager');
|
|
4
4
|
var types = require('@typescript-eslint/types');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
6
|
var memo = require('micro-memoize');
|
|
@@ -562,7 +562,7 @@ const globalStore = globalThis[globalStoreId];
|
|
|
562
562
|
*
|
|
563
563
|
* @category guards
|
|
564
564
|
* @since 2.0.0
|
|
565
|
-
*/ const isNullable = (input)=>input === null || input === undefined;
|
|
565
|
+
*/ const isNullable$1 = (input)=>input === null || input === undefined;
|
|
566
566
|
/**
|
|
567
567
|
* @since 2.0.0
|
|
568
568
|
*/ /**
|
|
@@ -715,17 +715,17 @@ const BIT_27 = 134217728.0;
|
|
|
715
715
|
*
|
|
716
716
|
* @memberOf PCGRandom
|
|
717
717
|
*/ constructor(seedHi, seedLo, incHi, incLo){
|
|
718
|
-
if (isNullable(seedLo) && isNullable(seedHi)) {
|
|
718
|
+
if (isNullable$1(seedLo) && isNullable$1(seedHi)) {
|
|
719
719
|
seedLo = Math.random() * 0xffffffff >>> 0;
|
|
720
720
|
seedHi = 0;
|
|
721
|
-
} else if (isNullable(seedLo)) {
|
|
721
|
+
} else if (isNullable$1(seedLo)) {
|
|
722
722
|
seedLo = seedHi;
|
|
723
723
|
seedHi = 0;
|
|
724
724
|
}
|
|
725
|
-
if (isNullable(incLo) && isNullable(incHi)) {
|
|
725
|
+
if (isNullable$1(incLo) && isNullable$1(incHi)) {
|
|
726
726
|
incLo = this._state ? this._state[3] : defaultIncLo;
|
|
727
727
|
incHi = this._state ? this._state[2] : defaultIncHi;
|
|
728
|
-
} else if (isNullable(incLo)) {
|
|
728
|
+
} else if (isNullable$1(incLo)) {
|
|
729
729
|
incLo = incHi;
|
|
730
730
|
incHi = 0;
|
|
731
731
|
}
|
|
@@ -6183,6 +6183,23 @@ Function.call.bind(Object.hasOwnProperty);
|
|
|
6183
6183
|
* @category guards
|
|
6184
6184
|
* @since 2.0.0
|
|
6185
6185
|
*/ const isString$1 = (input)=>typeof input === "string";
|
|
6186
|
+
/**
|
|
6187
|
+
* A guard that succeeds when the input is `null` or `undefined`.
|
|
6188
|
+
*
|
|
6189
|
+
* @param input - The value to test.
|
|
6190
|
+
*
|
|
6191
|
+
* @example
|
|
6192
|
+
* import { isNullable } from "effect/Predicate"
|
|
6193
|
+
*
|
|
6194
|
+
* assert.deepStrictEqual(isNullable(null), true)
|
|
6195
|
+
* assert.deepStrictEqual(isNullable(undefined), true)
|
|
6196
|
+
*
|
|
6197
|
+
* assert.deepStrictEqual(isNullable({}), false)
|
|
6198
|
+
* assert.deepStrictEqual(isNullable([]), false)
|
|
6199
|
+
*
|
|
6200
|
+
* @category guards
|
|
6201
|
+
* @since 2.0.0
|
|
6202
|
+
*/ const isNullable = (input)=>input === null || input === undefined;
|
|
6186
6203
|
const t$1 = Symbol.for("@ts-pattern/matcher"), e$1 = Symbol.for("@ts-pattern/isVariadic"), n$1 = "@ts-pattern/anonymous-select-key", r$1 = (t)=>Boolean(t && "object" == typeof t), i$1 = (e)=>e && !!e[t$1], s$1 = (n, o, c)=>{
|
|
6187
6204
|
if (i$1(n)) {
|
|
6188
6205
|
const e = n[t$1](), { matched: r, selections: i } = e.match(o);
|
|
@@ -6216,6 +6233,17 @@ const t$1 = Symbol.for("@ts-pattern/matcher"), e$1 = Symbol.for("@ts-pattern/isV
|
|
|
6216
6233
|
var n, s, a;
|
|
6217
6234
|
return r$1(e) ? i$1(e) ? null != (n = null == (s = (a = e[t$1]()).getSelectionKeys) ? void 0 : s.call(a)) ? n : [] : Array.isArray(e) ? c$1(e, o$1) : c$1(Object.values(e), o$1) : [];
|
|
6218
6235
|
}, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
|
|
6236
|
+
function a$1(...t) {
|
|
6237
|
+
if (1 === t.length) {
|
|
6238
|
+
const [e] = t;
|
|
6239
|
+
return (t)=>s$1(e, t, ()=>{});
|
|
6240
|
+
}
|
|
6241
|
+
if (2 === t.length) {
|
|
6242
|
+
const [e, n] = t;
|
|
6243
|
+
return s$1(e, n, ()=>{});
|
|
6244
|
+
}
|
|
6245
|
+
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
6246
|
+
}
|
|
6219
6247
|
function u$1(t) {
|
|
6220
6248
|
return Object.assign(t, {
|
|
6221
6249
|
optional: ()=>l$1(t),
|
|
@@ -6224,6 +6252,18 @@ function u$1(t) {
|
|
|
6224
6252
|
select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
|
|
6225
6253
|
});
|
|
6226
6254
|
}
|
|
6255
|
+
function h(t) {
|
|
6256
|
+
return Object.assign(((t)=>Object.assign(t, {
|
|
6257
|
+
*[Symbol.iterator] () {
|
|
6258
|
+
yield Object.assign(t, {
|
|
6259
|
+
[e$1]: !0
|
|
6260
|
+
});
|
|
6261
|
+
}
|
|
6262
|
+
}))(t), {
|
|
6263
|
+
optional: ()=>h(l$1(t)),
|
|
6264
|
+
select: (e)=>h(void 0 === e ? p$1(t) : p$1(e, t))
|
|
6265
|
+
});
|
|
6266
|
+
}
|
|
6227
6267
|
function l$1(e) {
|
|
6228
6268
|
return u$1({
|
|
6229
6269
|
[t$1]: ()=>({
|
|
@@ -6245,6 +6285,13 @@ function l$1(e) {
|
|
|
6245
6285
|
})
|
|
6246
6286
|
});
|
|
6247
6287
|
}
|
|
6288
|
+
const f = (t, e)=>{
|
|
6289
|
+
for (const n of t)if (!e(n)) return !1;
|
|
6290
|
+
return !0;
|
|
6291
|
+
}, g = (t, e)=>{
|
|
6292
|
+
for (const [n, r] of t.entries())if (!e(r, n)) return !1;
|
|
6293
|
+
return !0;
|
|
6294
|
+
};
|
|
6248
6295
|
function m$1(...e) {
|
|
6249
6296
|
return u$1({
|
|
6250
6297
|
[t$1]: ()=>({
|
|
@@ -6320,10 +6367,9 @@ function b$1(t) {
|
|
|
6320
6367
|
function w$1(t) {
|
|
6321
6368
|
return "bigint" == typeof t;
|
|
6322
6369
|
}
|
|
6323
|
-
u$1(d$1(function(t) {
|
|
6370
|
+
const S = u$1(d$1(function(t) {
|
|
6324
6371
|
return !0;
|
|
6325
|
-
}))
|
|
6326
|
-
const j$1 = (t)=>Object.assign(u$1(t), {
|
|
6372
|
+
})), O = S, j$1 = (t)=>Object.assign(u$1(t), {
|
|
6327
6373
|
startsWith: (e)=>{
|
|
6328
6374
|
return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
|
|
6329
6375
|
var n;
|
|
@@ -6342,9 +6388,7 @@ const j$1 = (t)=>Object.assign(u$1(t), {
|
|
|
6342
6388
|
return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
|
|
6343
6389
|
var n;
|
|
6344
6390
|
}
|
|
6345
|
-
})
|
|
6346
|
-
j$1(d$1(b$1));
|
|
6347
|
-
const K$1 = (t)=>Object.assign(u$1(t), {
|
|
6391
|
+
}), E = j$1(d$1(b$1)), K$1 = (t)=>Object.assign(u$1(t), {
|
|
6348
6392
|
between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
|
|
6349
6393
|
lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
|
|
6350
6394
|
gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
|
|
@@ -6354,9 +6398,7 @@ const K$1 = (t)=>Object.assign(u$1(t), {
|
|
|
6354
6398
|
finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
|
|
6355
6399
|
positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
|
|
6356
6400
|
negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
|
|
6357
|
-
})
|
|
6358
|
-
K$1(d$1(v$1));
|
|
6359
|
-
const x$1 = (t)=>Object.assign(u$1(t), {
|
|
6401
|
+
}), A = K$1(d$1(v$1)), x$1 = (t)=>Object.assign(u$1(t), {
|
|
6360
6402
|
between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
|
|
6361
6403
|
lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
|
|
6362
6404
|
gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
|
|
@@ -6364,17 +6406,148 @@ const x$1 = (t)=>Object.assign(u$1(t), {
|
|
|
6364
6406
|
gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
|
|
6365
6407
|
positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
|
|
6366
6408
|
negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
|
|
6367
|
-
})
|
|
6368
|
-
x$1(d$1(w$1));
|
|
6369
|
-
u$1(d$1(function(t) {
|
|
6409
|
+
}), P = x$1(d$1(w$1)), T = u$1(d$1(function(t) {
|
|
6370
6410
|
return "boolean" == typeof t;
|
|
6371
|
-
}))
|
|
6372
|
-
u$1(d$1(function(t) {
|
|
6411
|
+
})), k = u$1(d$1(function(t) {
|
|
6373
6412
|
return "symbol" == typeof t;
|
|
6374
|
-
}))
|
|
6375
|
-
u$1(d$1(function(t) {
|
|
6413
|
+
})), B = u$1(d$1(function(t) {
|
|
6376
6414
|
return null == t;
|
|
6377
6415
|
}));
|
|
6416
|
+
var _ = {
|
|
6417
|
+
__proto__: null,
|
|
6418
|
+
matcher: t$1,
|
|
6419
|
+
optional: l$1,
|
|
6420
|
+
array: function(...e) {
|
|
6421
|
+
return h({
|
|
6422
|
+
[t$1]: ()=>({
|
|
6423
|
+
match: (t)=>{
|
|
6424
|
+
if (!Array.isArray(t)) return {
|
|
6425
|
+
matched: !1
|
|
6426
|
+
};
|
|
6427
|
+
if (0 === e.length) return {
|
|
6428
|
+
matched: !0
|
|
6429
|
+
};
|
|
6430
|
+
const n = e[0];
|
|
6431
|
+
let r = {};
|
|
6432
|
+
if (0 === t.length) return o$1(n).forEach((t)=>{
|
|
6433
|
+
r[t] = [];
|
|
6434
|
+
}), {
|
|
6435
|
+
matched: !0,
|
|
6436
|
+
selections: r
|
|
6437
|
+
};
|
|
6438
|
+
const i = (t, e)=>{
|
|
6439
|
+
r[t] = (r[t] || []).concat([
|
|
6440
|
+
e
|
|
6441
|
+
]);
|
|
6442
|
+
};
|
|
6443
|
+
return {
|
|
6444
|
+
matched: t.every((t)=>s$1(n, t, i)),
|
|
6445
|
+
selections: r
|
|
6446
|
+
};
|
|
6447
|
+
},
|
|
6448
|
+
getSelectionKeys: ()=>0 === e.length ? [] : o$1(e[0])
|
|
6449
|
+
})
|
|
6450
|
+
});
|
|
6451
|
+
},
|
|
6452
|
+
set: function(...e) {
|
|
6453
|
+
return u$1({
|
|
6454
|
+
[t$1]: ()=>({
|
|
6455
|
+
match: (t)=>{
|
|
6456
|
+
if (!(t instanceof Set)) return {
|
|
6457
|
+
matched: !1
|
|
6458
|
+
};
|
|
6459
|
+
let n = {};
|
|
6460
|
+
if (0 === t.size) return {
|
|
6461
|
+
matched: !0,
|
|
6462
|
+
selections: n
|
|
6463
|
+
};
|
|
6464
|
+
if (0 === e.length) return {
|
|
6465
|
+
matched: !0
|
|
6466
|
+
};
|
|
6467
|
+
const r = (t, e)=>{
|
|
6468
|
+
n[t] = (n[t] || []).concat([
|
|
6469
|
+
e
|
|
6470
|
+
]);
|
|
6471
|
+
}, i = e[0];
|
|
6472
|
+
return {
|
|
6473
|
+
matched: f(t, (t)=>s$1(i, t, r)),
|
|
6474
|
+
selections: n
|
|
6475
|
+
};
|
|
6476
|
+
},
|
|
6477
|
+
getSelectionKeys: ()=>0 === e.length ? [] : o$1(e[0])
|
|
6478
|
+
})
|
|
6479
|
+
});
|
|
6480
|
+
},
|
|
6481
|
+
map: function(...e) {
|
|
6482
|
+
return u$1({
|
|
6483
|
+
[t$1]: ()=>({
|
|
6484
|
+
match: (t)=>{
|
|
6485
|
+
if (!(t instanceof Map)) return {
|
|
6486
|
+
matched: !1
|
|
6487
|
+
};
|
|
6488
|
+
let n = {};
|
|
6489
|
+
if (0 === t.size) return {
|
|
6490
|
+
matched: !0,
|
|
6491
|
+
selections: n
|
|
6492
|
+
};
|
|
6493
|
+
const r = (t, e)=>{
|
|
6494
|
+
n[t] = (n[t] || []).concat([
|
|
6495
|
+
e
|
|
6496
|
+
]);
|
|
6497
|
+
};
|
|
6498
|
+
if (0 === e.length) return {
|
|
6499
|
+
matched: !0
|
|
6500
|
+
};
|
|
6501
|
+
var i;
|
|
6502
|
+
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()}`);
|
|
6503
|
+
const [o, c] = e;
|
|
6504
|
+
return {
|
|
6505
|
+
matched: g(t, (t, e)=>{
|
|
6506
|
+
const n = s$1(o, e, r), i = s$1(c, t, r);
|
|
6507
|
+
return n && i;
|
|
6508
|
+
}),
|
|
6509
|
+
selections: n
|
|
6510
|
+
};
|
|
6511
|
+
},
|
|
6512
|
+
getSelectionKeys: ()=>0 === e.length ? [] : [
|
|
6513
|
+
...o$1(e[0]),
|
|
6514
|
+
...o$1(e[1])
|
|
6515
|
+
]
|
|
6516
|
+
})
|
|
6517
|
+
});
|
|
6518
|
+
},
|
|
6519
|
+
intersection: m$1,
|
|
6520
|
+
union: y$1,
|
|
6521
|
+
not: function(e) {
|
|
6522
|
+
return u$1({
|
|
6523
|
+
[t$1]: ()=>({
|
|
6524
|
+
match: (t)=>({
|
|
6525
|
+
matched: !s$1(e, t, ()=>{})
|
|
6526
|
+
}),
|
|
6527
|
+
getSelectionKeys: ()=>[],
|
|
6528
|
+
matcherType: "not"
|
|
6529
|
+
})
|
|
6530
|
+
});
|
|
6531
|
+
},
|
|
6532
|
+
when: d$1,
|
|
6533
|
+
select: p$1,
|
|
6534
|
+
any: S,
|
|
6535
|
+
_: O,
|
|
6536
|
+
string: E,
|
|
6537
|
+
number: A,
|
|
6538
|
+
bigint: P,
|
|
6539
|
+
boolean: T,
|
|
6540
|
+
symbol: k,
|
|
6541
|
+
nullish: B,
|
|
6542
|
+
instanceOf: function(t) {
|
|
6543
|
+
return u$1(d$1(function(t) {
|
|
6544
|
+
return (e)=>e instanceof t;
|
|
6545
|
+
}(t)));
|
|
6546
|
+
},
|
|
6547
|
+
shape: function(t) {
|
|
6548
|
+
return u$1(d$1(a$1(t)));
|
|
6549
|
+
}
|
|
6550
|
+
};
|
|
6378
6551
|
const NodeType = types.AST_NODE_TYPES;
|
|
6379
6552
|
const is = utils.ASTUtils.isNodeOfType;
|
|
6380
6553
|
const isOneOf = utils.ASTUtils.isNodeOfTypes;
|
|
@@ -6563,6 +6736,54 @@ Construction.None();
|
|
|
6563
6736
|
}
|
|
6564
6737
|
return returnStatements;
|
|
6565
6738
|
}
|
|
6739
|
+
/**
|
|
6740
|
+
* Checks if the given node is a function expression or arrow function expression of a object method.
|
|
6741
|
+
* @param node The node to check.
|
|
6742
|
+
* @returns `true` if the node is a function expression or arrow function expression of a object method, `false` otherwise.
|
|
6743
|
+
*/ a$1({
|
|
6744
|
+
type: _.union([
|
|
6745
|
+
NodeType.FunctionExpression,
|
|
6746
|
+
NodeType.ArrowFunctionExpression
|
|
6747
|
+
]),
|
|
6748
|
+
parent: {
|
|
6749
|
+
type: NodeType.Property,
|
|
6750
|
+
parent: {
|
|
6751
|
+
type: NodeType.ObjectExpression
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
|
+
});
|
|
6755
|
+
/**
|
|
6756
|
+
* Checks if the given node is a function expression or arrow function expression of a class method.
|
|
6757
|
+
* @param node The node to check.
|
|
6758
|
+
* @returns `true` if the node is a function expression or arrow function expression of a class method, `false` otherwise.
|
|
6759
|
+
*/ a$1({
|
|
6760
|
+
type: _.union([
|
|
6761
|
+
NodeType.FunctionExpression,
|
|
6762
|
+
NodeType.ArrowFunctionExpression
|
|
6763
|
+
]),
|
|
6764
|
+
parent: {
|
|
6765
|
+
type: NodeType.MethodDefinition,
|
|
6766
|
+
parent: {
|
|
6767
|
+
type: NodeType.ClassBody
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
});
|
|
6771
|
+
/**
|
|
6772
|
+
* Checks if the given node is a function expression or arrow function expression of a class property.
|
|
6773
|
+
* @param node The node to check.
|
|
6774
|
+
* @returns `true` if the node is a function expression or arrow function expression of a class property, `false` otherwise.
|
|
6775
|
+
*/ a$1({
|
|
6776
|
+
type: _.union([
|
|
6777
|
+
NodeType.FunctionExpression,
|
|
6778
|
+
NodeType.ArrowFunctionExpression
|
|
6779
|
+
]),
|
|
6780
|
+
parent: {
|
|
6781
|
+
type: NodeType.Property,
|
|
6782
|
+
parent: {
|
|
6783
|
+
type: NodeType.ClassBody
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
});
|
|
6566
6787
|
function isStringLiteral(node) {
|
|
6567
6788
|
return node?.type === NodeType.Literal && isString$1(node.value);
|
|
6568
6789
|
}
|
|
@@ -6605,7 +6826,7 @@ function isStringLiteral(node) {
|
|
|
6605
6826
|
/**
|
|
6606
6827
|
* @param variables The variables to search through
|
|
6607
6828
|
*/ return (variables)=>{
|
|
6608
|
-
return effectOption_esm.fromNullable(variables.find((variable)=>
|
|
6829
|
+
return effectOption_esm.fromNullable(variables.find((variable)=>variable.name === name));
|
|
6609
6830
|
};
|
|
6610
6831
|
}
|
|
6611
6832
|
/**
|
|
@@ -6614,7 +6835,7 @@ function isStringLiteral(node) {
|
|
|
6614
6835
|
*/ function getVariablesUpToGlobal(startScope) {
|
|
6615
6836
|
const scopeRef = effectMutableRef_esm.make(startScope);
|
|
6616
6837
|
const variablesRef = effectMutableRef_esm.make(effectMutableRef_esm.get(scopeRef).variables);
|
|
6617
|
-
while(effectMutableRef_esm.get(scopeRef).
|
|
6838
|
+
while(effectMutableRef_esm.get(scopeRef).type !== scopeManager.ScopeType.global){
|
|
6618
6839
|
effectMutableRef_esm.set(scopeRef, effectMutableRef_esm.get(scopeRef).upper);
|
|
6619
6840
|
effectMutableRef_esm.update(variablesRef, (variables)=>variables.concat(effectMutableRef_esm.get(scopeRef).variables));
|
|
6620
6841
|
}
|
|
@@ -6625,26 +6846,23 @@ function isStringLiteral(node) {
|
|
|
6625
6846
|
* @param name The name of the variable to find
|
|
6626
6847
|
* @param startScope The scope to start from
|
|
6627
6848
|
*/ function findVariableByNameUpToGlobal(name, startScope) {
|
|
6628
|
-
return
|
|
6849
|
+
return findVariableByName(name)(getVariablesUpToGlobal(startScope));
|
|
6629
6850
|
}
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6851
|
+
function resolveDefinitionInit(def) {
|
|
6852
|
+
if ("init" in def.node && !isNullable(def.node.init)) {
|
|
6853
|
+
return effectOption_esm.some(def.node.init);
|
|
6854
|
+
}
|
|
6855
|
+
// TODO: support other types of definitions
|
|
6856
|
+
return effectOption_esm.none();
|
|
6635
6857
|
}
|
|
6636
6858
|
/**
|
|
6637
6859
|
* Get the init node of the nth definition of a variable
|
|
6638
|
-
* @param
|
|
6639
|
-
* @
|
|
6640
|
-
*/ function getVariableInit(
|
|
6641
|
-
return
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
* Get the init node of the first definition of a variable
|
|
6645
|
-
* @param variable
|
|
6646
|
-
*/ function getVariableInitFirst(variable) {
|
|
6647
|
-
return getVariableInit(variable, getVariableDefinitionFirst);
|
|
6860
|
+
* @param at The index number of def in defs
|
|
6861
|
+
* @returns A function that takes a variable and returns the init node of the nth definition of that variable
|
|
6862
|
+
*/ function getVariableInit(at) {
|
|
6863
|
+
return (variable)=>{
|
|
6864
|
+
return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMap(resolveDefinitionInit));
|
|
6865
|
+
};
|
|
6648
6866
|
}
|
|
6649
6867
|
|
|
6650
6868
|
/**
|
|
@@ -7073,10 +7291,11 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7073
7291
|
|
|
7074
7292
|
/* eslint-disable perfectionist/sort-objects */ const JSXValueCheckHint = {
|
|
7075
7293
|
None: 0n,
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7294
|
+
SkipNull: 1n << 0n,
|
|
7295
|
+
SkipCreateElement: 1n << 1n,
|
|
7296
|
+
StrictArray: 1n << 2n,
|
|
7297
|
+
StrictLogical: 1n << 3n,
|
|
7298
|
+
StrictConditional: 1n << 4n
|
|
7080
7299
|
};
|
|
7081
7300
|
/* eslint-enable perfectionist/sort-objects */ /**
|
|
7082
7301
|
* Check if a node is a JSX value
|
|
@@ -7092,13 +7311,27 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7092
7311
|
type: NodeType.JSXElement
|
|
7093
7312
|
}, effectFunction_esm.constTrue).with({
|
|
7094
7313
|
type: NodeType.JSXFragment
|
|
7314
|
+
}, effectFunction_esm.constTrue).with({
|
|
7315
|
+
type: NodeType.JSXMemberExpression
|
|
7316
|
+
}, effectFunction_esm.constTrue).with({
|
|
7317
|
+
type: NodeType.JSXNamespacedName
|
|
7095
7318
|
}, effectFunction_esm.constTrue).with({
|
|
7096
7319
|
type: NodeType.Literal
|
|
7097
7320
|
}, (node)=>{
|
|
7098
|
-
if (!("value" in node) || hint & JSXValueCheckHint.
|
|
7321
|
+
if (!("value" in node) || hint & JSXValueCheckHint.SkipNull) {
|
|
7099
7322
|
return false;
|
|
7100
7323
|
}
|
|
7101
7324
|
return node.value === null;
|
|
7325
|
+
}).with({
|
|
7326
|
+
type: NodeType.ArrayExpression
|
|
7327
|
+
}, (node)=>{
|
|
7328
|
+
if (!("elements" in node)) {
|
|
7329
|
+
return false;
|
|
7330
|
+
}
|
|
7331
|
+
if (hint & JSXValueCheckHint.StrictArray) {
|
|
7332
|
+
return node.elements.every((n)=>isJSXValue(n, context, hint));
|
|
7333
|
+
}
|
|
7334
|
+
return node.elements.some((n)=>isJSXValue(n, context, hint));
|
|
7102
7335
|
}).with({
|
|
7103
7336
|
type: NodeType.ConditionalExpression
|
|
7104
7337
|
}, (node)=>{
|
|
@@ -7139,29 +7372,22 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7139
7372
|
}).with({
|
|
7140
7373
|
type: NodeType.CallExpression
|
|
7141
7374
|
}, (node)=>{
|
|
7142
|
-
if (hint & JSXValueCheckHint.
|
|
7375
|
+
if (hint & JSXValueCheckHint.SkipCreateElement) {
|
|
7143
7376
|
return false;
|
|
7144
7377
|
}
|
|
7145
7378
|
return isCreateElementCall(node, context);
|
|
7146
7379
|
}).with({
|
|
7147
7380
|
type: NodeType.Identifier
|
|
7148
7381
|
}, (node)=>{
|
|
7149
|
-
if (!("name" in node)) {
|
|
7150
|
-
return false;
|
|
7151
|
-
}
|
|
7152
7382
|
if (isJSXTagNameExpression(node)) {
|
|
7153
7383
|
return true;
|
|
7154
7384
|
}
|
|
7155
|
-
const
|
|
7156
|
-
return effectFunction_esm.pipe(
|
|
7385
|
+
const maybeVariable = findVariableByNameUpToGlobal(node.name, context.getScope());
|
|
7386
|
+
return effectFunction_esm.pipe(maybeVariable, effectOption_esm.flatMap(getVariableInit(0)), effectOption_esm.filter(isOneOf([
|
|
7157
7387
|
NodeType.JSXElement,
|
|
7158
7388
|
NodeType.JSXFragment
|
|
7159
7389
|
])), effectOption_esm.isSome);
|
|
7160
|
-
}).
|
|
7161
|
-
type: NodeType.JSXMemberExpression
|
|
7162
|
-
}, effectFunction_esm.constTrue).with({
|
|
7163
|
-
type: NodeType.JSXNamespacedName
|
|
7164
|
-
}, effectFunction_esm.constTrue).otherwise(effectFunction_esm.constFalse);
|
|
7390
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7165
7391
|
}
|
|
7166
7392
|
|
|
7167
7393
|
/**
|
|
@@ -7196,7 +7422,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7196
7422
|
}).when(is(NodeType.SpreadElement), (prop)=>{
|
|
7197
7423
|
return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
|
|
7198
7424
|
const { name } = argument;
|
|
7199
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7425
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7200
7426
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7201
7427
|
return false;
|
|
7202
7428
|
}
|
|
@@ -7251,7 +7477,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7251
7477
|
type: NodeType.Identifier
|
|
7252
7478
|
}, (argument)=>{
|
|
7253
7479
|
const { name } = argument;
|
|
7254
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7480
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7255
7481
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7256
7482
|
return false;
|
|
7257
7483
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -232,8 +232,9 @@ declare function isPaddingSpaces(node: TSESTree.Node): boolean;
|
|
|
232
232
|
|
|
233
233
|
declare const JSXValueCheckHint: {
|
|
234
234
|
readonly None: 0n;
|
|
235
|
-
readonly
|
|
236
|
-
readonly
|
|
235
|
+
readonly SkipNull: bigint;
|
|
236
|
+
readonly SkipCreateElement: bigint;
|
|
237
|
+
readonly StrictArray: bigint;
|
|
237
238
|
readonly StrictLogical: bigint;
|
|
238
239
|
readonly StrictConditional: bigint;
|
|
239
240
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -232,8 +232,9 @@ declare function isPaddingSpaces(node: TSESTree.Node): boolean;
|
|
|
232
232
|
|
|
233
233
|
declare const JSXValueCheckHint: {
|
|
234
234
|
readonly None: 0n;
|
|
235
|
-
readonly
|
|
236
|
-
readonly
|
|
235
|
+
readonly SkipNull: bigint;
|
|
236
|
+
readonly SkipCreateElement: bigint;
|
|
237
|
+
readonly StrictArray: bigint;
|
|
237
238
|
readonly StrictLogical: bigint;
|
|
238
239
|
readonly StrictConditional: bigint;
|
|
239
240
|
};
|