eslint-plugin-react-x 1.28.0-beta.1 → 1.28.0-beta.4
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 +38 -26
- package/dist/index.mjs +38 -26
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ var settings3 = {
|
|
|
137
137
|
|
|
138
138
|
// package.json
|
|
139
139
|
var name4 = "eslint-plugin-react-x";
|
|
140
|
-
var version = "1.28.0-beta.
|
|
140
|
+
var version = "1.28.0-beta.4";
|
|
141
141
|
var createRule = shared.createRuleForPlugin("x");
|
|
142
142
|
|
|
143
143
|
// src/utils/get-associated-tokens.ts
|
|
@@ -244,7 +244,7 @@ var ensure_forward_ref_using_ref_default = createRule({
|
|
|
244
244
|
create(context) {
|
|
245
245
|
return {
|
|
246
246
|
CallExpression(node) {
|
|
247
|
-
if (!core.isForwardRefCall(
|
|
247
|
+
if (!core.isForwardRefCall(context, node)) {
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
const [component] = node.arguments;
|
|
@@ -411,7 +411,7 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
|
411
411
|
function isReactChildrenMethod(name5) {
|
|
412
412
|
return reactChildrenMethod.some((method) => method === name5);
|
|
413
413
|
}
|
|
414
|
-
function isUsingReactChildren(
|
|
414
|
+
function isUsingReactChildren(context, node) {
|
|
415
415
|
const { importSource = "react" } = shared.unsafeDecodeSettings(context.settings);
|
|
416
416
|
const { callee } = node;
|
|
417
417
|
if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
|
|
@@ -429,7 +429,7 @@ function isUsingReactChildren(node, context) {
|
|
|
429
429
|
}
|
|
430
430
|
return false;
|
|
431
431
|
}
|
|
432
|
-
function getMapIndexParamName(
|
|
432
|
+
function getMapIndexParamName(context, node) {
|
|
433
433
|
const { callee } = node;
|
|
434
434
|
if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
|
|
435
435
|
return eff._;
|
|
@@ -441,7 +441,7 @@ function getMapIndexParamName(node, context) {
|
|
|
441
441
|
if (!iteratorFunctionIndexParamPosition.has(name5)) {
|
|
442
442
|
return eff._;
|
|
443
443
|
}
|
|
444
|
-
const callbackArg = node.arguments[isUsingReactChildren(
|
|
444
|
+
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
445
445
|
if (callbackArg == null) {
|
|
446
446
|
return eff._;
|
|
447
447
|
}
|
|
@@ -478,7 +478,7 @@ var no_array_index_key_default = createRule({
|
|
|
478
478
|
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
479
479
|
}
|
|
480
480
|
function isCreateOrCloneElementCall(node) {
|
|
481
|
-
return core.isCreateElementCall(
|
|
481
|
+
return core.isCreateElementCall(context, node) || core.isCloneElementCall(context, node);
|
|
482
482
|
}
|
|
483
483
|
function getReportDescriptors(node) {
|
|
484
484
|
switch (node.type) {
|
|
@@ -496,7 +496,7 @@ var no_array_index_key_default = createRule({
|
|
|
496
496
|
case types.AST_NODE_TYPES.TemplateLiteral:
|
|
497
497
|
case types.AST_NODE_TYPES.BinaryExpression: {
|
|
498
498
|
const descriptors = [];
|
|
499
|
-
const expressions = node.type === types.AST_NODE_TYPES.TemplateLiteral ? node.expressions :
|
|
499
|
+
const expressions = node.type === types.AST_NODE_TYPES.TemplateLiteral ? node.expressions : getIdentifiersFromBinaryExpression(node);
|
|
500
500
|
for (const expression of expressions) {
|
|
501
501
|
if (isArrayIndex(expression)) {
|
|
502
502
|
descriptors.push({
|
|
@@ -531,7 +531,7 @@ var no_array_index_key_default = createRule({
|
|
|
531
531
|
}
|
|
532
532
|
return {
|
|
533
533
|
CallExpression(node) {
|
|
534
|
-
indexParamNames.push(getMapIndexParamName(
|
|
534
|
+
indexParamNames.push(getMapIndexParamName(context, node));
|
|
535
535
|
if (node.arguments.length === 0) {
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
@@ -577,6 +577,18 @@ var no_array_index_key_default = createRule({
|
|
|
577
577
|
},
|
|
578
578
|
defaultOptions: []
|
|
579
579
|
});
|
|
580
|
+
function getIdentifiersFromBinaryExpression(side) {
|
|
581
|
+
if (side.type === types.AST_NODE_TYPES.Identifier) {
|
|
582
|
+
return [side];
|
|
583
|
+
}
|
|
584
|
+
if (side.type === types.AST_NODE_TYPES.BinaryExpression) {
|
|
585
|
+
return [
|
|
586
|
+
...getIdentifiersFromBinaryExpression(side.left),
|
|
587
|
+
...getIdentifiersFromBinaryExpression(side.right)
|
|
588
|
+
];
|
|
589
|
+
}
|
|
590
|
+
return [];
|
|
591
|
+
}
|
|
580
592
|
var RULE_NAME6 = "no-children-count";
|
|
581
593
|
var RULE_FEATURES6 = [
|
|
582
594
|
"CHK"
|
|
@@ -597,7 +609,7 @@ var no_children_count_default = createRule({
|
|
|
597
609
|
create(context) {
|
|
598
610
|
return {
|
|
599
611
|
MemberExpression(node) {
|
|
600
|
-
if (core.isChildrenCount(
|
|
612
|
+
if (core.isChildrenCount(context, node)) {
|
|
601
613
|
context.report({
|
|
602
614
|
messageId: "noChildrenCount",
|
|
603
615
|
node: node.property
|
|
@@ -628,7 +640,7 @@ var no_children_for_each_default = createRule({
|
|
|
628
640
|
create(context) {
|
|
629
641
|
return {
|
|
630
642
|
MemberExpression(node) {
|
|
631
|
-
if (core.isChildrenForEach(
|
|
643
|
+
if (core.isChildrenForEach(context, node)) {
|
|
632
644
|
context.report({
|
|
633
645
|
messageId: "noChildrenForEach",
|
|
634
646
|
node: node.property
|
|
@@ -659,7 +671,7 @@ var no_children_map_default = createRule({
|
|
|
659
671
|
create(context) {
|
|
660
672
|
return {
|
|
661
673
|
MemberExpression(node) {
|
|
662
|
-
if (core.isChildrenMap(
|
|
674
|
+
if (core.isChildrenMap(context, node)) {
|
|
663
675
|
context.report({
|
|
664
676
|
messageId: "noChildrenMap",
|
|
665
677
|
node: node.property
|
|
@@ -690,7 +702,7 @@ var no_children_only_default = createRule({
|
|
|
690
702
|
create(context) {
|
|
691
703
|
return {
|
|
692
704
|
MemberExpression(node) {
|
|
693
|
-
if (core.isChildrenOnly(
|
|
705
|
+
if (core.isChildrenOnly(context, node)) {
|
|
694
706
|
context.report({
|
|
695
707
|
messageId: "noChildrenOnly",
|
|
696
708
|
node: node.property
|
|
@@ -757,7 +769,7 @@ var no_children_to_array_default = createRule({
|
|
|
757
769
|
create(context) {
|
|
758
770
|
return {
|
|
759
771
|
MemberExpression(node) {
|
|
760
|
-
if (core.isChildrenToArray(
|
|
772
|
+
if (core.isChildrenToArray(context, node)) {
|
|
761
773
|
context.report({
|
|
762
774
|
messageId: "noChildrenToArray",
|
|
763
775
|
node: node.property
|
|
@@ -831,7 +843,7 @@ var no_clone_element_default = createRule({
|
|
|
831
843
|
create(context) {
|
|
832
844
|
return {
|
|
833
845
|
CallExpression(node) {
|
|
834
|
-
if (!core.isCloneElementCall(
|
|
846
|
+
if (!core.isCloneElementCall(context, node)) {
|
|
835
847
|
return;
|
|
836
848
|
}
|
|
837
849
|
context.report({
|
|
@@ -1166,7 +1178,7 @@ var no_create_ref_default = createRule({
|
|
|
1166
1178
|
create(context) {
|
|
1167
1179
|
return {
|
|
1168
1180
|
CallExpression(node) {
|
|
1169
|
-
if (core.isCreateRefCall(
|
|
1181
|
+
if (core.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
|
|
1170
1182
|
context.report({ messageId: "noCreateRef", node });
|
|
1171
1183
|
}
|
|
1172
1184
|
}
|
|
@@ -1448,20 +1460,20 @@ var no_forward_ref_default = createRule({
|
|
|
1448
1460
|
}
|
|
1449
1461
|
return {
|
|
1450
1462
|
CallExpression(node) {
|
|
1451
|
-
if (!core.isForwardRefCall(
|
|
1463
|
+
if (!core.isForwardRefCall(context, node)) {
|
|
1452
1464
|
return;
|
|
1453
1465
|
}
|
|
1454
1466
|
context.report({
|
|
1455
1467
|
messageId: "noForwardRef",
|
|
1456
1468
|
node,
|
|
1457
|
-
fix: getFix(
|
|
1469
|
+
fix: getFix(context, node)
|
|
1458
1470
|
});
|
|
1459
1471
|
}
|
|
1460
1472
|
};
|
|
1461
1473
|
},
|
|
1462
1474
|
defaultOptions: []
|
|
1463
1475
|
});
|
|
1464
|
-
function getFix(
|
|
1476
|
+
function getFix(context, node) {
|
|
1465
1477
|
return (fixer) => {
|
|
1466
1478
|
const [componentNode] = node.arguments;
|
|
1467
1479
|
if (componentNode == null || !AST11__namespace.isFunction(componentNode)) {
|
|
@@ -1801,7 +1813,7 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1801
1813
|
const displayNameAssignments = [];
|
|
1802
1814
|
return {
|
|
1803
1815
|
CallExpression(node) {
|
|
1804
|
-
if (!core.isCreateContextCall(
|
|
1816
|
+
if (!core.isCreateContextCall(context, node)) return;
|
|
1805
1817
|
createCalls.push(node);
|
|
1806
1818
|
},
|
|
1807
1819
|
[core.DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
@@ -1932,7 +1944,7 @@ var no_missing_key_default = createRule({
|
|
|
1932
1944
|
}
|
|
1933
1945
|
},
|
|
1934
1946
|
CallExpression(node) {
|
|
1935
|
-
state.isWithinChildrenToArray ||= core.isChildrenToArrayCall(
|
|
1947
|
+
state.isWithinChildrenToArray ||= core.isChildrenToArrayCall(context, node);
|
|
1936
1948
|
if (state.isWithinChildrenToArray) {
|
|
1937
1949
|
return;
|
|
1938
1950
|
}
|
|
@@ -1956,7 +1968,7 @@ var no_missing_key_default = createRule({
|
|
|
1956
1968
|
}
|
|
1957
1969
|
},
|
|
1958
1970
|
"CallExpression:exit"(node) {
|
|
1959
|
-
if (!core.isChildrenToArrayCall(
|
|
1971
|
+
if (!core.isChildrenToArrayCall(context, node)) {
|
|
1960
1972
|
return;
|
|
1961
1973
|
}
|
|
1962
1974
|
state.isWithinChildrenToArray = false;
|
|
@@ -2038,7 +2050,7 @@ var no_nested_components_default = createRule({
|
|
|
2038
2050
|
}
|
|
2039
2051
|
continue;
|
|
2040
2052
|
}
|
|
2041
|
-
if (core.isInsideCreateElementProps(
|
|
2053
|
+
if (core.isInsideCreateElementProps(context, component)) {
|
|
2042
2054
|
context.report({
|
|
2043
2055
|
messageId: "nestedComponentInProps",
|
|
2044
2056
|
node: component,
|
|
@@ -3016,7 +3028,7 @@ var no_use_context_default = createRule({
|
|
|
3016
3028
|
if (!core.isReactHookCall(node)) {
|
|
3017
3029
|
return;
|
|
3018
3030
|
}
|
|
3019
|
-
if (!core.isReactHookCallWithNameAlias("useContext",
|
|
3031
|
+
if (!core.isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
3020
3032
|
return;
|
|
3021
3033
|
}
|
|
3022
3034
|
context.report({
|
|
@@ -3081,7 +3093,7 @@ function trimLikeReact(text) {
|
|
|
3081
3093
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
3082
3094
|
return text.slice(start, end);
|
|
3083
3095
|
}
|
|
3084
|
-
function checkAndReport(
|
|
3096
|
+
function checkAndReport(context, node, allowExpressions) {
|
|
3085
3097
|
function fix(fixer) {
|
|
3086
3098
|
if (node.parent.type !== types.AST_NODE_TYPES.JSXElement && node.parent.type !== types.AST_NODE_TYPES.JSXFragment) {
|
|
3087
3099
|
if (node.children.length === 0) {
|
|
@@ -3202,10 +3214,10 @@ var no_useless_fragment_default = createRule({
|
|
|
3202
3214
|
return {
|
|
3203
3215
|
JSXElement(node) {
|
|
3204
3216
|
if (!JSX7__namespace.isFragmentElement(node)) return;
|
|
3205
|
-
checkAndReport(
|
|
3217
|
+
checkAndReport(context, node, allowExpressions);
|
|
3206
3218
|
},
|
|
3207
3219
|
JSXFragment(node) {
|
|
3208
|
-
checkAndReport(
|
|
3220
|
+
checkAndReport(context, node, allowExpressions);
|
|
3209
3221
|
}
|
|
3210
3222
|
};
|
|
3211
3223
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -110,7 +110,7 @@ var settings3 = {
|
|
|
110
110
|
|
|
111
111
|
// package.json
|
|
112
112
|
var name4 = "eslint-plugin-react-x";
|
|
113
|
-
var version = "1.28.0-beta.
|
|
113
|
+
var version = "1.28.0-beta.4";
|
|
114
114
|
var createRule = createRuleForPlugin("x");
|
|
115
115
|
|
|
116
116
|
// src/utils/get-associated-tokens.ts
|
|
@@ -217,7 +217,7 @@ var ensure_forward_ref_using_ref_default = createRule({
|
|
|
217
217
|
create(context) {
|
|
218
218
|
return {
|
|
219
219
|
CallExpression(node) {
|
|
220
|
-
if (!isForwardRefCall(
|
|
220
|
+
if (!isForwardRefCall(context, node)) {
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
const [component] = node.arguments;
|
|
@@ -384,7 +384,7 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
|
384
384
|
function isReactChildrenMethod(name5) {
|
|
385
385
|
return reactChildrenMethod.some((method) => method === name5);
|
|
386
386
|
}
|
|
387
|
-
function isUsingReactChildren(
|
|
387
|
+
function isUsingReactChildren(context, node) {
|
|
388
388
|
const { importSource = "react" } = unsafeDecodeSettings(context.settings);
|
|
389
389
|
const { callee } = node;
|
|
390
390
|
if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
|
|
@@ -402,7 +402,7 @@ function isUsingReactChildren(node, context) {
|
|
|
402
402
|
}
|
|
403
403
|
return false;
|
|
404
404
|
}
|
|
405
|
-
function getMapIndexParamName(
|
|
405
|
+
function getMapIndexParamName(context, node) {
|
|
406
406
|
const { callee } = node;
|
|
407
407
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) {
|
|
408
408
|
return _;
|
|
@@ -414,7 +414,7 @@ function getMapIndexParamName(node, context) {
|
|
|
414
414
|
if (!iteratorFunctionIndexParamPosition.has(name5)) {
|
|
415
415
|
return _;
|
|
416
416
|
}
|
|
417
|
-
const callbackArg = node.arguments[isUsingReactChildren(
|
|
417
|
+
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
418
418
|
if (callbackArg == null) {
|
|
419
419
|
return _;
|
|
420
420
|
}
|
|
@@ -451,7 +451,7 @@ var no_array_index_key_default = createRule({
|
|
|
451
451
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
452
452
|
}
|
|
453
453
|
function isCreateOrCloneElementCall(node) {
|
|
454
|
-
return isCreateElementCall(
|
|
454
|
+
return isCreateElementCall(context, node) || isCloneElementCall(context, node);
|
|
455
455
|
}
|
|
456
456
|
function getReportDescriptors(node) {
|
|
457
457
|
switch (node.type) {
|
|
@@ -469,7 +469,7 @@ var no_array_index_key_default = createRule({
|
|
|
469
469
|
case AST_NODE_TYPES.TemplateLiteral:
|
|
470
470
|
case AST_NODE_TYPES.BinaryExpression: {
|
|
471
471
|
const descriptors = [];
|
|
472
|
-
const expressions = node.type === AST_NODE_TYPES.TemplateLiteral ? node.expressions :
|
|
472
|
+
const expressions = node.type === AST_NODE_TYPES.TemplateLiteral ? node.expressions : getIdentifiersFromBinaryExpression(node);
|
|
473
473
|
for (const expression of expressions) {
|
|
474
474
|
if (isArrayIndex(expression)) {
|
|
475
475
|
descriptors.push({
|
|
@@ -504,7 +504,7 @@ var no_array_index_key_default = createRule({
|
|
|
504
504
|
}
|
|
505
505
|
return {
|
|
506
506
|
CallExpression(node) {
|
|
507
|
-
indexParamNames.push(getMapIndexParamName(
|
|
507
|
+
indexParamNames.push(getMapIndexParamName(context, node));
|
|
508
508
|
if (node.arguments.length === 0) {
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
@@ -550,6 +550,18 @@ var no_array_index_key_default = createRule({
|
|
|
550
550
|
},
|
|
551
551
|
defaultOptions: []
|
|
552
552
|
});
|
|
553
|
+
function getIdentifiersFromBinaryExpression(side) {
|
|
554
|
+
if (side.type === AST_NODE_TYPES.Identifier) {
|
|
555
|
+
return [side];
|
|
556
|
+
}
|
|
557
|
+
if (side.type === AST_NODE_TYPES.BinaryExpression) {
|
|
558
|
+
return [
|
|
559
|
+
...getIdentifiersFromBinaryExpression(side.left),
|
|
560
|
+
...getIdentifiersFromBinaryExpression(side.right)
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
return [];
|
|
564
|
+
}
|
|
553
565
|
var RULE_NAME6 = "no-children-count";
|
|
554
566
|
var RULE_FEATURES6 = [
|
|
555
567
|
"CHK"
|
|
@@ -570,7 +582,7 @@ var no_children_count_default = createRule({
|
|
|
570
582
|
create(context) {
|
|
571
583
|
return {
|
|
572
584
|
MemberExpression(node) {
|
|
573
|
-
if (isChildrenCount(
|
|
585
|
+
if (isChildrenCount(context, node)) {
|
|
574
586
|
context.report({
|
|
575
587
|
messageId: "noChildrenCount",
|
|
576
588
|
node: node.property
|
|
@@ -601,7 +613,7 @@ var no_children_for_each_default = createRule({
|
|
|
601
613
|
create(context) {
|
|
602
614
|
return {
|
|
603
615
|
MemberExpression(node) {
|
|
604
|
-
if (isChildrenForEach(
|
|
616
|
+
if (isChildrenForEach(context, node)) {
|
|
605
617
|
context.report({
|
|
606
618
|
messageId: "noChildrenForEach",
|
|
607
619
|
node: node.property
|
|
@@ -632,7 +644,7 @@ var no_children_map_default = createRule({
|
|
|
632
644
|
create(context) {
|
|
633
645
|
return {
|
|
634
646
|
MemberExpression(node) {
|
|
635
|
-
if (isChildrenMap(
|
|
647
|
+
if (isChildrenMap(context, node)) {
|
|
636
648
|
context.report({
|
|
637
649
|
messageId: "noChildrenMap",
|
|
638
650
|
node: node.property
|
|
@@ -663,7 +675,7 @@ var no_children_only_default = createRule({
|
|
|
663
675
|
create(context) {
|
|
664
676
|
return {
|
|
665
677
|
MemberExpression(node) {
|
|
666
|
-
if (isChildrenOnly(
|
|
678
|
+
if (isChildrenOnly(context, node)) {
|
|
667
679
|
context.report({
|
|
668
680
|
messageId: "noChildrenOnly",
|
|
669
681
|
node: node.property
|
|
@@ -730,7 +742,7 @@ var no_children_to_array_default = createRule({
|
|
|
730
742
|
create(context) {
|
|
731
743
|
return {
|
|
732
744
|
MemberExpression(node) {
|
|
733
|
-
if (isChildrenToArray(
|
|
745
|
+
if (isChildrenToArray(context, node)) {
|
|
734
746
|
context.report({
|
|
735
747
|
messageId: "noChildrenToArray",
|
|
736
748
|
node: node.property
|
|
@@ -804,7 +816,7 @@ var no_clone_element_default = createRule({
|
|
|
804
816
|
create(context) {
|
|
805
817
|
return {
|
|
806
818
|
CallExpression(node) {
|
|
807
|
-
if (!isCloneElementCall(
|
|
819
|
+
if (!isCloneElementCall(context, node)) {
|
|
808
820
|
return;
|
|
809
821
|
}
|
|
810
822
|
context.report({
|
|
@@ -1139,7 +1151,7 @@ var no_create_ref_default = createRule({
|
|
|
1139
1151
|
create(context) {
|
|
1140
1152
|
return {
|
|
1141
1153
|
CallExpression(node) {
|
|
1142
|
-
if (isCreateRefCall(
|
|
1154
|
+
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
1143
1155
|
context.report({ messageId: "noCreateRef", node });
|
|
1144
1156
|
}
|
|
1145
1157
|
}
|
|
@@ -1421,20 +1433,20 @@ var no_forward_ref_default = createRule({
|
|
|
1421
1433
|
}
|
|
1422
1434
|
return {
|
|
1423
1435
|
CallExpression(node) {
|
|
1424
|
-
if (!isForwardRefCall(
|
|
1436
|
+
if (!isForwardRefCall(context, node)) {
|
|
1425
1437
|
return;
|
|
1426
1438
|
}
|
|
1427
1439
|
context.report({
|
|
1428
1440
|
messageId: "noForwardRef",
|
|
1429
1441
|
node,
|
|
1430
|
-
fix: getFix(
|
|
1442
|
+
fix: getFix(context, node)
|
|
1431
1443
|
});
|
|
1432
1444
|
}
|
|
1433
1445
|
};
|
|
1434
1446
|
},
|
|
1435
1447
|
defaultOptions: []
|
|
1436
1448
|
});
|
|
1437
|
-
function getFix(
|
|
1449
|
+
function getFix(context, node) {
|
|
1438
1450
|
return (fixer) => {
|
|
1439
1451
|
const [componentNode] = node.arguments;
|
|
1440
1452
|
if (componentNode == null || !AST11.isFunction(componentNode)) {
|
|
@@ -1774,7 +1786,7 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1774
1786
|
const displayNameAssignments = [];
|
|
1775
1787
|
return {
|
|
1776
1788
|
CallExpression(node) {
|
|
1777
|
-
if (!isCreateContextCall(
|
|
1789
|
+
if (!isCreateContextCall(context, node)) return;
|
|
1778
1790
|
createCalls.push(node);
|
|
1779
1791
|
},
|
|
1780
1792
|
[DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
@@ -1905,7 +1917,7 @@ var no_missing_key_default = createRule({
|
|
|
1905
1917
|
}
|
|
1906
1918
|
},
|
|
1907
1919
|
CallExpression(node) {
|
|
1908
|
-
state.isWithinChildrenToArray ||= isChildrenToArrayCall(
|
|
1920
|
+
state.isWithinChildrenToArray ||= isChildrenToArrayCall(context, node);
|
|
1909
1921
|
if (state.isWithinChildrenToArray) {
|
|
1910
1922
|
return;
|
|
1911
1923
|
}
|
|
@@ -1929,7 +1941,7 @@ var no_missing_key_default = createRule({
|
|
|
1929
1941
|
}
|
|
1930
1942
|
},
|
|
1931
1943
|
"CallExpression:exit"(node) {
|
|
1932
|
-
if (!isChildrenToArrayCall(
|
|
1944
|
+
if (!isChildrenToArrayCall(context, node)) {
|
|
1933
1945
|
return;
|
|
1934
1946
|
}
|
|
1935
1947
|
state.isWithinChildrenToArray = false;
|
|
@@ -2011,7 +2023,7 @@ var no_nested_components_default = createRule({
|
|
|
2011
2023
|
}
|
|
2012
2024
|
continue;
|
|
2013
2025
|
}
|
|
2014
|
-
if (isInsideCreateElementProps(
|
|
2026
|
+
if (isInsideCreateElementProps(context, component)) {
|
|
2015
2027
|
context.report({
|
|
2016
2028
|
messageId: "nestedComponentInProps",
|
|
2017
2029
|
node: component,
|
|
@@ -2989,7 +3001,7 @@ var no_use_context_default = createRule({
|
|
|
2989
3001
|
if (!isReactHookCall(node)) {
|
|
2990
3002
|
return;
|
|
2991
3003
|
}
|
|
2992
|
-
if (!isReactHookCallWithNameAlias("useContext",
|
|
3004
|
+
if (!isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
2993
3005
|
return;
|
|
2994
3006
|
}
|
|
2995
3007
|
context.report({
|
|
@@ -3054,7 +3066,7 @@ function trimLikeReact(text) {
|
|
|
3054
3066
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
3055
3067
|
return text.slice(start, end);
|
|
3056
3068
|
}
|
|
3057
|
-
function checkAndReport(
|
|
3069
|
+
function checkAndReport(context, node, allowExpressions) {
|
|
3058
3070
|
function fix(fixer) {
|
|
3059
3071
|
if (node.parent.type !== AST_NODE_TYPES.JSXElement && node.parent.type !== AST_NODE_TYPES.JSXFragment) {
|
|
3060
3072
|
if (node.children.length === 0) {
|
|
@@ -3175,10 +3187,10 @@ var no_useless_fragment_default = createRule({
|
|
|
3175
3187
|
return {
|
|
3176
3188
|
JSXElement(node) {
|
|
3177
3189
|
if (!JSX7.isFragmentElement(node)) return;
|
|
3178
|
-
checkAndReport(
|
|
3190
|
+
checkAndReport(context, node, allowExpressions);
|
|
3179
3191
|
},
|
|
3180
3192
|
JSXFragment(node) {
|
|
3181
|
-
checkAndReport(
|
|
3193
|
+
checkAndReport(context, node, allowExpressions);
|
|
3182
3194
|
}
|
|
3183
3195
|
};
|
|
3184
3196
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.28.0-beta.
|
|
3
|
+
"version": "1.28.0-beta.4",
|
|
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,12 +50,12 @@
|
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.6.2",
|
|
53
|
-
"@eslint-react/ast": "1.28.0-beta.
|
|
54
|
-
"@eslint-react/core": "1.28.0-beta.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/shared": "1.28.0-beta.
|
|
58
|
-
"@eslint-react/var": "1.28.0-beta.
|
|
53
|
+
"@eslint-react/ast": "1.28.0-beta.4",
|
|
54
|
+
"@eslint-react/core": "1.28.0-beta.4",
|
|
55
|
+
"@eslint-react/eff": "1.28.0-beta.4",
|
|
56
|
+
"@eslint-react/jsx": "1.28.0-beta.4",
|
|
57
|
+
"@eslint-react/shared": "1.28.0-beta.4",
|
|
58
|
+
"@eslint-react/var": "1.28.0-beta.4"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.0.10",
|