eslint-plugin-react-x 1.37.1 → 1.37.2-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 +142 -130
- package/dist/index.mjs +142 -130
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint
|
|
|
11
11
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
12
12
|
import { unionConstituents, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
13
13
|
import ts from 'typescript';
|
|
14
|
+
import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
|
|
14
15
|
|
|
15
16
|
var __defProp = Object.defineProperty;
|
|
16
17
|
var __export = (target, all) => {
|
|
@@ -108,7 +109,7 @@ var settings3 = {
|
|
|
108
109
|
|
|
109
110
|
// package.json
|
|
110
111
|
var name4 = "eslint-plugin-react-x";
|
|
111
|
-
var version = "1.37.1";
|
|
112
|
+
var version = "1.37.2-beta.1";
|
|
112
113
|
var createRule = createRuleForPlugin("x");
|
|
113
114
|
|
|
114
115
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -558,20 +559,21 @@ var no_children_map_default = createRule({
|
|
|
558
559
|
schema: []
|
|
559
560
|
},
|
|
560
561
|
name: RULE_NAME7,
|
|
561
|
-
create
|
|
562
|
-
return {
|
|
563
|
-
MemberExpression(node) {
|
|
564
|
-
if (isChildrenMap(context, node)) {
|
|
565
|
-
context.report({
|
|
566
|
-
messageId: "noChildrenMap",
|
|
567
|
-
node: node.property
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
},
|
|
562
|
+
create: create7,
|
|
573
563
|
defaultOptions: []
|
|
574
564
|
});
|
|
565
|
+
function create7(context) {
|
|
566
|
+
return {
|
|
567
|
+
MemberExpression(node) {
|
|
568
|
+
if (isChildrenMap(context, node)) {
|
|
569
|
+
context.report({
|
|
570
|
+
messageId: "noChildrenMap",
|
|
571
|
+
node: node.property
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
}
|
|
575
577
|
var RULE_NAME8 = "no-children-only";
|
|
576
578
|
var RULE_FEATURES8 = [];
|
|
577
579
|
var no_children_only_default = createRule({
|
|
@@ -587,10 +589,10 @@ var no_children_only_default = createRule({
|
|
|
587
589
|
schema: []
|
|
588
590
|
},
|
|
589
591
|
name: RULE_NAME8,
|
|
590
|
-
create:
|
|
592
|
+
create: create8,
|
|
591
593
|
defaultOptions: []
|
|
592
594
|
});
|
|
593
|
-
function
|
|
595
|
+
function create8(context) {
|
|
594
596
|
return {
|
|
595
597
|
MemberExpression(node) {
|
|
596
598
|
if (isChildrenOnly(context, node)) {
|
|
@@ -617,10 +619,10 @@ var no_children_prop_default = createRule({
|
|
|
617
619
|
schema: []
|
|
618
620
|
},
|
|
619
621
|
name: RULE_NAME9,
|
|
620
|
-
create:
|
|
622
|
+
create: create9,
|
|
621
623
|
defaultOptions: []
|
|
622
624
|
});
|
|
623
|
-
function
|
|
625
|
+
function create9(context) {
|
|
624
626
|
return {
|
|
625
627
|
JSXElement(node) {
|
|
626
628
|
const attribute = JSX8.getAttribute(
|
|
@@ -652,10 +654,10 @@ var no_children_to_array_default = createRule({
|
|
|
652
654
|
schema: []
|
|
653
655
|
},
|
|
654
656
|
name: RULE_NAME10,
|
|
655
|
-
create:
|
|
657
|
+
create: create10,
|
|
656
658
|
defaultOptions: []
|
|
657
659
|
});
|
|
658
|
-
function
|
|
660
|
+
function create10(context) {
|
|
659
661
|
return {
|
|
660
662
|
MemberExpression(node) {
|
|
661
663
|
if (isChildrenToArray(context, node)) {
|
|
@@ -682,10 +684,10 @@ var no_class_component_default = createRule({
|
|
|
682
684
|
schema: []
|
|
683
685
|
},
|
|
684
686
|
name: RULE_NAME11,
|
|
685
|
-
create:
|
|
687
|
+
create: create11,
|
|
686
688
|
defaultOptions: []
|
|
687
689
|
});
|
|
688
|
-
function
|
|
690
|
+
function create11(context) {
|
|
689
691
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
690
692
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
691
693
|
return {
|
|
@@ -722,10 +724,10 @@ var no_clone_element_default = createRule({
|
|
|
722
724
|
schema: []
|
|
723
725
|
},
|
|
724
726
|
name: RULE_NAME12,
|
|
725
|
-
create:
|
|
727
|
+
create: create12,
|
|
726
728
|
defaultOptions: []
|
|
727
729
|
});
|
|
728
|
-
function
|
|
730
|
+
function create12(context) {
|
|
729
731
|
return {
|
|
730
732
|
CallExpression(node) {
|
|
731
733
|
if (!isCloneElementCall(context, node)) {
|
|
@@ -753,36 +755,37 @@ var no_comment_textnodes_default = createRule({
|
|
|
753
755
|
schema: []
|
|
754
756
|
},
|
|
755
757
|
name: RULE_NAME13,
|
|
756
|
-
create
|
|
757
|
-
function hasCommentLike(node) {
|
|
758
|
-
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
const rawValue = context.sourceCode.getText(node);
|
|
762
|
-
return /^\s*\/(?:\/|\*)/mu.test(rawValue);
|
|
763
|
-
}
|
|
764
|
-
const visitorFunction = (node) => {
|
|
765
|
-
if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
if (!hasCommentLike(node)) {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
if (!node.parent.type.includes("JSX")) {
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
context.report({
|
|
775
|
-
messageId: "noCommentTextnodes",
|
|
776
|
-
node
|
|
777
|
-
});
|
|
778
|
-
};
|
|
779
|
-
return {
|
|
780
|
-
JSXText: visitorFunction,
|
|
781
|
-
Literal: visitorFunction
|
|
782
|
-
};
|
|
783
|
-
},
|
|
758
|
+
create: create13,
|
|
784
759
|
defaultOptions: []
|
|
785
760
|
});
|
|
761
|
+
function create13(context) {
|
|
762
|
+
function hasCommentLike(node) {
|
|
763
|
+
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
const rawValue = context.sourceCode.getText(node);
|
|
767
|
+
return /^\s*\/(?:\/|\*)/mu.test(rawValue);
|
|
768
|
+
}
|
|
769
|
+
const visitorFunction = (node) => {
|
|
770
|
+
if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (!hasCommentLike(node)) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
if (!node.parent.type.includes("JSX")) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
context.report({
|
|
780
|
+
messageId: "noCommentTextnodes",
|
|
781
|
+
node
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
return {
|
|
785
|
+
JSXText: visitorFunction,
|
|
786
|
+
Literal: visitorFunction
|
|
787
|
+
};
|
|
788
|
+
}
|
|
786
789
|
var RULE_NAME14 = "no-complex-conditional-rendering";
|
|
787
790
|
var RULE_FEATURES14 = [];
|
|
788
791
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -798,10 +801,10 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
798
801
|
schema: []
|
|
799
802
|
},
|
|
800
803
|
name: RULE_NAME14,
|
|
801
|
-
create:
|
|
804
|
+
create: create14,
|
|
802
805
|
defaultOptions: []
|
|
803
806
|
});
|
|
804
|
-
function
|
|
807
|
+
function create14(context) {
|
|
805
808
|
const visitorFunction = (node) => {
|
|
806
809
|
const jsxExpContainer = node.parent?.parent;
|
|
807
810
|
if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -847,10 +850,10 @@ var no_component_will_mount_default = createRule({
|
|
|
847
850
|
schema: []
|
|
848
851
|
},
|
|
849
852
|
name: RULE_NAME15,
|
|
850
|
-
create:
|
|
853
|
+
create: create15,
|
|
851
854
|
defaultOptions: []
|
|
852
855
|
});
|
|
853
|
-
function
|
|
856
|
+
function create15(context) {
|
|
854
857
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
855
858
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
856
859
|
return {
|
|
@@ -898,10 +901,10 @@ var no_component_will_receive_props_default = createRule({
|
|
|
898
901
|
schema: []
|
|
899
902
|
},
|
|
900
903
|
name: RULE_NAME16,
|
|
901
|
-
create:
|
|
904
|
+
create: create16,
|
|
902
905
|
defaultOptions: []
|
|
903
906
|
});
|
|
904
|
-
function
|
|
907
|
+
function create16(context) {
|
|
905
908
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
906
909
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
907
910
|
return {
|
|
@@ -949,10 +952,10 @@ var no_component_will_update_default = createRule({
|
|
|
949
952
|
schema: []
|
|
950
953
|
},
|
|
951
954
|
name: RULE_NAME17,
|
|
952
|
-
create:
|
|
955
|
+
create: create17,
|
|
953
956
|
defaultOptions: []
|
|
954
957
|
});
|
|
955
|
-
function
|
|
958
|
+
function create17(context) {
|
|
956
959
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
957
960
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
958
961
|
return {
|
|
@@ -997,10 +1000,10 @@ var no_context_provider_default = createRule({
|
|
|
997
1000
|
schema: []
|
|
998
1001
|
},
|
|
999
1002
|
name: RULE_NAME18,
|
|
1000
|
-
create:
|
|
1003
|
+
create: create18,
|
|
1001
1004
|
defaultOptions: []
|
|
1002
1005
|
});
|
|
1003
|
-
function
|
|
1006
|
+
function create18(context) {
|
|
1004
1007
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1005
1008
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1006
1009
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1047,10 +1050,10 @@ var no_create_ref_default = createRule({
|
|
|
1047
1050
|
schema: []
|
|
1048
1051
|
},
|
|
1049
1052
|
name: RULE_NAME19,
|
|
1050
|
-
create:
|
|
1053
|
+
create: create19,
|
|
1051
1054
|
defaultOptions: []
|
|
1052
1055
|
});
|
|
1053
|
-
function
|
|
1056
|
+
function create19(context) {
|
|
1054
1057
|
return {
|
|
1055
1058
|
CallExpression(node) {
|
|
1056
1059
|
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
@@ -1074,10 +1077,10 @@ var no_default_props_default = createRule({
|
|
|
1074
1077
|
schema: []
|
|
1075
1078
|
},
|
|
1076
1079
|
name: RULE_NAME20,
|
|
1077
|
-
create:
|
|
1080
|
+
create: create20,
|
|
1078
1081
|
defaultOptions: []
|
|
1079
1082
|
});
|
|
1080
|
-
function
|
|
1083
|
+
function create20(context) {
|
|
1081
1084
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1082
1085
|
return {
|
|
1083
1086
|
AssignmentExpression(node) {
|
|
@@ -1129,10 +1132,10 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1129
1132
|
schema: []
|
|
1130
1133
|
},
|
|
1131
1134
|
name: RULE_NAME21,
|
|
1132
|
-
create:
|
|
1135
|
+
create: create21,
|
|
1133
1136
|
defaultOptions: []
|
|
1134
1137
|
});
|
|
1135
|
-
function
|
|
1138
|
+
function create21(context) {
|
|
1136
1139
|
return {
|
|
1137
1140
|
AssignmentExpression(node) {
|
|
1138
1141
|
if (!isAssignmentToThisState(node)) return;
|
|
@@ -1168,10 +1171,10 @@ var no_duplicate_jsx_props_default = createRule({
|
|
|
1168
1171
|
schema: []
|
|
1169
1172
|
},
|
|
1170
1173
|
name: RULE_NAME22,
|
|
1171
|
-
create:
|
|
1174
|
+
create: create22,
|
|
1172
1175
|
defaultOptions: []
|
|
1173
1176
|
});
|
|
1174
|
-
function
|
|
1177
|
+
function create22(context) {
|
|
1175
1178
|
return {
|
|
1176
1179
|
JSXOpeningElement(node) {
|
|
1177
1180
|
const props = [];
|
|
@@ -1210,10 +1213,10 @@ var no_duplicate_key_default = createRule({
|
|
|
1210
1213
|
schema: []
|
|
1211
1214
|
},
|
|
1212
1215
|
name: RULE_NAME23,
|
|
1213
|
-
create:
|
|
1216
|
+
create: create23,
|
|
1214
1217
|
defaultOptions: []
|
|
1215
1218
|
});
|
|
1216
|
-
function
|
|
1219
|
+
function create23(context) {
|
|
1217
1220
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1218
1221
|
return {};
|
|
1219
1222
|
}
|
|
@@ -1295,10 +1298,10 @@ var no_forward_ref_default = createRule({
|
|
|
1295
1298
|
schema: []
|
|
1296
1299
|
},
|
|
1297
1300
|
name: RULE_NAME24,
|
|
1298
|
-
create:
|
|
1301
|
+
create: create24,
|
|
1299
1302
|
defaultOptions: []
|
|
1300
1303
|
});
|
|
1301
|
-
function
|
|
1304
|
+
function create24(context) {
|
|
1302
1305
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1303
1306
|
return {};
|
|
1304
1307
|
}
|
|
@@ -1401,10 +1404,10 @@ var no_implicit_key_default = createRule({
|
|
|
1401
1404
|
schema: []
|
|
1402
1405
|
},
|
|
1403
1406
|
name: RULE_NAME25,
|
|
1404
|
-
create:
|
|
1407
|
+
create: create25,
|
|
1405
1408
|
defaultOptions: []
|
|
1406
1409
|
});
|
|
1407
|
-
function
|
|
1410
|
+
function create25(context) {
|
|
1408
1411
|
return {
|
|
1409
1412
|
JSXOpeningElement(node) {
|
|
1410
1413
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1513,10 +1516,10 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1513
1516
|
schema: []
|
|
1514
1517
|
},
|
|
1515
1518
|
name: RULE_NAME26,
|
|
1516
|
-
create:
|
|
1519
|
+
create: create26,
|
|
1517
1520
|
defaultOptions: []
|
|
1518
1521
|
});
|
|
1519
|
-
function
|
|
1522
|
+
function create26(context) {
|
|
1520
1523
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1521
1524
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1522
1525
|
const allowedVariants = [
|
|
@@ -1588,10 +1591,10 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1588
1591
|
schema: []
|
|
1589
1592
|
},
|
|
1590
1593
|
name: RULE_NAME27,
|
|
1591
|
-
create:
|
|
1594
|
+
create: create27,
|
|
1592
1595
|
defaultOptions: []
|
|
1593
1596
|
});
|
|
1594
|
-
function
|
|
1597
|
+
function create27(context) {
|
|
1595
1598
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1596
1599
|
const {
|
|
1597
1600
|
ctx,
|
|
@@ -1641,10 +1644,10 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1641
1644
|
schema: []
|
|
1642
1645
|
},
|
|
1643
1646
|
name: RULE_NAME28,
|
|
1644
|
-
create:
|
|
1647
|
+
create: create28,
|
|
1645
1648
|
defaultOptions: []
|
|
1646
1649
|
});
|
|
1647
|
-
function
|
|
1650
|
+
function create28(context) {
|
|
1648
1651
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1649
1652
|
const createCalls = [];
|
|
1650
1653
|
const displayNameAssignments = [];
|
|
@@ -1698,10 +1701,10 @@ var no_missing_key_default = createRule({
|
|
|
1698
1701
|
schema: []
|
|
1699
1702
|
},
|
|
1700
1703
|
name: RULE_NAME29,
|
|
1701
|
-
create:
|
|
1704
|
+
create: create29,
|
|
1702
1705
|
defaultOptions: []
|
|
1703
1706
|
});
|
|
1704
|
-
function
|
|
1707
|
+
function create29(context) {
|
|
1705
1708
|
const report = createReport(context);
|
|
1706
1709
|
const state = { isWithinChildrenToArray: false };
|
|
1707
1710
|
function checkIteratorElement(node) {
|
|
@@ -1830,10 +1833,10 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1830
1833
|
schema: []
|
|
1831
1834
|
},
|
|
1832
1835
|
name: RULE_NAME30,
|
|
1833
|
-
create:
|
|
1836
|
+
create: create30,
|
|
1834
1837
|
defaultOptions: []
|
|
1835
1838
|
});
|
|
1836
|
-
function
|
|
1839
|
+
function create30(context) {
|
|
1837
1840
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1838
1841
|
const collector = useComponentCollector(context, { hint });
|
|
1839
1842
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -1939,10 +1942,10 @@ var no_prop_types_default = createRule({
|
|
|
1939
1942
|
schema: []
|
|
1940
1943
|
},
|
|
1941
1944
|
name: RULE_NAME31,
|
|
1942
|
-
create:
|
|
1945
|
+
create: create31,
|
|
1943
1946
|
defaultOptions: []
|
|
1944
1947
|
});
|
|
1945
|
-
function
|
|
1948
|
+
function create31(context) {
|
|
1946
1949
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1947
1950
|
return {};
|
|
1948
1951
|
}
|
|
@@ -1996,10 +1999,10 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1996
1999
|
schema: []
|
|
1997
2000
|
},
|
|
1998
2001
|
name: RULE_NAME32,
|
|
1999
|
-
create:
|
|
2002
|
+
create: create32,
|
|
2000
2003
|
defaultOptions: []
|
|
2001
2004
|
});
|
|
2002
|
-
function
|
|
2005
|
+
function create32(context) {
|
|
2003
2006
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2004
2007
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2005
2008
|
return {
|
|
@@ -2044,10 +2047,10 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2044
2047
|
schema: []
|
|
2045
2048
|
},
|
|
2046
2049
|
name: RULE_NAME33,
|
|
2047
|
-
create:
|
|
2050
|
+
create: create33,
|
|
2048
2051
|
defaultOptions: []
|
|
2049
2052
|
});
|
|
2050
|
-
function
|
|
2053
|
+
function create33(context) {
|
|
2051
2054
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2052
2055
|
return {
|
|
2053
2056
|
CallExpression(node) {
|
|
@@ -2086,10 +2089,10 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2086
2089
|
schema: []
|
|
2087
2090
|
},
|
|
2088
2091
|
name: RULE_NAME34,
|
|
2089
|
-
create:
|
|
2092
|
+
create: create34,
|
|
2090
2093
|
defaultOptions: []
|
|
2091
2094
|
});
|
|
2092
|
-
function
|
|
2095
|
+
function create34(context) {
|
|
2093
2096
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2094
2097
|
return {
|
|
2095
2098
|
CallExpression(node) {
|
|
@@ -2128,10 +2131,10 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2128
2131
|
schema: []
|
|
2129
2132
|
},
|
|
2130
2133
|
name: RULE_NAME35,
|
|
2131
|
-
create:
|
|
2134
|
+
create: create35,
|
|
2132
2135
|
defaultOptions: []
|
|
2133
2136
|
});
|
|
2134
|
-
function
|
|
2137
|
+
function create35(context) {
|
|
2135
2138
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2136
2139
|
return {
|
|
2137
2140
|
CallExpression(node) {
|
|
@@ -2179,10 +2182,10 @@ var no_string_refs_default = createRule({
|
|
|
2179
2182
|
schema: []
|
|
2180
2183
|
},
|
|
2181
2184
|
name: RULE_NAME36,
|
|
2182
|
-
create:
|
|
2185
|
+
create: create36,
|
|
2183
2186
|
defaultOptions: []
|
|
2184
2187
|
});
|
|
2185
|
-
function
|
|
2188
|
+
function create36(context) {
|
|
2186
2189
|
return {
|
|
2187
2190
|
JSXAttribute(node) {
|
|
2188
2191
|
if (node.name.name !== "ref") {
|
|
@@ -2215,10 +2218,10 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2215
2218
|
schema: []
|
|
2216
2219
|
},
|
|
2217
2220
|
name: RULE_NAME37,
|
|
2218
|
-
create:
|
|
2221
|
+
create: create37,
|
|
2219
2222
|
defaultOptions: []
|
|
2220
2223
|
});
|
|
2221
|
-
function
|
|
2224
|
+
function create37(context) {
|
|
2222
2225
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2223
2226
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2224
2227
|
return {
|
|
@@ -2257,10 +2260,10 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2257
2260
|
schema: []
|
|
2258
2261
|
},
|
|
2259
2262
|
name: RULE_NAME38,
|
|
2260
|
-
create:
|
|
2263
|
+
create: create38,
|
|
2261
2264
|
defaultOptions: []
|
|
2262
2265
|
});
|
|
2263
|
-
function
|
|
2266
|
+
function create38(context) {
|
|
2264
2267
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2265
2268
|
return {};
|
|
2266
2269
|
}
|
|
@@ -2301,10 +2304,10 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2301
2304
|
schema: []
|
|
2302
2305
|
},
|
|
2303
2306
|
name: RULE_NAME39,
|
|
2304
|
-
create:
|
|
2307
|
+
create: create39,
|
|
2305
2308
|
defaultOptions: []
|
|
2306
2309
|
});
|
|
2307
|
-
function
|
|
2310
|
+
function create39(context) {
|
|
2308
2311
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2309
2312
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2310
2313
|
return {
|
|
@@ -2340,10 +2343,10 @@ var no_unstable_context_value_default = createRule({
|
|
|
2340
2343
|
schema: []
|
|
2341
2344
|
},
|
|
2342
2345
|
name: RULE_NAME40,
|
|
2343
|
-
create:
|
|
2346
|
+
create: create40,
|
|
2344
2347
|
defaultOptions: []
|
|
2345
2348
|
});
|
|
2346
|
-
function
|
|
2349
|
+
function create40(context) {
|
|
2347
2350
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2348
2351
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2349
2352
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2413,10 +2416,10 @@ var no_unstable_default_props_default = createRule({
|
|
|
2413
2416
|
schema: []
|
|
2414
2417
|
},
|
|
2415
2418
|
name: RULE_NAME41,
|
|
2416
|
-
create:
|
|
2419
|
+
create: create41,
|
|
2417
2420
|
defaultOptions: []
|
|
2418
2421
|
});
|
|
2419
|
-
function
|
|
2422
|
+
function create41(context) {
|
|
2420
2423
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2421
2424
|
const declarators = /* @__PURE__ */ new Map();
|
|
2422
2425
|
return {
|
|
@@ -2507,10 +2510,10 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2507
2510
|
schema: []
|
|
2508
2511
|
},
|
|
2509
2512
|
name: RULE_NAME42,
|
|
2510
|
-
create:
|
|
2513
|
+
create: create42,
|
|
2511
2514
|
defaultOptions: []
|
|
2512
2515
|
});
|
|
2513
|
-
function
|
|
2516
|
+
function create42(context) {
|
|
2514
2517
|
const classEntries = [];
|
|
2515
2518
|
const methodEntries = [];
|
|
2516
2519
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2638,10 +2641,10 @@ var no_unused_state_default = createRule({
|
|
|
2638
2641
|
schema: []
|
|
2639
2642
|
},
|
|
2640
2643
|
name: RULE_NAME43,
|
|
2641
|
-
create:
|
|
2644
|
+
create: create43,
|
|
2642
2645
|
defaultOptions: []
|
|
2643
2646
|
});
|
|
2644
|
-
function
|
|
2647
|
+
function create43(context) {
|
|
2645
2648
|
const classEntries = [];
|
|
2646
2649
|
const methodEntries = [];
|
|
2647
2650
|
const constructorEntries = [];
|
|
@@ -2793,10 +2796,10 @@ var no_use_context_default = createRule({
|
|
|
2793
2796
|
schema: []
|
|
2794
2797
|
},
|
|
2795
2798
|
name: RULE_NAME44,
|
|
2796
|
-
create:
|
|
2799
|
+
create: create44,
|
|
2797
2800
|
defaultOptions: []
|
|
2798
2801
|
});
|
|
2799
|
-
function
|
|
2802
|
+
function create44(context) {
|
|
2800
2803
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2801
2804
|
const settings4 = getSettingsFromContext(context);
|
|
2802
2805
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2889,10 +2892,10 @@ var no_useless_forward_ref_default = createRule({
|
|
|
2889
2892
|
schema: []
|
|
2890
2893
|
},
|
|
2891
2894
|
name: RULE_NAME45,
|
|
2892
|
-
create:
|
|
2895
|
+
create: create45,
|
|
2893
2896
|
defaultOptions: []
|
|
2894
2897
|
});
|
|
2895
|
-
function
|
|
2898
|
+
function create45(context) {
|
|
2896
2899
|
return {
|
|
2897
2900
|
CallExpression(node) {
|
|
2898
2901
|
if (!isForwardRefCall(context, node)) {
|
|
@@ -2940,10 +2943,10 @@ var no_useless_fragment_default = createRule({
|
|
|
2940
2943
|
}]
|
|
2941
2944
|
},
|
|
2942
2945
|
name: RULE_NAME46,
|
|
2943
|
-
create:
|
|
2946
|
+
create: create46,
|
|
2944
2947
|
defaultOptions
|
|
2945
2948
|
});
|
|
2946
|
-
function
|
|
2949
|
+
function create46(context, [option]) {
|
|
2947
2950
|
const { allowExpressions = true } = option;
|
|
2948
2951
|
return {
|
|
2949
2952
|
JSXElement(node) {
|
|
@@ -3073,10 +3076,10 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3073
3076
|
schema: []
|
|
3074
3077
|
},
|
|
3075
3078
|
name: RULE_NAME47,
|
|
3076
|
-
create:
|
|
3079
|
+
create: create47,
|
|
3077
3080
|
defaultOptions: []
|
|
3078
3081
|
});
|
|
3079
|
-
function
|
|
3082
|
+
function create47(context) {
|
|
3080
3083
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3081
3084
|
const memberExpressionWithNames = [];
|
|
3082
3085
|
return {
|
|
@@ -3154,10 +3157,10 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3154
3157
|
schema: []
|
|
3155
3158
|
},
|
|
3156
3159
|
name: RULE_NAME48,
|
|
3157
|
-
create:
|
|
3160
|
+
create: create48,
|
|
3158
3161
|
defaultOptions: []
|
|
3159
3162
|
});
|
|
3160
|
-
function
|
|
3163
|
+
function create48(context) {
|
|
3161
3164
|
const { importSource } = getSettingsFromContext(context);
|
|
3162
3165
|
return {
|
|
3163
3166
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3207,10 +3210,10 @@ var prefer_read_only_props_default = createRule({
|
|
|
3207
3210
|
schema: []
|
|
3208
3211
|
},
|
|
3209
3212
|
name: RULE_NAME49,
|
|
3210
|
-
create:
|
|
3213
|
+
create: create49,
|
|
3211
3214
|
defaultOptions: []
|
|
3212
3215
|
});
|
|
3213
|
-
function
|
|
3216
|
+
function create49(context) {
|
|
3214
3217
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3215
3218
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3216
3219
|
return {
|
|
@@ -3223,7 +3226,7 @@ function create47(context) {
|
|
|
3223
3226
|
continue;
|
|
3224
3227
|
}
|
|
3225
3228
|
const propsType = getConstrainedTypeAtLocation(services, props);
|
|
3226
|
-
if (
|
|
3229
|
+
if (isTypeReadonlyLoose(services, propsType)) {
|
|
3227
3230
|
continue;
|
|
3228
3231
|
}
|
|
3229
3232
|
context.report({ messageId: "preferReadOnlyProps", node: props });
|
|
@@ -3231,6 +3234,15 @@ function create47(context) {
|
|
|
3231
3234
|
}
|
|
3232
3235
|
};
|
|
3233
3236
|
}
|
|
3237
|
+
function isTypeReadonlyLoose(services, type) {
|
|
3238
|
+
if (isTypeReadonly(services.program, type)) return true;
|
|
3239
|
+
try {
|
|
3240
|
+
const im = getTypeImmutability(services.program, type);
|
|
3241
|
+
return isUnknown(im) || isImmutable(im) || isReadonlyShallow(im) || isReadonlyDeep(im);
|
|
3242
|
+
} catch {
|
|
3243
|
+
return true;
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3234
3246
|
var RULE_NAME50 = "prefer-shorthand-boolean";
|
|
3235
3247
|
var RULE_FEATURES49 = [
|
|
3236
3248
|
"FIX"
|
|
@@ -3249,10 +3261,10 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3249
3261
|
schema: []
|
|
3250
3262
|
},
|
|
3251
3263
|
name: RULE_NAME50,
|
|
3252
|
-
create:
|
|
3264
|
+
create: create50,
|
|
3253
3265
|
defaultOptions: []
|
|
3254
3266
|
});
|
|
3255
|
-
function
|
|
3267
|
+
function create50(context) {
|
|
3256
3268
|
return {
|
|
3257
3269
|
JSXAttribute(node) {
|
|
3258
3270
|
const { value } = node;
|
|
@@ -3290,10 +3302,10 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3290
3302
|
schema: []
|
|
3291
3303
|
},
|
|
3292
3304
|
name: RULE_NAME51,
|
|
3293
|
-
create:
|
|
3305
|
+
create: create51,
|
|
3294
3306
|
defaultOptions: []
|
|
3295
3307
|
});
|
|
3296
|
-
function
|
|
3308
|
+
function create51(context) {
|
|
3297
3309
|
return {
|
|
3298
3310
|
JSXElement(node) {
|
|
3299
3311
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3333,10 +3345,10 @@ var use_jsx_vars_default = createRule({
|
|
|
3333
3345
|
schema: []
|
|
3334
3346
|
},
|
|
3335
3347
|
name: RULE_NAME52,
|
|
3336
|
-
create:
|
|
3348
|
+
create: create52,
|
|
3337
3349
|
defaultOptions: []
|
|
3338
3350
|
});
|
|
3339
|
-
function
|
|
3351
|
+
function create52(context) {
|
|
3340
3352
|
return {
|
|
3341
3353
|
JSXOpeningElement(node) {
|
|
3342
3354
|
switch (node.name.type) {
|