eslint-plugin-react-x 3.0.0-beta.7 → 3.0.0-beta.8
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 +91 -91
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ const rules$7 = {
|
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region package.json
|
|
68
68
|
var name$6 = "eslint-plugin-react-x";
|
|
69
|
-
var version = "3.0.0-beta.
|
|
69
|
+
var version = "3.0.0-beta.8";
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/utils/create-rule.ts
|
|
@@ -694,7 +694,7 @@ function create$62(context) {
|
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
return {
|
|
697
|
+
return defineRuleListener({
|
|
698
698
|
CallExpression(node) {
|
|
699
699
|
if (!isHookWithDeps(node)) return;
|
|
700
700
|
const hookName = getHookName$1(node);
|
|
@@ -721,7 +721,7 @@ function create$62(context) {
|
|
|
721
721
|
"Program:exit"() {
|
|
722
722
|
for (const hookCall of collectedHookCalls) analyzeHookCall(hookCall);
|
|
723
723
|
}
|
|
724
|
-
};
|
|
724
|
+
});
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
//#endregion
|
|
@@ -776,10 +776,10 @@ function create$61(context) {
|
|
|
776
776
|
});
|
|
777
777
|
}
|
|
778
778
|
};
|
|
779
|
-
return {
|
|
779
|
+
return defineRuleListener({
|
|
780
780
|
JSXElement: visitorFunction,
|
|
781
781
|
JSXFragment: visitorFunction
|
|
782
|
-
};
|
|
782
|
+
});
|
|
783
783
|
}
|
|
784
784
|
|
|
785
785
|
//#endregion
|
|
@@ -802,7 +802,7 @@ function create$60(context) {
|
|
|
802
802
|
...core.getJsxConfigFromAnnotation(context)
|
|
803
803
|
};
|
|
804
804
|
if (jsx !== core.JsxEmit.ReactJSX && jsx !== core.JsxEmit.ReactJSXDev) return {};
|
|
805
|
-
return { JSXOpeningElement(node) {
|
|
805
|
+
return defineRuleListener({ JSXOpeningElement(node) {
|
|
806
806
|
let firstSpreadPropIndex = null;
|
|
807
807
|
for (const [index, prop] of node.attributes.entries()) {
|
|
808
808
|
if (prop.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
@@ -815,7 +815,7 @@ function create$60(context) {
|
|
|
815
815
|
node: prop
|
|
816
816
|
});
|
|
817
817
|
}
|
|
818
|
-
} };
|
|
818
|
+
} });
|
|
819
819
|
}
|
|
820
820
|
|
|
821
821
|
//#endregion
|
|
@@ -845,10 +845,10 @@ function create$59(context) {
|
|
|
845
845
|
node
|
|
846
846
|
});
|
|
847
847
|
};
|
|
848
|
-
return {
|
|
848
|
+
return defineRuleListener({
|
|
849
849
|
JSXText: visitorFunction,
|
|
850
850
|
Literal: visitorFunction
|
|
851
|
-
};
|
|
851
|
+
});
|
|
852
852
|
}
|
|
853
853
|
|
|
854
854
|
//#endregion
|
|
@@ -866,7 +866,7 @@ var jsx_no_duplicate_props_default = createRule({
|
|
|
866
866
|
defaultOptions: []
|
|
867
867
|
});
|
|
868
868
|
function create$58(context) {
|
|
869
|
-
return { JSXOpeningElement(node) {
|
|
869
|
+
return defineRuleListener({ JSXOpeningElement(node) {
|
|
870
870
|
const props = [];
|
|
871
871
|
for (const attr of node.attributes) {
|
|
872
872
|
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
@@ -881,7 +881,7 @@ function create$58(context) {
|
|
|
881
881
|
node: attr
|
|
882
882
|
});
|
|
883
883
|
}
|
|
884
|
-
} };
|
|
884
|
+
} });
|
|
885
885
|
}
|
|
886
886
|
|
|
887
887
|
//#endregion
|
|
@@ -899,7 +899,7 @@ var jsx_no_iife_default = createRule({
|
|
|
899
899
|
defaultOptions: []
|
|
900
900
|
});
|
|
901
901
|
function create$57(context) {
|
|
902
|
-
return {
|
|
902
|
+
return defineRuleListener({
|
|
903
903
|
"JSXElement :function"(node) {
|
|
904
904
|
if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
|
|
905
905
|
messageId: "default",
|
|
@@ -912,7 +912,7 @@ function create$57(context) {
|
|
|
912
912
|
node: node.parent
|
|
913
913
|
});
|
|
914
914
|
}
|
|
915
|
-
};
|
|
915
|
+
});
|
|
916
916
|
}
|
|
917
917
|
|
|
918
918
|
//#endregion
|
|
@@ -930,7 +930,7 @@ var jsx_no_undef_default = createRule({
|
|
|
930
930
|
defaultOptions: []
|
|
931
931
|
});
|
|
932
932
|
function create$56(context) {
|
|
933
|
-
return { JSXOpeningElement(node) {
|
|
933
|
+
return defineRuleListener({ JSXOpeningElement(node) {
|
|
934
934
|
const name = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
|
|
935
935
|
type: AST_NODE_TYPES.JSXMemberExpression,
|
|
936
936
|
object: { type: AST_NODE_TYPES.JSXIdentifier }
|
|
@@ -943,7 +943,7 @@ function create$56(context) {
|
|
|
943
943
|
node,
|
|
944
944
|
data: { name }
|
|
945
945
|
});
|
|
946
|
-
} };
|
|
946
|
+
} });
|
|
947
947
|
}
|
|
948
948
|
|
|
949
949
|
//#endregion
|
|
@@ -968,7 +968,7 @@ var jsx_shorthand_boolean_default = createRule({
|
|
|
968
968
|
});
|
|
969
969
|
function create$55(context) {
|
|
970
970
|
const policy = context.options[0] ?? defaultOptions$3[0];
|
|
971
|
-
return { JSXAttribute(node) {
|
|
971
|
+
return defineRuleListener({ JSXAttribute(node) {
|
|
972
972
|
const { value } = node;
|
|
973
973
|
const propName = core.getJsxAttributeName(context, node);
|
|
974
974
|
switch (true) {
|
|
@@ -989,7 +989,7 @@ function create$55(context) {
|
|
|
989
989
|
});
|
|
990
990
|
break;
|
|
991
991
|
}
|
|
992
|
-
} };
|
|
992
|
+
} });
|
|
993
993
|
}
|
|
994
994
|
|
|
995
995
|
//#endregion
|
|
@@ -1019,7 +1019,7 @@ function create$54(context) {
|
|
|
1019
1019
|
...core.getJsxConfigFromAnnotation(context)
|
|
1020
1020
|
};
|
|
1021
1021
|
const { jsxFragmentFactory } = jsxConfig;
|
|
1022
|
-
return match(policy).with(1, () => ({ JSXElement(node) {
|
|
1022
|
+
return match(policy).with(1, () => defineRuleListener({ JSXElement(node) {
|
|
1023
1023
|
if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
|
|
1024
1024
|
if (node.openingElement.attributes.length > 0) return;
|
|
1025
1025
|
context.report({
|
|
@@ -1032,7 +1032,7 @@ function create$54(context) {
|
|
|
1032
1032
|
return [fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"), fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")];
|
|
1033
1033
|
}
|
|
1034
1034
|
});
|
|
1035
|
-
} })).with(-1, () => ({ JSXFragment(node) {
|
|
1035
|
+
} })).with(-1, () => defineRuleListener({ JSXFragment(node) {
|
|
1036
1036
|
context.report({
|
|
1037
1037
|
messageId: "default",
|
|
1038
1038
|
node,
|
|
@@ -1073,11 +1073,11 @@ function create$53(context) {
|
|
|
1073
1073
|
context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
|
|
1074
1074
|
debugReport(context, node, jsxFragmentFactory);
|
|
1075
1075
|
}
|
|
1076
|
-
return {
|
|
1076
|
+
return defineRuleListener({
|
|
1077
1077
|
JSXFragment: handleJsxFragment,
|
|
1078
1078
|
JSXOpeningElement: handleJsxElement,
|
|
1079
1079
|
JSXOpeningFragment: handleJsxElement
|
|
1080
|
-
};
|
|
1080
|
+
});
|
|
1081
1081
|
}
|
|
1082
1082
|
function debugReport(context, node, name) {
|
|
1083
1083
|
if (process.env["ESLINT_REACT_DEBUG"] !== "1") return;
|
|
@@ -1103,7 +1103,7 @@ var jsx_uses_vars_default = createRule({
|
|
|
1103
1103
|
defaultOptions: []
|
|
1104
1104
|
});
|
|
1105
1105
|
function create$52(context) {
|
|
1106
|
-
return { JSXOpeningElement(node) {
|
|
1106
|
+
return defineRuleListener({ JSXOpeningElement(node) {
|
|
1107
1107
|
switch (node.name.type) {
|
|
1108
1108
|
case AST_NODE_TYPES.JSXIdentifier:
|
|
1109
1109
|
if (/^[a-z]/u.test(node.name.name)) return;
|
|
@@ -1115,7 +1115,7 @@ function create$52(context) {
|
|
|
1115
1115
|
break;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
|
-
} };
|
|
1118
|
+
} });
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
1121
|
//#endregion
|
|
@@ -1143,7 +1143,7 @@ function create$51(context) {
|
|
|
1143
1143
|
const classStack = [];
|
|
1144
1144
|
const methodStack = [];
|
|
1145
1145
|
const setStateStack = [];
|
|
1146
|
-
return {
|
|
1146
|
+
return defineRuleListener({
|
|
1147
1147
|
CallExpression(node) {
|
|
1148
1148
|
if (!core.isThisSetState(node)) return;
|
|
1149
1149
|
setStateStack.push([node, false]);
|
|
@@ -1204,7 +1204,7 @@ function create$51(context) {
|
|
|
1204
1204
|
node
|
|
1205
1205
|
});
|
|
1206
1206
|
}
|
|
1207
|
-
};
|
|
1207
|
+
});
|
|
1208
1208
|
}
|
|
1209
1209
|
|
|
1210
1210
|
//#endregion
|
|
@@ -1311,7 +1311,7 @@ function create$50(context) {
|
|
|
1311
1311
|
}
|
|
1312
1312
|
return [];
|
|
1313
1313
|
}
|
|
1314
|
-
return {
|
|
1314
|
+
return defineRuleListener({
|
|
1315
1315
|
CallExpression(node) {
|
|
1316
1316
|
indexParamNames.push(getMapIndexParamName(context, node));
|
|
1317
1317
|
if (node.arguments.length === 0) return;
|
|
@@ -1333,7 +1333,7 @@ function create$50(context) {
|
|
|
1333
1333
|
if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
1334
1334
|
for (const descriptor of getReportDescriptors(node.value.expression)) report(context)(descriptor);
|
|
1335
1335
|
}
|
|
1336
|
-
};
|
|
1336
|
+
});
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
1339
|
//#endregion
|
|
@@ -1351,12 +1351,12 @@ var no_children_count_default = createRule({
|
|
|
1351
1351
|
defaultOptions: []
|
|
1352
1352
|
});
|
|
1353
1353
|
function create$49(context) {
|
|
1354
|
-
return { MemberExpression(node) {
|
|
1354
|
+
return defineRuleListener({ MemberExpression(node) {
|
|
1355
1355
|
if (core.isChildrenCount(context, node)) context.report({
|
|
1356
1356
|
messageId: "default",
|
|
1357
1357
|
node: node.property
|
|
1358
1358
|
});
|
|
1359
|
-
} };
|
|
1359
|
+
} });
|
|
1360
1360
|
}
|
|
1361
1361
|
|
|
1362
1362
|
//#endregion
|
|
@@ -1374,12 +1374,12 @@ var no_children_for_each_default = createRule({
|
|
|
1374
1374
|
defaultOptions: []
|
|
1375
1375
|
});
|
|
1376
1376
|
function create$48(context) {
|
|
1377
|
-
return { MemberExpression(node) {
|
|
1377
|
+
return defineRuleListener({ MemberExpression(node) {
|
|
1378
1378
|
if (core.isChildrenForEach(context, node)) context.report({
|
|
1379
1379
|
messageId: "default",
|
|
1380
1380
|
node: node.property
|
|
1381
1381
|
});
|
|
1382
|
-
} };
|
|
1382
|
+
} });
|
|
1383
1383
|
}
|
|
1384
1384
|
|
|
1385
1385
|
//#endregion
|
|
@@ -1397,12 +1397,12 @@ var no_children_map_default = createRule({
|
|
|
1397
1397
|
defaultOptions: []
|
|
1398
1398
|
});
|
|
1399
1399
|
function create$47(context) {
|
|
1400
|
-
return { MemberExpression(node) {
|
|
1400
|
+
return defineRuleListener({ MemberExpression(node) {
|
|
1401
1401
|
if (core.isChildrenMap(context, node)) context.report({
|
|
1402
1402
|
messageId: "default",
|
|
1403
1403
|
node: node.property
|
|
1404
1404
|
});
|
|
1405
|
-
} };
|
|
1405
|
+
} });
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
1408
|
//#endregion
|
|
@@ -1420,12 +1420,12 @@ var no_children_only_default = createRule({
|
|
|
1420
1420
|
defaultOptions: []
|
|
1421
1421
|
});
|
|
1422
1422
|
function create$46(context) {
|
|
1423
|
-
return { MemberExpression(node) {
|
|
1423
|
+
return defineRuleListener({ MemberExpression(node) {
|
|
1424
1424
|
if (core.isChildrenOnly(context, node)) context.report({
|
|
1425
1425
|
messageId: "default",
|
|
1426
1426
|
node: node.property
|
|
1427
1427
|
});
|
|
1428
|
-
} };
|
|
1428
|
+
} });
|
|
1429
1429
|
}
|
|
1430
1430
|
|
|
1431
1431
|
//#endregion
|
|
@@ -1443,13 +1443,13 @@ var no_children_prop_default = createRule({
|
|
|
1443
1443
|
defaultOptions: []
|
|
1444
1444
|
});
|
|
1445
1445
|
function create$45(context) {
|
|
1446
|
-
return { JSXElement(node) {
|
|
1446
|
+
return defineRuleListener({ JSXElement(node) {
|
|
1447
1447
|
const childrenProp = core.getJsxAttribute(context, node)("children");
|
|
1448
1448
|
if (childrenProp != null) context.report({
|
|
1449
1449
|
messageId: "default",
|
|
1450
1450
|
node: childrenProp
|
|
1451
1451
|
});
|
|
1452
|
-
} };
|
|
1452
|
+
} });
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
1455
|
//#endregion
|
|
@@ -1467,12 +1467,12 @@ var no_children_to_array_default = createRule({
|
|
|
1467
1467
|
defaultOptions: []
|
|
1468
1468
|
});
|
|
1469
1469
|
function create$44(context) {
|
|
1470
|
-
return { MemberExpression(node) {
|
|
1470
|
+
return defineRuleListener({ MemberExpression(node) {
|
|
1471
1471
|
if (core.isChildrenToArray(context, node)) context.report({
|
|
1472
1472
|
messageId: "default",
|
|
1473
1473
|
node: node.property
|
|
1474
1474
|
});
|
|
1475
|
-
} };
|
|
1475
|
+
} });
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
1478
|
//#endregion
|
|
@@ -1519,12 +1519,12 @@ var no_clone_element_default = createRule({
|
|
|
1519
1519
|
defaultOptions: []
|
|
1520
1520
|
});
|
|
1521
1521
|
function create$42(context) {
|
|
1522
|
-
return { CallExpression(node) {
|
|
1522
|
+
return defineRuleListener({ CallExpression(node) {
|
|
1523
1523
|
if (core.isCloneElementCall(context, node)) context.report({
|
|
1524
1524
|
messageId: "default",
|
|
1525
1525
|
node
|
|
1526
1526
|
});
|
|
1527
|
-
} };
|
|
1527
|
+
} });
|
|
1528
1528
|
}
|
|
1529
1529
|
|
|
1530
1530
|
//#endregion
|
|
@@ -1645,7 +1645,7 @@ function create$38(context) {
|
|
|
1645
1645
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1646
1646
|
const { version } = getSettingsFromContext(context);
|
|
1647
1647
|
if (compare(version, "19.0.0", "<")) return {};
|
|
1648
|
-
return { JSXElement(node) {
|
|
1648
|
+
return defineRuleListener({ JSXElement(node) {
|
|
1649
1649
|
const parts = core.getJsxElementType(context, node).split(".");
|
|
1650
1650
|
const selfName = parts.pop();
|
|
1651
1651
|
const contextFullName = parts.join(".");
|
|
@@ -1663,7 +1663,7 @@ function create$38(context) {
|
|
|
1663
1663
|
return [fixer.replaceText(openingElement.name, contextFullName), fixer.replaceText(closingElement.name, contextFullName)];
|
|
1664
1664
|
}
|
|
1665
1665
|
});
|
|
1666
|
-
} };
|
|
1666
|
+
} });
|
|
1667
1667
|
}
|
|
1668
1668
|
|
|
1669
1669
|
//#endregion
|
|
@@ -1681,12 +1681,12 @@ var no_create_ref_default = createRule({
|
|
|
1681
1681
|
defaultOptions: []
|
|
1682
1682
|
});
|
|
1683
1683
|
function create$37(context) {
|
|
1684
|
-
return { CallExpression(node) {
|
|
1684
|
+
return defineRuleListener({ CallExpression(node) {
|
|
1685
1685
|
if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
|
|
1686
1686
|
messageId: "default",
|
|
1687
1687
|
node
|
|
1688
1688
|
});
|
|
1689
|
-
} };
|
|
1689
|
+
} });
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
1692
1692
|
//#endregion
|
|
@@ -1707,7 +1707,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1707
1707
|
defaultOptions: []
|
|
1708
1708
|
});
|
|
1709
1709
|
function create$36(context) {
|
|
1710
|
-
return { AssignmentExpression(node) {
|
|
1710
|
+
return defineRuleListener({ AssignmentExpression(node) {
|
|
1711
1711
|
if (!core.isAssignmentToThisState(node)) return;
|
|
1712
1712
|
const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
|
|
1713
1713
|
if (parentClass == null) return;
|
|
@@ -1715,7 +1715,7 @@ function create$36(context) {
|
|
|
1715
1715
|
messageId: "default",
|
|
1716
1716
|
node
|
|
1717
1717
|
});
|
|
1718
|
-
} };
|
|
1718
|
+
} });
|
|
1719
1719
|
}
|
|
1720
1720
|
|
|
1721
1721
|
//#endregion
|
|
@@ -1741,7 +1741,7 @@ function create$35(context) {
|
|
|
1741
1741
|
if (aValue == null || bValue == null) return false;
|
|
1742
1742
|
return ast.isNodeEqual(aValue, bValue);
|
|
1743
1743
|
}
|
|
1744
|
-
return {
|
|
1744
|
+
return defineRuleListener({
|
|
1745
1745
|
"JSXAttribute[name.name='key']"(node) {
|
|
1746
1746
|
const jsxElement = node.parent.parent;
|
|
1747
1747
|
switch (jsxElement.parent.type) {
|
|
@@ -1782,7 +1782,7 @@ function create$35(context) {
|
|
|
1782
1782
|
});
|
|
1783
1783
|
}
|
|
1784
1784
|
}
|
|
1785
|
-
};
|
|
1785
|
+
});
|
|
1786
1786
|
}
|
|
1787
1787
|
|
|
1788
1788
|
//#endregion
|
|
@@ -1804,7 +1804,7 @@ function create$34(context) {
|
|
|
1804
1804
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
1805
1805
|
const { version } = getSettingsFromContext(context);
|
|
1806
1806
|
if (compare(version, "19.0.0", "<")) return {};
|
|
1807
|
-
return { CallExpression(node) {
|
|
1807
|
+
return defineRuleListener({ CallExpression(node) {
|
|
1808
1808
|
if (!core.isForwardRefCall(context, node)) return;
|
|
1809
1809
|
const id = ast.getFunctionId(node);
|
|
1810
1810
|
const fix = canFix(context, node) ? getFix(context, node) : null;
|
|
@@ -1813,7 +1813,7 @@ function create$34(context) {
|
|
|
1813
1813
|
node: id ?? node,
|
|
1814
1814
|
fix
|
|
1815
1815
|
});
|
|
1816
|
-
} };
|
|
1816
|
+
} });
|
|
1817
1817
|
}
|
|
1818
1818
|
/**
|
|
1819
1819
|
* Determine whether the given CallExpression can be safely auto-fixed by replacing
|
|
@@ -1910,7 +1910,7 @@ var no_implicit_key_default = createRule({
|
|
|
1910
1910
|
function create$33(context) {
|
|
1911
1911
|
const services = ESLintUtils.getParserServices(context, false);
|
|
1912
1912
|
const checker = services.program.getTypeChecker();
|
|
1913
|
-
return { JSXSpreadAttribute(node) {
|
|
1913
|
+
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
1914
1914
|
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
1915
1915
|
const key = type.getProperty("key");
|
|
1916
1916
|
if (key == null) continue;
|
|
@@ -1920,7 +1920,7 @@ function create$33(context) {
|
|
|
1920
1920
|
node
|
|
1921
1921
|
});
|
|
1922
1922
|
}
|
|
1923
|
-
} };
|
|
1923
|
+
} });
|
|
1924
1924
|
}
|
|
1925
1925
|
|
|
1926
1926
|
//#endregion
|
|
@@ -1989,7 +1989,7 @@ function create$32(context) {
|
|
|
1989
1989
|
return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => unit);
|
|
1990
1990
|
}).otherwise(() => unit);
|
|
1991
1991
|
}
|
|
1992
|
-
return { JSXExpressionContainer: flow(getReportDescriptor, report(context)) };
|
|
1992
|
+
return defineRuleListener({ JSXExpressionContainer: flow(getReportDescriptor, report(context)) });
|
|
1993
1993
|
}
|
|
1994
1994
|
|
|
1995
1995
|
//#endregion
|
|
@@ -2045,7 +2045,7 @@ function create$30(context) {
|
|
|
2045
2045
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
2046
2046
|
const createCalls = [];
|
|
2047
2047
|
const displayNameAssignments = [];
|
|
2048
|
-
return {
|
|
2048
|
+
return defineRuleListener({
|
|
2049
2049
|
[ast.SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
2050
2050
|
displayNameAssignments.push(node);
|
|
2051
2051
|
},
|
|
@@ -2088,7 +2088,7 @@ function create$30(context) {
|
|
|
2088
2088
|
});
|
|
2089
2089
|
}
|
|
2090
2090
|
}
|
|
2091
|
-
};
|
|
2091
|
+
});
|
|
2092
2092
|
}
|
|
2093
2093
|
|
|
2094
2094
|
//#endregion
|
|
@@ -2133,7 +2133,7 @@ function create$29(ctx) {
|
|
|
2133
2133
|
function checkBlock(node) {
|
|
2134
2134
|
return ast.getNestedReturnStatements(node).filter((stmt) => stmt.argument != null).map((stmt) => check(stmt.argument)).filter((d) => d != null);
|
|
2135
2135
|
}
|
|
2136
|
-
return {
|
|
2136
|
+
return defineRuleListener({
|
|
2137
2137
|
ArrayExpression(node) {
|
|
2138
2138
|
if (inChildrenToArray) return;
|
|
2139
2139
|
const elements = node.elements.filter(ast.is(AST_NODE_TYPES.JSXElement));
|
|
@@ -2167,7 +2167,7 @@ function create$29(ctx) {
|
|
|
2167
2167
|
node
|
|
2168
2168
|
});
|
|
2169
2169
|
}
|
|
2170
|
-
};
|
|
2170
|
+
});
|
|
2171
2171
|
}
|
|
2172
2172
|
|
|
2173
2173
|
//#endregion
|
|
@@ -2190,7 +2190,7 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2190
2190
|
function create$28(context) {
|
|
2191
2191
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
2192
2192
|
const { importSource } = getSettingsFromContext(context);
|
|
2193
|
-
return {
|
|
2193
|
+
return defineRuleListener({
|
|
2194
2194
|
CallExpression(node) {
|
|
2195
2195
|
if (!core.isCaptureOwnerStackCall(context, node)) return;
|
|
2196
2196
|
if (ast.findParentNode(node, isDevelopmentOnlyCheck) == null) context.report({
|
|
@@ -2209,7 +2209,7 @@ function create$28(context) {
|
|
|
2209
2209
|
});
|
|
2210
2210
|
}
|
|
2211
2211
|
}
|
|
2212
|
-
};
|
|
2212
|
+
});
|
|
2213
2213
|
}
|
|
2214
2214
|
function isDevelopmentOnlyCheck(node) {
|
|
2215
2215
|
if (node.type !== AST_NODE_TYPES.IfStatement) return false;
|
|
@@ -2423,7 +2423,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2423
2423
|
});
|
|
2424
2424
|
function create$24(context) {
|
|
2425
2425
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2426
|
-
return { CallExpression(node) {
|
|
2426
|
+
return defineRuleListener({ CallExpression(node) {
|
|
2427
2427
|
if (!core.isThisSetState(node)) return;
|
|
2428
2428
|
const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
|
|
2429
2429
|
const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentDidMount(n));
|
|
@@ -2434,7 +2434,7 @@ function create$24(context) {
|
|
|
2434
2434
|
messageId: "default",
|
|
2435
2435
|
node
|
|
2436
2436
|
});
|
|
2437
|
-
} };
|
|
2437
|
+
} });
|
|
2438
2438
|
}
|
|
2439
2439
|
|
|
2440
2440
|
//#endregion
|
|
@@ -2453,7 +2453,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2453
2453
|
});
|
|
2454
2454
|
function create$23(context) {
|
|
2455
2455
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2456
|
-
return { CallExpression(node) {
|
|
2456
|
+
return defineRuleListener({ CallExpression(node) {
|
|
2457
2457
|
if (!core.isThisSetState(node)) return;
|
|
2458
2458
|
const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
|
|
2459
2459
|
const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentDidUpdate(n));
|
|
@@ -2464,7 +2464,7 @@ function create$23(context) {
|
|
|
2464
2464
|
messageId: "default",
|
|
2465
2465
|
node
|
|
2466
2466
|
});
|
|
2467
|
-
} };
|
|
2467
|
+
} });
|
|
2468
2468
|
}
|
|
2469
2469
|
|
|
2470
2470
|
//#endregion
|
|
@@ -2483,7 +2483,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2483
2483
|
});
|
|
2484
2484
|
function create$22(context) {
|
|
2485
2485
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2486
|
-
return { CallExpression(node) {
|
|
2486
|
+
return defineRuleListener({ CallExpression(node) {
|
|
2487
2487
|
if (!core.isThisSetState(node)) return;
|
|
2488
2488
|
const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
|
|
2489
2489
|
const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentWillUpdate(n));
|
|
@@ -2494,7 +2494,7 @@ function create$22(context) {
|
|
|
2494
2494
|
messageId: "default",
|
|
2495
2495
|
node
|
|
2496
2496
|
});
|
|
2497
|
-
} };
|
|
2497
|
+
} });
|
|
2498
2498
|
}
|
|
2499
2499
|
|
|
2500
2500
|
//#endregion
|
|
@@ -2516,7 +2516,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
2516
2516
|
});
|
|
2517
2517
|
function create$21(context) {
|
|
2518
2518
|
if (!context.sourceCode.text.includes("useCallback")) return {};
|
|
2519
|
-
return { VariableDeclarator(node) {
|
|
2519
|
+
return defineRuleListener({ VariableDeclarator(node) {
|
|
2520
2520
|
const { id, init } = node;
|
|
2521
2521
|
if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseCallbackCall(init)) return;
|
|
2522
2522
|
const [cbk, ...rest] = context.sourceCode.getDeclaredVariables(node);
|
|
@@ -2552,7 +2552,7 @@ function create$21(context) {
|
|
|
2552
2552
|
return;
|
|
2553
2553
|
}
|
|
2554
2554
|
report(context)(checkForUsageInsideUseEffectReport);
|
|
2555
|
-
} };
|
|
2555
|
+
} });
|
|
2556
2556
|
}
|
|
2557
2557
|
function checkForUsageInsideUseEffect$1(sourceCode, node) {
|
|
2558
2558
|
if (!/use\w*Effect/u.test(sourceCode.text)) return;
|
|
@@ -2593,7 +2593,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
2593
2593
|
});
|
|
2594
2594
|
function create$20(context) {
|
|
2595
2595
|
if (!context.sourceCode.text.includes("useMemo")) return {};
|
|
2596
|
-
return { VariableDeclarator(node) {
|
|
2596
|
+
return defineRuleListener({ VariableDeclarator(node) {
|
|
2597
2597
|
const { id, init } = node;
|
|
2598
2598
|
if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseMemoCall(init)) return;
|
|
2599
2599
|
const [mem, ...rest] = context.sourceCode.getDeclaredVariables(node);
|
|
@@ -2633,7 +2633,7 @@ function create$20(context) {
|
|
|
2633
2633
|
return;
|
|
2634
2634
|
}
|
|
2635
2635
|
report(context)(checkForUsageInsideUseEffectReport);
|
|
2636
|
-
} };
|
|
2636
|
+
} });
|
|
2637
2637
|
}
|
|
2638
2638
|
function checkForUsageInsideUseEffect(sourceCode, node) {
|
|
2639
2639
|
if (!/use\w*Effect/u.test(sourceCode.text)) return;
|
|
@@ -2989,7 +2989,7 @@ function create$13(context) {
|
|
|
2989
2989
|
function methodExit() {
|
|
2990
2990
|
methodStack.pop();
|
|
2991
2991
|
}
|
|
2992
|
-
return {
|
|
2992
|
+
return defineRuleListener({
|
|
2993
2993
|
ClassDeclaration: classEnter,
|
|
2994
2994
|
"ClassDeclaration:exit": classExit,
|
|
2995
2995
|
ClassExpression: classEnter,
|
|
@@ -3023,7 +3023,7 @@ function create$13(context) {
|
|
|
3023
3023
|
}
|
|
3024
3024
|
}
|
|
3025
3025
|
}
|
|
3026
|
-
};
|
|
3026
|
+
});
|
|
3027
3027
|
}
|
|
3028
3028
|
|
|
3029
3029
|
//#endregion
|
|
@@ -3204,7 +3204,7 @@ function create$11(context) {
|
|
|
3204
3204
|
function constructorExit() {
|
|
3205
3205
|
constructorStack.pop();
|
|
3206
3206
|
}
|
|
3207
|
-
return {
|
|
3207
|
+
return defineRuleListener({
|
|
3208
3208
|
AssignmentExpression(node) {
|
|
3209
3209
|
if (!core.isAssignmentToThisState(node)) return;
|
|
3210
3210
|
const currentClass = classStack.at(-1);
|
|
@@ -3260,7 +3260,7 @@ function create$11(context) {
|
|
|
3260
3260
|
isUsed: true
|
|
3261
3261
|
});
|
|
3262
3262
|
}
|
|
3263
|
-
};
|
|
3263
|
+
});
|
|
3264
3264
|
}
|
|
3265
3265
|
|
|
3266
3266
|
//#endregion
|
|
@@ -3283,7 +3283,7 @@ function create$10(context) {
|
|
|
3283
3283
|
const settings = getSettingsFromContext(context);
|
|
3284
3284
|
if (compare(settings.version, "19.0.0", "<")) return {};
|
|
3285
3285
|
const hookCalls = /* @__PURE__ */ new Set();
|
|
3286
|
-
return {
|
|
3286
|
+
return defineRuleListener({
|
|
3287
3287
|
CallExpression(node) {
|
|
3288
3288
|
if (!core.isHookCall(node)) return;
|
|
3289
3289
|
hookCalls.add(node);
|
|
@@ -3330,7 +3330,7 @@ function create$10(context) {
|
|
|
3330
3330
|
});
|
|
3331
3331
|
}
|
|
3332
3332
|
}
|
|
3333
|
-
};
|
|
3333
|
+
});
|
|
3334
3334
|
}
|
|
3335
3335
|
function getCorrelativeTokens(context, node) {
|
|
3336
3336
|
const tokenBefore = context.sourceCode.getTokenBefore(node);
|
|
@@ -3356,7 +3356,7 @@ var no_useless_forward_ref_default = createRule({
|
|
|
3356
3356
|
defaultOptions: []
|
|
3357
3357
|
});
|
|
3358
3358
|
function create$9(context) {
|
|
3359
|
-
return { CallExpression(node) {
|
|
3359
|
+
return defineRuleListener({ CallExpression(node) {
|
|
3360
3360
|
if (!core.isForwardRefCall(context, node)) return;
|
|
3361
3361
|
const [component] = node.arguments;
|
|
3362
3362
|
if (component == null || !ast.isFunction(component)) return;
|
|
@@ -3365,7 +3365,7 @@ function create$9(context) {
|
|
|
3365
3365
|
messageId: "default",
|
|
3366
3366
|
node: node.callee
|
|
3367
3367
|
});
|
|
3368
|
-
} };
|
|
3368
|
+
} });
|
|
3369
3369
|
}
|
|
3370
3370
|
|
|
3371
3371
|
//#endregion
|
|
@@ -3475,7 +3475,7 @@ function create$8(context, [option]) {
|
|
|
3475
3475
|
if (node.children.length === 0) return false;
|
|
3476
3476
|
return !node.children.some((child) => core.isJsxText(child) && !isWhiteSpace(child) || ast.is(AST_NODE_TYPES.JSXExpressionContainer)(child));
|
|
3477
3477
|
}
|
|
3478
|
-
return {
|
|
3478
|
+
return defineRuleListener({
|
|
3479
3479
|
JSXElement(node) {
|
|
3480
3480
|
if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
|
|
3481
3481
|
checkNode(context, node);
|
|
@@ -3483,7 +3483,7 @@ function create$8(context, [option]) {
|
|
|
3483
3483
|
JSXFragment(node) {
|
|
3484
3484
|
checkNode(context, node);
|
|
3485
3485
|
}
|
|
3486
|
-
};
|
|
3486
|
+
});
|
|
3487
3487
|
}
|
|
3488
3488
|
/**
|
|
3489
3489
|
* Check if a Literal or JSXText node is whitespace
|
|
@@ -3561,7 +3561,7 @@ var prefer_namespace_import_default = createRule({
|
|
|
3561
3561
|
});
|
|
3562
3562
|
function create$6(context) {
|
|
3563
3563
|
const { importSource } = getSettingsFromContext(context);
|
|
3564
|
-
return { [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3564
|
+
return defineRuleListener({ [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3565
3565
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
3566
3566
|
context.report({
|
|
3567
3567
|
messageId: "default",
|
|
@@ -3578,7 +3578,7 @@ function create$6(context) {
|
|
|
3578
3578
|
return fixer.replaceText(node.parent, [`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`, `${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semi}`].join("\n"));
|
|
3579
3579
|
}
|
|
3580
3580
|
});
|
|
3581
|
-
} };
|
|
3581
|
+
} });
|
|
3582
3582
|
}
|
|
3583
3583
|
|
|
3584
3584
|
//#endregion
|
|
@@ -3654,7 +3654,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
|
|
|
3654
3654
|
defaultOptions: []
|
|
3655
3655
|
});
|
|
3656
3656
|
function create$4(context) {
|
|
3657
|
-
return { CallExpression(node) {
|
|
3657
|
+
return defineRuleListener({ CallExpression(node) {
|
|
3658
3658
|
if (!core.isUseStateCall(node)) return;
|
|
3659
3659
|
const [useStateInput] = node.arguments;
|
|
3660
3660
|
if (useStateInput == null) return;
|
|
@@ -3677,7 +3677,7 @@ function create$4(context) {
|
|
|
3677
3677
|
node: expr
|
|
3678
3678
|
});
|
|
3679
3679
|
}
|
|
3680
|
-
} };
|
|
3680
|
+
} });
|
|
3681
3681
|
}
|
|
3682
3682
|
|
|
3683
3683
|
//#endregion
|
|
@@ -3936,7 +3936,7 @@ function create$2(context) {
|
|
|
3936
3936
|
return;
|
|
3937
3937
|
}
|
|
3938
3938
|
}
|
|
3939
|
-
return {
|
|
3939
|
+
return defineRuleListener({
|
|
3940
3940
|
":function"(node) {
|
|
3941
3941
|
const kind = getFunctionEntryKind(node);
|
|
3942
3942
|
functionStack.push({
|
|
@@ -3968,7 +3968,7 @@ function create$2(context) {
|
|
|
3968
3968
|
const idx = body.indexOf(stmt);
|
|
3969
3969
|
if (idx !== -1 && idx < body.length - 1) entry.hasEarlyReturn = true;
|
|
3970
3970
|
}
|
|
3971
|
-
};
|
|
3971
|
+
});
|
|
3972
3972
|
}
|
|
3973
3973
|
|
|
3974
3974
|
//#endregion
|
|
@@ -3977,7 +3977,7 @@ const RULE_NAME$1 = "set-state-in-effect";
|
|
|
3977
3977
|
var set_state_in_effect_default = createRule({
|
|
3978
3978
|
meta: {
|
|
3979
3979
|
type: "problem",
|
|
3980
|
-
docs: { description: "Validates against
|
|
3980
|
+
docs: { description: "Validates against setting state synchronously in an effect, which can lead to re-renders that degrade performance." },
|
|
3981
3981
|
messages: { default: "Do not call the 'set' function '{{name}}' of 'useState' synchronously in an effect. This can lead to unnecessary re-renders and performance issues." },
|
|
3982
3982
|
schema: []
|
|
3983
3983
|
},
|
|
@@ -4058,7 +4058,7 @@ function create$1(context) {
|
|
|
4058
4058
|
default: return false;
|
|
4059
4059
|
}
|
|
4060
4060
|
}
|
|
4061
|
-
return {
|
|
4061
|
+
return defineRuleListener({
|
|
4062
4062
|
":function"(node) {
|
|
4063
4063
|
const kind = getFunctionKind(node);
|
|
4064
4064
|
functionEntries.push({
|
|
@@ -4159,7 +4159,7 @@ function create$1(context) {
|
|
|
4159
4159
|
});
|
|
4160
4160
|
}
|
|
4161
4161
|
}
|
|
4162
|
-
};
|
|
4162
|
+
});
|
|
4163
4163
|
}
|
|
4164
4164
|
function isInitFromHookCall(init) {
|
|
4165
4165
|
if (init?.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
@@ -4262,7 +4262,7 @@ function create(context) {
|
|
|
4262
4262
|
if (parent.type === AST_NODE_TYPES.CallExpression && parent.callee !== node) return "callback";
|
|
4263
4263
|
return "other";
|
|
4264
4264
|
}
|
|
4265
|
-
return {
|
|
4265
|
+
return defineRuleListener({
|
|
4266
4266
|
":function"(node) {
|
|
4267
4267
|
const kind = getFunctionKind(node);
|
|
4268
4268
|
functionEntries.push({
|
|
@@ -4309,7 +4309,7 @@ function create(context) {
|
|
|
4309
4309
|
const idx = body.indexOf(stmt);
|
|
4310
4310
|
if (idx !== -1 && idx < body.length - 1) componentHasEarlyReturn.current = true;
|
|
4311
4311
|
}
|
|
4312
|
-
};
|
|
4312
|
+
});
|
|
4313
4313
|
}
|
|
4314
4314
|
|
|
4315
4315
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.8",
|
|
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,11 +45,11 @@
|
|
|
45
45
|
"is-immutable-type": "^5.0.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "3.0.0-beta.
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "3.0.0-beta.8",
|
|
49
|
+
"@eslint-react/core": "3.0.0-beta.8",
|
|
50
|
+
"@eslint-react/eff": "3.0.0-beta.8",
|
|
51
|
+
"@eslint-react/shared": "3.0.0-beta.8",
|
|
52
|
+
"@eslint-react/var": "3.0.0-beta.8"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|