eslint-plugin-react-x 1.38.5-next.2 → 1.39.0-beta.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.js +81 -80
- package/dist/index.mjs +80 -80
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var eff = require('@eslint-react/eff');
|
|
|
8
8
|
var VAR2 = require('@eslint-react/var');
|
|
9
9
|
var tsPattern = require('ts-pattern');
|
|
10
10
|
var AST11 = require('@eslint-react/ast');
|
|
11
|
-
var
|
|
11
|
+
var ER21 = require('@eslint-react/core');
|
|
12
12
|
var kit = require('@eslint-react/kit');
|
|
13
13
|
var compareVersions = require('compare-versions');
|
|
14
14
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
@@ -39,6 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
|
|
40
40
|
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
41
41
|
var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
42
|
+
var ER21__namespace = /*#__PURE__*/_interopNamespace(ER21);
|
|
42
43
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
43
44
|
|
|
44
45
|
var __defProp = Object.defineProperty;
|
|
@@ -138,7 +139,7 @@ var settings3 = {
|
|
|
138
139
|
|
|
139
140
|
// package.json
|
|
140
141
|
var name4 = "eslint-plugin-react-x";
|
|
141
|
-
var version = "1.
|
|
142
|
+
var version = "1.39.0-beta.1";
|
|
142
143
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
143
144
|
|
|
144
145
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -356,25 +357,25 @@ function create6(context) {
|
|
|
356
357
|
const setStateEntries = [];
|
|
357
358
|
return {
|
|
358
359
|
CallExpression(node) {
|
|
359
|
-
if (!
|
|
360
|
+
if (!ER21__namespace.isThisSetState(node)) {
|
|
360
361
|
return;
|
|
361
362
|
}
|
|
362
363
|
setStateEntries.push([node, false]);
|
|
363
364
|
},
|
|
364
365
|
"CallExpression:exit"(node) {
|
|
365
|
-
if (!
|
|
366
|
+
if (!ER21__namespace.isThisSetState(node)) {
|
|
366
367
|
return;
|
|
367
368
|
}
|
|
368
369
|
setStateEntries.pop();
|
|
369
370
|
},
|
|
370
371
|
ClassDeclaration(node) {
|
|
371
|
-
classEntries.push([node,
|
|
372
|
+
classEntries.push([node, ER21__namespace.isClassComponent(node)]);
|
|
372
373
|
},
|
|
373
374
|
"ClassDeclaration:exit"() {
|
|
374
375
|
classEntries.pop();
|
|
375
376
|
},
|
|
376
377
|
ClassExpression(node) {
|
|
377
|
-
classEntries.push([node,
|
|
378
|
+
classEntries.push([node, ER21__namespace.isClassComponent(node)]);
|
|
378
379
|
},
|
|
379
380
|
"ClassExpression:exit"() {
|
|
380
381
|
classEntries.pop();
|
|
@@ -458,7 +459,7 @@ function isUsingReactChildren(context, node) {
|
|
|
458
459
|
return true;
|
|
459
460
|
}
|
|
460
461
|
if (callee.object.type === types.AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
|
|
461
|
-
return
|
|
462
|
+
return ER21__namespace.isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
462
463
|
}
|
|
463
464
|
return false;
|
|
464
465
|
}
|
|
@@ -527,7 +528,7 @@ function create7(context) {
|
|
|
527
528
|
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
528
529
|
}
|
|
529
530
|
function isCreateOrCloneElementCall(node) {
|
|
530
|
-
return
|
|
531
|
+
return ER21__namespace.isCreateElementCall(context, node) || ER21__namespace.isCloneElementCall(context, node);
|
|
531
532
|
}
|
|
532
533
|
function getReportDescriptors(node) {
|
|
533
534
|
switch (node.type) {
|
|
@@ -639,7 +640,7 @@ var no_children_count_default = createRule({
|
|
|
639
640
|
function create8(context) {
|
|
640
641
|
return {
|
|
641
642
|
MemberExpression(node) {
|
|
642
|
-
if (
|
|
643
|
+
if (ER21__namespace.isChildrenCount(context, node)) {
|
|
643
644
|
context.report({
|
|
644
645
|
messageId: "noChildrenCount",
|
|
645
646
|
node: node.property
|
|
@@ -669,7 +670,7 @@ var no_children_for_each_default = createRule({
|
|
|
669
670
|
function create9(context) {
|
|
670
671
|
return {
|
|
671
672
|
MemberExpression(node) {
|
|
672
|
-
if (
|
|
673
|
+
if (ER21__namespace.isChildrenForEach(context, node)) {
|
|
673
674
|
context.report({
|
|
674
675
|
messageId: "noChildrenForEach",
|
|
675
676
|
node: node.property
|
|
@@ -699,7 +700,7 @@ var no_children_map_default = createRule({
|
|
|
699
700
|
function create10(context) {
|
|
700
701
|
return {
|
|
701
702
|
MemberExpression(node) {
|
|
702
|
-
if (
|
|
703
|
+
if (ER21__namespace.isChildrenMap(context, node)) {
|
|
703
704
|
context.report({
|
|
704
705
|
messageId: "noChildrenMap",
|
|
705
706
|
node: node.property
|
|
@@ -729,7 +730,7 @@ var no_children_only_default = createRule({
|
|
|
729
730
|
function create11(context) {
|
|
730
731
|
return {
|
|
731
732
|
MemberExpression(node) {
|
|
732
|
-
if (
|
|
733
|
+
if (ER21__namespace.isChildrenOnly(context, node)) {
|
|
733
734
|
context.report({
|
|
734
735
|
messageId: "noChildrenOnly",
|
|
735
736
|
node: node.property
|
|
@@ -794,7 +795,7 @@ var no_children_to_array_default = createRule({
|
|
|
794
795
|
function create13(context) {
|
|
795
796
|
return {
|
|
796
797
|
MemberExpression(node) {
|
|
797
|
-
if (
|
|
798
|
+
if (ER21__namespace.isChildrenToArray(context, node)) {
|
|
798
799
|
context.report({
|
|
799
800
|
messageId: "noChildrenToArray",
|
|
800
801
|
node: node.property
|
|
@@ -823,13 +824,13 @@ var no_class_component_default = createRule({
|
|
|
823
824
|
});
|
|
824
825
|
function create14(context) {
|
|
825
826
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
826
|
-
const { ctx, listeners } =
|
|
827
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
827
828
|
return {
|
|
828
829
|
...listeners,
|
|
829
830
|
"Program:exit"(node) {
|
|
830
831
|
const components = ctx.getAllComponents(node);
|
|
831
832
|
for (const { name: name5 = "anonymous", node: component } of components.values()) {
|
|
832
|
-
if (component.body.body.some((m) =>
|
|
833
|
+
if (component.body.body.some((m) => ER21__namespace.isComponentDidCatch(m) || ER21__namespace.isGetDerivedStateFromError(m))) {
|
|
833
834
|
continue;
|
|
834
835
|
}
|
|
835
836
|
context.report({
|
|
@@ -864,7 +865,7 @@ var no_clone_element_default = createRule({
|
|
|
864
865
|
function create15(context) {
|
|
865
866
|
return {
|
|
866
867
|
CallExpression(node) {
|
|
867
|
-
if (!
|
|
868
|
+
if (!ER21__namespace.isCloneElementCall(context, node)) {
|
|
868
869
|
return;
|
|
869
870
|
}
|
|
870
871
|
context.report({
|
|
@@ -991,7 +992,7 @@ var no_component_will_mount_default = createRule({
|
|
|
991
992
|
});
|
|
992
993
|
function create18(context) {
|
|
993
994
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
994
|
-
const { ctx, listeners } =
|
|
995
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
995
996
|
return {
|
|
996
997
|
...listeners,
|
|
997
998
|
"Program:exit"(node) {
|
|
@@ -1042,7 +1043,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1042
1043
|
});
|
|
1043
1044
|
function create19(context) {
|
|
1044
1045
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1045
|
-
const { ctx, listeners } =
|
|
1046
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
1046
1047
|
return {
|
|
1047
1048
|
...listeners,
|
|
1048
1049
|
"Program:exit"(node) {
|
|
@@ -1093,7 +1094,7 @@ var no_component_will_update_default = createRule({
|
|
|
1093
1094
|
});
|
|
1094
1095
|
function create20(context) {
|
|
1095
1096
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1096
|
-
const { ctx, listeners } =
|
|
1097
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
1097
1098
|
return {
|
|
1098
1099
|
...listeners,
|
|
1099
1100
|
"Program:exit"(node) {
|
|
@@ -1156,7 +1157,7 @@ function create21(context) {
|
|
|
1156
1157
|
messageId: "noContextProvider",
|
|
1157
1158
|
node,
|
|
1158
1159
|
fix(fixer) {
|
|
1159
|
-
if (!
|
|
1160
|
+
if (!ER21__namespace.isComponentNameLoose(contextSelfName)) return null;
|
|
1160
1161
|
const openingElement = node.openingElement;
|
|
1161
1162
|
const closingElement = node.closingElement;
|
|
1162
1163
|
if (closingElement == null) {
|
|
@@ -1192,7 +1193,7 @@ var no_create_ref_default = createRule({
|
|
|
1192
1193
|
function create22(context) {
|
|
1193
1194
|
return {
|
|
1194
1195
|
CallExpression(node) {
|
|
1195
|
-
if (
|
|
1196
|
+
if (ER21__namespace.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, ER21__namespace.isClassComponent) == null) {
|
|
1196
1197
|
context.report({ messageId: "noCreateRef", node });
|
|
1197
1198
|
}
|
|
1198
1199
|
}
|
|
@@ -1230,17 +1231,17 @@ function create23(context) {
|
|
|
1230
1231
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
|
|
1231
1232
|
return;
|
|
1232
1233
|
}
|
|
1233
|
-
if (!
|
|
1234
|
+
if (!ER21__namespace.isComponentNameLoose(object.name)) {
|
|
1234
1235
|
return;
|
|
1235
1236
|
}
|
|
1236
1237
|
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1237
1238
|
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
1238
1239
|
if (variableNode == null) return;
|
|
1239
|
-
if (!AST11__namespace.isFunction(variableNode) && !
|
|
1240
|
+
if (!AST11__namespace.isFunction(variableNode) && !ER21__namespace.isClassComponent(variableNode)) return;
|
|
1240
1241
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
1241
1242
|
},
|
|
1242
1243
|
PropertyDefinition(node) {
|
|
1243
|
-
if (!
|
|
1244
|
+
if (!ER21__namespace.isClassComponent(node.parent.parent)) {
|
|
1244
1245
|
return;
|
|
1245
1246
|
}
|
|
1246
1247
|
if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") {
|
|
@@ -1274,7 +1275,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1274
1275
|
function create24(context) {
|
|
1275
1276
|
return {
|
|
1276
1277
|
AssignmentExpression(node) {
|
|
1277
|
-
if (!
|
|
1278
|
+
if (!ER21__namespace.isAssignmentToThisState(node)) return;
|
|
1278
1279
|
const parentClass = AST11__namespace.findParentNode(
|
|
1279
1280
|
node,
|
|
1280
1281
|
AST11__namespace.isOneOf([
|
|
@@ -1283,7 +1284,7 @@ function create24(context) {
|
|
|
1283
1284
|
])
|
|
1284
1285
|
);
|
|
1285
1286
|
if (parentClass == null) return;
|
|
1286
|
-
if (
|
|
1287
|
+
if (ER21__namespace.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNode(node, isConstructorFunction)) {
|
|
1287
1288
|
context.report({
|
|
1288
1289
|
messageId: "noDirectMutationState",
|
|
1289
1290
|
node
|
|
@@ -1405,7 +1406,7 @@ function create26(context) {
|
|
|
1405
1406
|
}
|
|
1406
1407
|
return {
|
|
1407
1408
|
CallExpression(node) {
|
|
1408
|
-
if (!
|
|
1409
|
+
if (!ER21__namespace.isForwardRefCall(context, node)) {
|
|
1409
1410
|
return;
|
|
1410
1411
|
}
|
|
1411
1412
|
context.report({
|
|
@@ -1695,12 +1696,12 @@ function create29(context) {
|
|
|
1695
1696
|
const {
|
|
1696
1697
|
ctx,
|
|
1697
1698
|
listeners
|
|
1698
|
-
} =
|
|
1699
|
+
} = ER21__namespace.useComponentCollector(
|
|
1699
1700
|
context,
|
|
1700
1701
|
{
|
|
1701
1702
|
collectDisplayName: true,
|
|
1702
1703
|
collectHookCalls: false,
|
|
1703
|
-
hint:
|
|
1704
|
+
hint: ER21__namespace.DEFAULT_COMPONENT_HINT
|
|
1704
1705
|
}
|
|
1705
1706
|
);
|
|
1706
1707
|
return {
|
|
@@ -1708,7 +1709,7 @@ function create29(context) {
|
|
|
1708
1709
|
"Program:exit"(node) {
|
|
1709
1710
|
const components = ctx.getAllComponents(node);
|
|
1710
1711
|
for (const { node: node2, displayName, flag } of components.values()) {
|
|
1711
|
-
const isMemoOrForwardRef = (flag & (
|
|
1712
|
+
const isMemoOrForwardRef = (flag & (ER21__namespace.ComponentFlag.ForwardRef | ER21__namespace.ComponentFlag.Memo)) > 0n;
|
|
1712
1713
|
if (AST11__namespace.getFunctionIdentifier(node2) != null) {
|
|
1713
1714
|
continue;
|
|
1714
1715
|
}
|
|
@@ -1749,15 +1750,15 @@ function create30(context) {
|
|
|
1749
1750
|
const displayNameAssignments = [];
|
|
1750
1751
|
return {
|
|
1751
1752
|
CallExpression(node) {
|
|
1752
|
-
if (!
|
|
1753
|
+
if (!ER21__namespace.isCreateContextCall(context, node)) return;
|
|
1753
1754
|
createCalls.push(node);
|
|
1754
1755
|
},
|
|
1755
|
-
[
|
|
1756
|
+
[ER21__namespace.DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
1756
1757
|
displayNameAssignments.push(node);
|
|
1757
1758
|
},
|
|
1758
1759
|
"Program:exit"() {
|
|
1759
1760
|
for (const call of createCalls) {
|
|
1760
|
-
const id =
|
|
1761
|
+
const id = ER21__namespace.getInstanceId(call);
|
|
1761
1762
|
if (id == null) {
|
|
1762
1763
|
context.report({
|
|
1763
1764
|
messageId: "noMissingContextDisplayName",
|
|
@@ -1769,7 +1770,7 @@ function create30(context) {
|
|
|
1769
1770
|
const left = node.left;
|
|
1770
1771
|
if (left.type !== types.AST_NODE_TYPES.MemberExpression) return false;
|
|
1771
1772
|
const object = left.object;
|
|
1772
|
-
return
|
|
1773
|
+
return ER21__namespace.isInstanceIdEqual(context, id, object);
|
|
1773
1774
|
});
|
|
1774
1775
|
if (!hasDisplayNameAssignment) {
|
|
1775
1776
|
context.report({
|
|
@@ -1873,7 +1874,7 @@ function create31(context) {
|
|
|
1873
1874
|
}
|
|
1874
1875
|
},
|
|
1875
1876
|
CallExpression(node) {
|
|
1876
|
-
state.isWithinChildrenToArray ||=
|
|
1877
|
+
state.isWithinChildrenToArray ||= ER21__namespace.isChildrenToArrayCall(context, node);
|
|
1877
1878
|
if (state.isWithinChildrenToArray) {
|
|
1878
1879
|
return;
|
|
1879
1880
|
}
|
|
@@ -1892,7 +1893,7 @@ function create31(context) {
|
|
|
1892
1893
|
report(checkExpression(fn.body));
|
|
1893
1894
|
},
|
|
1894
1895
|
"CallExpression:exit"(node) {
|
|
1895
|
-
if (!
|
|
1896
|
+
if (!ER21__namespace.isChildrenToArrayCall(context, node)) {
|
|
1896
1897
|
return;
|
|
1897
1898
|
}
|
|
1898
1899
|
state.isWithinChildrenToArray = false;
|
|
@@ -1932,9 +1933,9 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1932
1933
|
defaultOptions: []
|
|
1933
1934
|
});
|
|
1934
1935
|
function create32(context) {
|
|
1935
|
-
const hint =
|
|
1936
|
-
const collector =
|
|
1937
|
-
const collectorLegacy =
|
|
1936
|
+
const hint = ER21__namespace.ComponentCollectorHint.SkipArrayMapArgument | ER21__namespace.ComponentCollectorHint.SkipNullLiteral | ER21__namespace.ComponentCollectorHint.SkipUndefined | ER21__namespace.ComponentCollectorHint.SkipBooleanLiteral | ER21__namespace.ComponentCollectorHint.SkipStringLiteral | ER21__namespace.ComponentCollectorHint.SkipNumberLiteral | ER21__namespace.ComponentCollectorHint.StrictLogical | ER21__namespace.ComponentCollectorHint.StrictConditional;
|
|
1937
|
+
const collector = ER21__namespace.useComponentCollector(context, { hint });
|
|
1938
|
+
const collectorLegacy = ER21__namespace.useComponentCollectorLegacy();
|
|
1938
1939
|
return {
|
|
1939
1940
|
...collector.listeners,
|
|
1940
1941
|
...collectorLegacy.listeners,
|
|
@@ -1953,9 +1954,9 @@ function create32(context) {
|
|
|
1953
1954
|
};
|
|
1954
1955
|
for (const { name: name5, node: component } of functionComponents) {
|
|
1955
1956
|
if (name5 == null) continue;
|
|
1956
|
-
if (
|
|
1957
|
+
if (ER21__namespace.isDirectValueOfRenderPropertyLoose(component)) continue;
|
|
1957
1958
|
if (isInsideJSXAttributeValue(component)) {
|
|
1958
|
-
if (!
|
|
1959
|
+
if (!ER21__namespace.isDeclaredInRenderPropLoose(component)) {
|
|
1959
1960
|
context.report({
|
|
1960
1961
|
messageId: "noNestedComponentDefinitions",
|
|
1961
1962
|
node: component,
|
|
@@ -1979,7 +1980,7 @@ function create32(context) {
|
|
|
1979
1980
|
continue;
|
|
1980
1981
|
}
|
|
1981
1982
|
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
1982
|
-
if (parentComponent != null && !
|
|
1983
|
+
if (parentComponent != null && !ER21__namespace.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1983
1984
|
context.report({
|
|
1984
1985
|
messageId: "noNestedComponentDefinitions",
|
|
1985
1986
|
node: component,
|
|
@@ -1990,7 +1991,7 @@ function create32(context) {
|
|
|
1990
1991
|
});
|
|
1991
1992
|
continue;
|
|
1992
1993
|
}
|
|
1993
|
-
if (
|
|
1994
|
+
if (ER21__namespace.isInsideRenderMethod(component)) {
|
|
1994
1995
|
context.report({
|
|
1995
1996
|
messageId: "noNestedComponentDefinitions",
|
|
1996
1997
|
node: component,
|
|
@@ -2021,7 +2022,7 @@ function isInsideJSXAttributeValue(node) {
|
|
|
2021
2022
|
return node.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX8__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
2022
2023
|
}
|
|
2023
2024
|
function isInsideCreateElementProps(context, node) {
|
|
2024
|
-
const call = AST11__namespace.findParentNode(node,
|
|
2025
|
+
const call = AST11__namespace.findParentNode(node, ER21__namespace.isCreateElementCall(context));
|
|
2025
2026
|
if (call == null) return false;
|
|
2026
2027
|
const prop = AST11__namespace.findParentNode(node, AST11__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
|
|
2027
2028
|
if (prop == null) return false;
|
|
@@ -2061,17 +2062,17 @@ function create33(context) {
|
|
|
2061
2062
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
|
|
2062
2063
|
return;
|
|
2063
2064
|
}
|
|
2064
|
-
if (!
|
|
2065
|
+
if (!ER21__namespace.isComponentNameLoose(object.name)) {
|
|
2065
2066
|
return;
|
|
2066
2067
|
}
|
|
2067
2068
|
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2068
2069
|
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
2069
|
-
if (variableNode != null && (AST11__namespace.isFunction(variableNode) ||
|
|
2070
|
+
if (variableNode != null && (AST11__namespace.isFunction(variableNode) || ER21__namespace.isClassComponent(variableNode))) {
|
|
2070
2071
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2071
2072
|
}
|
|
2072
2073
|
},
|
|
2073
2074
|
PropertyDefinition(node) {
|
|
2074
|
-
if (!
|
|
2075
|
+
if (!ER21__namespace.isClassComponent(node.parent.parent)) {
|
|
2075
2076
|
return;
|
|
2076
2077
|
}
|
|
2077
2078
|
if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") {
|
|
@@ -2104,13 +2105,13 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2104
2105
|
});
|
|
2105
2106
|
function create34(context) {
|
|
2106
2107
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2107
|
-
const { ctx, listeners } =
|
|
2108
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2108
2109
|
return {
|
|
2109
2110
|
...listeners,
|
|
2110
2111
|
"Program:exit"(node) {
|
|
2111
2112
|
const components = ctx.getAllComponents(node);
|
|
2112
2113
|
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
2113
|
-
if ((flag &
|
|
2114
|
+
if ((flag & ER21__namespace.ComponentFlag.PureComponent) === 0n) {
|
|
2114
2115
|
continue;
|
|
2115
2116
|
}
|
|
2116
2117
|
const { body } = component.body;
|
|
@@ -2154,10 +2155,10 @@ function create35(context) {
|
|
|
2154
2155
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2155
2156
|
return {
|
|
2156
2157
|
CallExpression(node) {
|
|
2157
|
-
if (!
|
|
2158
|
+
if (!ER21__namespace.isThisSetState(node)) {
|
|
2158
2159
|
return;
|
|
2159
2160
|
}
|
|
2160
|
-
const clazz = AST11__namespace.findParentNode(node,
|
|
2161
|
+
const clazz = AST11__namespace.findParentNode(node, ER21__namespace.isClassComponent);
|
|
2161
2162
|
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
|
|
2162
2163
|
if (clazz == null || method == null || method === clazz) return;
|
|
2163
2164
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2196,10 +2197,10 @@ function create36(context) {
|
|
|
2196
2197
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2197
2198
|
return {
|
|
2198
2199
|
CallExpression(node) {
|
|
2199
|
-
if (!
|
|
2200
|
+
if (!ER21__namespace.isThisSetState(node)) {
|
|
2200
2201
|
return;
|
|
2201
2202
|
}
|
|
2202
|
-
const clazz = AST11__namespace.findParentNode(node,
|
|
2203
|
+
const clazz = AST11__namespace.findParentNode(node, ER21__namespace.isClassComponent);
|
|
2203
2204
|
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
|
|
2204
2205
|
if (clazz == null || method == null || method === clazz) return;
|
|
2205
2206
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2238,10 +2239,10 @@ function create37(context) {
|
|
|
2238
2239
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2239
2240
|
return {
|
|
2240
2241
|
CallExpression(node) {
|
|
2241
|
-
if (!
|
|
2242
|
+
if (!ER21__namespace.isThisSetState(node)) {
|
|
2242
2243
|
return;
|
|
2243
2244
|
}
|
|
2244
|
-
const clazz = AST11__namespace.findParentNode(node,
|
|
2245
|
+
const clazz = AST11__namespace.findParentNode(node, ER21__namespace.isClassComponent);
|
|
2245
2246
|
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
|
|
2246
2247
|
if (clazz == null || method == null || method === clazz) return;
|
|
2247
2248
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2323,7 +2324,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2323
2324
|
});
|
|
2324
2325
|
function create39(context) {
|
|
2325
2326
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2326
|
-
const { ctx, listeners } =
|
|
2327
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2327
2328
|
return {
|
|
2328
2329
|
...listeners,
|
|
2329
2330
|
"Program:exit"(node) {
|
|
@@ -2367,7 +2368,7 @@ function create40(context) {
|
|
|
2367
2368
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2368
2369
|
return {};
|
|
2369
2370
|
}
|
|
2370
|
-
const { ctx, listeners } =
|
|
2371
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2371
2372
|
return {
|
|
2372
2373
|
...listeners,
|
|
2373
2374
|
"Program:exit"(node) {
|
|
@@ -2409,7 +2410,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2409
2410
|
});
|
|
2410
2411
|
function create41(context) {
|
|
2411
2412
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2412
|
-
const { ctx, listeners } =
|
|
2413
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2413
2414
|
return {
|
|
2414
2415
|
...listeners,
|
|
2415
2416
|
"Program:exit"(node) {
|
|
@@ -2449,7 +2450,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2449
2450
|
function create42(context) {
|
|
2450
2451
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2451
2452
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2452
|
-
const { ctx, listeners } =
|
|
2453
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
2453
2454
|
const constructions = /* @__PURE__ */ new Map();
|
|
2454
2455
|
return {
|
|
2455
2456
|
...listeners,
|
|
@@ -2470,7 +2471,7 @@ function create42(context) {
|
|
|
2470
2471
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2471
2472
|
const construction = VAR2__namespace.getValueConstruction(valueExpression, initialScope);
|
|
2472
2473
|
if (construction == null) return;
|
|
2473
|
-
if (
|
|
2474
|
+
if (ER21__namespace.isReactHookCall(construction.node)) {
|
|
2474
2475
|
return;
|
|
2475
2476
|
}
|
|
2476
2477
|
eff.getOrUpdate(constructions, functionEntry.node, () => []).push(construction);
|
|
@@ -2520,7 +2521,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2520
2521
|
defaultOptions: []
|
|
2521
2522
|
});
|
|
2522
2523
|
function create43(context) {
|
|
2523
|
-
const { ctx, listeners } =
|
|
2524
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
2524
2525
|
const declarators = /* @__PURE__ */ new Map();
|
|
2525
2526
|
return {
|
|
2526
2527
|
...listeners,
|
|
@@ -2550,7 +2551,7 @@ function create43(context) {
|
|
|
2550
2551
|
if (construction == null) {
|
|
2551
2552
|
continue;
|
|
2552
2553
|
}
|
|
2553
|
-
if (
|
|
2554
|
+
if (ER21__namespace.isReactHookCall(construction.node)) {
|
|
2554
2555
|
continue;
|
|
2555
2556
|
}
|
|
2556
2557
|
const forbiddenType = AST11__namespace.toReadableNodeType(right);
|
|
@@ -2620,7 +2621,7 @@ function create44(context) {
|
|
|
2620
2621
|
const propertyUsages = /* @__PURE__ */ new WeakMap();
|
|
2621
2622
|
function classEnter(node) {
|
|
2622
2623
|
classEntries.push(node);
|
|
2623
|
-
if (!
|
|
2624
|
+
if (!ER21__namespace.isClassComponent(node)) {
|
|
2624
2625
|
return;
|
|
2625
2626
|
}
|
|
2626
2627
|
propertyDefs.set(node, /* @__PURE__ */ new Set());
|
|
@@ -2628,7 +2629,7 @@ function create44(context) {
|
|
|
2628
2629
|
}
|
|
2629
2630
|
function classExit() {
|
|
2630
2631
|
const currentClass = classEntries.pop();
|
|
2631
|
-
if (currentClass == null || !
|
|
2632
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2632
2633
|
return;
|
|
2633
2634
|
}
|
|
2634
2635
|
const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
|
|
@@ -2658,7 +2659,7 @@ function create44(context) {
|
|
|
2658
2659
|
function methodEnter(node) {
|
|
2659
2660
|
methodEntries.push(node);
|
|
2660
2661
|
const currentClass = classEntries.at(-1);
|
|
2661
|
-
if (currentClass == null || !
|
|
2662
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2662
2663
|
return;
|
|
2663
2664
|
}
|
|
2664
2665
|
if (node.static) {
|
|
@@ -2682,7 +2683,7 @@ function create44(context) {
|
|
|
2682
2683
|
if (currentClass == null || currentMethod == null) {
|
|
2683
2684
|
return;
|
|
2684
2685
|
}
|
|
2685
|
-
if (!
|
|
2686
|
+
if (!ER21__namespace.isClassComponent(currentClass) || currentMethod.static) {
|
|
2686
2687
|
return;
|
|
2687
2688
|
}
|
|
2688
2689
|
if (!AST11__namespace.isThisExpression(node.object) || !isKeyLiteral2(node, node.property)) {
|
|
@@ -2707,7 +2708,7 @@ function create44(context) {
|
|
|
2707
2708
|
if (currentClass == null || currentMethod == null) {
|
|
2708
2709
|
return;
|
|
2709
2710
|
}
|
|
2710
|
-
if (!
|
|
2711
|
+
if (!ER21__namespace.isClassComponent(currentClass) || currentMethod.static) {
|
|
2711
2712
|
return;
|
|
2712
2713
|
}
|
|
2713
2714
|
if (node.init != null && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern) {
|
|
@@ -2754,7 +2755,7 @@ function create45(context) {
|
|
|
2754
2755
|
}
|
|
2755
2756
|
function classExit() {
|
|
2756
2757
|
const currentClass = classEntries.pop();
|
|
2757
|
-
if (currentClass == null || !
|
|
2758
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2758
2759
|
return;
|
|
2759
2760
|
}
|
|
2760
2761
|
const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
|
|
@@ -2773,11 +2774,11 @@ function create45(context) {
|
|
|
2773
2774
|
function methodEnter(node) {
|
|
2774
2775
|
methodEntries.push(node);
|
|
2775
2776
|
const currentClass = classEntries.at(-1);
|
|
2776
|
-
if (currentClass == null || !
|
|
2777
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2777
2778
|
return;
|
|
2778
2779
|
}
|
|
2779
2780
|
if (node.static) {
|
|
2780
|
-
if (
|
|
2781
|
+
if (ER21__namespace.isGetDerivedStateFromProps(node) && tsPattern.isMatching({ params: [tsPattern.P.nonNullable, ...tsPattern.P.array()] })(node.value)) {
|
|
2781
2782
|
const defNode = stateDefs.get(currentClass)?.node;
|
|
2782
2783
|
stateDefs.set(currentClass, { node: defNode, isUsed: true });
|
|
2783
2784
|
}
|
|
@@ -2798,11 +2799,11 @@ function create45(context) {
|
|
|
2798
2799
|
}
|
|
2799
2800
|
return {
|
|
2800
2801
|
AssignmentExpression(node) {
|
|
2801
|
-
if (!
|
|
2802
|
+
if (!ER21__namespace.isAssignmentToThisState(node)) {
|
|
2802
2803
|
return;
|
|
2803
2804
|
}
|
|
2804
2805
|
const currentClass = classEntries.at(-1);
|
|
2805
|
-
if (currentClass == null || !
|
|
2806
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2806
2807
|
return;
|
|
2807
2808
|
}
|
|
2808
2809
|
const currentConstructor = constructorEntries.at(-1);
|
|
@@ -2824,7 +2825,7 @@ function create45(context) {
|
|
|
2824
2825
|
return;
|
|
2825
2826
|
}
|
|
2826
2827
|
const currentClass = classEntries.at(-1);
|
|
2827
|
-
if (currentClass == null || !
|
|
2828
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2828
2829
|
return;
|
|
2829
2830
|
}
|
|
2830
2831
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2848,7 +2849,7 @@ function create45(context) {
|
|
|
2848
2849
|
"PropertyDefinition:exit": methodExit,
|
|
2849
2850
|
VariableDeclarator(node) {
|
|
2850
2851
|
const currentClass = classEntries.at(-1);
|
|
2851
|
-
if (currentClass == null || !
|
|
2852
|
+
if (currentClass == null || !ER21__namespace.isClassComponent(currentClass)) {
|
|
2852
2853
|
return;
|
|
2853
2854
|
}
|
|
2854
2855
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2908,10 +2909,10 @@ function create46(context) {
|
|
|
2908
2909
|
}
|
|
2909
2910
|
return {
|
|
2910
2911
|
CallExpression(node) {
|
|
2911
|
-
if (!
|
|
2912
|
+
if (!ER21__namespace.isReactHookCall(node)) {
|
|
2912
2913
|
return;
|
|
2913
2914
|
}
|
|
2914
|
-
if (!
|
|
2915
|
+
if (!ER21__namespace.isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
2915
2916
|
return;
|
|
2916
2917
|
}
|
|
2917
2918
|
context.report({
|
|
@@ -2998,7 +2999,7 @@ var no_useless_forward_ref_default = createRule({
|
|
|
2998
2999
|
function create47(context) {
|
|
2999
3000
|
return {
|
|
3000
3001
|
CallExpression(node) {
|
|
3001
|
-
if (!
|
|
3002
|
+
if (!ER21__namespace.isForwardRefCall(context, node)) {
|
|
3002
3003
|
return;
|
|
3003
3004
|
}
|
|
3004
3005
|
const [component] = node.arguments;
|
|
@@ -3180,7 +3181,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3180
3181
|
defaultOptions: []
|
|
3181
3182
|
});
|
|
3182
3183
|
function create49(context) {
|
|
3183
|
-
const { ctx, listeners } =
|
|
3184
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
3184
3185
|
const memberExpressionWithNames = [];
|
|
3185
3186
|
return {
|
|
3186
3187
|
...listeners,
|
|
@@ -3199,7 +3200,7 @@ function create49(context) {
|
|
|
3199
3200
|
return false;
|
|
3200
3201
|
}
|
|
3201
3202
|
const id = AST11__namespace.getFunctionIdentifier(block);
|
|
3202
|
-
return id != null &&
|
|
3203
|
+
return id != null && ER21__namespace.isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3203
3204
|
}
|
|
3204
3205
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
3205
3206
|
let scope = initialScope;
|
|
@@ -3316,7 +3317,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
3316
3317
|
});
|
|
3317
3318
|
function create51(context) {
|
|
3318
3319
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3319
|
-
const { ctx, listeners } =
|
|
3320
|
+
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
3320
3321
|
return {
|
|
3321
3322
|
...listeners,
|
|
3322
3323
|
"Program:exit"(node) {
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
|
6
6
|
import * as VAR2 from '@eslint-react/var';
|
|
7
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
8
8
|
import * as AST11 from '@eslint-react/ast';
|
|
9
|
-
import
|
|
9
|
+
import * as ER21 from '@eslint-react/core';
|
|
10
10
|
import { createReport } from '@eslint-react/kit';
|
|
11
11
|
import { compare } from 'compare-versions';
|
|
12
12
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
@@ -111,7 +111,7 @@ var settings3 = {
|
|
|
111
111
|
|
|
112
112
|
// package.json
|
|
113
113
|
var name4 = "eslint-plugin-react-x";
|
|
114
|
-
var version = "1.
|
|
114
|
+
var version = "1.39.0-beta.1";
|
|
115
115
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
116
116
|
|
|
117
117
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -329,25 +329,25 @@ function create6(context) {
|
|
|
329
329
|
const setStateEntries = [];
|
|
330
330
|
return {
|
|
331
331
|
CallExpression(node) {
|
|
332
|
-
if (!isThisSetState(node)) {
|
|
332
|
+
if (!ER21.isThisSetState(node)) {
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
335
|
setStateEntries.push([node, false]);
|
|
336
336
|
},
|
|
337
337
|
"CallExpression:exit"(node) {
|
|
338
|
-
if (!isThisSetState(node)) {
|
|
338
|
+
if (!ER21.isThisSetState(node)) {
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
341
|
setStateEntries.pop();
|
|
342
342
|
},
|
|
343
343
|
ClassDeclaration(node) {
|
|
344
|
-
classEntries.push([node, isClassComponent(node)]);
|
|
344
|
+
classEntries.push([node, ER21.isClassComponent(node)]);
|
|
345
345
|
},
|
|
346
346
|
"ClassDeclaration:exit"() {
|
|
347
347
|
classEntries.pop();
|
|
348
348
|
},
|
|
349
349
|
ClassExpression(node) {
|
|
350
|
-
classEntries.push([node, isClassComponent(node)]);
|
|
350
|
+
classEntries.push([node, ER21.isClassComponent(node)]);
|
|
351
351
|
},
|
|
352
352
|
"ClassExpression:exit"() {
|
|
353
353
|
classEntries.pop();
|
|
@@ -431,7 +431,7 @@ function isUsingReactChildren(context, node) {
|
|
|
431
431
|
return true;
|
|
432
432
|
}
|
|
433
433
|
if (callee.object.type === AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
|
|
434
|
-
return isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
434
|
+
return ER21.isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
435
435
|
}
|
|
436
436
|
return false;
|
|
437
437
|
}
|
|
@@ -500,7 +500,7 @@ function create7(context) {
|
|
|
500
500
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
501
501
|
}
|
|
502
502
|
function isCreateOrCloneElementCall(node) {
|
|
503
|
-
return isCreateElementCall(context, node) || isCloneElementCall(context, node);
|
|
503
|
+
return ER21.isCreateElementCall(context, node) || ER21.isCloneElementCall(context, node);
|
|
504
504
|
}
|
|
505
505
|
function getReportDescriptors(node) {
|
|
506
506
|
switch (node.type) {
|
|
@@ -612,7 +612,7 @@ var no_children_count_default = createRule({
|
|
|
612
612
|
function create8(context) {
|
|
613
613
|
return {
|
|
614
614
|
MemberExpression(node) {
|
|
615
|
-
if (isChildrenCount(context, node)) {
|
|
615
|
+
if (ER21.isChildrenCount(context, node)) {
|
|
616
616
|
context.report({
|
|
617
617
|
messageId: "noChildrenCount",
|
|
618
618
|
node: node.property
|
|
@@ -642,7 +642,7 @@ var no_children_for_each_default = createRule({
|
|
|
642
642
|
function create9(context) {
|
|
643
643
|
return {
|
|
644
644
|
MemberExpression(node) {
|
|
645
|
-
if (isChildrenForEach(context, node)) {
|
|
645
|
+
if (ER21.isChildrenForEach(context, node)) {
|
|
646
646
|
context.report({
|
|
647
647
|
messageId: "noChildrenForEach",
|
|
648
648
|
node: node.property
|
|
@@ -672,7 +672,7 @@ var no_children_map_default = createRule({
|
|
|
672
672
|
function create10(context) {
|
|
673
673
|
return {
|
|
674
674
|
MemberExpression(node) {
|
|
675
|
-
if (isChildrenMap(context, node)) {
|
|
675
|
+
if (ER21.isChildrenMap(context, node)) {
|
|
676
676
|
context.report({
|
|
677
677
|
messageId: "noChildrenMap",
|
|
678
678
|
node: node.property
|
|
@@ -702,7 +702,7 @@ var no_children_only_default = createRule({
|
|
|
702
702
|
function create11(context) {
|
|
703
703
|
return {
|
|
704
704
|
MemberExpression(node) {
|
|
705
|
-
if (isChildrenOnly(context, node)) {
|
|
705
|
+
if (ER21.isChildrenOnly(context, node)) {
|
|
706
706
|
context.report({
|
|
707
707
|
messageId: "noChildrenOnly",
|
|
708
708
|
node: node.property
|
|
@@ -767,7 +767,7 @@ var no_children_to_array_default = createRule({
|
|
|
767
767
|
function create13(context) {
|
|
768
768
|
return {
|
|
769
769
|
MemberExpression(node) {
|
|
770
|
-
if (isChildrenToArray(context, node)) {
|
|
770
|
+
if (ER21.isChildrenToArray(context, node)) {
|
|
771
771
|
context.report({
|
|
772
772
|
messageId: "noChildrenToArray",
|
|
773
773
|
node: node.property
|
|
@@ -796,13 +796,13 @@ var no_class_component_default = createRule({
|
|
|
796
796
|
});
|
|
797
797
|
function create14(context) {
|
|
798
798
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
799
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
799
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
800
800
|
return {
|
|
801
801
|
...listeners,
|
|
802
802
|
"Program:exit"(node) {
|
|
803
803
|
const components = ctx.getAllComponents(node);
|
|
804
804
|
for (const { name: name5 = "anonymous", node: component } of components.values()) {
|
|
805
|
-
if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
|
|
805
|
+
if (component.body.body.some((m) => ER21.isComponentDidCatch(m) || ER21.isGetDerivedStateFromError(m))) {
|
|
806
806
|
continue;
|
|
807
807
|
}
|
|
808
808
|
context.report({
|
|
@@ -837,7 +837,7 @@ var no_clone_element_default = createRule({
|
|
|
837
837
|
function create15(context) {
|
|
838
838
|
return {
|
|
839
839
|
CallExpression(node) {
|
|
840
|
-
if (!isCloneElementCall(context, node)) {
|
|
840
|
+
if (!ER21.isCloneElementCall(context, node)) {
|
|
841
841
|
return;
|
|
842
842
|
}
|
|
843
843
|
context.report({
|
|
@@ -964,7 +964,7 @@ var no_component_will_mount_default = createRule({
|
|
|
964
964
|
});
|
|
965
965
|
function create18(context) {
|
|
966
966
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
967
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
967
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
968
968
|
return {
|
|
969
969
|
...listeners,
|
|
970
970
|
"Program:exit"(node) {
|
|
@@ -1015,7 +1015,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1015
1015
|
});
|
|
1016
1016
|
function create19(context) {
|
|
1017
1017
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1018
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
1018
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
1019
1019
|
return {
|
|
1020
1020
|
...listeners,
|
|
1021
1021
|
"Program:exit"(node) {
|
|
@@ -1066,7 +1066,7 @@ var no_component_will_update_default = createRule({
|
|
|
1066
1066
|
});
|
|
1067
1067
|
function create20(context) {
|
|
1068
1068
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1069
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
1069
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
1070
1070
|
return {
|
|
1071
1071
|
...listeners,
|
|
1072
1072
|
"Program:exit"(node) {
|
|
@@ -1129,7 +1129,7 @@ function create21(context) {
|
|
|
1129
1129
|
messageId: "noContextProvider",
|
|
1130
1130
|
node,
|
|
1131
1131
|
fix(fixer) {
|
|
1132
|
-
if (!isComponentNameLoose(contextSelfName)) return null;
|
|
1132
|
+
if (!ER21.isComponentNameLoose(contextSelfName)) return null;
|
|
1133
1133
|
const openingElement = node.openingElement;
|
|
1134
1134
|
const closingElement = node.closingElement;
|
|
1135
1135
|
if (closingElement == null) {
|
|
@@ -1165,7 +1165,7 @@ var no_create_ref_default = createRule({
|
|
|
1165
1165
|
function create22(context) {
|
|
1166
1166
|
return {
|
|
1167
1167
|
CallExpression(node) {
|
|
1168
|
-
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
1168
|
+
if (ER21.isCreateRefCall(context, node) && AST11.findParentNode(node, ER21.isClassComponent) == null) {
|
|
1169
1169
|
context.report({ messageId: "noCreateRef", node });
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
@@ -1203,17 +1203,17 @@ function create23(context) {
|
|
|
1203
1203
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
|
|
1204
1204
|
return;
|
|
1205
1205
|
}
|
|
1206
|
-
if (!isComponentNameLoose(object.name)) {
|
|
1206
|
+
if (!ER21.isComponentNameLoose(object.name)) {
|
|
1207
1207
|
return;
|
|
1208
1208
|
}
|
|
1209
1209
|
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1210
1210
|
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
1211
1211
|
if (variableNode == null) return;
|
|
1212
|
-
if (!AST11.isFunction(variableNode) && !isClassComponent(variableNode)) return;
|
|
1212
|
+
if (!AST11.isFunction(variableNode) && !ER21.isClassComponent(variableNode)) return;
|
|
1213
1213
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
1214
1214
|
},
|
|
1215
1215
|
PropertyDefinition(node) {
|
|
1216
|
-
if (!isClassComponent(node.parent.parent)) {
|
|
1216
|
+
if (!ER21.isClassComponent(node.parent.parent)) {
|
|
1217
1217
|
return;
|
|
1218
1218
|
}
|
|
1219
1219
|
if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") {
|
|
@@ -1247,7 +1247,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1247
1247
|
function create24(context) {
|
|
1248
1248
|
return {
|
|
1249
1249
|
AssignmentExpression(node) {
|
|
1250
|
-
if (!isAssignmentToThisState(node)) return;
|
|
1250
|
+
if (!ER21.isAssignmentToThisState(node)) return;
|
|
1251
1251
|
const parentClass = AST11.findParentNode(
|
|
1252
1252
|
node,
|
|
1253
1253
|
AST11.isOneOf([
|
|
@@ -1256,7 +1256,7 @@ function create24(context) {
|
|
|
1256
1256
|
])
|
|
1257
1257
|
);
|
|
1258
1258
|
if (parentClass == null) return;
|
|
1259
|
-
if (isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNode(node, isConstructorFunction)) {
|
|
1259
|
+
if (ER21.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNode(node, isConstructorFunction)) {
|
|
1260
1260
|
context.report({
|
|
1261
1261
|
messageId: "noDirectMutationState",
|
|
1262
1262
|
node
|
|
@@ -1378,7 +1378,7 @@ function create26(context) {
|
|
|
1378
1378
|
}
|
|
1379
1379
|
return {
|
|
1380
1380
|
CallExpression(node) {
|
|
1381
|
-
if (!isForwardRefCall(context, node)) {
|
|
1381
|
+
if (!ER21.isForwardRefCall(context, node)) {
|
|
1382
1382
|
return;
|
|
1383
1383
|
}
|
|
1384
1384
|
context.report({
|
|
@@ -1668,12 +1668,12 @@ function create29(context) {
|
|
|
1668
1668
|
const {
|
|
1669
1669
|
ctx,
|
|
1670
1670
|
listeners
|
|
1671
|
-
} = useComponentCollector(
|
|
1671
|
+
} = ER21.useComponentCollector(
|
|
1672
1672
|
context,
|
|
1673
1673
|
{
|
|
1674
1674
|
collectDisplayName: true,
|
|
1675
1675
|
collectHookCalls: false,
|
|
1676
|
-
hint: DEFAULT_COMPONENT_HINT
|
|
1676
|
+
hint: ER21.DEFAULT_COMPONENT_HINT
|
|
1677
1677
|
}
|
|
1678
1678
|
);
|
|
1679
1679
|
return {
|
|
@@ -1681,7 +1681,7 @@ function create29(context) {
|
|
|
1681
1681
|
"Program:exit"(node) {
|
|
1682
1682
|
const components = ctx.getAllComponents(node);
|
|
1683
1683
|
for (const { node: node2, displayName, flag } of components.values()) {
|
|
1684
|
-
const isMemoOrForwardRef = (flag & (
|
|
1684
|
+
const isMemoOrForwardRef = (flag & (ER21.ComponentFlag.ForwardRef | ER21.ComponentFlag.Memo)) > 0n;
|
|
1685
1685
|
if (AST11.getFunctionIdentifier(node2) != null) {
|
|
1686
1686
|
continue;
|
|
1687
1687
|
}
|
|
@@ -1722,15 +1722,15 @@ function create30(context) {
|
|
|
1722
1722
|
const displayNameAssignments = [];
|
|
1723
1723
|
return {
|
|
1724
1724
|
CallExpression(node) {
|
|
1725
|
-
if (!isCreateContextCall(context, node)) return;
|
|
1725
|
+
if (!ER21.isCreateContextCall(context, node)) return;
|
|
1726
1726
|
createCalls.push(node);
|
|
1727
1727
|
},
|
|
1728
|
-
[DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
1728
|
+
[ER21.DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
1729
1729
|
displayNameAssignments.push(node);
|
|
1730
1730
|
},
|
|
1731
1731
|
"Program:exit"() {
|
|
1732
1732
|
for (const call of createCalls) {
|
|
1733
|
-
const id = getInstanceId(call);
|
|
1733
|
+
const id = ER21.getInstanceId(call);
|
|
1734
1734
|
if (id == null) {
|
|
1735
1735
|
context.report({
|
|
1736
1736
|
messageId: "noMissingContextDisplayName",
|
|
@@ -1742,7 +1742,7 @@ function create30(context) {
|
|
|
1742
1742
|
const left = node.left;
|
|
1743
1743
|
if (left.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
1744
1744
|
const object = left.object;
|
|
1745
|
-
return isInstanceIdEqual(context, id, object);
|
|
1745
|
+
return ER21.isInstanceIdEqual(context, id, object);
|
|
1746
1746
|
});
|
|
1747
1747
|
if (!hasDisplayNameAssignment) {
|
|
1748
1748
|
context.report({
|
|
@@ -1846,7 +1846,7 @@ function create31(context) {
|
|
|
1846
1846
|
}
|
|
1847
1847
|
},
|
|
1848
1848
|
CallExpression(node) {
|
|
1849
|
-
state.isWithinChildrenToArray ||= isChildrenToArrayCall(context, node);
|
|
1849
|
+
state.isWithinChildrenToArray ||= ER21.isChildrenToArrayCall(context, node);
|
|
1850
1850
|
if (state.isWithinChildrenToArray) {
|
|
1851
1851
|
return;
|
|
1852
1852
|
}
|
|
@@ -1865,7 +1865,7 @@ function create31(context) {
|
|
|
1865
1865
|
report(checkExpression(fn.body));
|
|
1866
1866
|
},
|
|
1867
1867
|
"CallExpression:exit"(node) {
|
|
1868
|
-
if (!isChildrenToArrayCall(context, node)) {
|
|
1868
|
+
if (!ER21.isChildrenToArrayCall(context, node)) {
|
|
1869
1869
|
return;
|
|
1870
1870
|
}
|
|
1871
1871
|
state.isWithinChildrenToArray = false;
|
|
@@ -1905,9 +1905,9 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1905
1905
|
defaultOptions: []
|
|
1906
1906
|
});
|
|
1907
1907
|
function create32(context) {
|
|
1908
|
-
const hint =
|
|
1909
|
-
const collector = useComponentCollector(context, { hint });
|
|
1910
|
-
const collectorLegacy = useComponentCollectorLegacy();
|
|
1908
|
+
const hint = ER21.ComponentCollectorHint.SkipArrayMapArgument | ER21.ComponentCollectorHint.SkipNullLiteral | ER21.ComponentCollectorHint.SkipUndefined | ER21.ComponentCollectorHint.SkipBooleanLiteral | ER21.ComponentCollectorHint.SkipStringLiteral | ER21.ComponentCollectorHint.SkipNumberLiteral | ER21.ComponentCollectorHint.StrictLogical | ER21.ComponentCollectorHint.StrictConditional;
|
|
1909
|
+
const collector = ER21.useComponentCollector(context, { hint });
|
|
1910
|
+
const collectorLegacy = ER21.useComponentCollectorLegacy();
|
|
1911
1911
|
return {
|
|
1912
1912
|
...collector.listeners,
|
|
1913
1913
|
...collectorLegacy.listeners,
|
|
@@ -1926,9 +1926,9 @@ function create32(context) {
|
|
|
1926
1926
|
};
|
|
1927
1927
|
for (const { name: name5, node: component } of functionComponents) {
|
|
1928
1928
|
if (name5 == null) continue;
|
|
1929
|
-
if (isDirectValueOfRenderPropertyLoose(component)) continue;
|
|
1929
|
+
if (ER21.isDirectValueOfRenderPropertyLoose(component)) continue;
|
|
1930
1930
|
if (isInsideJSXAttributeValue(component)) {
|
|
1931
|
-
if (!isDeclaredInRenderPropLoose(component)) {
|
|
1931
|
+
if (!ER21.isDeclaredInRenderPropLoose(component)) {
|
|
1932
1932
|
context.report({
|
|
1933
1933
|
messageId: "noNestedComponentDefinitions",
|
|
1934
1934
|
node: component,
|
|
@@ -1952,7 +1952,7 @@ function create32(context) {
|
|
|
1952
1952
|
continue;
|
|
1953
1953
|
}
|
|
1954
1954
|
const parentComponent = AST11.findParentNode(component, isFunctionComponent);
|
|
1955
|
-
if (parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1955
|
+
if (parentComponent != null && !ER21.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1956
1956
|
context.report({
|
|
1957
1957
|
messageId: "noNestedComponentDefinitions",
|
|
1958
1958
|
node: component,
|
|
@@ -1963,7 +1963,7 @@ function create32(context) {
|
|
|
1963
1963
|
});
|
|
1964
1964
|
continue;
|
|
1965
1965
|
}
|
|
1966
|
-
if (isInsideRenderMethod(component)) {
|
|
1966
|
+
if (ER21.isInsideRenderMethod(component)) {
|
|
1967
1967
|
context.report({
|
|
1968
1968
|
messageId: "noNestedComponentDefinitions",
|
|
1969
1969
|
node: component,
|
|
@@ -1994,7 +1994,7 @@ function isInsideJSXAttributeValue(node) {
|
|
|
1994
1994
|
return node.parent.type === AST_NODE_TYPES.JSXAttribute || JSX8.findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
1995
1995
|
}
|
|
1996
1996
|
function isInsideCreateElementProps(context, node) {
|
|
1997
|
-
const call = AST11.findParentNode(node, isCreateElementCall(context));
|
|
1997
|
+
const call = AST11.findParentNode(node, ER21.isCreateElementCall(context));
|
|
1998
1998
|
if (call == null) return false;
|
|
1999
1999
|
const prop = AST11.findParentNode(node, AST11.is(AST_NODE_TYPES.ObjectExpression));
|
|
2000
2000
|
if (prop == null) return false;
|
|
@@ -2034,17 +2034,17 @@ function create33(context) {
|
|
|
2034
2034
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
|
|
2035
2035
|
return;
|
|
2036
2036
|
}
|
|
2037
|
-
if (!isComponentNameLoose(object.name)) {
|
|
2037
|
+
if (!ER21.isComponentNameLoose(object.name)) {
|
|
2038
2038
|
return;
|
|
2039
2039
|
}
|
|
2040
2040
|
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2041
2041
|
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
2042
|
-
if (variableNode != null && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
|
|
2042
|
+
if (variableNode != null && (AST11.isFunction(variableNode) || ER21.isClassComponent(variableNode))) {
|
|
2043
2043
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2044
2044
|
}
|
|
2045
2045
|
},
|
|
2046
2046
|
PropertyDefinition(node) {
|
|
2047
|
-
if (!isClassComponent(node.parent.parent)) {
|
|
2047
|
+
if (!ER21.isClassComponent(node.parent.parent)) {
|
|
2048
2048
|
return;
|
|
2049
2049
|
}
|
|
2050
2050
|
if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") {
|
|
@@ -2077,13 +2077,13 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2077
2077
|
});
|
|
2078
2078
|
function create34(context) {
|
|
2079
2079
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2080
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2080
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2081
2081
|
return {
|
|
2082
2082
|
...listeners,
|
|
2083
2083
|
"Program:exit"(node) {
|
|
2084
2084
|
const components = ctx.getAllComponents(node);
|
|
2085
2085
|
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
2086
|
-
if ((flag &
|
|
2086
|
+
if ((flag & ER21.ComponentFlag.PureComponent) === 0n) {
|
|
2087
2087
|
continue;
|
|
2088
2088
|
}
|
|
2089
2089
|
const { body } = component.body;
|
|
@@ -2127,10 +2127,10 @@ function create35(context) {
|
|
|
2127
2127
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2128
2128
|
return {
|
|
2129
2129
|
CallExpression(node) {
|
|
2130
|
-
if (!isThisSetState(node)) {
|
|
2130
|
+
if (!ER21.isThisSetState(node)) {
|
|
2131
2131
|
return;
|
|
2132
2132
|
}
|
|
2133
|
-
const clazz = AST11.findParentNode(node, isClassComponent);
|
|
2133
|
+
const clazz = AST11.findParentNode(node, ER21.isClassComponent);
|
|
2134
2134
|
const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
|
|
2135
2135
|
if (clazz == null || method == null || method === clazz) return;
|
|
2136
2136
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2169,10 +2169,10 @@ function create36(context) {
|
|
|
2169
2169
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2170
2170
|
return {
|
|
2171
2171
|
CallExpression(node) {
|
|
2172
|
-
if (!isThisSetState(node)) {
|
|
2172
|
+
if (!ER21.isThisSetState(node)) {
|
|
2173
2173
|
return;
|
|
2174
2174
|
}
|
|
2175
|
-
const clazz = AST11.findParentNode(node, isClassComponent);
|
|
2175
|
+
const clazz = AST11.findParentNode(node, ER21.isClassComponent);
|
|
2176
2176
|
const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
|
|
2177
2177
|
if (clazz == null || method == null || method === clazz) return;
|
|
2178
2178
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2211,10 +2211,10 @@ function create37(context) {
|
|
|
2211
2211
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2212
2212
|
return {
|
|
2213
2213
|
CallExpression(node) {
|
|
2214
|
-
if (!isThisSetState(node)) {
|
|
2214
|
+
if (!ER21.isThisSetState(node)) {
|
|
2215
2215
|
return;
|
|
2216
2216
|
}
|
|
2217
|
-
const clazz = AST11.findParentNode(node, isClassComponent);
|
|
2217
|
+
const clazz = AST11.findParentNode(node, ER21.isClassComponent);
|
|
2218
2218
|
const method = AST11.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
|
|
2219
2219
|
if (clazz == null || method == null || method === clazz) return;
|
|
2220
2220
|
const methodScope = context.sourceCode.getScope(method);
|
|
@@ -2296,7 +2296,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2296
2296
|
});
|
|
2297
2297
|
function create39(context) {
|
|
2298
2298
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2299
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2299
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2300
2300
|
return {
|
|
2301
2301
|
...listeners,
|
|
2302
2302
|
"Program:exit"(node) {
|
|
@@ -2340,7 +2340,7 @@ function create40(context) {
|
|
|
2340
2340
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2341
2341
|
return {};
|
|
2342
2342
|
}
|
|
2343
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2343
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2344
2344
|
return {
|
|
2345
2345
|
...listeners,
|
|
2346
2346
|
"Program:exit"(node) {
|
|
@@ -2382,7 +2382,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2382
2382
|
});
|
|
2383
2383
|
function create41(context) {
|
|
2384
2384
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2385
|
-
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2385
|
+
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2386
2386
|
return {
|
|
2387
2387
|
...listeners,
|
|
2388
2388
|
"Program:exit"(node) {
|
|
@@ -2422,7 +2422,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2422
2422
|
function create42(context) {
|
|
2423
2423
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2424
2424
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2425
|
-
const { ctx, listeners } = useComponentCollector(context);
|
|
2425
|
+
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
2426
2426
|
const constructions = /* @__PURE__ */ new Map();
|
|
2427
2427
|
return {
|
|
2428
2428
|
...listeners,
|
|
@@ -2443,7 +2443,7 @@ function create42(context) {
|
|
|
2443
2443
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2444
2444
|
const construction = VAR2.getValueConstruction(valueExpression, initialScope);
|
|
2445
2445
|
if (construction == null) return;
|
|
2446
|
-
if (isReactHookCall(construction.node)) {
|
|
2446
|
+
if (ER21.isReactHookCall(construction.node)) {
|
|
2447
2447
|
return;
|
|
2448
2448
|
}
|
|
2449
2449
|
getOrUpdate(constructions, functionEntry.node, () => []).push(construction);
|
|
@@ -2493,7 +2493,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2493
2493
|
defaultOptions: []
|
|
2494
2494
|
});
|
|
2495
2495
|
function create43(context) {
|
|
2496
|
-
const { ctx, listeners } = useComponentCollector(context);
|
|
2496
|
+
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
2497
2497
|
const declarators = /* @__PURE__ */ new Map();
|
|
2498
2498
|
return {
|
|
2499
2499
|
...listeners,
|
|
@@ -2523,7 +2523,7 @@ function create43(context) {
|
|
|
2523
2523
|
if (construction == null) {
|
|
2524
2524
|
continue;
|
|
2525
2525
|
}
|
|
2526
|
-
if (isReactHookCall(construction.node)) {
|
|
2526
|
+
if (ER21.isReactHookCall(construction.node)) {
|
|
2527
2527
|
continue;
|
|
2528
2528
|
}
|
|
2529
2529
|
const forbiddenType = AST11.toReadableNodeType(right);
|
|
@@ -2593,7 +2593,7 @@ function create44(context) {
|
|
|
2593
2593
|
const propertyUsages = /* @__PURE__ */ new WeakMap();
|
|
2594
2594
|
function classEnter(node) {
|
|
2595
2595
|
classEntries.push(node);
|
|
2596
|
-
if (!isClassComponent(node)) {
|
|
2596
|
+
if (!ER21.isClassComponent(node)) {
|
|
2597
2597
|
return;
|
|
2598
2598
|
}
|
|
2599
2599
|
propertyDefs.set(node, /* @__PURE__ */ new Set());
|
|
@@ -2601,7 +2601,7 @@ function create44(context) {
|
|
|
2601
2601
|
}
|
|
2602
2602
|
function classExit() {
|
|
2603
2603
|
const currentClass = classEntries.pop();
|
|
2604
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2604
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2605
2605
|
return;
|
|
2606
2606
|
}
|
|
2607
2607
|
const className = AST11.getClassIdentifier(currentClass)?.name;
|
|
@@ -2631,7 +2631,7 @@ function create44(context) {
|
|
|
2631
2631
|
function methodEnter(node) {
|
|
2632
2632
|
methodEntries.push(node);
|
|
2633
2633
|
const currentClass = classEntries.at(-1);
|
|
2634
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2634
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2635
2635
|
return;
|
|
2636
2636
|
}
|
|
2637
2637
|
if (node.static) {
|
|
@@ -2655,7 +2655,7 @@ function create44(context) {
|
|
|
2655
2655
|
if (currentClass == null || currentMethod == null) {
|
|
2656
2656
|
return;
|
|
2657
2657
|
}
|
|
2658
|
-
if (!isClassComponent(currentClass) || currentMethod.static) {
|
|
2658
|
+
if (!ER21.isClassComponent(currentClass) || currentMethod.static) {
|
|
2659
2659
|
return;
|
|
2660
2660
|
}
|
|
2661
2661
|
if (!AST11.isThisExpression(node.object) || !isKeyLiteral2(node, node.property)) {
|
|
@@ -2680,7 +2680,7 @@ function create44(context) {
|
|
|
2680
2680
|
if (currentClass == null || currentMethod == null) {
|
|
2681
2681
|
return;
|
|
2682
2682
|
}
|
|
2683
|
-
if (!isClassComponent(currentClass) || currentMethod.static) {
|
|
2683
|
+
if (!ER21.isClassComponent(currentClass) || currentMethod.static) {
|
|
2684
2684
|
return;
|
|
2685
2685
|
}
|
|
2686
2686
|
if (node.init != null && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
|
|
@@ -2727,7 +2727,7 @@ function create45(context) {
|
|
|
2727
2727
|
}
|
|
2728
2728
|
function classExit() {
|
|
2729
2729
|
const currentClass = classEntries.pop();
|
|
2730
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2730
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2731
2731
|
return;
|
|
2732
2732
|
}
|
|
2733
2733
|
const className = AST11.getClassIdentifier(currentClass)?.name;
|
|
@@ -2746,11 +2746,11 @@ function create45(context) {
|
|
|
2746
2746
|
function methodEnter(node) {
|
|
2747
2747
|
methodEntries.push(node);
|
|
2748
2748
|
const currentClass = classEntries.at(-1);
|
|
2749
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2749
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2750
2750
|
return;
|
|
2751
2751
|
}
|
|
2752
2752
|
if (node.static) {
|
|
2753
|
-
if (isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
|
|
2753
|
+
if (ER21.isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
|
|
2754
2754
|
const defNode = stateDefs.get(currentClass)?.node;
|
|
2755
2755
|
stateDefs.set(currentClass, { node: defNode, isUsed: true });
|
|
2756
2756
|
}
|
|
@@ -2771,11 +2771,11 @@ function create45(context) {
|
|
|
2771
2771
|
}
|
|
2772
2772
|
return {
|
|
2773
2773
|
AssignmentExpression(node) {
|
|
2774
|
-
if (!isAssignmentToThisState(node)) {
|
|
2774
|
+
if (!ER21.isAssignmentToThisState(node)) {
|
|
2775
2775
|
return;
|
|
2776
2776
|
}
|
|
2777
2777
|
const currentClass = classEntries.at(-1);
|
|
2778
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2778
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2779
2779
|
return;
|
|
2780
2780
|
}
|
|
2781
2781
|
const currentConstructor = constructorEntries.at(-1);
|
|
@@ -2797,7 +2797,7 @@ function create45(context) {
|
|
|
2797
2797
|
return;
|
|
2798
2798
|
}
|
|
2799
2799
|
const currentClass = classEntries.at(-1);
|
|
2800
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2800
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2801
2801
|
return;
|
|
2802
2802
|
}
|
|
2803
2803
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2821,7 +2821,7 @@ function create45(context) {
|
|
|
2821
2821
|
"PropertyDefinition:exit": methodExit,
|
|
2822
2822
|
VariableDeclarator(node) {
|
|
2823
2823
|
const currentClass = classEntries.at(-1);
|
|
2824
|
-
if (currentClass == null || !isClassComponent(currentClass)) {
|
|
2824
|
+
if (currentClass == null || !ER21.isClassComponent(currentClass)) {
|
|
2825
2825
|
return;
|
|
2826
2826
|
}
|
|
2827
2827
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2881,10 +2881,10 @@ function create46(context) {
|
|
|
2881
2881
|
}
|
|
2882
2882
|
return {
|
|
2883
2883
|
CallExpression(node) {
|
|
2884
|
-
if (!isReactHookCall(node)) {
|
|
2884
|
+
if (!ER21.isReactHookCall(node)) {
|
|
2885
2885
|
return;
|
|
2886
2886
|
}
|
|
2887
|
-
if (!isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
2887
|
+
if (!ER21.isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
2888
2888
|
return;
|
|
2889
2889
|
}
|
|
2890
2890
|
context.report({
|
|
@@ -2971,7 +2971,7 @@ var no_useless_forward_ref_default = createRule({
|
|
|
2971
2971
|
function create47(context) {
|
|
2972
2972
|
return {
|
|
2973
2973
|
CallExpression(node) {
|
|
2974
|
-
if (!isForwardRefCall(context, node)) {
|
|
2974
|
+
if (!ER21.isForwardRefCall(context, node)) {
|
|
2975
2975
|
return;
|
|
2976
2976
|
}
|
|
2977
2977
|
const [component] = node.arguments;
|
|
@@ -3153,7 +3153,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3153
3153
|
defaultOptions: []
|
|
3154
3154
|
});
|
|
3155
3155
|
function create49(context) {
|
|
3156
|
-
const { ctx, listeners } = useComponentCollector(context);
|
|
3156
|
+
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
3157
3157
|
const memberExpressionWithNames = [];
|
|
3158
3158
|
return {
|
|
3159
3159
|
...listeners,
|
|
@@ -3172,7 +3172,7 @@ function create49(context) {
|
|
|
3172
3172
|
return false;
|
|
3173
3173
|
}
|
|
3174
3174
|
const id = AST11.getFunctionIdentifier(block);
|
|
3175
|
-
return id != null && isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3175
|
+
return id != null && ER21.isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3176
3176
|
}
|
|
3177
3177
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
3178
3178
|
let scope = initialScope;
|
|
@@ -3289,7 +3289,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
3289
3289
|
});
|
|
3290
3290
|
function create51(context) {
|
|
3291
3291
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3292
|
-
const { ctx, listeners } = useComponentCollector(context);
|
|
3292
|
+
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
3293
3293
|
return {
|
|
3294
3294
|
...listeners,
|
|
3295
3295
|
"Program:exit"(node) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0-beta.1",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.7.0",
|
|
53
|
-
"@eslint-react/ast": "1.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
59
|
-
"@eslint-react/var": "1.
|
|
53
|
+
"@eslint-react/ast": "1.39.0-beta.1",
|
|
54
|
+
"@eslint-react/core": "1.39.0-beta.1",
|
|
55
|
+
"@eslint-react/eff": "1.39.0-beta.1",
|
|
56
|
+
"@eslint-react/jsx": "1.39.0-beta.1",
|
|
57
|
+
"@eslint-react/kit": "1.39.0-beta.1",
|
|
58
|
+
"@eslint-react/shared": "1.39.0-beta.1",
|
|
59
|
+
"@eslint-react/var": "1.39.0-beta.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.0.12",
|