eslint-plugin-react-x 5.30.0-beta.3 → 5.30.0-beta.5
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 +120 -59
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from "@eslint-react/shared";
|
|
2
2
|
import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
3
|
-
import { Check, Collect, Compare, Extract, Traverse } from "@eslint-react/ast";
|
|
3
|
+
import { Analyze, Check, Collect, Compare, Extract, Traverse } from "@eslint-react/ast";
|
|
4
4
|
import * as core from "@eslint-react/core";
|
|
5
5
|
import { getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
7
7
|
import { P, isMatching, match } from "ts-pattern";
|
|
8
|
-
import { isAssignmentTargetEqual, isInitializedFromReact, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin } from "@eslint-react/var";
|
|
8
|
+
import { isAssignmentTargetEqual, isInitializedFromReact, resolveBindingTarget, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin } from "@eslint-react/var";
|
|
9
9
|
import { DefinitionType, ScopeType } from "@typescript-eslint/scope-manager";
|
|
10
10
|
import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
11
11
|
import { findParentAttribute, getCreateElementPropsObject, getElementFullType, hasAttribute, isAttribute, isInsideCreateElementProps } from "@eslint-react/jsx";
|
|
@@ -130,7 +130,7 @@ const rules$6 = {
|
|
|
130
130
|
};
|
|
131
131
|
// package.json
|
|
132
132
|
var name$6 = "eslint-plugin-react-x";
|
|
133
|
-
var version = "5.30.0-beta.
|
|
133
|
+
var version = "5.30.0-beta.5";
|
|
134
134
|
// src/utils/create-rule.ts
|
|
135
135
|
function getDocsUrl(ruleName) {
|
|
136
136
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
@@ -1727,7 +1727,7 @@ function isArrayIndexReference(context, node) {
|
|
|
1727
1727
|
if (call.arguments[callbackPosition] !== argument) return false;
|
|
1728
1728
|
const param = callback.params[indexPosition];
|
|
1729
1729
|
if (param == null) return false;
|
|
1730
|
-
return param === def.name
|
|
1730
|
+
return resolveBindingTarget(param) === def.name;
|
|
1731
1731
|
}
|
|
1732
1732
|
function getIdentifiersFromBinaryExpression(side) {
|
|
1733
1733
|
if (Check.isIdentifier(side)) return [side];
|
|
@@ -1997,7 +1997,7 @@ function memoize(f) {
|
|
|
1997
1997
|
function not(predicate) {
|
|
1998
1998
|
return (data) => !predicate(data);
|
|
1999
1999
|
}
|
|
2000
|
-
|
|
2000
|
+
dual(2, (a, b) => (data) => a(data) && b(data));
|
|
2001
2001
|
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
2002
2002
|
dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
2003
2003
|
dual(2, (a, b) => (data) => a(data) === b(data));
|
|
@@ -3298,7 +3298,7 @@ function create$12(context, [options]) {
|
|
|
3298
3298
|
return declarators.get(component)?.filter((d) => d.init.name === name).flatMap((d) => d.id.properties) ?? [];
|
|
3299
3299
|
}).otherwise(() => []);
|
|
3300
3300
|
for (const prop of properties) {
|
|
3301
|
-
if (prop.type !== AST_NODE_TYPES.Property || prop.value
|
|
3301
|
+
if (prop.type !== AST_NODE_TYPES.Property || !Check.isObjectPatternElementDefault(prop.value)) continue;
|
|
3302
3302
|
const { value } = prop;
|
|
3303
3303
|
const { right } = value;
|
|
3304
3304
|
const construction = resolveObjectType(context, value);
|
|
@@ -3440,7 +3440,7 @@ function collectUsedPropKeysOfParameter(context, usedPropKeys, parameter) {
|
|
|
3440
3440
|
switch (parameter.type) {
|
|
3441
3441
|
case AST_NODE_TYPES.Identifier: return collectUsedPropKeysOfIdentifier(context, usedPropKeys, parameter);
|
|
3442
3442
|
case AST_NODE_TYPES.ObjectPattern: return collectUsedPropKeysOfObjectPattern(context, usedPropKeys, parameter);
|
|
3443
|
-
case AST_NODE_TYPES.AssignmentPattern: return collectUsedPropKeysOfParameter(context, usedPropKeys, parameter
|
|
3443
|
+
case AST_NODE_TYPES.AssignmentPattern: return collectUsedPropKeysOfParameter(context, usedPropKeys, resolveBindingTarget(parameter));
|
|
3444
3444
|
default: return false;
|
|
3445
3445
|
}
|
|
3446
3446
|
}
|
|
@@ -4021,7 +4021,7 @@ function hasUseClientDirective(program) {
|
|
|
4021
4021
|
function getDestructuredPropertyName(pattern, name) {
|
|
4022
4022
|
for (const property of pattern.properties) {
|
|
4023
4023
|
if (property.type !== AST_NODE_TYPES.Property) continue;
|
|
4024
|
-
if ((property.value
|
|
4024
|
+
if (resolveBindingTarget(property.value) !== name) continue;
|
|
4025
4025
|
return Extract.getPropertyName(property, "max");
|
|
4026
4026
|
}
|
|
4027
4027
|
return null;
|
|
@@ -4292,18 +4292,6 @@ function getGuardDisposition(node, getNullBranch) {
|
|
|
4292
4292
|
}
|
|
4293
4293
|
return null;
|
|
4294
4294
|
}
|
|
4295
|
-
function isUnconditionallyTerminating(statement) {
|
|
4296
|
-
switch (statement.type) {
|
|
4297
|
-
case AST_NODE_TYPES.ReturnStatement:
|
|
4298
|
-
case AST_NODE_TYPES.ThrowStatement: return true;
|
|
4299
|
-
case AST_NODE_TYPES.BlockStatement: {
|
|
4300
|
-
const last = statement.body.at(-1);
|
|
4301
|
-
return last != null && isUnconditionallyTerminating(last);
|
|
4302
|
-
}
|
|
4303
|
-
case AST_NODE_TYPES.IfStatement: return statement.alternate != null && isUnconditionallyTerminating(statement.consequent) && isUnconditionallyTerminating(statement.alternate);
|
|
4304
|
-
default: return false;
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
4295
|
function isAfterTerminatingNonNullGuard(node, getNullBranch) {
|
|
4308
4296
|
let statement = node;
|
|
4309
4297
|
while (statement.parent?.type !== AST_NODE_TYPES.BlockStatement) {
|
|
@@ -4318,7 +4306,7 @@ function isAfterTerminatingNonNullGuard(node, getNullBranch) {
|
|
|
4318
4306
|
const nullBranch = getNullBranch(sibling.test);
|
|
4319
4307
|
if (nullBranch == null) continue;
|
|
4320
4308
|
const nonNullBranch = nullBranch === "alternate" ? sibling.consequent : sibling.alternate;
|
|
4321
|
-
return nonNullBranch != null && isUnconditionallyTerminating(nonNullBranch);
|
|
4309
|
+
return nonNullBranch != null && Analyze.isUnconditionallyTerminating(nonNullBranch);
|
|
4322
4310
|
}
|
|
4323
4311
|
return false;
|
|
4324
4312
|
}
|
|
@@ -6374,10 +6362,11 @@ function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
|
|
|
6374
6362
|
};
|
|
6375
6363
|
}
|
|
6376
6364
|
// src/rules/set-state-in-effect/helpers.ts
|
|
6377
|
-
function
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
return
|
|
6365
|
+
function getImmediateInvocation(fn) {
|
|
6366
|
+
let parent = fn.parent;
|
|
6367
|
+
while (Check.isTypeOrChainExpression(parent)) parent = parent.parent;
|
|
6368
|
+
if (parent.type !== AST_NODE_TYPES.CallExpression) return null;
|
|
6369
|
+
return Extract.unwrap(parent.callee) === fn ? parent : null;
|
|
6381
6370
|
}
|
|
6382
6371
|
function getConditionalBranch(node) {
|
|
6383
6372
|
let child = node;
|
|
@@ -6412,11 +6401,8 @@ function isRefLikeName(name) {
|
|
|
6412
6401
|
return name === "ref" || name.endsWith("Ref");
|
|
6413
6402
|
}
|
|
6414
6403
|
function getParameterId(param) {
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
case AST_NODE_TYPES.AssignmentPattern: return param.left.type === AST_NODE_TYPES.Identifier ? param.left : null;
|
|
6418
|
-
default: return null;
|
|
6419
|
-
}
|
|
6404
|
+
const target = resolveBindingTarget(param);
|
|
6405
|
+
return target.type === AST_NODE_TYPES.Identifier ? target : null;
|
|
6420
6406
|
}
|
|
6421
6407
|
function getRefSourceName(node) {
|
|
6422
6408
|
switch (node.type) {
|
|
@@ -6541,6 +6527,47 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6541
6527
|
}
|
|
6542
6528
|
return refParams;
|
|
6543
6529
|
}
|
|
6530
|
+
function isDeferredInvocation(invocation) {
|
|
6531
|
+
let current = invocation.parent;
|
|
6532
|
+
while (current != null) {
|
|
6533
|
+
if (Check.isFunction(current)) return false;
|
|
6534
|
+
switch (current.type) {
|
|
6535
|
+
case AST_NODE_TYPES.AssignmentPattern: return true;
|
|
6536
|
+
case AST_NODE_TYPES.PropertyDefinition: {
|
|
6537
|
+
if (current.static) return false;
|
|
6538
|
+
const value = current.value;
|
|
6539
|
+
return value != null && (value === invocation || Traverse.hasParent(invocation, (n) => n === value));
|
|
6540
|
+
}
|
|
6541
|
+
default: current = current.parent;
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
return false;
|
|
6545
|
+
}
|
|
6546
|
+
function getVisibleWriteLocation(value, id) {
|
|
6547
|
+
let branch = getConditionalBranch(value);
|
|
6548
|
+
let node = value;
|
|
6549
|
+
let order = 1;
|
|
6550
|
+
let boundary = Traverse.findParent(value, Check.isFunction);
|
|
6551
|
+
while (boundary != null) {
|
|
6552
|
+
if (Traverse.hasParent(id, (n) => n === boundary)) return {
|
|
6553
|
+
branch,
|
|
6554
|
+
node,
|
|
6555
|
+
order
|
|
6556
|
+
};
|
|
6557
|
+
if (boundary.async || boundary.generator) return null;
|
|
6558
|
+
const invocation = getImmediateInvocation(boundary);
|
|
6559
|
+
if (invocation == null || isDeferredInvocation(invocation)) return null;
|
|
6560
|
+
branch ??= getConditionalBranch(invocation);
|
|
6561
|
+
node = invocation;
|
|
6562
|
+
order = 0;
|
|
6563
|
+
boundary = Traverse.findParent(invocation, Check.isFunction);
|
|
6564
|
+
}
|
|
6565
|
+
return {
|
|
6566
|
+
branch,
|
|
6567
|
+
node,
|
|
6568
|
+
order
|
|
6569
|
+
};
|
|
6570
|
+
}
|
|
6544
6571
|
function isInitializedFromRef(id, refParams, seen = /* @__PURE__ */ new Set()) {
|
|
6545
6572
|
const variable = findVariable(context.sourceCode.getScope(id), id);
|
|
6546
6573
|
if (variable == null) return false;
|
|
@@ -6549,11 +6576,16 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6549
6576
|
seen.add(key);
|
|
6550
6577
|
if (isStateHeldDomNode(variable)) return true;
|
|
6551
6578
|
const candidates = [];
|
|
6552
|
-
const addCandidate = (value,
|
|
6553
|
-
|
|
6579
|
+
const addCandidate = (value, visibility = {
|
|
6580
|
+
branch: getConditionalBranch(value),
|
|
6581
|
+
node: value,
|
|
6582
|
+
order: 1
|
|
6583
|
+
}, previous) => {
|
|
6584
|
+
if (visibility.node.range[1] > id.range[0] || candidates.some((c) => c.value === value)) return;
|
|
6554
6585
|
candidates.push({
|
|
6555
|
-
branch:
|
|
6556
|
-
|
|
6586
|
+
branch: visibility.branch,
|
|
6587
|
+
order: visibility.order,
|
|
6588
|
+
position: visibility.node.range[1],
|
|
6557
6589
|
previous,
|
|
6558
6590
|
value
|
|
6559
6591
|
});
|
|
@@ -6566,12 +6598,13 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6566
6598
|
if (!reference.isWrite() || reference.writeExpr == null) continue;
|
|
6567
6599
|
if (reference.init === true && variable.defs.some((d) => d.type === DefinitionType.Parameter && refParams?.has(d.name) === true)) continue;
|
|
6568
6600
|
const writeExpr = reference.writeExpr;
|
|
6569
|
-
|
|
6601
|
+
const visibility = getVisibleWriteLocation(writeExpr, id);
|
|
6602
|
+
if (visibility == null) continue;
|
|
6570
6603
|
const parent = reference.identifier.parent;
|
|
6571
|
-
addCandidate(writeExpr, parent.type === AST_NODE_TYPES.AssignmentExpression && parent.operator !== "=" && Extract.unwrap(parent.left) === reference.identifier ? reference.identifier : void 0);
|
|
6604
|
+
addCandidate(writeExpr, visibility, parent.type === AST_NODE_TYPES.AssignmentExpression && parent.operator !== "=" && Extract.unwrap(parent.left) === reference.identifier ? reference.identifier : void 0);
|
|
6572
6605
|
}
|
|
6573
6606
|
const survivingCandidates = [];
|
|
6574
|
-
for (const candidate of [...candidates].sort((a, b) => a.position - b.position)) {
|
|
6607
|
+
for (const candidate of [...candidates].sort((a, b) => a.position - b.position || a.order - b.order)) {
|
|
6575
6608
|
if (candidate.branch == null) survivingCandidates.length = 0;
|
|
6576
6609
|
else {
|
|
6577
6610
|
const previousIndex = survivingCandidates.findIndex((o) => o.branch === candidate.branch);
|
|
@@ -6621,7 +6654,11 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6621
6654
|
case AST_NODE_TYPES.LogicalExpression: return isRefValue(expression.left, refParams, seen, mode) || isRefValue(expression.right, refParams, seen, mode);
|
|
6622
6655
|
case AST_NODE_TYPES.UnaryExpression:
|
|
6623
6656
|
case AST_NODE_TYPES.UpdateExpression: return isRefValue(expression.argument, refParams, seen, mode);
|
|
6624
|
-
case AST_NODE_TYPES.ConditionalExpression: return
|
|
6657
|
+
case AST_NODE_TYPES.ConditionalExpression: return [
|
|
6658
|
+
mode === "initializer" ? expression.test : null,
|
|
6659
|
+
expression.consequent,
|
|
6660
|
+
expression.alternate
|
|
6661
|
+
].some((e) => e != null && isRefValue(e, refParams, seen, mode));
|
|
6625
6662
|
case AST_NODE_TYPES.SequenceExpression: return expression.expressions.some((p) => isRefValue(p, refParams, seen, mode));
|
|
6626
6663
|
case AST_NODE_TYPES.TemplateLiteral: return expression.expressions.some((p) => isRefValue(p, refParams, seen, mode));
|
|
6627
6664
|
case AST_NODE_TYPES.TaggedTemplateExpression: return isRefValue(expression.tag, refParams, seen, mode) || isRefValue(expression.quasi, refParams, seen, mode);
|
|
@@ -6644,6 +6681,29 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6644
6681
|
function isRefInExpression(node, refParams) {
|
|
6645
6682
|
return Collect.getIdentifiers(node).some((id) => isInitializedFromRef(id, refParams));
|
|
6646
6683
|
}
|
|
6684
|
+
function hasRefGatedTerminator(statements, refParams) {
|
|
6685
|
+
return statements.some((statement) => isRefGatedTerminator(statement, refParams));
|
|
6686
|
+
}
|
|
6687
|
+
function isRefGatedTerminator(statement, refParams) {
|
|
6688
|
+
switch (statement.type) {
|
|
6689
|
+
case AST_NODE_TYPES.IfStatement: return isRefInExpression(statement.test, refParams) && (Analyze.isTerminatingStatement(statement.consequent) || statement.alternate != null && Analyze.isTerminatingStatement(statement.alternate));
|
|
6690
|
+
case AST_NODE_TYPES.BlockStatement: return hasRefGatedTerminator(statement.body, refParams);
|
|
6691
|
+
case AST_NODE_TYPES.TryStatement:
|
|
6692
|
+
if (statement.finalizer != null && hasRefGatedTerminator(statement.finalizer.body, refParams)) return true;
|
|
6693
|
+
if (statement.handler != null && !Analyze.isTerminatingStatement(statement.handler.body)) return false;
|
|
6694
|
+
return hasRefGatedTerminator(statement.block.body, refParams);
|
|
6695
|
+
default: return false;
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6698
|
+
function hasRefGatedEarlyExit(statements, child, refParams) {
|
|
6699
|
+
const index = statements.findIndex((statement) => statement === child);
|
|
6700
|
+
if (index < 0) return false;
|
|
6701
|
+
for (let i = 0; i < index; i++) {
|
|
6702
|
+
const statement = statements[i];
|
|
6703
|
+
if (statement != null && isRefGatedTerminator(statement, refParams)) return true;
|
|
6704
|
+
}
|
|
6705
|
+
return false;
|
|
6706
|
+
}
|
|
6647
6707
|
function isRefGatedContext(node, refParams) {
|
|
6648
6708
|
let child = node;
|
|
6649
6709
|
let current = node.parent;
|
|
@@ -6657,15 +6717,16 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6657
6717
|
case AST_NODE_TYPES.LogicalExpression:
|
|
6658
6718
|
if (child === current.right && isRefInExpression(current.left, refParams)) return true;
|
|
6659
6719
|
break;
|
|
6660
|
-
case AST_NODE_TYPES.
|
|
6661
|
-
|
|
6662
|
-
for (const statement of current.body.slice(0, Math.max(0, index))) {
|
|
6663
|
-
if (statement.type !== AST_NODE_TYPES.IfStatement) continue;
|
|
6664
|
-
if (!isRefInExpression(statement.test, refParams)) continue;
|
|
6665
|
-
if (isTerminatingStatement(statement.consequent)) return true;
|
|
6666
|
-
}
|
|
6720
|
+
case AST_NODE_TYPES.WhileStatement:
|
|
6721
|
+
if (child === current.body && isRefInExpression(current.test, refParams)) return true;
|
|
6667
6722
|
break;
|
|
6668
|
-
|
|
6723
|
+
case AST_NODE_TYPES.ForStatement:
|
|
6724
|
+
if ((child === current.body || child === current.update) && current.test != null && isRefInExpression(current.test, refParams)) return true;
|
|
6725
|
+
break;
|
|
6726
|
+
case AST_NODE_TYPES.BlockStatement:
|
|
6727
|
+
if (hasRefGatedEarlyExit(current.body, child, refParams)) return true;
|
|
6728
|
+
break;
|
|
6729
|
+
case AST_NODE_TYPES.SwitchCase: if (hasRefGatedEarlyExit(current.consequent, child, refParams)) return true;
|
|
6669
6730
|
}
|
|
6670
6731
|
child = current;
|
|
6671
6732
|
current = current.parent;
|
|
@@ -6704,24 +6765,24 @@ function inferViolations$2(context, facts) {
|
|
|
6704
6765
|
visited.add(key);
|
|
6705
6766
|
queue.push(state);
|
|
6706
6767
|
};
|
|
6707
|
-
const report = (
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6768
|
+
const report = (setter, reportNode) => {
|
|
6769
|
+
const name = resolver.getSetterName(setter.node);
|
|
6770
|
+
const key = `${String(reportNode.range[0])}:${String(reportNode.range[1])}:${name}`;
|
|
6771
|
+
getOrInsertComputed(violations, key, () => ({
|
|
6772
|
+
name,
|
|
6711
6773
|
node: reportNode
|
|
6712
|
-
});
|
|
6774
|
+
}));
|
|
6713
6775
|
};
|
|
6714
6776
|
const isExemptCall = (call, state) => {
|
|
6715
6777
|
if (state.inheritedRefGate || resolver.isRefGatedContext(call, state.refParams)) return true;
|
|
6716
|
-
|
|
6717
|
-
return argument != null && resolver.isArgumentUsingRefValue(argument, state.refParams);
|
|
6778
|
+
return call.arguments.some((argument) => resolver.isArgumentUsingRefValue(argument, state.refParams));
|
|
6718
6779
|
};
|
|
6719
6780
|
for (const root of [...facts.effectRoots].sort((a, b) => a.node.range[0] - b.node.range[0])) {
|
|
6720
6781
|
const setup = root.setup;
|
|
6721
6782
|
const unwrappedSetup = Extract.unwrap(setup);
|
|
6722
6783
|
for (const target of resolver.resolveValues(setup)) {
|
|
6723
6784
|
if (target.kind === "setter") {
|
|
6724
|
-
if (!resolver.isRefGatedContext(setup)) report(target
|
|
6785
|
+
if (!resolver.isRefGatedContext(setup)) report(target, setup);
|
|
6725
6786
|
continue;
|
|
6726
6787
|
}
|
|
6727
6788
|
const reportNode = unwrappedSetup === target.node ? null : setup;
|
|
@@ -6739,7 +6800,7 @@ function inferViolations$2(context, facts) {
|
|
|
6739
6800
|
const calls = callsByFunction.get(state.fn) ?? [];
|
|
6740
6801
|
for (const call of calls) for (const target of resolver.resolveValues(call.callee)) {
|
|
6741
6802
|
if (target.kind === "setter") {
|
|
6742
|
-
if (!isExemptCall(call, state)) report(
|
|
6803
|
+
if (!isExemptCall(call, state)) report(target, state.reportNode ?? call);
|
|
6743
6804
|
continue;
|
|
6744
6805
|
}
|
|
6745
6806
|
enqueue({
|
|
@@ -7126,7 +7187,7 @@ function isConfiguredStableHookValue(variable, configs) {
|
|
|
7126
7187
|
if (id.type !== AST_NODE_TYPES.ArrayPattern) return false;
|
|
7127
7188
|
const index = id.elements.findIndex((element) => {
|
|
7128
7189
|
if (element == null) return false;
|
|
7129
|
-
const binding = element
|
|
7190
|
+
const binding = resolveBindingTarget(element);
|
|
7130
7191
|
return variable.identifiers.some((identifier) => identifier === binding);
|
|
7131
7192
|
});
|
|
7132
7193
|
return index !== -1 && stableResult.has(index);
|
|
@@ -7290,8 +7351,8 @@ const rule = {
|
|
|
7290
7351
|
} else if (name === "useState" || name === "useReducer" || name === "useActionState") {
|
|
7291
7352
|
const isActionState = name === "useActionState";
|
|
7292
7353
|
if (id.type === "ArrayPattern" && (isActionState ? id.elements.length >= 2 : id.elements.length === 2) && isArray(resolved.identifiers)) {
|
|
7293
|
-
const firstElement = id.elements[0]
|
|
7294
|
-
const secondElement = id.elements[1]
|
|
7354
|
+
const firstElement = resolveBindingTarget(id.elements[0] ?? null);
|
|
7355
|
+
const secondElement = resolveBindingTarget(id.elements[1] ?? null);
|
|
7295
7356
|
if (resolved.identifiers.some((identifier) => identifier === secondElement)) {
|
|
7296
7357
|
if (name === "useState") {
|
|
7297
7358
|
const references = resolved.references;
|
|
@@ -7311,7 +7372,7 @@ const rule = {
|
|
|
7311
7372
|
}
|
|
7312
7373
|
} else if (name === "useTransition") {
|
|
7313
7374
|
if (id.type === "ArrayPattern" && id.elements.length === 2 && Array.isArray(resolved.identifiers)) {
|
|
7314
|
-
const secondElement = id.elements[1]
|
|
7375
|
+
const secondElement = resolveBindingTarget(id.elements[1] ?? null);
|
|
7315
7376
|
if (resolved.identifiers.some((identifier) => identifier === secondElement)) return true;
|
|
7316
7377
|
}
|
|
7317
7378
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.30.0-beta.
|
|
3
|
+
"version": "5.30.0-beta.5",
|
|
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",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@eslint-react/ast": "5.30.0-beta.
|
|
40
|
-
"@eslint-react/core": "5.30.0-beta.
|
|
41
|
-
"@eslint-react/eslint": "5.30.0-beta.
|
|
42
|
-
"@eslint-react/jsx": "5.30.0-beta.
|
|
43
|
-
"@eslint-react/shared": "5.30.0-beta.
|
|
44
|
-
"@eslint-react/var": "5.30.0-beta.
|
|
45
|
-
"@typescript-eslint/scope-manager": "^8.72.
|
|
46
|
-
"@typescript-eslint/types": "^8.72.
|
|
47
|
-
"@typescript-eslint/utils": "^8.72.
|
|
39
|
+
"@eslint-react/ast": "5.30.0-beta.5",
|
|
40
|
+
"@eslint-react/core": "5.30.0-beta.5",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0-beta.5",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0-beta.5",
|
|
43
|
+
"@eslint-react/shared": "5.30.0-beta.5",
|
|
44
|
+
"@eslint-react/var": "5.30.0-beta.5",
|
|
45
|
+
"@typescript-eslint/scope-manager": "^8.72.1",
|
|
46
|
+
"@typescript-eslint/types": "^8.72.1",
|
|
47
|
+
"@typescript-eslint/utils": "^8.72.1",
|
|
48
48
|
"compare-versions": "^6.1.1",
|
|
49
49
|
"string-ts": "^2.3.1",
|
|
50
50
|
"ts-api-utils": "^2.5.0",
|