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