@eslint-react/jsx 0.6.0 → 0.6.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 +257 -171
- package/dist/index.d.mts +59 -65
- package/dist/index.d.ts +59 -65
- package/dist/index.js +257 -171
- package/dist/index.mjs +256 -170
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -468,9 +468,10 @@ var effectFunction_esm = /*#__PURE__*/ Object.freeze({
|
|
|
468
468
|
unsafeCoerce: unsafeCoerce,
|
|
469
469
|
untupled: untupled
|
|
470
470
|
});
|
|
471
|
+
const moduleVersion = "2.0.0-next.54";
|
|
471
472
|
/**
|
|
472
473
|
* @since 2.0.0
|
|
473
|
-
*/ const globalStoreId = /*#__PURE__*/ Symbol.for(
|
|
474
|
+
*/ const globalStoreId = /*#__PURE__*/ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
|
|
474
475
|
if (!(globalStoreId in globalThis)) {
|
|
475
476
|
globalThis[globalStoreId] = /*#__PURE__*/ new Map();
|
|
476
477
|
}
|
|
@@ -514,7 +515,35 @@ const globalStore = globalThis[globalStoreId];
|
|
|
514
515
|
*
|
|
515
516
|
* @category guards
|
|
516
517
|
* @since 2.0.0
|
|
517
|
-
*/ const isObject = (input)=>typeof input === "object" && input
|
|
518
|
+
*/ const isObject = (input)=>typeof input === "object" && input !== null || isFunction(input);
|
|
519
|
+
/**
|
|
520
|
+
* Checks whether a value is an `object` containing a specified property key.
|
|
521
|
+
*
|
|
522
|
+
* @param property - The field to check within the object.
|
|
523
|
+
* @param self - The value to examine.
|
|
524
|
+
*
|
|
525
|
+
* @category guards
|
|
526
|
+
* @since 2.0.0
|
|
527
|
+
*/ const hasProperty = /*#__PURE__*/ dual(2, (self, property)=>isObject(self) && property in self);
|
|
528
|
+
/**
|
|
529
|
+
* Tests if a value is an `object` with a property `_tag` that matches the given tag.
|
|
530
|
+
*
|
|
531
|
+
* @param input - The value to test.
|
|
532
|
+
* @param tag - The tag to test for.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* import { isTagged } from "effect/Predicate"
|
|
536
|
+
*
|
|
537
|
+
* assert.deepStrictEqual(isTagged(1, "a"), false)
|
|
538
|
+
* assert.deepStrictEqual(isTagged(null, "a"), false)
|
|
539
|
+
* assert.deepStrictEqual(isTagged({}, "a"), false)
|
|
540
|
+
* assert.deepStrictEqual(isTagged({ a: "a" }, "a"), false)
|
|
541
|
+
* assert.deepStrictEqual(isTagged({ _tag: "a" }, "a"), true)
|
|
542
|
+
* assert.deepStrictEqual(isTagged("a")({ _tag: "a" }), true)
|
|
543
|
+
*
|
|
544
|
+
* @category guards
|
|
545
|
+
* @since 2.0.0
|
|
546
|
+
*/ const isTagged = /*#__PURE__*/ dual(2, (self, tag)=>hasProperty(self, "_tag") && self["_tag"] === tag);
|
|
518
547
|
/**
|
|
519
548
|
* A guard that succeeds when the input is `null` or `undefined`.
|
|
520
549
|
*
|
|
@@ -893,7 +922,7 @@ function add64(out, aHi, aLo, bHi, bLo) {
|
|
|
893
922
|
/**
|
|
894
923
|
* @since 2.0.0
|
|
895
924
|
* @category guards
|
|
896
|
-
*/ const isHash = (u)=>
|
|
925
|
+
*/ const isHash = (u)=>hasProperty(u, symbol$1);
|
|
897
926
|
/**
|
|
898
927
|
* @since 2.0.0
|
|
899
928
|
* @category hashing
|
|
@@ -980,7 +1009,7 @@ function compareBoth(self, that) {
|
|
|
980
1009
|
/**
|
|
981
1010
|
* @since 2.0.0
|
|
982
1011
|
* @category guards
|
|
983
|
-
*/ const isEqual = (u)=>
|
|
1012
|
+
*/ const isEqual = (u)=>hasProperty(u, symbol);
|
|
984
1013
|
/**
|
|
985
1014
|
* @since 2.0.0
|
|
986
1015
|
* @category instances
|
|
@@ -1016,7 +1045,7 @@ function compareBoth(self, that) {
|
|
|
1016
1045
|
*/ /**
|
|
1017
1046
|
* @since 2.0.0
|
|
1018
1047
|
*/ const toJSON = (x)=>{
|
|
1019
|
-
if (
|
|
1048
|
+
if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
|
|
1020
1049
|
return x.toJSON();
|
|
1021
1050
|
} else if (Array.isArray(x)) {
|
|
1022
1051
|
return x.map(toJSON);
|
|
@@ -1110,10 +1139,11 @@ function compareBoth(self, that) {
|
|
|
1110
1139
|
/** @internal */ const StreamTypeId = /*#__PURE__*/ Symbol.for("effect/Stream");
|
|
1111
1140
|
/** @internal */ const SinkTypeId = /*#__PURE__*/ Symbol.for("effect/Sink");
|
|
1112
1141
|
/** @internal */ const ChannelTypeId = /*#__PURE__*/ Symbol.for("effect/Channel");
|
|
1113
|
-
/** @internal */ const effectVariance
|
|
1142
|
+
/** @internal */ const effectVariance = {
|
|
1114
1143
|
_R: (_)=>_,
|
|
1115
1144
|
_E: (_)=>_,
|
|
1116
|
-
_A: (_)=>_
|
|
1145
|
+
_A: (_)=>_,
|
|
1146
|
+
_V: moduleVersion
|
|
1117
1147
|
};
|
|
1118
1148
|
/** @internal */ const sinkVariance = {
|
|
1119
1149
|
_R: (_)=>_,
|
|
@@ -1132,8 +1162,8 @@ function compareBoth(self, that) {
|
|
|
1132
1162
|
_OutDone: (_)=>_
|
|
1133
1163
|
};
|
|
1134
1164
|
/** @internal */ const EffectPrototype = {
|
|
1135
|
-
[EffectTypeId$1]: effectVariance
|
|
1136
|
-
[StreamTypeId]: effectVariance
|
|
1165
|
+
[EffectTypeId$1]: effectVariance,
|
|
1166
|
+
[StreamTypeId]: effectVariance,
|
|
1137
1167
|
[SinkTypeId]: sinkVariance,
|
|
1138
1168
|
[ChannelTypeId]: channelVariance,
|
|
1139
1169
|
[symbol] (that) {
|
|
@@ -1202,7 +1232,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
|
|
|
1202
1232
|
};
|
|
1203
1233
|
}
|
|
1204
1234
|
});
|
|
1205
|
-
/** @internal */ const isOption$1 = (input)=>
|
|
1235
|
+
/** @internal */ const isOption$1 = (input)=>hasProperty(input, TypeId$8);
|
|
1206
1236
|
/** @internal */ const isNone$1 = (fa)=>fa._tag === "None";
|
|
1207
1237
|
/** @internal */ const isSome$1 = (fa)=>fa._tag === "Some";
|
|
1208
1238
|
/** @internal */ const none$1 = /*#__PURE__*/ Object.create(NoneProto);
|
|
@@ -1262,7 +1292,7 @@ const LeftProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
|
|
|
1262
1292
|
};
|
|
1263
1293
|
}
|
|
1264
1294
|
});
|
|
1265
|
-
/** @internal */ const isEither$1 = (input)=>
|
|
1295
|
+
/** @internal */ const isEither$1 = (input)=>hasProperty(input, TypeId$7);
|
|
1266
1296
|
/** @internal */ const isLeft$1 = (ma)=>ma._tag === "Left";
|
|
1267
1297
|
/** @internal */ const isRight$1 = (ma)=>ma._tag === "Right";
|
|
1268
1298
|
/** @internal */ const left$1 = (left)=>{
|
|
@@ -2289,7 +2319,7 @@ const emptyArray = [];
|
|
|
2289
2319
|
*
|
|
2290
2320
|
* @category equivalence
|
|
2291
2321
|
* @since 2.0.0
|
|
2292
|
-
*/ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
|
|
2322
|
+
*/ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>self.length === that.length && toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
|
|
2293
2323
|
const _equivalence$1 = /*#__PURE__*/ getEquivalence$1(equals);
|
|
2294
2324
|
const ChunkProto = {
|
|
2295
2325
|
[TypeId$4]: {
|
|
@@ -2385,7 +2415,7 @@ const makeChunk = (backing)=>{
|
|
|
2385
2415
|
*
|
|
2386
2416
|
* @category constructors
|
|
2387
2417
|
* @since 2.0.0
|
|
2388
|
-
*/ const isChunk = (u)=>
|
|
2418
|
+
*/ const isChunk = (u)=>hasProperty(u, TypeId$4);
|
|
2389
2419
|
const _empty$4 = /*#__PURE__*/ makeChunk({
|
|
2390
2420
|
_tag: "IEmpty"
|
|
2391
2421
|
});
|
|
@@ -2713,7 +2743,7 @@ const copyToArray = (self, array, initial)=>{
|
|
|
2713
2743
|
...EffectPrototype,
|
|
2714
2744
|
_tag: "Tag",
|
|
2715
2745
|
_op: "Tag",
|
|
2716
|
-
[STMTypeId]: effectVariance
|
|
2746
|
+
[STMTypeId]: effectVariance,
|
|
2717
2747
|
[TagTypeId]: {
|
|
2718
2748
|
_S: (_)=>_,
|
|
2719
2749
|
_I: (_)=>_
|
|
@@ -2801,7 +2831,7 @@ const tagRegistry = /*#__PURE__*/ globalValue("effect/Context/Tag/tagRegistry",
|
|
|
2801
2831
|
context.unsafeMap = unsafeMap;
|
|
2802
2832
|
return context;
|
|
2803
2833
|
};
|
|
2804
|
-
/** @internal */ const isContext = (u)=>
|
|
2834
|
+
/** @internal */ const isContext = (u)=>hasProperty(u, TypeId$3);
|
|
2805
2835
|
const _empty$3 = /*#__PURE__*/ makeContext(/*#__PURE__*/ new Map());
|
|
2806
2836
|
/** @internal */ const empty$7 = ()=>_empty$3;
|
|
2807
2837
|
/** @internal */ const make$4 = (tag, service)=>makeContext(new Map([
|
|
@@ -3089,7 +3119,7 @@ const makeUpdateService = (tag, update)=>{
|
|
|
3089
3119
|
}
|
|
3090
3120
|
}
|
|
3091
3121
|
/** @internal */ function isEmptyNode(a) {
|
|
3092
|
-
return
|
|
3122
|
+
return isTagged(a, "EmptyNode");
|
|
3093
3123
|
}
|
|
3094
3124
|
/** @internal */ function isLeafNode(node) {
|
|
3095
3125
|
return isEmptyNode(node) || node._tag === "LeafNode" || node._tag === "CollisionNode";
|
|
@@ -3440,7 +3470,7 @@ const visitLazyChildren = (len, children, i, f, cont)=>{
|
|
|
3440
3470
|
};
|
|
3441
3471
|
const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(), 0);
|
|
3442
3472
|
/** @internal */ const empty$4 = ()=>_empty$1;
|
|
3443
|
-
/** @internal */ const isHashMap = (u)=>
|
|
3473
|
+
/** @internal */ const isHashMap = (u)=>hasProperty(u, HashMapTypeId);
|
|
3444
3474
|
/** @internal */ const getHash = /*#__PURE__*/ dual(3, (self, key, hash)=>{
|
|
3445
3475
|
let node = self._root;
|
|
3446
3476
|
let shift = 0;
|
|
@@ -3574,7 +3604,7 @@ const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(
|
|
|
3574
3604
|
set._keyMap = keyMap;
|
|
3575
3605
|
return set;
|
|
3576
3606
|
};
|
|
3577
|
-
/** @internal */ const isHashSet = (u)=>
|
|
3607
|
+
/** @internal */ const isHashSet = (u)=>hasProperty(u, HashSetTypeId);
|
|
3578
3608
|
const _empty = /*#__PURE__*/ makeImpl(/*#__PURE__*/ empty$4());
|
|
3579
3609
|
/** @internal */ const empty$3 = ()=>_empty;
|
|
3580
3610
|
/** @internal */ const size$2 = (self)=>size$3(self._keyMap);
|
|
@@ -3905,7 +3935,7 @@ var effectMutableRef_esm = /*#__PURE__*/ Object.freeze({
|
|
|
3905
3935
|
// -----------------------------------------------------------------------------
|
|
3906
3936
|
// Refinements
|
|
3907
3937
|
// -----------------------------------------------------------------------------
|
|
3908
|
-
/** @internal */ const isCause = (u)=>
|
|
3938
|
+
/** @internal */ const isCause = (u)=>hasProperty(u, CauseTypeId);
|
|
3909
3939
|
/** @internal */ const isInterruptedOnly = (self)=>reduceWithContext(undefined, IsInterruptedOnlyCauseReducer)(self);
|
|
3910
3940
|
/** @internal */ const causeEquals = (left, right)=>{
|
|
3911
3941
|
let leftStack = of$1(left);
|
|
@@ -4275,7 +4305,7 @@ class PrettyError {
|
|
|
4275
4305
|
return `Error: ${u}`;
|
|
4276
4306
|
}
|
|
4277
4307
|
// 2)
|
|
4278
|
-
if (
|
|
4308
|
+
if (hasProperty(u, "toString") && isFunction(u["toString"]) && u["toString"] !== Object.prototype.toString) {
|
|
4279
4309
|
return u["toString"]();
|
|
4280
4310
|
}
|
|
4281
4311
|
// 3)
|
|
@@ -4283,8 +4313,8 @@ class PrettyError {
|
|
|
4283
4313
|
};
|
|
4284
4314
|
const spanSymbol$1 = /*#__PURE__*/ Symbol.for("effect/SpanAnnotation");
|
|
4285
4315
|
const defaultRenderError = (error)=>{
|
|
4286
|
-
const span =
|
|
4287
|
-
if (
|
|
4316
|
+
const span = hasProperty(error, spanSymbol$1) && error[spanSymbol$1];
|
|
4317
|
+
if (error instanceof Error) {
|
|
4288
4318
|
return new PrettyError(prettyErrorMessage(error), error.stack?.split("\n").filter((_)=>_.match(/at (.*)/)).join("\n"), span);
|
|
4289
4319
|
}
|
|
4290
4320
|
return new PrettyError(prettyErrorMessage(error), void 0, span);
|
|
@@ -4384,11 +4414,6 @@ const defaultRenderError = (error)=>{
|
|
|
4384
4414
|
return this.toJSON();
|
|
4385
4415
|
}
|
|
4386
4416
|
}
|
|
4387
|
-
/** @internal */ const effectVariance = {
|
|
4388
|
-
_R: (_)=>_,
|
|
4389
|
-
_E: (_)=>_,
|
|
4390
|
-
_A: (_)=>_
|
|
4391
|
-
};
|
|
4392
4417
|
/* @internal */ const withFiberRuntime = (withRuntime)=>{
|
|
4393
4418
|
const effect = new EffectPrimitive(OP_WITH_RUNTIME);
|
|
4394
4419
|
effect.i0 = withRuntime;
|
|
@@ -4416,7 +4441,7 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
|
|
|
4416
4441
|
}
|
|
4417
4442
|
return obj;
|
|
4418
4443
|
};
|
|
4419
|
-
/* @internal */ const fail$1 = (error)=>
|
|
4444
|
+
/* @internal */ const fail$1 = (error)=>isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber)=>failCause(fail$2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail$2(error));
|
|
4420
4445
|
/* @internal */ const failCause = (cause)=>{
|
|
4421
4446
|
const effect = new EffectPrimitiveFailure(OP_FAILURE);
|
|
4422
4447
|
effect.i0 = cause;
|
|
@@ -4462,14 +4487,14 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
|
|
|
4462
4487
|
*
|
|
4463
4488
|
* @see https://github.com/oven-sh/bun/issues/3333
|
|
4464
4489
|
*/ /** @internal */ typeof process === "undefined" ? false : !!process?.isBun;
|
|
4465
|
-
/**
|
|
4466
|
-
* @since 2.0.0
|
|
4467
|
-
* @category constructors
|
|
4468
|
-
*/ const fail = fail$1;
|
|
4469
4490
|
/**
|
|
4470
4491
|
* @since 2.0.0
|
|
4471
4492
|
* @category prototypes
|
|
4472
4493
|
*/ const StructuralCommitPrototype = StructuralCommitPrototype$1;
|
|
4494
|
+
/**
|
|
4495
|
+
* @since 2.0.0
|
|
4496
|
+
* @category constructors
|
|
4497
|
+
*/ const fail = fail$1;
|
|
4473
4498
|
/**
|
|
4474
4499
|
* @since 2.0.0
|
|
4475
4500
|
*/ /**
|
|
@@ -6496,13 +6521,24 @@ function isStringLiteral(node) {
|
|
|
6496
6521
|
*/ function findVariableByNameUpToGlobal(name, startScope) {
|
|
6497
6522
|
return effectFunction_esm.pipe(getVariablesUpToGlobal(startScope), findVariableByName(name));
|
|
6498
6523
|
}
|
|
6524
|
+
/**
|
|
6525
|
+
* Get the first definition of a variable
|
|
6526
|
+
* @param variable The variable to get the definition from
|
|
6527
|
+
*/ function getVariableDefinitionFirst(variable) {
|
|
6528
|
+
return effectOption_esm.fromNullable(variable.defs[0]);
|
|
6529
|
+
}
|
|
6499
6530
|
/**
|
|
6500
6531
|
* Get the init node of the nth definition of a variable
|
|
6501
|
-
* @param
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6532
|
+
* @param variable
|
|
6533
|
+
* @param getDefinition A function that returns the nth definition of a variable
|
|
6534
|
+
*/ function getVariableInit(variable, getDefinition) {
|
|
6535
|
+
return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMap(getDefinition), effectOption_esm.flatMapNullable((d)=>d.node), effectOption_esm.flatMapNullable((n)=>"init" in n ? n.init : null));
|
|
6536
|
+
}
|
|
6537
|
+
/**
|
|
6538
|
+
* Get the init node of the first definition of a variable
|
|
6539
|
+
* @param variable
|
|
6540
|
+
*/ function getVariableInitFirst(variable) {
|
|
6541
|
+
return getVariableInit(variable, getVariableDefinitionFirst);
|
|
6506
6542
|
}
|
|
6507
6543
|
|
|
6508
6544
|
/**
|
|
@@ -6561,7 +6597,7 @@ const getPragmaFromContext = memo((context)=>{
|
|
|
6561
6597
|
return effectFunction_esm.pipe(effectOption_esm.orElse(effectOption_esm.fromNullable(settings.react?.pragma), ()=>effectFunction_esm.pipe(effectOption_esm.fromNullable(pragmaNode), effectOption_esm.map(({ value })=>RE_JSX_ANNOTATION_REGEX.exec(value)), effectOption_esm.flatMapNullable((matches)=>matches?.[1]?.split(".")[0]))), effectOption_esm.flatMap(effectOption_esm.liftPredicate((x)=>RE_JS_IDENTIFIER_REGEX.test(x))), effectOption_esm.getOrElse(effectFunction_esm.constant("React")));
|
|
6562
6598
|
});
|
|
6563
6599
|
|
|
6564
|
-
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],s=(n,o,c)=>{if(i(n)){const e=n[t](),{matched:r,selections:i}=e.match(o);return r&&i&&Object.keys(i).forEach(t=>c(t,i[t])),r}if(r(n)){if(!r(o))return !1;if(Array.isArray(n)){if(!Array.isArray(o))return !1;let t=[],r=[],a=[];for(const s of n.keys()){const o=n[s];i(o)&&o[e]?a.push(o):a.length?r.push(o):t.push(o);}if(a.length){if(a.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(o.length<t.length+r.length)return !1;const e=o.slice(0,t.length),n=0===r.length?[]:o.slice(-r.length),i=o.slice(t.length,0===r.length?Infinity:-r.length);return t.every((t,n)=>s(t,e[n],c))&&r.every((t,e)=>s(t,n[e],c))&&(0===a.length||s(a[0],i,c))}return n.length===o.length&&n.every((t,e)=>s(t,o[e],c))}return Object.keys(n).every(e=>{const r=n[e];return (e in o||i(a=r)&&"optional"===a[t]().matcherType)&&s(r,o[e],c);var a;})}return Object.is(o,n)},o=e=>{var n,s,a;return r(e)?i(e)?null!=(n=null==(s=(a=e[t]()).getSelectionKeys)?void 0:s.call(a))?n:[]:Array.isArray(e)?c(e,o):c(Object.values(e),o):[]},c=(t,e)=>t.reduce((t,n)=>t.concat(e(n)),[]);function a(...t){if(1===t.length){const[e]=t;return t=>s(e,t,()=>{})}if(2===t.length){const[e,n]=t;return s(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`)}function u(t){return Object.assign(t,{optional:()=>l(t),and:e=>m(t,e),or:e=>y(t,e),select:e=>void 0===e?p(t):p(e,t)})}function
|
|
6600
|
+
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],s=(n,o,c)=>{if(i(n)){const e=n[t](),{matched:r,selections:i}=e.match(o);return r&&i&&Object.keys(i).forEach(t=>c(t,i[t])),r}if(r(n)){if(!r(o))return !1;if(Array.isArray(n)){if(!Array.isArray(o))return !1;let t=[],r=[],a=[];for(const s of n.keys()){const o=n[s];i(o)&&o[e]?a.push(o):a.length?r.push(o):t.push(o);}if(a.length){if(a.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(o.length<t.length+r.length)return !1;const e=o.slice(0,t.length),n=0===r.length?[]:o.slice(-r.length),i=o.slice(t.length,0===r.length?Infinity:-r.length);return t.every((t,n)=>s(t,e[n],c))&&r.every((t,e)=>s(t,n[e],c))&&(0===a.length||s(a[0],i,c))}return n.length===o.length&&n.every((t,e)=>s(t,o[e],c))}return Object.keys(n).every(e=>{const r=n[e];return (e in o||i(a=r)&&"optional"===a[t]().matcherType)&&s(r,o[e],c);var a;})}return Object.is(o,n)},o=e=>{var n,s,a;return r(e)?i(e)?null!=(n=null==(s=(a=e[t]()).getSelectionKeys)?void 0:s.call(a))?n:[]:Array.isArray(e)?c(e,o):c(Object.values(e),o):[]},c=(t,e)=>t.reduce((t,n)=>t.concat(e(n)),[]);function a(...t){if(1===t.length){const[e]=t;return t=>s(e,t,()=>{})}if(2===t.length){const[e,n]=t;return s(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`)}function u(t){return Object.assign(t,{optional:()=>l(t),and:e=>m(t,e),or:e=>y(t,e),select:e=>void 0===e?p(t):p(e,t)})}function l(e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return void 0===t?(o(e).forEach(t=>r(t,void 0)),{matched:!0,selections:n}):{matched:s(e,t,r),selections:n}},getSelectionKeys:()=>o(e),matcherType:"optional"})})}function m(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return {matched:e.every(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"and"})})}function y(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return c(e,o).forEach(t=>r(t,void 0)),{matched:e.some(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"or"})})}function d(e){return {[t]:()=>({match:t=>({matched:Boolean(e(t))})})}}function p(...e){const r="string"==typeof e[0]?e[0]:void 0,i=2===e.length?e[1]:"string"==typeof e[0]?void 0:e[0];return u({[t]:()=>({match:t=>{let e={[null!=r?r:n]:t};return {matched:void 0===i||s(i,t,(t,n)=>{e[t]=n;}),selections:e}},getSelectionKeys:()=>[null!=r?r:n].concat(void 0===i?[]:o(i))})})}function v(t){return "number"==typeof t}function b(t){return "string"==typeof t}function w(t){return "bigint"==typeof t}u(d(function(t){return !0}));const j=t=>Object.assign(u(t),{startsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.startsWith(n)))));var n;},endsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.endsWith(n)))));var n;},minLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length>=t))(e))),maxLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length<=t))(e))),includes:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.includes(n)))));var n;},regex:e=>{return j(m(t,(n=e,d(t=>b(t)&&Boolean(t.match(n))))));var n;}});j(d(b));const K=t=>Object.assign(u(t),{between:(e,n)=>K(m(t,((t,e)=>d(n=>v(n)&&t<=n&&e>=n))(e,n))),lt:e=>K(m(t,(t=>d(e=>v(e)&&e<t))(e))),gt:e=>K(m(t,(t=>d(e=>v(e)&&e>t))(e))),lte:e=>K(m(t,(t=>d(e=>v(e)&&e<=t))(e))),gte:e=>K(m(t,(t=>d(e=>v(e)&&e>=t))(e))),int:()=>K(m(t,d(t=>v(t)&&Number.isInteger(t)))),finite:()=>K(m(t,d(t=>v(t)&&Number.isFinite(t)))),positive:()=>K(m(t,d(t=>v(t)&&t>0))),negative:()=>K(m(t,d(t=>v(t)&&t<0)))});K(d(v));const x=t=>Object.assign(u(t),{between:(e,n)=>x(m(t,((t,e)=>d(n=>w(n)&&t<=n&&e>=n))(e,n))),lt:e=>x(m(t,(t=>d(e=>w(e)&&e<t))(e))),gt:e=>x(m(t,(t=>d(e=>w(e)&&e>t))(e))),lte:e=>x(m(t,(t=>d(e=>w(e)&&e<=t))(e))),gte:e=>x(m(t,(t=>d(e=>w(e)&&e>=t))(e))),positive:()=>x(m(t,d(t=>w(t)&&t>0))),negative:()=>x(m(t,d(t=>w(t)&&t<0)))});x(d(w));u(d(function(t){return "boolean"==typeof t}));u(d(function(t){return "symbol"==typeof t}));u(d(function(t){return null==t}));const W={matched:!1,value:void 0};function N(t){return new $(t,W)}class ${constructor(t,e){this.input=void 0,this.state=void 0,this.input=t,this.state=e;}with(...t){if(this.state.matched)return this;const e=t[t.length-1],r=[t[0]];let i;3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i=t[1]):t.length>2&&r.push(...t.slice(1,t.length-1));let o=!1,c={};const a=(t,e)=>{o=!0,c[t]=e;},u=!r.some(t=>s(t,this.input,a))||i&&!Boolean(i(this.input))?W:{matched:!0,value:e(o?n in c?c[n]:c:this.input,this.input)};return new $(this.input,u)}when(t,e){if(this.state.matched)return this;const n=Boolean(t(this.input));return new $(this.input,n?{matched:!0,value:e(this.input,this.input)}:W)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input);}catch(e){t=this.input;}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}
|
|
6565
6601
|
|
|
6566
6602
|
function isPropertyOfPragma(name, context, pragma = getPragmaFromContext(context)) {
|
|
6567
6603
|
const isMatch = a({
|
|
@@ -6929,190 +6965,175 @@ function isFragmentWithSingleExpression(node) {
|
|
|
6929
6965
|
return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
|
|
6930
6966
|
}
|
|
6931
6967
|
|
|
6932
|
-
const
|
|
6933
|
-
|
|
6934
|
-
|
|
6968
|
+
/* eslint-disable perfectionist/sort-objects */ const JSXValueCheckHint = {
|
|
6969
|
+
None: 0n,
|
|
6970
|
+
IgnoreNull: 1n << 0n,
|
|
6971
|
+
IgnoreCreateElement: 1n << 1n,
|
|
6972
|
+
StrictLogical: 1n << 2n,
|
|
6973
|
+
StrictConditional: 1n << 3n
|
|
6935
6974
|
};
|
|
6936
|
-
/**
|
|
6975
|
+
/* eslint-enable perfectionist/sort-objects */ /**
|
|
6937
6976
|
* Check if a node is a JSX value
|
|
6938
6977
|
* @param node The AST node to check
|
|
6939
6978
|
* @param context The rule context
|
|
6940
|
-
* @param
|
|
6979
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
6941
6980
|
* @returns boolean
|
|
6942
|
-
*/ function isJSXValue(node, context,
|
|
6981
|
+
*/ function isJSXValue(node, context, hint = JSXValueCheckHint.None) {
|
|
6943
6982
|
if (!node) {
|
|
6944
6983
|
return false;
|
|
6945
6984
|
}
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6985
|
+
return N(node).with({
|
|
6986
|
+
type: NodeType.JSXElement
|
|
6987
|
+
}, effectFunction_esm.constTrue).with({
|
|
6988
|
+
type: NodeType.JSXFragment
|
|
6989
|
+
}, effectFunction_esm.constTrue).with({
|
|
6990
|
+
type: NodeType.Literal
|
|
6991
|
+
}, (node)=>{
|
|
6992
|
+
if (!("value" in node) || hint & JSXValueCheckHint.IgnoreNull) {
|
|
6951
6993
|
return false;
|
|
6952
6994
|
}
|
|
6953
6995
|
return node.value === null;
|
|
6954
|
-
}).with(
|
|
6996
|
+
}).with({
|
|
6997
|
+
type: NodeType.ConditionalExpression
|
|
6998
|
+
}, (node)=>{
|
|
6955
6999
|
if (!("consequent" in node)) {
|
|
6956
7000
|
return false;
|
|
6957
7001
|
}
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
7002
|
+
function leftHasJSX(node) {
|
|
7003
|
+
if (!("consequent" in node)) {
|
|
7004
|
+
return false;
|
|
7005
|
+
}
|
|
7006
|
+
if (Array.isArray(node.consequent)) {
|
|
7007
|
+
return node.consequent.some((n)=>isJSXValue(n, context, hint));
|
|
7008
|
+
}
|
|
7009
|
+
return isJSXValue(node.consequent, context, hint);
|
|
6961
7010
|
}
|
|
6962
|
-
|
|
6963
|
-
|
|
7011
|
+
function rightHasJSX(node) {
|
|
7012
|
+
return "alternate" in node && isJSXValue(node.alternate, context, hint);
|
|
7013
|
+
}
|
|
7014
|
+
if (hint & JSXValueCheckHint.StrictConditional) {
|
|
7015
|
+
return leftHasJSX(node) && rightHasJSX(node);
|
|
7016
|
+
}
|
|
7017
|
+
return leftHasJSX(node) || rightHasJSX(node);
|
|
7018
|
+
}).with({
|
|
7019
|
+
type: NodeType.LogicalExpression
|
|
7020
|
+
}, (node)=>{
|
|
6964
7021
|
if (!("left" in node)) {
|
|
6965
7022
|
return false;
|
|
6966
7023
|
}
|
|
6967
|
-
return isJSXValue(node.left, context,
|
|
6968
|
-
}).with(
|
|
7024
|
+
return isJSXValue(node.left, context, hint) || isJSXValue(node.right, context, hint);
|
|
7025
|
+
}).with({
|
|
7026
|
+
type: NodeType.SequenceExpression
|
|
7027
|
+
}, (node)=>{
|
|
6969
7028
|
if (!("expressions" in node)) {
|
|
6970
7029
|
return false;
|
|
6971
7030
|
}
|
|
6972
7031
|
const exp = node.expressions.at(-1);
|
|
6973
|
-
return isJSXValue(exp, context,
|
|
6974
|
-
}).with(
|
|
7032
|
+
return isJSXValue(exp, context, hint);
|
|
7033
|
+
}).with({
|
|
7034
|
+
type: NodeType.CallExpression
|
|
7035
|
+
}, (node)=>{
|
|
7036
|
+
if (hint & JSXValueCheckHint.IgnoreCreateElement) {
|
|
7037
|
+
return false;
|
|
7038
|
+
}
|
|
7039
|
+
return isCreateElementCall(node, context);
|
|
7040
|
+
}).with({
|
|
7041
|
+
type: NodeType.Identifier
|
|
7042
|
+
}, (node)=>{
|
|
6975
7043
|
if (!("name" in node)) {
|
|
6976
7044
|
return false;
|
|
6977
7045
|
}
|
|
6978
7046
|
if (isJSXTagNameExpression(node)) {
|
|
6979
7047
|
return true;
|
|
6980
7048
|
}
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
}
|
|
6984
|
-
const name = N(node.name).with(_.string, effectFunction_esm.identity).with({
|
|
6985
|
-
type: NodeType.Identifier
|
|
6986
|
-
}, (n)=>n.name).exhaustive();
|
|
6987
|
-
const variable = findVariableByNameUpToGlobal(name, context.getScope());
|
|
6988
|
-
return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableNthDefNodeInit(0)), effectOption_esm.map(isOneOf([
|
|
7049
|
+
const variable = findVariableByNameUpToGlobal(node.name, context.getScope());
|
|
7050
|
+
return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableInitFirst), effectOption_esm.filter(isOneOf([
|
|
6989
7051
|
NodeType.JSXElement,
|
|
6990
7052
|
NodeType.JSXFragment
|
|
6991
|
-
])), effectOption_esm.
|
|
6992
|
-
}).
|
|
7053
|
+
])), effectOption_esm.isSome);
|
|
7054
|
+
}).with({
|
|
7055
|
+
type: NodeType.JSXMemberExpression
|
|
7056
|
+
}, effectFunction_esm.constTrue).with({
|
|
7057
|
+
type: NodeType.JSXNamespacedName
|
|
7058
|
+
}, effectFunction_esm.constTrue).otherwise(effectFunction_esm.constFalse);
|
|
6993
7059
|
}
|
|
6994
7060
|
|
|
6995
7061
|
/**
|
|
6996
7062
|
* Check if function is returning JSX
|
|
6997
7063
|
* @param node The return statement node to check
|
|
6998
7064
|
* @param context The rule context
|
|
6999
|
-
* @param
|
|
7065
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
7000
7066
|
* @returns boolean
|
|
7001
|
-
*/ function isFunctionReturningJSXValue(node, context,
|
|
7067
|
+
*/ function isFunctionReturningJSXValue(node, context, hint = JSXValueCheckHint.None) {
|
|
7002
7068
|
if (node.body.type !== NodeType.BlockStatement) {
|
|
7003
|
-
return isJSXValue(node.body, context,
|
|
7069
|
+
return isJSXValue(node.body, context, hint);
|
|
7004
7070
|
}
|
|
7005
7071
|
const statements = getNestedReturnStatements(node.body);
|
|
7006
|
-
return statements.some((statement)=>isJSXValue(statement.argument, context,
|
|
7072
|
+
return statements.some((statement)=>isJSXValue(statement.argument, context, hint));
|
|
7007
7073
|
}
|
|
7008
7074
|
|
|
7009
|
-
/**
|
|
7010
|
-
* Check if the given prop name is present in the given attributes
|
|
7011
|
-
* @param attributes The attributes to search in
|
|
7012
|
-
* @param propName The prop name to search for
|
|
7013
|
-
* @param context The rule context
|
|
7014
|
-
* @returns `true` if the given prop name is present in the given properties
|
|
7015
|
-
*/ function hasProp(attributes, propName, context) {
|
|
7016
|
-
return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
|
|
7017
|
-
}
|
|
7018
|
-
/**
|
|
7019
|
-
* Check if any of the given prop names are present in the given attributes
|
|
7020
|
-
* @param attributes The attributes to search in
|
|
7021
|
-
* @param propNames The prop names to search for
|
|
7022
|
-
* @param context The rule context
|
|
7023
|
-
* @returns `true` if any of the given prop names are present in the given attributes
|
|
7024
|
-
*/ function hasAnyProp(attributes, propNames, context) {
|
|
7025
|
-
return propNames.some((propName)=>hasProp(attributes, propName, context));
|
|
7026
|
-
}
|
|
7027
|
-
/**
|
|
7028
|
-
* Check if all of the given prop names are present in the given attributes
|
|
7029
|
-
* @param attributes The attributes to search in
|
|
7030
|
-
* @param propNames The prop names to search for
|
|
7031
|
-
* @param context The rule context
|
|
7032
|
-
* @returns `true` if all of the given prop names are present in the given attributes
|
|
7033
|
-
*/ function hasEveryProp(attributes, propNames, context) {
|
|
7034
|
-
return propNames.every((propName)=>hasProp(attributes, propName, context));
|
|
7035
|
-
}
|
|
7036
|
-
/**
|
|
7037
|
-
* Get the name of a JSX attribute
|
|
7038
|
-
* @param node The JSX attribute node
|
|
7039
|
-
* @returns string
|
|
7040
|
-
*/ function getPropName(node) {
|
|
7041
|
-
return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>n.name.name).exhaustive();
|
|
7042
|
-
}
|
|
7043
|
-
/**
|
|
7044
|
-
* Get the name of a JSX attribute with namespace
|
|
7045
|
-
* @param node The JSX attribute node
|
|
7046
|
-
* @returns string
|
|
7047
|
-
*/ function getPropNameWithNamespace(node) {
|
|
7048
|
-
return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
|
|
7049
|
-
}
|
|
7050
|
-
/**
|
|
7051
|
-
* Traverses up prop node
|
|
7052
|
-
* @param node The AST node to start traversing from
|
|
7053
|
-
* @param predicate The predicate to check each node
|
|
7054
|
-
* @returns prop node if found
|
|
7055
|
-
*/ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
|
|
7056
|
-
const matcher = (node)=>{
|
|
7057
|
-
return node.type === NodeType.JSXAttribute && predicate(node);
|
|
7058
|
-
};
|
|
7059
|
-
return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
|
|
7060
|
-
}
|
|
7061
|
-
/**
|
|
7062
|
-
* Checks if the node is inside a prop's value
|
|
7063
|
-
* @param node The AST node to check
|
|
7064
|
-
* @returns `true` if the node is inside a prop's value
|
|
7065
|
-
*/ function isInsidePropValue(node) {
|
|
7066
|
-
if (isStringLiteral(node)) {
|
|
7067
|
-
return node.parent.type === NodeType.JSXAttribute;
|
|
7068
|
-
}
|
|
7069
|
-
return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
|
|
7070
|
-
}
|
|
7071
7075
|
/**
|
|
7072
7076
|
* @param properties The properties to search in
|
|
7073
7077
|
* @param context The rule context
|
|
7074
7078
|
* @param seenProps The properties that have already been seen
|
|
7075
7079
|
* @returns A function that searches for a property in the given properties
|
|
7076
7080
|
*/ function findPropInProperties(properties, context, seenProps = []) {
|
|
7081
|
+
const startScope = context.getScope();
|
|
7077
7082
|
/**
|
|
7078
7083
|
* Search for a property in the given properties
|
|
7079
7084
|
* @param propName The name of the property to search for
|
|
7080
7085
|
* @returns The property if found
|
|
7081
7086
|
*/ return (propName)=>{
|
|
7082
7087
|
return effectOption_esm.fromNullable(properties.find((prop)=>{
|
|
7083
|
-
|
|
7088
|
+
return N(prop).when(is(NodeType.Property), (prop)=>{
|
|
7084
7089
|
return "name" in prop.key && prop.key.name === propName;
|
|
7085
|
-
}
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7090
|
+
}).when(is(NodeType.SpreadElement), (prop)=>{
|
|
7091
|
+
return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
|
|
7092
|
+
const { name } = argument;
|
|
7093
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
|
|
7094
|
+
if (effectOption_esm.isNone(maybeInit)) {
|
|
7095
|
+
return false;
|
|
7096
|
+
}
|
|
7097
|
+
const init = maybeInit.value;
|
|
7098
|
+
if (init.type !== NodeType.ObjectExpression) {
|
|
7099
|
+
return false;
|
|
7100
|
+
}
|
|
7101
|
+
if (seenProps.includes(name)) {
|
|
7102
|
+
return false;
|
|
7103
|
+
}
|
|
7104
|
+
return effectOption_esm.isSome(findPropInProperties(init.properties, context, [
|
|
7105
|
+
...seenProps,
|
|
7106
|
+
name
|
|
7107
|
+
])(propName));
|
|
7108
|
+
}).when(is(NodeType.ObjectExpression), (argument)=>{
|
|
7109
|
+
return effectOption_esm.isSome(findPropInProperties(argument.properties, context, seenProps)(propName));
|
|
7110
|
+
}).when(is(NodeType.MemberExpression), ()=>{
|
|
7111
|
+
// Not implemented
|
|
7112
|
+
}).when(is(NodeType.CallExpression), ()=>{
|
|
7113
|
+
// Not implemented
|
|
7114
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7115
|
+
}).when(is(NodeType.RestElement), ()=>{
|
|
7116
|
+
// Not implemented
|
|
7117
|
+
return false;
|
|
7118
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7108
7119
|
}));
|
|
7109
7120
|
};
|
|
7110
7121
|
}
|
|
7122
|
+
|
|
7123
|
+
/**
|
|
7124
|
+
* Get the name of a JSX attribute with namespace
|
|
7125
|
+
* @param node The JSX attribute node
|
|
7126
|
+
* @returns string
|
|
7127
|
+
*/ function getPropName(node) {
|
|
7128
|
+
return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
|
|
7129
|
+
}
|
|
7130
|
+
|
|
7111
7131
|
/**
|
|
7112
7132
|
* @param attributes The attributes to search in
|
|
7113
7133
|
* @param context The rule context
|
|
7114
7134
|
* @returns A function that searches for a property in the given attributes
|
|
7115
7135
|
*/ function findPropInAttributes(attributes, context) {
|
|
7136
|
+
const startScope = context.getScope();
|
|
7116
7137
|
/**
|
|
7117
7138
|
* Search for a property in the given attributes
|
|
7118
7139
|
* @param propName The name of the property to search for
|
|
@@ -7120,22 +7141,36 @@ const defaultJSXValueCheckOptions = {
|
|
|
7120
7141
|
*/ return (propName)=>{
|
|
7121
7142
|
return effectOption_esm.fromNullable(attributes.find((attr)=>{
|
|
7122
7143
|
return N(attr).when(is(NodeType.JSXAttribute), (attr)=>getPropName(attr) === propName).when(is(NodeType.JSXSpreadAttribute), (attr)=>{
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
}
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7144
|
+
return N(attr.argument).with({
|
|
7145
|
+
type: NodeType.Identifier
|
|
7146
|
+
}, (argument)=>{
|
|
7147
|
+
const { name } = argument;
|
|
7148
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
|
|
7149
|
+
if (effectOption_esm.isNone(maybeInit)) {
|
|
7150
|
+
return false;
|
|
7151
|
+
}
|
|
7152
|
+
const init = maybeInit.value;
|
|
7153
|
+
if (!("properties" in init)) {
|
|
7154
|
+
return false;
|
|
7155
|
+
}
|
|
7156
|
+
return effectOption_esm.isSome(findPropInProperties(init.properties, context)(propName));
|
|
7157
|
+
}).when(is(NodeType.ObjectExpression), (argument)=>{
|
|
7158
|
+
return effectOption_esm.isSome(findPropInProperties(argument.properties, context)(propName));
|
|
7159
|
+
}).when(is(NodeType.MemberExpression), ()=>{
|
|
7160
|
+
// Not implemented
|
|
7129
7161
|
return false;
|
|
7130
|
-
}
|
|
7131
|
-
|
|
7162
|
+
}).when(is(NodeType.CallExpression), ()=>{
|
|
7163
|
+
// Not implemented
|
|
7132
7164
|
return false;
|
|
7133
|
-
}
|
|
7134
|
-
return effectOption_esm.isSome(findPropInProperties(maybeFirstDefNodeInit.value.properties, context)(propName));
|
|
7165
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7135
7166
|
}).otherwise(effectFunction_esm.constFalse);
|
|
7136
7167
|
}));
|
|
7137
7168
|
};
|
|
7138
7169
|
}
|
|
7170
|
+
|
|
7171
|
+
function getProp(props, propName, context) {
|
|
7172
|
+
return findPropInAttributes(props, context)(propName);
|
|
7173
|
+
}
|
|
7139
7174
|
/**
|
|
7140
7175
|
* Gets and resolves the static value of a JSX attribute
|
|
7141
7176
|
* @param attribute The JSX attribute to get the value of
|
|
@@ -7160,4 +7195,55 @@ const defaultJSXValueCheckOptions = {
|
|
|
7160
7195
|
return effectOption_esm.some(getStaticValue(argument, scope));
|
|
7161
7196
|
}
|
|
7162
7197
|
|
|
7163
|
-
|
|
7198
|
+
/**
|
|
7199
|
+
* Check if the given prop name is present in the given attributes
|
|
7200
|
+
* @param attributes The attributes to search in
|
|
7201
|
+
* @param propName The prop name to search for
|
|
7202
|
+
* @param context The rule context
|
|
7203
|
+
* @returns `true` if the given prop name is present in the given properties
|
|
7204
|
+
*/ function hasProp(attributes, propName, context) {
|
|
7205
|
+
return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
|
|
7206
|
+
}
|
|
7207
|
+
/**
|
|
7208
|
+
* Check if any of the given prop names are present in the given attributes
|
|
7209
|
+
* @param attributes The attributes to search in
|
|
7210
|
+
* @param propNames The prop names to search for
|
|
7211
|
+
* @param context The rule context
|
|
7212
|
+
* @returns `true` if any of the given prop names are present in the given attributes
|
|
7213
|
+
*/ function hasAnyProp(attributes, propNames, context) {
|
|
7214
|
+
return propNames.some((propName)=>hasProp(attributes, propName, context));
|
|
7215
|
+
}
|
|
7216
|
+
/**
|
|
7217
|
+
* Check if all of the given prop names are present in the given attributes
|
|
7218
|
+
* @param attributes The attributes to search in
|
|
7219
|
+
* @param propNames The prop names to search for
|
|
7220
|
+
* @param context The rule context
|
|
7221
|
+
* @returns `true` if all of the given prop names are present in the given attributes
|
|
7222
|
+
*/ function hasEveryProp(attributes, propNames, context) {
|
|
7223
|
+
return propNames.every((propName)=>hasProp(attributes, propName, context));
|
|
7224
|
+
}
|
|
7225
|
+
|
|
7226
|
+
/**
|
|
7227
|
+
* Traverses up prop node
|
|
7228
|
+
* @param node The AST node to start traversing from
|
|
7229
|
+
* @param predicate The predicate to check each node
|
|
7230
|
+
* @returns prop node if found
|
|
7231
|
+
*/ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
|
|
7232
|
+
const matcher = (node)=>{
|
|
7233
|
+
return node.type === NodeType.JSXAttribute && predicate(node);
|
|
7234
|
+
};
|
|
7235
|
+
return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
|
|
7236
|
+
}
|
|
7237
|
+
|
|
7238
|
+
/**
|
|
7239
|
+
* Checks if the node is inside a prop's value
|
|
7240
|
+
* @param node The AST node to check
|
|
7241
|
+
* @returns `true` if the node is inside a prop's value
|
|
7242
|
+
*/ function isInsidePropValue(node) {
|
|
7243
|
+
if (isStringLiteral(node)) {
|
|
7244
|
+
return node.parent.type === NodeType.JSXAttribute;
|
|
7245
|
+
}
|
|
7246
|
+
return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
|
|
7247
|
+
}
|
|
7248
|
+
|
|
7249
|
+
export { JSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|