@eslint-react/jsx 0.6.2 → 0.7.0
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 +59 -37
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +59 -37
- package/dist/index.mjs +59 -37
- package/package.json +4 -4
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);
|
|
@@ -6605,7 +6622,7 @@ function isStringLiteral(node) {
|
|
|
6605
6622
|
/**
|
|
6606
6623
|
* @param variables The variables to search through
|
|
6607
6624
|
*/ return (variables)=>{
|
|
6608
|
-
return effectOption_esm.fromNullable(variables.find((variable)=>
|
|
6625
|
+
return effectOption_esm.fromNullable(variables.find((variable)=>variable.name === name));
|
|
6609
6626
|
};
|
|
6610
6627
|
}
|
|
6611
6628
|
/**
|
|
@@ -6614,7 +6631,7 @@ function isStringLiteral(node) {
|
|
|
6614
6631
|
*/ function getVariablesUpToGlobal(startScope) {
|
|
6615
6632
|
const scopeRef = effectMutableRef_esm.make(startScope);
|
|
6616
6633
|
const variablesRef = effectMutableRef_esm.make(effectMutableRef_esm.get(scopeRef).variables);
|
|
6617
|
-
while(effectMutableRef_esm.get(scopeRef).
|
|
6634
|
+
while(effectMutableRef_esm.get(scopeRef).type !== scopeManager.ScopeType.global){
|
|
6618
6635
|
effectMutableRef_esm.set(scopeRef, effectMutableRef_esm.get(scopeRef).upper);
|
|
6619
6636
|
effectMutableRef_esm.update(variablesRef, (variables)=>variables.concat(effectMutableRef_esm.get(scopeRef).variables));
|
|
6620
6637
|
}
|
|
@@ -6625,26 +6642,23 @@ function isStringLiteral(node) {
|
|
|
6625
6642
|
* @param name The name of the variable to find
|
|
6626
6643
|
* @param startScope The scope to start from
|
|
6627
6644
|
*/ function findVariableByNameUpToGlobal(name, startScope) {
|
|
6628
|
-
return
|
|
6645
|
+
return findVariableByName(name)(getVariablesUpToGlobal(startScope));
|
|
6629
6646
|
}
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6647
|
+
function resolveDefinitionInit(def) {
|
|
6648
|
+
if ("init" in def.node && !isNullable(def.node.init)) {
|
|
6649
|
+
return effectOption_esm.some(def.node.init);
|
|
6650
|
+
}
|
|
6651
|
+
// TODO: support other types of definitions
|
|
6652
|
+
return effectOption_esm.none();
|
|
6635
6653
|
}
|
|
6636
6654
|
/**
|
|
6637
6655
|
* 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);
|
|
6656
|
+
* @param at The index number of def in defs
|
|
6657
|
+
* @returns A function that takes a variable and returns the init node of the nth definition of that variable
|
|
6658
|
+
*/ function getVariableInit(at) {
|
|
6659
|
+
return (variable)=>{
|
|
6660
|
+
return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMap(resolveDefinitionInit));
|
|
6661
|
+
};
|
|
6648
6662
|
}
|
|
6649
6663
|
|
|
6650
6664
|
/**
|
|
@@ -7076,7 +7090,8 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7076
7090
|
IgnoreNull: 1n << 0n,
|
|
7077
7091
|
IgnoreCreateElement: 1n << 1n,
|
|
7078
7092
|
StrictLogical: 1n << 2n,
|
|
7079
|
-
StrictConditional: 1n << 3n
|
|
7093
|
+
StrictConditional: 1n << 3n,
|
|
7094
|
+
StrictArrayExpression: 1n << 4n
|
|
7080
7095
|
};
|
|
7081
7096
|
/* eslint-enable perfectionist/sort-objects */ /**
|
|
7082
7097
|
* Check if a node is a JSX value
|
|
@@ -7092,6 +7107,10 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7092
7107
|
type: NodeType.JSXElement
|
|
7093
7108
|
}, effectFunction_esm.constTrue).with({
|
|
7094
7109
|
type: NodeType.JSXFragment
|
|
7110
|
+
}, effectFunction_esm.constTrue).with({
|
|
7111
|
+
type: NodeType.JSXMemberExpression
|
|
7112
|
+
}, effectFunction_esm.constTrue).with({
|
|
7113
|
+
type: NodeType.JSXNamespacedName
|
|
7095
7114
|
}, effectFunction_esm.constTrue).with({
|
|
7096
7115
|
type: NodeType.Literal
|
|
7097
7116
|
}, (node)=>{
|
|
@@ -7099,6 +7118,16 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7099
7118
|
return false;
|
|
7100
7119
|
}
|
|
7101
7120
|
return node.value === null;
|
|
7121
|
+
}).with({
|
|
7122
|
+
type: NodeType.ArrayExpression
|
|
7123
|
+
}, (node)=>{
|
|
7124
|
+
if (!("elements" in node)) {
|
|
7125
|
+
return false;
|
|
7126
|
+
}
|
|
7127
|
+
if (hint & JSXValueCheckHint.StrictArrayExpression) {
|
|
7128
|
+
return node.elements.every((n)=>isJSXValue(n, context, hint));
|
|
7129
|
+
}
|
|
7130
|
+
return node.elements.some((n)=>isJSXValue(n, context, hint));
|
|
7102
7131
|
}).with({
|
|
7103
7132
|
type: NodeType.ConditionalExpression
|
|
7104
7133
|
}, (node)=>{
|
|
@@ -7146,22 +7175,15 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7146
7175
|
}).with({
|
|
7147
7176
|
type: NodeType.Identifier
|
|
7148
7177
|
}, (node)=>{
|
|
7149
|
-
if (!("name" in node)) {
|
|
7150
|
-
return false;
|
|
7151
|
-
}
|
|
7152
7178
|
if (isJSXTagNameExpression(node)) {
|
|
7153
7179
|
return true;
|
|
7154
7180
|
}
|
|
7155
|
-
const
|
|
7156
|
-
return effectFunction_esm.pipe(
|
|
7181
|
+
const maybeVariable = findVariableByNameUpToGlobal(node.name, context.getScope());
|
|
7182
|
+
return effectFunction_esm.pipe(maybeVariable, effectOption_esm.flatMap(getVariableInit(0)), effectOption_esm.filter(isOneOf([
|
|
7157
7183
|
NodeType.JSXElement,
|
|
7158
7184
|
NodeType.JSXFragment
|
|
7159
7185
|
])), 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);
|
|
7186
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7165
7187
|
}
|
|
7166
7188
|
|
|
7167
7189
|
/**
|
|
@@ -7196,7 +7218,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7196
7218
|
}).when(is(NodeType.SpreadElement), (prop)=>{
|
|
7197
7219
|
return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
|
|
7198
7220
|
const { name } = argument;
|
|
7199
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7221
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7200
7222
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7201
7223
|
return false;
|
|
7202
7224
|
}
|
|
@@ -7251,7 +7273,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7251
7273
|
type: NodeType.Identifier
|
|
7252
7274
|
}, (argument)=>{
|
|
7253
7275
|
const { name } = argument;
|
|
7254
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7276
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7255
7277
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7256
7278
|
return false;
|
|
7257
7279
|
}
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
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);
|
|
@@ -6605,7 +6622,7 @@ function isStringLiteral(node) {
|
|
|
6605
6622
|
/**
|
|
6606
6623
|
* @param variables The variables to search through
|
|
6607
6624
|
*/ return (variables)=>{
|
|
6608
|
-
return effectOption_esm.fromNullable(variables.find((variable)=>
|
|
6625
|
+
return effectOption_esm.fromNullable(variables.find((variable)=>variable.name === name));
|
|
6609
6626
|
};
|
|
6610
6627
|
}
|
|
6611
6628
|
/**
|
|
@@ -6614,7 +6631,7 @@ function isStringLiteral(node) {
|
|
|
6614
6631
|
*/ function getVariablesUpToGlobal(startScope) {
|
|
6615
6632
|
const scopeRef = effectMutableRef_esm.make(startScope);
|
|
6616
6633
|
const variablesRef = effectMutableRef_esm.make(effectMutableRef_esm.get(scopeRef).variables);
|
|
6617
|
-
while(effectMutableRef_esm.get(scopeRef).
|
|
6634
|
+
while(effectMutableRef_esm.get(scopeRef).type !== scopeManager.ScopeType.global){
|
|
6618
6635
|
effectMutableRef_esm.set(scopeRef, effectMutableRef_esm.get(scopeRef).upper);
|
|
6619
6636
|
effectMutableRef_esm.update(variablesRef, (variables)=>variables.concat(effectMutableRef_esm.get(scopeRef).variables));
|
|
6620
6637
|
}
|
|
@@ -6625,26 +6642,23 @@ function isStringLiteral(node) {
|
|
|
6625
6642
|
* @param name The name of the variable to find
|
|
6626
6643
|
* @param startScope The scope to start from
|
|
6627
6644
|
*/ function findVariableByNameUpToGlobal(name, startScope) {
|
|
6628
|
-
return
|
|
6645
|
+
return findVariableByName(name)(getVariablesUpToGlobal(startScope));
|
|
6629
6646
|
}
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6647
|
+
function resolveDefinitionInit(def) {
|
|
6648
|
+
if ("init" in def.node && !isNullable(def.node.init)) {
|
|
6649
|
+
return effectOption_esm.some(def.node.init);
|
|
6650
|
+
}
|
|
6651
|
+
// TODO: support other types of definitions
|
|
6652
|
+
return effectOption_esm.none();
|
|
6635
6653
|
}
|
|
6636
6654
|
/**
|
|
6637
6655
|
* 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);
|
|
6656
|
+
* @param at The index number of def in defs
|
|
6657
|
+
* @returns A function that takes a variable and returns the init node of the nth definition of that variable
|
|
6658
|
+
*/ function getVariableInit(at) {
|
|
6659
|
+
return (variable)=>{
|
|
6660
|
+
return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMap(resolveDefinitionInit));
|
|
6661
|
+
};
|
|
6648
6662
|
}
|
|
6649
6663
|
|
|
6650
6664
|
/**
|
|
@@ -7076,7 +7090,8 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7076
7090
|
IgnoreNull: 1n << 0n,
|
|
7077
7091
|
IgnoreCreateElement: 1n << 1n,
|
|
7078
7092
|
StrictLogical: 1n << 2n,
|
|
7079
|
-
StrictConditional: 1n << 3n
|
|
7093
|
+
StrictConditional: 1n << 3n,
|
|
7094
|
+
StrictArrayExpression: 1n << 4n
|
|
7080
7095
|
};
|
|
7081
7096
|
/* eslint-enable perfectionist/sort-objects */ /**
|
|
7082
7097
|
* Check if a node is a JSX value
|
|
@@ -7092,6 +7107,10 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7092
7107
|
type: NodeType.JSXElement
|
|
7093
7108
|
}, effectFunction_esm.constTrue).with({
|
|
7094
7109
|
type: NodeType.JSXFragment
|
|
7110
|
+
}, effectFunction_esm.constTrue).with({
|
|
7111
|
+
type: NodeType.JSXMemberExpression
|
|
7112
|
+
}, effectFunction_esm.constTrue).with({
|
|
7113
|
+
type: NodeType.JSXNamespacedName
|
|
7095
7114
|
}, effectFunction_esm.constTrue).with({
|
|
7096
7115
|
type: NodeType.Literal
|
|
7097
7116
|
}, (node)=>{
|
|
@@ -7099,6 +7118,16 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7099
7118
|
return false;
|
|
7100
7119
|
}
|
|
7101
7120
|
return node.value === null;
|
|
7121
|
+
}).with({
|
|
7122
|
+
type: NodeType.ArrayExpression
|
|
7123
|
+
}, (node)=>{
|
|
7124
|
+
if (!("elements" in node)) {
|
|
7125
|
+
return false;
|
|
7126
|
+
}
|
|
7127
|
+
if (hint & JSXValueCheckHint.StrictArrayExpression) {
|
|
7128
|
+
return node.elements.every((n)=>isJSXValue(n, context, hint));
|
|
7129
|
+
}
|
|
7130
|
+
return node.elements.some((n)=>isJSXValue(n, context, hint));
|
|
7102
7131
|
}).with({
|
|
7103
7132
|
type: NodeType.ConditionalExpression
|
|
7104
7133
|
}, (node)=>{
|
|
@@ -7146,22 +7175,15 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7146
7175
|
}).with({
|
|
7147
7176
|
type: NodeType.Identifier
|
|
7148
7177
|
}, (node)=>{
|
|
7149
|
-
if (!("name" in node)) {
|
|
7150
|
-
return false;
|
|
7151
|
-
}
|
|
7152
7178
|
if (isJSXTagNameExpression(node)) {
|
|
7153
7179
|
return true;
|
|
7154
7180
|
}
|
|
7155
|
-
const
|
|
7156
|
-
return effectFunction_esm.pipe(
|
|
7181
|
+
const maybeVariable = findVariableByNameUpToGlobal(node.name, context.getScope());
|
|
7182
|
+
return effectFunction_esm.pipe(maybeVariable, effectOption_esm.flatMap(getVariableInit(0)), effectOption_esm.filter(isOneOf([
|
|
7157
7183
|
NodeType.JSXElement,
|
|
7158
7184
|
NodeType.JSXFragment
|
|
7159
7185
|
])), 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);
|
|
7186
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7165
7187
|
}
|
|
7166
7188
|
|
|
7167
7189
|
/**
|
|
@@ -7196,7 +7218,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7196
7218
|
}).when(is(NodeType.SpreadElement), (prop)=>{
|
|
7197
7219
|
return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
|
|
7198
7220
|
const { name } = argument;
|
|
7199
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7221
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7200
7222
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7201
7223
|
return false;
|
|
7202
7224
|
}
|
|
@@ -7251,7 +7273,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7251
7273
|
type: NodeType.Identifier
|
|
7252
7274
|
}, (argument)=>{
|
|
7253
7275
|
const { name } = argument;
|
|
7254
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7276
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7255
7277
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7256
7278
|
return false;
|
|
7257
7279
|
}
|
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);
|
|
@@ -6603,7 +6620,7 @@ function isStringLiteral(node) {
|
|
|
6603
6620
|
/**
|
|
6604
6621
|
* @param variables The variables to search through
|
|
6605
6622
|
*/ return (variables)=>{
|
|
6606
|
-
return effectOption_esm.fromNullable(variables.find((variable)=>
|
|
6623
|
+
return effectOption_esm.fromNullable(variables.find((variable)=>variable.name === name));
|
|
6607
6624
|
};
|
|
6608
6625
|
}
|
|
6609
6626
|
/**
|
|
@@ -6612,7 +6629,7 @@ function isStringLiteral(node) {
|
|
|
6612
6629
|
*/ function getVariablesUpToGlobal(startScope) {
|
|
6613
6630
|
const scopeRef = effectMutableRef_esm.make(startScope);
|
|
6614
6631
|
const variablesRef = effectMutableRef_esm.make(effectMutableRef_esm.get(scopeRef).variables);
|
|
6615
|
-
while(effectMutableRef_esm.get(scopeRef).
|
|
6632
|
+
while(effectMutableRef_esm.get(scopeRef).type !== ScopeType.global){
|
|
6616
6633
|
effectMutableRef_esm.set(scopeRef, effectMutableRef_esm.get(scopeRef).upper);
|
|
6617
6634
|
effectMutableRef_esm.update(variablesRef, (variables)=>variables.concat(effectMutableRef_esm.get(scopeRef).variables));
|
|
6618
6635
|
}
|
|
@@ -6623,26 +6640,23 @@ function isStringLiteral(node) {
|
|
|
6623
6640
|
* @param name The name of the variable to find
|
|
6624
6641
|
* @param startScope The scope to start from
|
|
6625
6642
|
*/ function findVariableByNameUpToGlobal(name, startScope) {
|
|
6626
|
-
return
|
|
6643
|
+
return findVariableByName(name)(getVariablesUpToGlobal(startScope));
|
|
6627
6644
|
}
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6645
|
+
function resolveDefinitionInit(def) {
|
|
6646
|
+
if ("init" in def.node && !isNullable(def.node.init)) {
|
|
6647
|
+
return effectOption_esm.some(def.node.init);
|
|
6648
|
+
}
|
|
6649
|
+
// TODO: support other types of definitions
|
|
6650
|
+
return effectOption_esm.none();
|
|
6633
6651
|
}
|
|
6634
6652
|
/**
|
|
6635
6653
|
* 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);
|
|
6654
|
+
* @param at The index number of def in defs
|
|
6655
|
+
* @returns A function that takes a variable and returns the init node of the nth definition of that variable
|
|
6656
|
+
*/ function getVariableInit(at) {
|
|
6657
|
+
return (variable)=>{
|
|
6658
|
+
return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMap(resolveDefinitionInit));
|
|
6659
|
+
};
|
|
6646
6660
|
}
|
|
6647
6661
|
|
|
6648
6662
|
/**
|
|
@@ -7074,7 +7088,8 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7074
7088
|
IgnoreNull: 1n << 0n,
|
|
7075
7089
|
IgnoreCreateElement: 1n << 1n,
|
|
7076
7090
|
StrictLogical: 1n << 2n,
|
|
7077
|
-
StrictConditional: 1n << 3n
|
|
7091
|
+
StrictConditional: 1n << 3n,
|
|
7092
|
+
StrictArrayExpression: 1n << 4n
|
|
7078
7093
|
};
|
|
7079
7094
|
/* eslint-enable perfectionist/sort-objects */ /**
|
|
7080
7095
|
* Check if a node is a JSX value
|
|
@@ -7090,6 +7105,10 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7090
7105
|
type: NodeType.JSXElement
|
|
7091
7106
|
}, effectFunction_esm.constTrue).with({
|
|
7092
7107
|
type: NodeType.JSXFragment
|
|
7108
|
+
}, effectFunction_esm.constTrue).with({
|
|
7109
|
+
type: NodeType.JSXMemberExpression
|
|
7110
|
+
}, effectFunction_esm.constTrue).with({
|
|
7111
|
+
type: NodeType.JSXNamespacedName
|
|
7093
7112
|
}, effectFunction_esm.constTrue).with({
|
|
7094
7113
|
type: NodeType.Literal
|
|
7095
7114
|
}, (node)=>{
|
|
@@ -7097,6 +7116,16 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7097
7116
|
return false;
|
|
7098
7117
|
}
|
|
7099
7118
|
return node.value === null;
|
|
7119
|
+
}).with({
|
|
7120
|
+
type: NodeType.ArrayExpression
|
|
7121
|
+
}, (node)=>{
|
|
7122
|
+
if (!("elements" in node)) {
|
|
7123
|
+
return false;
|
|
7124
|
+
}
|
|
7125
|
+
if (hint & JSXValueCheckHint.StrictArrayExpression) {
|
|
7126
|
+
return node.elements.every((n)=>isJSXValue(n, context, hint));
|
|
7127
|
+
}
|
|
7128
|
+
return node.elements.some((n)=>isJSXValue(n, context, hint));
|
|
7100
7129
|
}).with({
|
|
7101
7130
|
type: NodeType.ConditionalExpression
|
|
7102
7131
|
}, (node)=>{
|
|
@@ -7144,22 +7173,15 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7144
7173
|
}).with({
|
|
7145
7174
|
type: NodeType.Identifier
|
|
7146
7175
|
}, (node)=>{
|
|
7147
|
-
if (!("name" in node)) {
|
|
7148
|
-
return false;
|
|
7149
|
-
}
|
|
7150
7176
|
if (isJSXTagNameExpression(node)) {
|
|
7151
7177
|
return true;
|
|
7152
7178
|
}
|
|
7153
|
-
const
|
|
7154
|
-
return effectFunction_esm.pipe(
|
|
7179
|
+
const maybeVariable = findVariableByNameUpToGlobal(node.name, context.getScope());
|
|
7180
|
+
return effectFunction_esm.pipe(maybeVariable, effectOption_esm.flatMap(getVariableInit(0)), effectOption_esm.filter(isOneOf([
|
|
7155
7181
|
NodeType.JSXElement,
|
|
7156
7182
|
NodeType.JSXFragment
|
|
7157
7183
|
])), 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);
|
|
7184
|
+
}).otherwise(effectFunction_esm.constFalse);
|
|
7163
7185
|
}
|
|
7164
7186
|
|
|
7165
7187
|
/**
|
|
@@ -7194,7 +7216,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7194
7216
|
}).when(is(NodeType.SpreadElement), (prop)=>{
|
|
7195
7217
|
return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
|
|
7196
7218
|
const { name } = argument;
|
|
7197
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7219
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7198
7220
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7199
7221
|
return false;
|
|
7200
7222
|
}
|
|
@@ -7249,7 +7271,7 @@ function isFragmentWithSingleExpression(node) {
|
|
|
7249
7271
|
type: NodeType.Identifier
|
|
7250
7272
|
}, (argument)=>{
|
|
7251
7273
|
const { name } = argument;
|
|
7252
|
-
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope),
|
|
7274
|
+
const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInit(0));
|
|
7253
7275
|
if (effectOption_esm.isNone(maybeInit)) {
|
|
7254
7276
|
return false;
|
|
7255
7277
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "AST Utility Module for Static Analysis of JSX",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"micro-memoize": "4.1.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@eslint-react/ast": "0.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
43
|
+
"@eslint-react/ast": "0.7.0",
|
|
44
|
+
"@eslint-react/types": "0.7.0",
|
|
45
|
+
"@eslint-react/tools": "0.7.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "rollup -c rollup.config.ts --configPlugin swc3 && cp dist/index.d.ts dist/index.d.mts",
|