eslint-plugin-react-x 5.8.3 → 5.8.4-next.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.js +19 -15
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -143,7 +143,7 @@ const rules$6 = {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region package.json
|
|
145
145
|
var name$6 = "eslint-plugin-react-x";
|
|
146
|
-
var version = "5.8.
|
|
146
|
+
var version = "5.8.4-next.0";
|
|
147
147
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/utils/create-rule.ts
|
|
@@ -1326,8 +1326,7 @@ function identifierExistsInPattern(pattern, name) {
|
|
|
1326
1326
|
case AST_NODE_TYPES.Identifier: return pattern.name === name;
|
|
1327
1327
|
case AST_NODE_TYPES.ObjectPattern: return pattern.properties.some((p) => {
|
|
1328
1328
|
if (p.type === AST_NODE_TYPES.Property) return identifierExistsInPattern(p.value, name);
|
|
1329
|
-
|
|
1330
|
-
return false;
|
|
1329
|
+
return identifierExistsInPattern(p.argument, name);
|
|
1331
1330
|
});
|
|
1332
1331
|
case AST_NODE_TYPES.ArrayPattern: return pattern.elements.some((el) => el != null && identifierExistsInPattern(el, name));
|
|
1333
1332
|
case AST_NODE_TYPES.RestElement: return identifierExistsInPattern(pattern.argument, name);
|
|
@@ -1405,9 +1404,12 @@ function create$48(context) {
|
|
|
1405
1404
|
if (variable == null) return null;
|
|
1406
1405
|
for (const def of variable.defs) {
|
|
1407
1406
|
if (def.type !== DefinitionType.Parameter) continue;
|
|
1408
|
-
if (def.node == null) continue;
|
|
1409
1407
|
let fn = def.node;
|
|
1410
|
-
|
|
1408
|
+
for (;;) {
|
|
1409
|
+
if (Check.isFunction(fn)) break;
|
|
1410
|
+
fn = fn.parent ?? null;
|
|
1411
|
+
if (fn == null) break;
|
|
1412
|
+
}
|
|
1411
1413
|
if (fn == null) continue;
|
|
1412
1414
|
const func = fn;
|
|
1413
1415
|
if (func.params.some((param) => identifierExistsInPattern(param, id.name))) return func;
|
|
@@ -1428,7 +1430,7 @@ function create$48(context) {
|
|
|
1428
1430
|
CallExpression(node) {
|
|
1429
1431
|
if (isUseStateCall(node) || core.isUseReducerCall(context, node)) {
|
|
1430
1432
|
const declarator = node.parent;
|
|
1431
|
-
if (declarator
|
|
1433
|
+
if (declarator.type === AST_NODE_TYPES.VariableDeclarator && declarator.id.type === AST_NODE_TYPES.ArrayPattern) {
|
|
1432
1434
|
const [firstElement] = declarator.id.elements;
|
|
1433
1435
|
if (firstElement?.type === AST_NODE_TYPES.Identifier && isRefLikeName(firstElement.name)) context.report({
|
|
1434
1436
|
data: { name: firstElement.name },
|
|
@@ -3105,7 +3107,7 @@ function create$21(context) {
|
|
|
3105
3107
|
...hc.api.getAllHooks(program),
|
|
3106
3108
|
...cc.api.getAllComponents(program)
|
|
3107
3109
|
];
|
|
3108
|
-
for (const lazy of lazyCalls) if (Traverse.findParent(lazy, (n) => significantParents.some((p) => p.node === n))) context.report({
|
|
3110
|
+
for (const lazy of lazyCalls) if (Traverse.findParent(lazy, (n) => significantParents.some((p) => p.node === n)) != null) context.report({
|
|
3109
3111
|
messageId: "default",
|
|
3110
3112
|
node: lazy
|
|
3111
3113
|
});
|
|
@@ -3749,7 +3751,7 @@ function create$9(context) {
|
|
|
3749
3751
|
CallExpression(node) {
|
|
3750
3752
|
if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
|
|
3751
3753
|
const { parent } = node;
|
|
3752
|
-
if (parent
|
|
3754
|
+
if (parent.type !== AST_NODE_TYPES.VariableDeclarator || parent.id.type !== AST_NODE_TYPES.ArrayPattern) return;
|
|
3753
3755
|
const [stateEl] = parent.id.elements;
|
|
3754
3756
|
if (stateEl?.type !== AST_NODE_TYPES.Identifier) return;
|
|
3755
3757
|
stateEntries.push({
|
|
@@ -4159,7 +4161,8 @@ function create$7(context) {
|
|
|
4159
4161
|
case expr.type === AST_NODE_TYPES.Identifier: {
|
|
4160
4162
|
const builtinName = resolveBuiltinObjectName(context, expr);
|
|
4161
4163
|
if (builtinName == null) return;
|
|
4162
|
-
|
|
4164
|
+
const globalThisImpure = IMPURE_FUNCS.get("globalThis");
|
|
4165
|
+
if (globalThisImpure == null || !globalThisImpure.has(builtinName)) return;
|
|
4163
4166
|
const func = Traverse.findParent(node, Check.isFunction);
|
|
4164
4167
|
if (func == null) return;
|
|
4165
4168
|
cEntries.push({
|
|
@@ -4174,7 +4177,8 @@ function create$7(context) {
|
|
|
4174
4177
|
const objectName = resolveBuiltinObjectName(context, rootId);
|
|
4175
4178
|
if (objectName == null) return;
|
|
4176
4179
|
const propertyName = expr.property.name;
|
|
4177
|
-
|
|
4180
|
+
const objectImpure = IMPURE_FUNCS.get(objectName);
|
|
4181
|
+
if (objectImpure == null || !objectImpure.has(propertyName)) return;
|
|
4178
4182
|
const func = Traverse.findParent(node, Check.isFunction);
|
|
4179
4183
|
if (func == null) return;
|
|
4180
4184
|
cEntries.push({
|
|
@@ -4238,7 +4242,7 @@ function isInNullCheckTest(node) {
|
|
|
4238
4242
|
if (!isLiteralNull(parent.left === node || Extract.unwrap(parent.left) === node ? parent.right : parent.left)) return false;
|
|
4239
4243
|
if (isIfTest(parent)) return true;
|
|
4240
4244
|
const grandparent = parent.parent;
|
|
4241
|
-
if (grandparent
|
|
4245
|
+
if (grandparent.type === AST_NODE_TYPES.UnaryExpression && grandparent.operator === "!" && isIfTest(grandparent)) return true;
|
|
4242
4246
|
return false;
|
|
4243
4247
|
}
|
|
4244
4248
|
if (parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "!") return isIfTest(parent);
|
|
@@ -4390,7 +4394,7 @@ function create$6(context) {
|
|
|
4390
4394
|
let isLazyInit = isInNullCheckTest(node);
|
|
4391
4395
|
if (!isLazyInit) {
|
|
4392
4396
|
let current = node.parent;
|
|
4393
|
-
findIf:
|
|
4397
|
+
findIf: for (;;) {
|
|
4394
4398
|
if (current.type === AST_NODE_TYPES.IfStatement) {
|
|
4395
4399
|
if (isRefCurrentNullCheck(current.test, refName)) isLazyInit = true;
|
|
4396
4400
|
break;
|
|
@@ -6740,7 +6744,7 @@ function isRefInExpression(context, node) {
|
|
|
6740
6744
|
* @returns The actual CallExpression node
|
|
6741
6745
|
*/
|
|
6742
6746
|
function getSetStateCallExpression(node) {
|
|
6743
|
-
return node.type === AST_NODE_TYPES.Identifier && node.parent
|
|
6747
|
+
return node.type === AST_NODE_TYPES.Identifier && node.parent.type === AST_NODE_TYPES.CallExpression ? node.parent : node;
|
|
6744
6748
|
}
|
|
6745
6749
|
|
|
6746
6750
|
//#endregion
|
|
@@ -7174,7 +7178,7 @@ function getDynamicComponentSource(context, variable, isInsideRender, seen = /*
|
|
|
7174
7178
|
for (const ref of variable.references) {
|
|
7175
7179
|
if (!ref.isWrite()) continue;
|
|
7176
7180
|
const id = ref.identifier;
|
|
7177
|
-
if (id.parent
|
|
7181
|
+
if (id.parent.type === AST_NODE_TYPES.AssignmentExpression && id.parent.left === id) {
|
|
7178
7182
|
const source = resolveDynamicValue(context, id.parent.right, isInsideRender, seen);
|
|
7179
7183
|
if (source != null) return {
|
|
7180
7184
|
creationNode: source,
|
|
@@ -7400,7 +7404,7 @@ function create$1(context) {
|
|
|
7400
7404
|
if (node.type !== AST_NODE_TYPES.AssignmentExpression) return;
|
|
7401
7405
|
const left = Extract.unwrap(node.left);
|
|
7402
7406
|
if (left.type !== AST_NODE_TYPES.Identifier) return;
|
|
7403
|
-
if (Traverse.findParent(node, Check.isFunction, (n) => n === callback)) return;
|
|
7407
|
+
if (Traverse.findParent(node, Check.isFunction, (n) => n === callback) != null) return;
|
|
7404
7408
|
const variable = findVariable(context.sourceCode.getScope(left), left);
|
|
7405
7409
|
if (variable != null && variable.defs.length > 0 && isDeclaredInsideCallback(variable, callback)) return;
|
|
7406
7410
|
violations.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.4-next.0",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.5.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "5.8.
|
|
49
|
-
"@eslint-react/core": "5.8.
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/var": "5.8.
|
|
48
|
+
"@eslint-react/ast": "5.8.4-next.0",
|
|
49
|
+
"@eslint-react/core": "5.8.4-next.0",
|
|
50
|
+
"@eslint-react/jsx": "5.8.4-next.0",
|
|
51
|
+
"@eslint-react/shared": "5.8.4-next.0",
|
|
52
|
+
"@eslint-react/eslint": "5.8.4-next.0",
|
|
53
|
+
"@eslint-react/var": "5.8.4-next.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.14",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"tsl": "^1.0.30",
|
|
64
64
|
"tsl-dx": "^0.12.1",
|
|
65
65
|
"typescript": "^6.0.3",
|
|
66
|
-
"@local/
|
|
67
|
-
"@local/
|
|
66
|
+
"@local/eff": "3.0.0-beta.72",
|
|
67
|
+
"@local/configs": "0.0.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"eslint": "^10.3.0",
|