eslint-plugin-react-x 1.18.1-beta.1 → 1.18.1-beta.3
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/README.md +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +182 -75
- package/dist/index.mjs +181 -74
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var JSX8 = require('@eslint-react/jsx');
|
|
4
4
|
var tools = require('@eslint-react/tools');
|
|
5
5
|
var shared = require('@eslint-react/shared');
|
|
6
6
|
var AST11 = require('@eslint-react/ast');
|
|
7
7
|
var core = require('@eslint-react/core');
|
|
8
8
|
var types = require('@typescript-eslint/types');
|
|
9
9
|
var tsPattern = require('ts-pattern');
|
|
10
|
-
var VAR = require('@eslint-react/var');
|
|
11
10
|
var compareVersions = require('compare-versions');
|
|
11
|
+
var VAR = require('@eslint-react/var');
|
|
12
12
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
13
13
|
var utils = require('@typescript-eslint/utils');
|
|
14
14
|
var ts = require('typescript');
|
|
@@ -34,14 +34,14 @@ function _interopNamespace(e) {
|
|
|
34
34
|
return Object.freeze(n);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
var
|
|
37
|
+
var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
|
|
38
38
|
var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
39
39
|
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
40
40
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
41
41
|
|
|
42
42
|
// package.json
|
|
43
43
|
var name = "eslint-plugin-react-x";
|
|
44
|
-
var version = "1.18.1-beta.
|
|
44
|
+
var version = "1.18.1-beta.3";
|
|
45
45
|
var createRule = shared.createRuleForPlugin("x");
|
|
46
46
|
|
|
47
47
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -65,7 +65,7 @@ var avoid_shorthand_boolean_default = createRule({
|
|
|
65
65
|
messageId: "avoidShorthandBoolean",
|
|
66
66
|
node,
|
|
67
67
|
data: {
|
|
68
|
-
propName:
|
|
68
|
+
propName: JSX8__namespace.getPropName(node)
|
|
69
69
|
},
|
|
70
70
|
fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
|
|
71
71
|
});
|
|
@@ -568,7 +568,7 @@ var no_children_prop_default = createRule({
|
|
|
568
568
|
return {
|
|
569
569
|
JSXElement(node) {
|
|
570
570
|
const initialScope = context.sourceCode.getScope(node);
|
|
571
|
-
const prop =
|
|
571
|
+
const prop = JSX8__namespace.getProp(node.openingElement.attributes, "children", initialScope);
|
|
572
572
|
const reportDescriptor = tools.O.map(prop, (prop2) => ({ messageId: "noChildrenProp", node: prop2 }));
|
|
573
573
|
tools.O.map(reportDescriptor, context.report);
|
|
574
574
|
}
|
|
@@ -868,7 +868,48 @@ var no_component_will_update_default = createRule({
|
|
|
868
868
|
},
|
|
869
869
|
defaultOptions: []
|
|
870
870
|
});
|
|
871
|
-
var RULE_NAME21 = "no-
|
|
871
|
+
var RULE_NAME21 = "no-context-provider";
|
|
872
|
+
var no_context_provider_default = createRule({
|
|
873
|
+
meta: {
|
|
874
|
+
type: "problem",
|
|
875
|
+
docs: {
|
|
876
|
+
description: "disallow the use of '<Context.Provider>'"
|
|
877
|
+
},
|
|
878
|
+
fixable: "code",
|
|
879
|
+
messages: {
|
|
880
|
+
noContextProvider: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'."
|
|
881
|
+
},
|
|
882
|
+
schema: []
|
|
883
|
+
},
|
|
884
|
+
name: RULE_NAME21,
|
|
885
|
+
create(context) {
|
|
886
|
+
if (!context.sourceCode.text.includes(".Provider")) return {};
|
|
887
|
+
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
888
|
+
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
889
|
+
return {
|
|
890
|
+
JSXElement(node) {
|
|
891
|
+
const elementName = JSX8__namespace.getElementName(node.openingElement);
|
|
892
|
+
if (!elementName.endsWith(".Provider")) return;
|
|
893
|
+
context.report({
|
|
894
|
+
messageId: "noContextProvider",
|
|
895
|
+
node,
|
|
896
|
+
fix(fixer) {
|
|
897
|
+
const providerName = elementName.replace(/\.Provider$/, "");
|
|
898
|
+
const openingElement = node.openingElement;
|
|
899
|
+
const closingElement = node.closingElement;
|
|
900
|
+
if (!closingElement) return fixer.replaceText(openingElement.name, providerName);
|
|
901
|
+
return [
|
|
902
|
+
fixer.replaceText(openingElement.name, providerName),
|
|
903
|
+
fixer.replaceText(closingElement.name, providerName)
|
|
904
|
+
];
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
},
|
|
910
|
+
defaultOptions: []
|
|
911
|
+
});
|
|
912
|
+
var RULE_NAME22 = "no-create-ref";
|
|
872
913
|
var no_create_ref_default = createRule({
|
|
873
914
|
meta: {
|
|
874
915
|
type: "problem",
|
|
@@ -880,7 +921,7 @@ var no_create_ref_default = createRule({
|
|
|
880
921
|
},
|
|
881
922
|
schema: []
|
|
882
923
|
},
|
|
883
|
-
name:
|
|
924
|
+
name: RULE_NAME22,
|
|
884
925
|
create(context) {
|
|
885
926
|
return {
|
|
886
927
|
CallExpression(node) {
|
|
@@ -892,7 +933,7 @@ var no_create_ref_default = createRule({
|
|
|
892
933
|
},
|
|
893
934
|
defaultOptions: []
|
|
894
935
|
});
|
|
895
|
-
var
|
|
936
|
+
var RULE_NAME23 = "no-default-props";
|
|
896
937
|
var no_default_props_default = createRule({
|
|
897
938
|
meta: {
|
|
898
939
|
type: "problem",
|
|
@@ -904,7 +945,7 @@ var no_default_props_default = createRule({
|
|
|
904
945
|
},
|
|
905
946
|
schema: []
|
|
906
947
|
},
|
|
907
|
-
name:
|
|
948
|
+
name: RULE_NAME23,
|
|
908
949
|
create(context) {
|
|
909
950
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
910
951
|
return {
|
|
@@ -931,7 +972,7 @@ var no_default_props_default = createRule({
|
|
|
931
972
|
},
|
|
932
973
|
defaultOptions: []
|
|
933
974
|
});
|
|
934
|
-
var
|
|
975
|
+
var RULE_NAME24 = "no-direct-mutation-state";
|
|
935
976
|
function getName2(node) {
|
|
936
977
|
if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
|
|
937
978
|
return getName2(node.expression);
|
|
@@ -965,7 +1006,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
965
1006
|
},
|
|
966
1007
|
schema: []
|
|
967
1008
|
},
|
|
968
|
-
name:
|
|
1009
|
+
name: RULE_NAME24,
|
|
969
1010
|
create(context) {
|
|
970
1011
|
function getReportDescriptor(node) {
|
|
971
1012
|
if (!isAssignmentToThisState(node)) return tools.O.none();
|
|
@@ -989,7 +1030,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
989
1030
|
},
|
|
990
1031
|
defaultOptions: []
|
|
991
1032
|
});
|
|
992
|
-
var
|
|
1033
|
+
var RULE_NAME25 = "no-duplicate-key";
|
|
993
1034
|
var no_duplicate_key_default = createRule({
|
|
994
1035
|
meta: {
|
|
995
1036
|
type: "problem",
|
|
@@ -1001,7 +1042,7 @@ var no_duplicate_key_default = createRule({
|
|
|
1001
1042
|
},
|
|
1002
1043
|
schema: []
|
|
1003
1044
|
},
|
|
1004
|
-
name:
|
|
1045
|
+
name: RULE_NAME25,
|
|
1005
1046
|
create(context) {
|
|
1006
1047
|
const isWithinChildrenToArrayRef = tools.MutRef.make(false);
|
|
1007
1048
|
function isKeyEqual(a, b) {
|
|
@@ -1011,7 +1052,7 @@ var no_duplicate_key_default = createRule({
|
|
|
1011
1052
|
if (node.type !== types.AST_NODE_TYPES.JSXElement) return tools.O.none();
|
|
1012
1053
|
const initialScope = context.sourceCode.getScope(node);
|
|
1013
1054
|
return tools.F.pipe(
|
|
1014
|
-
|
|
1055
|
+
JSX8__namespace.findPropInAttributes(node.openingElement.attributes, initialScope)("key"),
|
|
1015
1056
|
tools.O.flatMap((k) => "value" in k ? tools.O.fromNullable(k.value) : tools.O.none()),
|
|
1016
1057
|
tools.O.flatMap((v) => {
|
|
1017
1058
|
return isKeyEqual(v, v) ? tools.O.some({
|
|
@@ -1118,19 +1159,20 @@ var no_duplicate_key_default = createRule({
|
|
|
1118
1159
|
},
|
|
1119
1160
|
defaultOptions: []
|
|
1120
1161
|
});
|
|
1121
|
-
var
|
|
1162
|
+
var RULE_NAME26 = "no-forward-ref";
|
|
1122
1163
|
var no_forward_ref_default = createRule({
|
|
1123
1164
|
meta: {
|
|
1124
1165
|
type: "problem",
|
|
1125
1166
|
docs: {
|
|
1126
1167
|
description: "disallow the use of 'forwardRef'"
|
|
1127
1168
|
},
|
|
1169
|
+
fixable: "code",
|
|
1128
1170
|
messages: {
|
|
1129
1171
|
noForwardRef: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead."
|
|
1130
1172
|
},
|
|
1131
1173
|
schema: []
|
|
1132
1174
|
},
|
|
1133
|
-
name:
|
|
1175
|
+
name: RULE_NAME26,
|
|
1134
1176
|
create(context) {
|
|
1135
1177
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
1136
1178
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1140,14 +1182,78 @@ var no_forward_ref_default = createRule({
|
|
|
1140
1182
|
if (!core.isForwardRefCall(node, context)) return;
|
|
1141
1183
|
context.report({
|
|
1142
1184
|
messageId: "noForwardRef",
|
|
1143
|
-
node
|
|
1185
|
+
node,
|
|
1186
|
+
fix: getFix(node, context)
|
|
1144
1187
|
});
|
|
1145
1188
|
}
|
|
1146
1189
|
};
|
|
1147
1190
|
},
|
|
1148
1191
|
defaultOptions: []
|
|
1149
1192
|
});
|
|
1150
|
-
|
|
1193
|
+
function getFix(node, context) {
|
|
1194
|
+
return (fixer) => {
|
|
1195
|
+
const [componentNode] = node.arguments;
|
|
1196
|
+
if (!componentNode || !AST11__namespace.isFunction(componentNode)) return [];
|
|
1197
|
+
return [
|
|
1198
|
+
fixer.removeRange([node.range[0], componentNode.range[0]]),
|
|
1199
|
+
fixer.removeRange([componentNode.range[1], node.range[1]]),
|
|
1200
|
+
...getParamsFixes(componentNode, context, node.typeArguments?.params ?? [], fixer)
|
|
1201
|
+
];
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
function getParamsFixes(node, context, typeArguments, fixer) {
|
|
1205
|
+
const [arg0, arg1] = node.params;
|
|
1206
|
+
const [typeArg0, typeArg1] = typeArguments;
|
|
1207
|
+
if (arg0?.type !== types.AST_NODE_TYPES.Identifier) return [];
|
|
1208
|
+
if (!arg1) {
|
|
1209
|
+
return [fixer.replaceText(
|
|
1210
|
+
arg0,
|
|
1211
|
+
[
|
|
1212
|
+
"{",
|
|
1213
|
+
"ref,",
|
|
1214
|
+
`...${arg0.name}`,
|
|
1215
|
+
"}"
|
|
1216
|
+
].join(" ")
|
|
1217
|
+
)];
|
|
1218
|
+
}
|
|
1219
|
+
if (arg1.type !== types.AST_NODE_TYPES.Identifier) return [];
|
|
1220
|
+
if (!typeArg0 || !typeArg1) {
|
|
1221
|
+
return [
|
|
1222
|
+
fixer.replaceText(
|
|
1223
|
+
arg0,
|
|
1224
|
+
[
|
|
1225
|
+
"{",
|
|
1226
|
+
arg1.name === "ref" ? `ref,` : `ref: ${arg1.name},`,
|
|
1227
|
+
`...${arg0.name}`,
|
|
1228
|
+
"}"
|
|
1229
|
+
].join(" ")
|
|
1230
|
+
),
|
|
1231
|
+
fixer.remove(arg1),
|
|
1232
|
+
fixer.removeRange([arg0.range[1], arg1.range[0]])
|
|
1233
|
+
];
|
|
1234
|
+
}
|
|
1235
|
+
const getText = (node2) => context.sourceCode.getText(node2);
|
|
1236
|
+
return [
|
|
1237
|
+
fixer.replaceText(
|
|
1238
|
+
arg0,
|
|
1239
|
+
[
|
|
1240
|
+
"{",
|
|
1241
|
+
arg1.name === "ref" ? `ref,` : `ref: ${arg1.name},`,
|
|
1242
|
+
`...${arg0.name}`,
|
|
1243
|
+
"}:",
|
|
1244
|
+
getText(typeArg1),
|
|
1245
|
+
"&",
|
|
1246
|
+
"{",
|
|
1247
|
+
`ref:`,
|
|
1248
|
+
`React.RefObject<${getText(typeArg0)}>`,
|
|
1249
|
+
"}"
|
|
1250
|
+
].join(" ")
|
|
1251
|
+
),
|
|
1252
|
+
fixer.remove(arg1),
|
|
1253
|
+
fixer.removeRange([arg0.range[1], arg1.range[0]])
|
|
1254
|
+
];
|
|
1255
|
+
}
|
|
1256
|
+
var RULE_NAME27 = "no-implicit-key";
|
|
1151
1257
|
var no_implicit_key_default = createRule({
|
|
1152
1258
|
meta: {
|
|
1153
1259
|
type: "problem",
|
|
@@ -1159,11 +1265,11 @@ var no_implicit_key_default = createRule({
|
|
|
1159
1265
|
},
|
|
1160
1266
|
schema: []
|
|
1161
1267
|
},
|
|
1162
|
-
name:
|
|
1268
|
+
name: RULE_NAME27,
|
|
1163
1269
|
create(context) {
|
|
1164
1270
|
function getReportDescriptor(node) {
|
|
1165
1271
|
const initialScope = context.sourceCode.getScope(node);
|
|
1166
|
-
const keyPropFound =
|
|
1272
|
+
const keyPropFound = JSX8__namespace.findPropInAttributes(node.attributes, initialScope)("key");
|
|
1167
1273
|
const keyPropOnElement = node.attributes.some(
|
|
1168
1274
|
(n) => AST11__namespace.is(types.AST_NODE_TYPES.JSXAttribute)(n) && n.name.name === "key"
|
|
1169
1275
|
);
|
|
@@ -1202,7 +1308,7 @@ function isTrueLiteralType(type) {
|
|
|
1202
1308
|
function unionTypeParts(type) {
|
|
1203
1309
|
return isUnionType(type) ? type.types : [type];
|
|
1204
1310
|
}
|
|
1205
|
-
var
|
|
1311
|
+
var RULE_NAME28 = "no-leaked-conditional-rendering";
|
|
1206
1312
|
var tsHelpers = {
|
|
1207
1313
|
isAnyType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.TypeParameter | ts__default.default.TypeFlags.Any),
|
|
1208
1314
|
isBigIntType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.BigIntLike),
|
|
@@ -1306,7 +1412,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1306
1412
|
},
|
|
1307
1413
|
schema: []
|
|
1308
1414
|
},
|
|
1309
|
-
name:
|
|
1415
|
+
name: RULE_NAME28,
|
|
1310
1416
|
create(context) {
|
|
1311
1417
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1312
1418
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1363,7 +1469,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1363
1469
|
},
|
|
1364
1470
|
defaultOptions: []
|
|
1365
1471
|
});
|
|
1366
|
-
var
|
|
1472
|
+
var RULE_NAME29 = "no-missing-component-display-name";
|
|
1367
1473
|
var no_missing_component_display_name_default = createRule({
|
|
1368
1474
|
meta: {
|
|
1369
1475
|
type: "problem",
|
|
@@ -1375,7 +1481,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1375
1481
|
},
|
|
1376
1482
|
schema: []
|
|
1377
1483
|
},
|
|
1378
|
-
name:
|
|
1484
|
+
name: RULE_NAME29,
|
|
1379
1485
|
create(context) {
|
|
1380
1486
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1381
1487
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -1399,7 +1505,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1399
1505
|
},
|
|
1400
1506
|
defaultOptions: []
|
|
1401
1507
|
});
|
|
1402
|
-
var
|
|
1508
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1403
1509
|
var no_missing_key_default = createRule({
|
|
1404
1510
|
meta: {
|
|
1405
1511
|
type: "problem",
|
|
@@ -1412,14 +1518,14 @@ var no_missing_key_default = createRule({
|
|
|
1412
1518
|
},
|
|
1413
1519
|
schema: []
|
|
1414
1520
|
},
|
|
1415
|
-
name:
|
|
1521
|
+
name: RULE_NAME30,
|
|
1416
1522
|
create(context) {
|
|
1417
1523
|
const isWithinChildrenToArrayRef = tools.MutRef.make(false);
|
|
1418
1524
|
function checkIteratorElement(node) {
|
|
1419
1525
|
switch (node.type) {
|
|
1420
1526
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1421
1527
|
const initialScope = context.sourceCode.getScope(node);
|
|
1422
|
-
if (!
|
|
1528
|
+
if (!JSX8__namespace.hasProp(node.openingElement.attributes, "key", initialScope)) {
|
|
1423
1529
|
return tools.O.some({
|
|
1424
1530
|
messageId: "noMissingKey",
|
|
1425
1531
|
node
|
|
@@ -1468,7 +1574,7 @@ var no_missing_key_default = createRule({
|
|
|
1468
1574
|
if (elements.length === 0) return;
|
|
1469
1575
|
const initialScope = context.sourceCode.getScope(node);
|
|
1470
1576
|
for (const element of elements) {
|
|
1471
|
-
if (!
|
|
1577
|
+
if (!JSX8__namespace.hasProp(element.openingElement.attributes, "key", initialScope)) {
|
|
1472
1578
|
context.report({
|
|
1473
1579
|
messageId: "noMissingKey",
|
|
1474
1580
|
node: element
|
|
@@ -1516,7 +1622,7 @@ var no_missing_key_default = createRule({
|
|
|
1516
1622
|
},
|
|
1517
1623
|
defaultOptions: []
|
|
1518
1624
|
});
|
|
1519
|
-
var
|
|
1625
|
+
var RULE_NAME31 = "no-nested-components";
|
|
1520
1626
|
var no_nested_components_default = createRule({
|
|
1521
1627
|
meta: {
|
|
1522
1628
|
type: "problem",
|
|
@@ -1529,7 +1635,7 @@ var no_nested_components_default = createRule({
|
|
|
1529
1635
|
},
|
|
1530
1636
|
schema: []
|
|
1531
1637
|
},
|
|
1532
|
-
name:
|
|
1638
|
+
name: RULE_NAME31,
|
|
1533
1639
|
create(context) {
|
|
1534
1640
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefinedLiteral | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1535
1641
|
const collector = core.useComponentCollector(context, hint);
|
|
@@ -1551,7 +1657,7 @@ var no_nested_components_default = createRule({
|
|
|
1551
1657
|
if (tools.O.isNone(componentName)) continue;
|
|
1552
1658
|
const name2 = componentName.value;
|
|
1553
1659
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
1554
|
-
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || tools.O.isSome(
|
|
1660
|
+
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || tools.O.isSome(JSX8__namespace.traverseUpProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer));
|
|
1555
1661
|
if (isInsideJSXPropValue) {
|
|
1556
1662
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1557
1663
|
context.report({
|
|
@@ -1613,7 +1719,7 @@ var no_nested_components_default = createRule({
|
|
|
1613
1719
|
},
|
|
1614
1720
|
defaultOptions: []
|
|
1615
1721
|
});
|
|
1616
|
-
var
|
|
1722
|
+
var RULE_NAME32 = "no-prop-types";
|
|
1617
1723
|
var no_prop_types_default = createRule({
|
|
1618
1724
|
meta: {
|
|
1619
1725
|
type: "problem",
|
|
@@ -1625,7 +1731,7 @@ var no_prop_types_default = createRule({
|
|
|
1625
1731
|
},
|
|
1626
1732
|
schema: []
|
|
1627
1733
|
},
|
|
1628
|
-
name:
|
|
1734
|
+
name: RULE_NAME32,
|
|
1629
1735
|
create(context) {
|
|
1630
1736
|
if (!context.sourceCode.text.includes("propTypes")) return {};
|
|
1631
1737
|
return {
|
|
@@ -1652,7 +1758,7 @@ var no_prop_types_default = createRule({
|
|
|
1652
1758
|
},
|
|
1653
1759
|
defaultOptions: []
|
|
1654
1760
|
});
|
|
1655
|
-
var
|
|
1761
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
1656
1762
|
function isShouldComponentUpdate(node) {
|
|
1657
1763
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
1658
1764
|
}
|
|
@@ -1667,7 +1773,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1667
1773
|
},
|
|
1668
1774
|
schema: []
|
|
1669
1775
|
},
|
|
1670
|
-
name:
|
|
1776
|
+
name: RULE_NAME33,
|
|
1671
1777
|
create(context) {
|
|
1672
1778
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
1673
1779
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1695,7 +1801,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1695
1801
|
},
|
|
1696
1802
|
defaultOptions: []
|
|
1697
1803
|
});
|
|
1698
|
-
var
|
|
1804
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
1699
1805
|
function isComponentDidMount(node) {
|
|
1700
1806
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
1701
1807
|
}
|
|
@@ -1710,7 +1816,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1710
1816
|
},
|
|
1711
1817
|
schema: []
|
|
1712
1818
|
},
|
|
1713
|
-
name:
|
|
1819
|
+
name: RULE_NAME34,
|
|
1714
1820
|
create(context) {
|
|
1715
1821
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
1716
1822
|
function getReportDescriptor(node) {
|
|
@@ -1738,7 +1844,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1738
1844
|
},
|
|
1739
1845
|
defaultOptions: []
|
|
1740
1846
|
});
|
|
1741
|
-
var
|
|
1847
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
1742
1848
|
function isComponentDidUpdate(node) {
|
|
1743
1849
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
1744
1850
|
}
|
|
@@ -1753,7 +1859,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1753
1859
|
},
|
|
1754
1860
|
schema: []
|
|
1755
1861
|
},
|
|
1756
|
-
name:
|
|
1862
|
+
name: RULE_NAME35,
|
|
1757
1863
|
create(context) {
|
|
1758
1864
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
1759
1865
|
function getReportDescriptor(node) {
|
|
@@ -1781,7 +1887,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1781
1887
|
},
|
|
1782
1888
|
defaultOptions: []
|
|
1783
1889
|
});
|
|
1784
|
-
var
|
|
1890
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
1785
1891
|
function isComponentWillUpdate3(node) {
|
|
1786
1892
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
1787
1893
|
}
|
|
@@ -1796,7 +1902,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1796
1902
|
},
|
|
1797
1903
|
schema: []
|
|
1798
1904
|
},
|
|
1799
|
-
name:
|
|
1905
|
+
name: RULE_NAME36,
|
|
1800
1906
|
create(context) {
|
|
1801
1907
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1802
1908
|
function getReportDescriptor(node) {
|
|
@@ -1824,7 +1930,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1824
1930
|
},
|
|
1825
1931
|
defaultOptions: []
|
|
1826
1932
|
});
|
|
1827
|
-
var
|
|
1933
|
+
var RULE_NAME37 = "no-string-refs";
|
|
1828
1934
|
function containsStringLiteral({ value }) {
|
|
1829
1935
|
return value?.type === types.AST_NODE_TYPES.Literal && tools.isString(value.value);
|
|
1830
1936
|
}
|
|
@@ -1844,7 +1950,7 @@ var no_string_refs_default = createRule({
|
|
|
1844
1950
|
},
|
|
1845
1951
|
schema: []
|
|
1846
1952
|
},
|
|
1847
|
-
name:
|
|
1953
|
+
name: RULE_NAME37,
|
|
1848
1954
|
create(context) {
|
|
1849
1955
|
return {
|
|
1850
1956
|
JSXAttribute(node) {
|
|
@@ -1860,7 +1966,7 @@ var no_string_refs_default = createRule({
|
|
|
1860
1966
|
},
|
|
1861
1967
|
defaultOptions: []
|
|
1862
1968
|
});
|
|
1863
|
-
var
|
|
1969
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
1864
1970
|
function isUnsafeComponentWillMount(node) {
|
|
1865
1971
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
1866
1972
|
}
|
|
@@ -1875,7 +1981,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
1875
1981
|
},
|
|
1876
1982
|
schema: []
|
|
1877
1983
|
},
|
|
1878
|
-
name:
|
|
1984
|
+
name: RULE_NAME38,
|
|
1879
1985
|
create(context) {
|
|
1880
1986
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
1881
1987
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1899,7 +2005,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
1899
2005
|
},
|
|
1900
2006
|
defaultOptions: []
|
|
1901
2007
|
});
|
|
1902
|
-
var
|
|
2008
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
1903
2009
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
1904
2010
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
1905
2011
|
}
|
|
@@ -1914,7 +2020,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
1914
2020
|
},
|
|
1915
2021
|
schema: []
|
|
1916
2022
|
},
|
|
1917
|
-
name:
|
|
2023
|
+
name: RULE_NAME39,
|
|
1918
2024
|
create(context) {
|
|
1919
2025
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
1920
2026
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1938,7 +2044,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
1938
2044
|
},
|
|
1939
2045
|
defaultOptions: []
|
|
1940
2046
|
});
|
|
1941
|
-
var
|
|
2047
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
1942
2048
|
function isUnsafeComponentWillUpdate(node) {
|
|
1943
2049
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
1944
2050
|
}
|
|
@@ -1953,7 +2059,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
1953
2059
|
},
|
|
1954
2060
|
schema: []
|
|
1955
2061
|
},
|
|
1956
|
-
name:
|
|
2062
|
+
name: RULE_NAME40,
|
|
1957
2063
|
create(context) {
|
|
1958
2064
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
1959
2065
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1977,7 +2083,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
1977
2083
|
},
|
|
1978
2084
|
defaultOptions: []
|
|
1979
2085
|
});
|
|
1980
|
-
var
|
|
2086
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
1981
2087
|
var no_unstable_context_value_default = createRule({
|
|
1982
2088
|
meta: {
|
|
1983
2089
|
type: "problem",
|
|
@@ -1991,7 +2097,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
1991
2097
|
},
|
|
1992
2098
|
schema: []
|
|
1993
2099
|
},
|
|
1994
|
-
name:
|
|
2100
|
+
name: RULE_NAME41,
|
|
1995
2101
|
create(context) {
|
|
1996
2102
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
1997
2103
|
const possibleValueConstructions = /* @__PURE__ */ new Map();
|
|
@@ -2044,7 +2150,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2044
2150
|
},
|
|
2045
2151
|
defaultOptions: []
|
|
2046
2152
|
});
|
|
2047
|
-
var
|
|
2153
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2048
2154
|
var no_unstable_default_props_default = createRule({
|
|
2049
2155
|
meta: {
|
|
2050
2156
|
type: "problem",
|
|
@@ -2056,7 +2162,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2056
2162
|
},
|
|
2057
2163
|
schema: []
|
|
2058
2164
|
},
|
|
2059
|
-
name:
|
|
2165
|
+
name: RULE_NAME42,
|
|
2060
2166
|
create(context) {
|
|
2061
2167
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2062
2168
|
const possibleDestructuringDeclarators = /* @__PURE__ */ new WeakMap();
|
|
@@ -2109,7 +2215,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2109
2215
|
},
|
|
2110
2216
|
defaultOptions: []
|
|
2111
2217
|
});
|
|
2112
|
-
var
|
|
2218
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2113
2219
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2114
2220
|
"componentDidCatch",
|
|
2115
2221
|
"componentDidMount",
|
|
@@ -2153,7 +2259,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2153
2259
|
},
|
|
2154
2260
|
schema: []
|
|
2155
2261
|
},
|
|
2156
|
-
name:
|
|
2262
|
+
name: RULE_NAME43,
|
|
2157
2263
|
create(context) {
|
|
2158
2264
|
const classStack = [];
|
|
2159
2265
|
const methodStack = [];
|
|
@@ -2236,7 +2342,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2236
2342
|
},
|
|
2237
2343
|
defaultOptions: []
|
|
2238
2344
|
});
|
|
2239
|
-
var
|
|
2345
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2240
2346
|
function getName4(node) {
|
|
2241
2347
|
if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
|
|
2242
2348
|
return getName4(node.expression);
|
|
@@ -2276,7 +2382,7 @@ var no_unused_state_default = createRule({
|
|
|
2276
2382
|
},
|
|
2277
2383
|
schema: []
|
|
2278
2384
|
},
|
|
2279
|
-
name:
|
|
2385
|
+
name: RULE_NAME44,
|
|
2280
2386
|
create(context) {
|
|
2281
2387
|
const classStack = [];
|
|
2282
2388
|
const methodStack = [];
|
|
@@ -2377,21 +2483,21 @@ var no_unused_state_default = createRule({
|
|
|
2377
2483
|
},
|
|
2378
2484
|
defaultOptions: []
|
|
2379
2485
|
});
|
|
2380
|
-
var
|
|
2486
|
+
var RULE_NAME45 = "no-useless-fragment";
|
|
2381
2487
|
function check(node, context, allowExpressions) {
|
|
2382
2488
|
const initialScope = context.sourceCode.getScope(node);
|
|
2383
|
-
if (
|
|
2384
|
-
if (
|
|
2489
|
+
if (JSX8__namespace.isKeyedElement(node, initialScope)) return;
|
|
2490
|
+
if (JSX8__namespace.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node });
|
|
2385
2491
|
if (node.children.length === 0) return context.report({ messageId: "noUselessFragment", node });
|
|
2386
2492
|
const isChildren = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
2387
2493
|
const [firstChildren] = node.children;
|
|
2388
|
-
if (allowExpressions && node.children.length === 1 &&
|
|
2494
|
+
if (allowExpressions && node.children.length === 1 && JSX8__namespace.isLiteral(firstChildren) && !isChildren) return;
|
|
2389
2495
|
if (!allowExpressions && isChildren) {
|
|
2390
2496
|
return context.report({ messageId: "noUselessFragment", node });
|
|
2391
2497
|
} else if (!allowExpressions && !isChildren && node.children.length === 1) {
|
|
2392
2498
|
return context.report({ messageId: "noUselessFragment", node });
|
|
2393
2499
|
}
|
|
2394
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
2500
|
+
const nonPaddingChildren = node.children.filter((child) => !JSX8__namespace.isPaddingSpaces(child));
|
|
2395
2501
|
if (nonPaddingChildren.length > 1) return;
|
|
2396
2502
|
if (nonPaddingChildren.length === 0) return context.report({ messageId: "noUselessFragment", node });
|
|
2397
2503
|
const [first] = nonPaddingChildren;
|
|
@@ -2419,7 +2525,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2419
2525
|
}
|
|
2420
2526
|
}]
|
|
2421
2527
|
},
|
|
2422
|
-
name:
|
|
2528
|
+
name: RULE_NAME45,
|
|
2423
2529
|
create(context, [option]) {
|
|
2424
2530
|
const { allowExpressions = true } = option;
|
|
2425
2531
|
return {
|
|
@@ -2436,7 +2542,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2436
2542
|
allowExpressions: true
|
|
2437
2543
|
}]
|
|
2438
2544
|
});
|
|
2439
|
-
var
|
|
2545
|
+
var RULE_NAME46 = "prefer-destructuring-assignment";
|
|
2440
2546
|
function isMemberExpressionWithObjectName(node) {
|
|
2441
2547
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
2442
2548
|
}
|
|
@@ -2451,7 +2557,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2451
2557
|
},
|
|
2452
2558
|
schema: []
|
|
2453
2559
|
},
|
|
2454
|
-
name:
|
|
2560
|
+
name: RULE_NAME46,
|
|
2455
2561
|
create(context) {
|
|
2456
2562
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2457
2563
|
const memberExpressionWithNames = [];
|
|
@@ -2506,7 +2612,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2506
2612
|
},
|
|
2507
2613
|
defaultOptions: []
|
|
2508
2614
|
});
|
|
2509
|
-
var
|
|
2615
|
+
var RULE_NAME47 = "prefer-react-namespace-import";
|
|
2510
2616
|
var prefer_react_namespace_import_default = createRule({
|
|
2511
2617
|
meta: {
|
|
2512
2618
|
type: "problem",
|
|
@@ -2519,7 +2625,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2519
2625
|
},
|
|
2520
2626
|
schema: []
|
|
2521
2627
|
},
|
|
2522
|
-
name:
|
|
2628
|
+
name: RULE_NAME47,
|
|
2523
2629
|
create(context) {
|
|
2524
2630
|
const importSource = shared.decodeSettings(context.settings).importSource ?? "react";
|
|
2525
2631
|
return {
|
|
@@ -2555,7 +2661,7 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
2555
2661
|
},
|
|
2556
2662
|
defaultOptions: []
|
|
2557
2663
|
});
|
|
2558
|
-
var
|
|
2664
|
+
var RULE_NAME48 = "prefer-read-only-props";
|
|
2559
2665
|
function isReadonlyType(type, services) {
|
|
2560
2666
|
try {
|
|
2561
2667
|
const im = isImmutableType.getTypeImmutability(services.program, type);
|
|
@@ -2575,7 +2681,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
2575
2681
|
},
|
|
2576
2682
|
schema: []
|
|
2577
2683
|
},
|
|
2578
|
-
name:
|
|
2684
|
+
name: RULE_NAME48,
|
|
2579
2685
|
create(context) {
|
|
2580
2686
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
2581
2687
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2595,7 +2701,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
2595
2701
|
},
|
|
2596
2702
|
defaultOptions: []
|
|
2597
2703
|
});
|
|
2598
|
-
var
|
|
2704
|
+
var RULE_NAME49 = "prefer-shorthand-boolean";
|
|
2599
2705
|
var prefer_shorthand_boolean_default = createRule({
|
|
2600
2706
|
meta: {
|
|
2601
2707
|
type: "problem",
|
|
@@ -2608,11 +2714,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2608
2714
|
},
|
|
2609
2715
|
schema: []
|
|
2610
2716
|
},
|
|
2611
|
-
name:
|
|
2717
|
+
name: RULE_NAME49,
|
|
2612
2718
|
create(context) {
|
|
2613
2719
|
function getReportDescriptor(node) {
|
|
2614
2720
|
const { value } = node;
|
|
2615
|
-
const propName =
|
|
2721
|
+
const propName = JSX8__namespace.getPropName(node);
|
|
2616
2722
|
const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
|
|
2617
2723
|
if (!hasValueTrue) return tools.O.none();
|
|
2618
2724
|
return tools.O.some({
|
|
@@ -2630,7 +2736,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2630
2736
|
},
|
|
2631
2737
|
defaultOptions: []
|
|
2632
2738
|
});
|
|
2633
|
-
var
|
|
2739
|
+
var RULE_NAME50 = "prefer-shorthand-fragment";
|
|
2634
2740
|
var prefer_shorthand_fragment_default = createRule({
|
|
2635
2741
|
meta: {
|
|
2636
2742
|
type: "problem",
|
|
@@ -2642,7 +2748,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
2642
2748
|
},
|
|
2643
2749
|
schema: []
|
|
2644
2750
|
},
|
|
2645
|
-
name:
|
|
2751
|
+
name: RULE_NAME50,
|
|
2646
2752
|
create(context) {
|
|
2647
2753
|
function getReportDescriptor(node) {
|
|
2648
2754
|
if (!core.isFragmentElement(node, context)) return tools.O.none();
|
|
@@ -2695,6 +2801,7 @@ var src_default = {
|
|
|
2695
2801
|
"no-component-will-mount": no_component_will_mount_default,
|
|
2696
2802
|
"no-component-will-receive-props": no_component_will_receive_props_default,
|
|
2697
2803
|
"no-component-will-update": no_component_will_update_default,
|
|
2804
|
+
"no-context-provider": no_context_provider_default,
|
|
2698
2805
|
"no-create-ref": no_create_ref_default,
|
|
2699
2806
|
"no-default-props": no_default_props_default,
|
|
2700
2807
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|