eslint-plugin-react-x 1.18.1-beta.0 → 1.18.1-beta.2
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 +116 -74
- package/dist/index.mjs +115 -73
- 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.2";
|
|
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,7 +1159,7 @@ 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",
|
|
@@ -1130,7 +1171,7 @@ var no_forward_ref_default = createRule({
|
|
|
1130
1171
|
},
|
|
1131
1172
|
schema: []
|
|
1132
1173
|
},
|
|
1133
|
-
name:
|
|
1174
|
+
name: RULE_NAME26,
|
|
1134
1175
|
create(context) {
|
|
1135
1176
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
1136
1177
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1147,7 +1188,7 @@ var no_forward_ref_default = createRule({
|
|
|
1147
1188
|
},
|
|
1148
1189
|
defaultOptions: []
|
|
1149
1190
|
});
|
|
1150
|
-
var
|
|
1191
|
+
var RULE_NAME27 = "no-implicit-key";
|
|
1151
1192
|
var no_implicit_key_default = createRule({
|
|
1152
1193
|
meta: {
|
|
1153
1194
|
type: "problem",
|
|
@@ -1159,11 +1200,11 @@ var no_implicit_key_default = createRule({
|
|
|
1159
1200
|
},
|
|
1160
1201
|
schema: []
|
|
1161
1202
|
},
|
|
1162
|
-
name:
|
|
1203
|
+
name: RULE_NAME27,
|
|
1163
1204
|
create(context) {
|
|
1164
1205
|
function getReportDescriptor(node) {
|
|
1165
1206
|
const initialScope = context.sourceCode.getScope(node);
|
|
1166
|
-
const keyPropFound =
|
|
1207
|
+
const keyPropFound = JSX8__namespace.findPropInAttributes(node.attributes, initialScope)("key");
|
|
1167
1208
|
const keyPropOnElement = node.attributes.some(
|
|
1168
1209
|
(n) => AST11__namespace.is(types.AST_NODE_TYPES.JSXAttribute)(n) && n.name.name === "key"
|
|
1169
1210
|
);
|
|
@@ -1202,7 +1243,7 @@ function isTrueLiteralType(type) {
|
|
|
1202
1243
|
function unionTypeParts(type) {
|
|
1203
1244
|
return isUnionType(type) ? type.types : [type];
|
|
1204
1245
|
}
|
|
1205
|
-
var
|
|
1246
|
+
var RULE_NAME28 = "no-leaked-conditional-rendering";
|
|
1206
1247
|
var tsHelpers = {
|
|
1207
1248
|
isAnyType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.TypeParameter | ts__default.default.TypeFlags.Any),
|
|
1208
1249
|
isBigIntType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.BigIntLike),
|
|
@@ -1306,7 +1347,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1306
1347
|
},
|
|
1307
1348
|
schema: []
|
|
1308
1349
|
},
|
|
1309
|
-
name:
|
|
1350
|
+
name: RULE_NAME28,
|
|
1310
1351
|
create(context) {
|
|
1311
1352
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1312
1353
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1363,7 +1404,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1363
1404
|
},
|
|
1364
1405
|
defaultOptions: []
|
|
1365
1406
|
});
|
|
1366
|
-
var
|
|
1407
|
+
var RULE_NAME29 = "no-missing-component-display-name";
|
|
1367
1408
|
var no_missing_component_display_name_default = createRule({
|
|
1368
1409
|
meta: {
|
|
1369
1410
|
type: "problem",
|
|
@@ -1375,7 +1416,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1375
1416
|
},
|
|
1376
1417
|
schema: []
|
|
1377
1418
|
},
|
|
1378
|
-
name:
|
|
1419
|
+
name: RULE_NAME29,
|
|
1379
1420
|
create(context) {
|
|
1380
1421
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1381
1422
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -1399,7 +1440,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1399
1440
|
},
|
|
1400
1441
|
defaultOptions: []
|
|
1401
1442
|
});
|
|
1402
|
-
var
|
|
1443
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1403
1444
|
var no_missing_key_default = createRule({
|
|
1404
1445
|
meta: {
|
|
1405
1446
|
type: "problem",
|
|
@@ -1412,14 +1453,14 @@ var no_missing_key_default = createRule({
|
|
|
1412
1453
|
},
|
|
1413
1454
|
schema: []
|
|
1414
1455
|
},
|
|
1415
|
-
name:
|
|
1456
|
+
name: RULE_NAME30,
|
|
1416
1457
|
create(context) {
|
|
1417
1458
|
const isWithinChildrenToArrayRef = tools.MutRef.make(false);
|
|
1418
1459
|
function checkIteratorElement(node) {
|
|
1419
1460
|
switch (node.type) {
|
|
1420
1461
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1421
1462
|
const initialScope = context.sourceCode.getScope(node);
|
|
1422
|
-
if (!
|
|
1463
|
+
if (!JSX8__namespace.hasProp(node.openingElement.attributes, "key", initialScope)) {
|
|
1423
1464
|
return tools.O.some({
|
|
1424
1465
|
messageId: "noMissingKey",
|
|
1425
1466
|
node
|
|
@@ -1468,7 +1509,7 @@ var no_missing_key_default = createRule({
|
|
|
1468
1509
|
if (elements.length === 0) return;
|
|
1469
1510
|
const initialScope = context.sourceCode.getScope(node);
|
|
1470
1511
|
for (const element of elements) {
|
|
1471
|
-
if (!
|
|
1512
|
+
if (!JSX8__namespace.hasProp(element.openingElement.attributes, "key", initialScope)) {
|
|
1472
1513
|
context.report({
|
|
1473
1514
|
messageId: "noMissingKey",
|
|
1474
1515
|
node: element
|
|
@@ -1516,7 +1557,7 @@ var no_missing_key_default = createRule({
|
|
|
1516
1557
|
},
|
|
1517
1558
|
defaultOptions: []
|
|
1518
1559
|
});
|
|
1519
|
-
var
|
|
1560
|
+
var RULE_NAME31 = "no-nested-components";
|
|
1520
1561
|
var no_nested_components_default = createRule({
|
|
1521
1562
|
meta: {
|
|
1522
1563
|
type: "problem",
|
|
@@ -1529,7 +1570,7 @@ var no_nested_components_default = createRule({
|
|
|
1529
1570
|
},
|
|
1530
1571
|
schema: []
|
|
1531
1572
|
},
|
|
1532
|
-
name:
|
|
1573
|
+
name: RULE_NAME31,
|
|
1533
1574
|
create(context) {
|
|
1534
1575
|
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
1576
|
const collector = core.useComponentCollector(context, hint);
|
|
@@ -1551,7 +1592,7 @@ var no_nested_components_default = createRule({
|
|
|
1551
1592
|
if (tools.O.isNone(componentName)) continue;
|
|
1552
1593
|
const name2 = componentName.value;
|
|
1553
1594
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
1554
|
-
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || tools.O.isSome(
|
|
1595
|
+
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
1596
|
if (isInsideJSXPropValue) {
|
|
1556
1597
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1557
1598
|
context.report({
|
|
@@ -1613,7 +1654,7 @@ var no_nested_components_default = createRule({
|
|
|
1613
1654
|
},
|
|
1614
1655
|
defaultOptions: []
|
|
1615
1656
|
});
|
|
1616
|
-
var
|
|
1657
|
+
var RULE_NAME32 = "no-prop-types";
|
|
1617
1658
|
var no_prop_types_default = createRule({
|
|
1618
1659
|
meta: {
|
|
1619
1660
|
type: "problem",
|
|
@@ -1625,7 +1666,7 @@ var no_prop_types_default = createRule({
|
|
|
1625
1666
|
},
|
|
1626
1667
|
schema: []
|
|
1627
1668
|
},
|
|
1628
|
-
name:
|
|
1669
|
+
name: RULE_NAME32,
|
|
1629
1670
|
create(context) {
|
|
1630
1671
|
if (!context.sourceCode.text.includes("propTypes")) return {};
|
|
1631
1672
|
return {
|
|
@@ -1652,7 +1693,7 @@ var no_prop_types_default = createRule({
|
|
|
1652
1693
|
},
|
|
1653
1694
|
defaultOptions: []
|
|
1654
1695
|
});
|
|
1655
|
-
var
|
|
1696
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
1656
1697
|
function isShouldComponentUpdate(node) {
|
|
1657
1698
|
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
1699
|
}
|
|
@@ -1667,7 +1708,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1667
1708
|
},
|
|
1668
1709
|
schema: []
|
|
1669
1710
|
},
|
|
1670
|
-
name:
|
|
1711
|
+
name: RULE_NAME33,
|
|
1671
1712
|
create(context) {
|
|
1672
1713
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
1673
1714
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1695,7 +1736,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1695
1736
|
},
|
|
1696
1737
|
defaultOptions: []
|
|
1697
1738
|
});
|
|
1698
|
-
var
|
|
1739
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
1699
1740
|
function isComponentDidMount(node) {
|
|
1700
1741
|
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
1742
|
}
|
|
@@ -1710,7 +1751,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1710
1751
|
},
|
|
1711
1752
|
schema: []
|
|
1712
1753
|
},
|
|
1713
|
-
name:
|
|
1754
|
+
name: RULE_NAME34,
|
|
1714
1755
|
create(context) {
|
|
1715
1756
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
1716
1757
|
function getReportDescriptor(node) {
|
|
@@ -1738,7 +1779,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1738
1779
|
},
|
|
1739
1780
|
defaultOptions: []
|
|
1740
1781
|
});
|
|
1741
|
-
var
|
|
1782
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
1742
1783
|
function isComponentDidUpdate(node) {
|
|
1743
1784
|
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
1785
|
}
|
|
@@ -1753,7 +1794,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1753
1794
|
},
|
|
1754
1795
|
schema: []
|
|
1755
1796
|
},
|
|
1756
|
-
name:
|
|
1797
|
+
name: RULE_NAME35,
|
|
1757
1798
|
create(context) {
|
|
1758
1799
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
1759
1800
|
function getReportDescriptor(node) {
|
|
@@ -1781,7 +1822,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1781
1822
|
},
|
|
1782
1823
|
defaultOptions: []
|
|
1783
1824
|
});
|
|
1784
|
-
var
|
|
1825
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
1785
1826
|
function isComponentWillUpdate3(node) {
|
|
1786
1827
|
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
1828
|
}
|
|
@@ -1796,7 +1837,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1796
1837
|
},
|
|
1797
1838
|
schema: []
|
|
1798
1839
|
},
|
|
1799
|
-
name:
|
|
1840
|
+
name: RULE_NAME36,
|
|
1800
1841
|
create(context) {
|
|
1801
1842
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1802
1843
|
function getReportDescriptor(node) {
|
|
@@ -1824,7 +1865,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1824
1865
|
},
|
|
1825
1866
|
defaultOptions: []
|
|
1826
1867
|
});
|
|
1827
|
-
var
|
|
1868
|
+
var RULE_NAME37 = "no-string-refs";
|
|
1828
1869
|
function containsStringLiteral({ value }) {
|
|
1829
1870
|
return value?.type === types.AST_NODE_TYPES.Literal && tools.isString(value.value);
|
|
1830
1871
|
}
|
|
@@ -1844,7 +1885,7 @@ var no_string_refs_default = createRule({
|
|
|
1844
1885
|
},
|
|
1845
1886
|
schema: []
|
|
1846
1887
|
},
|
|
1847
|
-
name:
|
|
1888
|
+
name: RULE_NAME37,
|
|
1848
1889
|
create(context) {
|
|
1849
1890
|
return {
|
|
1850
1891
|
JSXAttribute(node) {
|
|
@@ -1860,7 +1901,7 @@ var no_string_refs_default = createRule({
|
|
|
1860
1901
|
},
|
|
1861
1902
|
defaultOptions: []
|
|
1862
1903
|
});
|
|
1863
|
-
var
|
|
1904
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
1864
1905
|
function isUnsafeComponentWillMount(node) {
|
|
1865
1906
|
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
1907
|
}
|
|
@@ -1875,7 +1916,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
1875
1916
|
},
|
|
1876
1917
|
schema: []
|
|
1877
1918
|
},
|
|
1878
|
-
name:
|
|
1919
|
+
name: RULE_NAME38,
|
|
1879
1920
|
create(context) {
|
|
1880
1921
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
1881
1922
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1899,7 +1940,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
1899
1940
|
},
|
|
1900
1941
|
defaultOptions: []
|
|
1901
1942
|
});
|
|
1902
|
-
var
|
|
1943
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
1903
1944
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
1904
1945
|
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
1946
|
}
|
|
@@ -1914,7 +1955,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
1914
1955
|
},
|
|
1915
1956
|
schema: []
|
|
1916
1957
|
},
|
|
1917
|
-
name:
|
|
1958
|
+
name: RULE_NAME39,
|
|
1918
1959
|
create(context) {
|
|
1919
1960
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
1920
1961
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1938,7 +1979,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
1938
1979
|
},
|
|
1939
1980
|
defaultOptions: []
|
|
1940
1981
|
});
|
|
1941
|
-
var
|
|
1982
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
1942
1983
|
function isUnsafeComponentWillUpdate(node) {
|
|
1943
1984
|
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
1985
|
}
|
|
@@ -1953,7 +1994,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
1953
1994
|
},
|
|
1954
1995
|
schema: []
|
|
1955
1996
|
},
|
|
1956
|
-
name:
|
|
1997
|
+
name: RULE_NAME40,
|
|
1957
1998
|
create(context) {
|
|
1958
1999
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
1959
2000
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1977,7 +2018,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
1977
2018
|
},
|
|
1978
2019
|
defaultOptions: []
|
|
1979
2020
|
});
|
|
1980
|
-
var
|
|
2021
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
1981
2022
|
var no_unstable_context_value_default = createRule({
|
|
1982
2023
|
meta: {
|
|
1983
2024
|
type: "problem",
|
|
@@ -1991,7 +2032,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
1991
2032
|
},
|
|
1992
2033
|
schema: []
|
|
1993
2034
|
},
|
|
1994
|
-
name:
|
|
2035
|
+
name: RULE_NAME41,
|
|
1995
2036
|
create(context) {
|
|
1996
2037
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
1997
2038
|
const possibleValueConstructions = /* @__PURE__ */ new Map();
|
|
@@ -2044,7 +2085,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2044
2085
|
},
|
|
2045
2086
|
defaultOptions: []
|
|
2046
2087
|
});
|
|
2047
|
-
var
|
|
2088
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2048
2089
|
var no_unstable_default_props_default = createRule({
|
|
2049
2090
|
meta: {
|
|
2050
2091
|
type: "problem",
|
|
@@ -2056,7 +2097,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2056
2097
|
},
|
|
2057
2098
|
schema: []
|
|
2058
2099
|
},
|
|
2059
|
-
name:
|
|
2100
|
+
name: RULE_NAME42,
|
|
2060
2101
|
create(context) {
|
|
2061
2102
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2062
2103
|
const possibleDestructuringDeclarators = /* @__PURE__ */ new WeakMap();
|
|
@@ -2109,7 +2150,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2109
2150
|
},
|
|
2110
2151
|
defaultOptions: []
|
|
2111
2152
|
});
|
|
2112
|
-
var
|
|
2153
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2113
2154
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2114
2155
|
"componentDidCatch",
|
|
2115
2156
|
"componentDidMount",
|
|
@@ -2153,7 +2194,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2153
2194
|
},
|
|
2154
2195
|
schema: []
|
|
2155
2196
|
},
|
|
2156
|
-
name:
|
|
2197
|
+
name: RULE_NAME43,
|
|
2157
2198
|
create(context) {
|
|
2158
2199
|
const classStack = [];
|
|
2159
2200
|
const methodStack = [];
|
|
@@ -2236,7 +2277,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2236
2277
|
},
|
|
2237
2278
|
defaultOptions: []
|
|
2238
2279
|
});
|
|
2239
|
-
var
|
|
2280
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2240
2281
|
function getName4(node) {
|
|
2241
2282
|
if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
|
|
2242
2283
|
return getName4(node.expression);
|
|
@@ -2276,7 +2317,7 @@ var no_unused_state_default = createRule({
|
|
|
2276
2317
|
},
|
|
2277
2318
|
schema: []
|
|
2278
2319
|
},
|
|
2279
|
-
name:
|
|
2320
|
+
name: RULE_NAME44,
|
|
2280
2321
|
create(context) {
|
|
2281
2322
|
const classStack = [];
|
|
2282
2323
|
const methodStack = [];
|
|
@@ -2377,21 +2418,21 @@ var no_unused_state_default = createRule({
|
|
|
2377
2418
|
},
|
|
2378
2419
|
defaultOptions: []
|
|
2379
2420
|
});
|
|
2380
|
-
var
|
|
2421
|
+
var RULE_NAME45 = "no-useless-fragment";
|
|
2381
2422
|
function check(node, context, allowExpressions) {
|
|
2382
2423
|
const initialScope = context.sourceCode.getScope(node);
|
|
2383
|
-
if (
|
|
2384
|
-
if (
|
|
2424
|
+
if (JSX8__namespace.isKeyedElement(node, initialScope)) return;
|
|
2425
|
+
if (JSX8__namespace.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node });
|
|
2385
2426
|
if (node.children.length === 0) return context.report({ messageId: "noUselessFragment", node });
|
|
2386
2427
|
const isChildren = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
2387
2428
|
const [firstChildren] = node.children;
|
|
2388
|
-
if (allowExpressions && node.children.length === 1 &&
|
|
2429
|
+
if (allowExpressions && node.children.length === 1 && JSX8__namespace.isLiteral(firstChildren) && !isChildren) return;
|
|
2389
2430
|
if (!allowExpressions && isChildren) {
|
|
2390
2431
|
return context.report({ messageId: "noUselessFragment", node });
|
|
2391
2432
|
} else if (!allowExpressions && !isChildren && node.children.length === 1) {
|
|
2392
2433
|
return context.report({ messageId: "noUselessFragment", node });
|
|
2393
2434
|
}
|
|
2394
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
2435
|
+
const nonPaddingChildren = node.children.filter((child) => !JSX8__namespace.isPaddingSpaces(child));
|
|
2395
2436
|
if (nonPaddingChildren.length > 1) return;
|
|
2396
2437
|
if (nonPaddingChildren.length === 0) return context.report({ messageId: "noUselessFragment", node });
|
|
2397
2438
|
const [first] = nonPaddingChildren;
|
|
@@ -2419,7 +2460,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2419
2460
|
}
|
|
2420
2461
|
}]
|
|
2421
2462
|
},
|
|
2422
|
-
name:
|
|
2463
|
+
name: RULE_NAME45,
|
|
2423
2464
|
create(context, [option]) {
|
|
2424
2465
|
const { allowExpressions = true } = option;
|
|
2425
2466
|
return {
|
|
@@ -2436,7 +2477,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2436
2477
|
allowExpressions: true
|
|
2437
2478
|
}]
|
|
2438
2479
|
});
|
|
2439
|
-
var
|
|
2480
|
+
var RULE_NAME46 = "prefer-destructuring-assignment";
|
|
2440
2481
|
function isMemberExpressionWithObjectName(node) {
|
|
2441
2482
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
2442
2483
|
}
|
|
@@ -2451,7 +2492,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2451
2492
|
},
|
|
2452
2493
|
schema: []
|
|
2453
2494
|
},
|
|
2454
|
-
name:
|
|
2495
|
+
name: RULE_NAME46,
|
|
2455
2496
|
create(context) {
|
|
2456
2497
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2457
2498
|
const memberExpressionWithNames = [];
|
|
@@ -2506,7 +2547,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2506
2547
|
},
|
|
2507
2548
|
defaultOptions: []
|
|
2508
2549
|
});
|
|
2509
|
-
var
|
|
2550
|
+
var RULE_NAME47 = "prefer-react-namespace-import";
|
|
2510
2551
|
var prefer_react_namespace_import_default = createRule({
|
|
2511
2552
|
meta: {
|
|
2512
2553
|
type: "problem",
|
|
@@ -2519,7 +2560,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2519
2560
|
},
|
|
2520
2561
|
schema: []
|
|
2521
2562
|
},
|
|
2522
|
-
name:
|
|
2563
|
+
name: RULE_NAME47,
|
|
2523
2564
|
create(context) {
|
|
2524
2565
|
const importSource = shared.decodeSettings(context.settings).importSource ?? "react";
|
|
2525
2566
|
return {
|
|
@@ -2555,7 +2596,7 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
2555
2596
|
},
|
|
2556
2597
|
defaultOptions: []
|
|
2557
2598
|
});
|
|
2558
|
-
var
|
|
2599
|
+
var RULE_NAME48 = "prefer-read-only-props";
|
|
2559
2600
|
function isReadonlyType(type, services) {
|
|
2560
2601
|
try {
|
|
2561
2602
|
const im = isImmutableType.getTypeImmutability(services.program, type);
|
|
@@ -2575,7 +2616,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
2575
2616
|
},
|
|
2576
2617
|
schema: []
|
|
2577
2618
|
},
|
|
2578
|
-
name:
|
|
2619
|
+
name: RULE_NAME48,
|
|
2579
2620
|
create(context) {
|
|
2580
2621
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
2581
2622
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2595,7 +2636,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
2595
2636
|
},
|
|
2596
2637
|
defaultOptions: []
|
|
2597
2638
|
});
|
|
2598
|
-
var
|
|
2639
|
+
var RULE_NAME49 = "prefer-shorthand-boolean";
|
|
2599
2640
|
var prefer_shorthand_boolean_default = createRule({
|
|
2600
2641
|
meta: {
|
|
2601
2642
|
type: "problem",
|
|
@@ -2608,11 +2649,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2608
2649
|
},
|
|
2609
2650
|
schema: []
|
|
2610
2651
|
},
|
|
2611
|
-
name:
|
|
2652
|
+
name: RULE_NAME49,
|
|
2612
2653
|
create(context) {
|
|
2613
2654
|
function getReportDescriptor(node) {
|
|
2614
2655
|
const { value } = node;
|
|
2615
|
-
const propName =
|
|
2656
|
+
const propName = JSX8__namespace.getPropName(node);
|
|
2616
2657
|
const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
|
|
2617
2658
|
if (!hasValueTrue) return tools.O.none();
|
|
2618
2659
|
return tools.O.some({
|
|
@@ -2630,7 +2671,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2630
2671
|
},
|
|
2631
2672
|
defaultOptions: []
|
|
2632
2673
|
});
|
|
2633
|
-
var
|
|
2674
|
+
var RULE_NAME50 = "prefer-shorthand-fragment";
|
|
2634
2675
|
var prefer_shorthand_fragment_default = createRule({
|
|
2635
2676
|
meta: {
|
|
2636
2677
|
type: "problem",
|
|
@@ -2642,7 +2683,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
2642
2683
|
},
|
|
2643
2684
|
schema: []
|
|
2644
2685
|
},
|
|
2645
|
-
name:
|
|
2686
|
+
name: RULE_NAME50,
|
|
2646
2687
|
create(context) {
|
|
2647
2688
|
function getReportDescriptor(node) {
|
|
2648
2689
|
if (!core.isFragmentElement(node, context)) return tools.O.none();
|
|
@@ -2695,6 +2736,7 @@ var src_default = {
|
|
|
2695
2736
|
"no-component-will-mount": no_component_will_mount_default,
|
|
2696
2737
|
"no-component-will-receive-props": no_component_will_receive_props_default,
|
|
2697
2738
|
"no-component-will-update": no_component_will_update_default,
|
|
2739
|
+
"no-context-provider": no_context_provider_default,
|
|
2698
2740
|
"no-create-ref": no_create_ref_default,
|
|
2699
2741
|
"no-default-props": no_default_props_default,
|
|
2700
2742
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|