eslint-plugin-react-x 1.43.2-next.1 → 1.45.0-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 +1 -1
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +410 -280
- package/dist/index.mjs +408 -278
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var shared = require('@eslint-react/shared');
|
|
4
|
-
var
|
|
4
|
+
var JSX9 = require('@eslint-react/jsx');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
|
+
var kit = require('@eslint-react/kit');
|
|
6
7
|
var types = require('@typescript-eslint/types');
|
|
7
8
|
var VAR2 = require('@eslint-react/var');
|
|
8
9
|
var tsPattern = require('ts-pattern');
|
|
9
|
-
var kit = require('@eslint-react/kit');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
var AST8 = require('@eslint-react/ast');
|
|
12
|
-
var
|
|
12
|
+
var ER22 = require('@eslint-react/core');
|
|
13
13
|
var eff = require('@eslint-react/eff');
|
|
14
14
|
var compareVersions = require('compare-versions');
|
|
15
15
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
@@ -36,11 +36,11 @@ function _interopNamespace(e) {
|
|
|
36
36
|
return Object.freeze(n);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var JSX9__namespace = /*#__PURE__*/_interopNamespace(JSX9);
|
|
40
40
|
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
41
41
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
42
42
|
var AST8__namespace = /*#__PURE__*/_interopNamespace(AST8);
|
|
43
|
-
var
|
|
43
|
+
var ER22__namespace = /*#__PURE__*/_interopNamespace(ER22);
|
|
44
44
|
|
|
45
45
|
var __defProp = Object.defineProperty;
|
|
46
46
|
var __export = (target, all) => {
|
|
@@ -80,7 +80,9 @@ var rules = {
|
|
|
80
80
|
"react-x/no-forward-ref": "warn",
|
|
81
81
|
"react-x/no-implicit-key": "warn",
|
|
82
82
|
"react-x/no-missing-key": "error",
|
|
83
|
+
"react-x/no-misused-capture-owner-stack": "error",
|
|
83
84
|
"react-x/no-nested-component-definitions": "error",
|
|
85
|
+
"react-x/no-nested-lazy-component-declarations": "warn",
|
|
84
86
|
"react-x/no-prop-types": "error",
|
|
85
87
|
"react-x/no-redundant-should-component-update": "error",
|
|
86
88
|
"react-x/no-set-state-in-component-did-mount": "warn",
|
|
@@ -141,7 +143,7 @@ var settings3 = {
|
|
|
141
143
|
|
|
142
144
|
// package.json
|
|
143
145
|
var name4 = "eslint-plugin-react-x";
|
|
144
|
-
var version = "1.
|
|
146
|
+
var version = "1.45.0-beta.3";
|
|
145
147
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
146
148
|
|
|
147
149
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -172,7 +174,7 @@ function create(context) {
|
|
|
172
174
|
messageId: "avoidShorthandBoolean",
|
|
173
175
|
node,
|
|
174
176
|
data: {
|
|
175
|
-
propName:
|
|
177
|
+
propName: JSX9__namespace.getAttributeName(node)
|
|
176
178
|
},
|
|
177
179
|
fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
|
|
178
180
|
});
|
|
@@ -180,8 +182,6 @@ function create(context) {
|
|
|
180
182
|
}
|
|
181
183
|
};
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
// src/rules/avoid-shorthand-fragment.ts
|
|
185
185
|
var RULE_NAME2 = "avoid-shorthand-fragment";
|
|
186
186
|
var RULE_FEATURES2 = [];
|
|
187
187
|
var avoid_shorthand_fragment_default = createRule({
|
|
@@ -192,7 +192,7 @@ var avoid_shorthand_fragment_default = createRule({
|
|
|
192
192
|
[Symbol.for("rule_features")]: RULE_FEATURES2
|
|
193
193
|
},
|
|
194
194
|
messages: {
|
|
195
|
-
avoidShorthandFragment: "Avoid using shorthand fragment syntax. Use '
|
|
195
|
+
avoidShorthandFragment: "Avoid using shorthand fragment syntax. Use '{{jsxFragmentFactory}}' component instead."
|
|
196
196
|
},
|
|
197
197
|
schema: []
|
|
198
198
|
},
|
|
@@ -201,11 +201,20 @@ var avoid_shorthand_fragment_default = createRule({
|
|
|
201
201
|
defaultOptions: []
|
|
202
202
|
});
|
|
203
203
|
function create2(context) {
|
|
204
|
+
const jsxConfigFromContext = kit.JsxConfig.getFromContext(context);
|
|
205
|
+
const jsxConfigFromAnnotation = kit.JsxConfig.getFromAnnotation(context);
|
|
206
|
+
const jsxConfig = {
|
|
207
|
+
...jsxConfigFromContext,
|
|
208
|
+
...jsxConfigFromAnnotation
|
|
209
|
+
};
|
|
204
210
|
return {
|
|
205
211
|
JSXFragment(node) {
|
|
206
212
|
context.report({
|
|
207
213
|
messageId: "avoidShorthandFragment",
|
|
208
|
-
node
|
|
214
|
+
node,
|
|
215
|
+
data: {
|
|
216
|
+
jsxFragmentFactory: jsxConfig.jsxFragmentFactory
|
|
217
|
+
}
|
|
209
218
|
});
|
|
210
219
|
}
|
|
211
220
|
};
|
|
@@ -406,25 +415,25 @@ function create7(context) {
|
|
|
406
415
|
const setStateEntries = [];
|
|
407
416
|
return {
|
|
408
417
|
CallExpression(node) {
|
|
409
|
-
if (!
|
|
418
|
+
if (!ER22__namespace.isThisSetState(node)) {
|
|
410
419
|
return;
|
|
411
420
|
}
|
|
412
421
|
setStateEntries.push([node, false]);
|
|
413
422
|
},
|
|
414
423
|
"CallExpression:exit"(node) {
|
|
415
|
-
if (!
|
|
424
|
+
if (!ER22__namespace.isThisSetState(node)) {
|
|
416
425
|
return;
|
|
417
426
|
}
|
|
418
427
|
setStateEntries.pop();
|
|
419
428
|
},
|
|
420
429
|
ClassDeclaration(node) {
|
|
421
|
-
classEntries.push([node,
|
|
430
|
+
classEntries.push([node, ER22__namespace.isClassComponent(node)]);
|
|
422
431
|
},
|
|
423
432
|
"ClassDeclaration:exit"() {
|
|
424
433
|
classEntries.pop();
|
|
425
434
|
},
|
|
426
435
|
ClassExpression(node) {
|
|
427
|
-
classEntries.push([node,
|
|
436
|
+
classEntries.push([node, ER22__namespace.isClassComponent(node)]);
|
|
428
437
|
},
|
|
429
438
|
"ClassExpression:exit"() {
|
|
430
439
|
classEntries.pop();
|
|
@@ -508,7 +517,7 @@ function isUsingReactChildren(context, node) {
|
|
|
508
517
|
return true;
|
|
509
518
|
}
|
|
510
519
|
if (callee.object.type === types.AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
|
|
511
|
-
return
|
|
520
|
+
return ER22__namespace.isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
512
521
|
}
|
|
513
522
|
return false;
|
|
514
523
|
}
|
|
@@ -574,7 +583,7 @@ function create8(context) {
|
|
|
574
583
|
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
575
584
|
}
|
|
576
585
|
function isCreateOrCloneElementCall(node) {
|
|
577
|
-
return
|
|
586
|
+
return ER22__namespace.isCreateElementCall(context, node) || ER22__namespace.isCloneElementCall(context, node);
|
|
578
587
|
}
|
|
579
588
|
function getReportDescriptors(node) {
|
|
580
589
|
switch (node.type) {
|
|
@@ -690,7 +699,7 @@ var no_children_count_default = createRule({
|
|
|
690
699
|
function create9(context) {
|
|
691
700
|
return {
|
|
692
701
|
MemberExpression(node) {
|
|
693
|
-
if (
|
|
702
|
+
if (ER22__namespace.isChildrenCount(context, node)) {
|
|
694
703
|
context.report({
|
|
695
704
|
messageId: "noChildrenCount",
|
|
696
705
|
node: node.property
|
|
@@ -720,7 +729,7 @@ var no_children_for_each_default = createRule({
|
|
|
720
729
|
function create10(context) {
|
|
721
730
|
return {
|
|
722
731
|
MemberExpression(node) {
|
|
723
|
-
if (
|
|
732
|
+
if (ER22__namespace.isChildrenForEach(context, node)) {
|
|
724
733
|
context.report({
|
|
725
734
|
messageId: "noChildrenForEach",
|
|
726
735
|
node: node.property
|
|
@@ -750,7 +759,7 @@ var no_children_map_default = createRule({
|
|
|
750
759
|
function create11(context) {
|
|
751
760
|
return {
|
|
752
761
|
MemberExpression(node) {
|
|
753
|
-
if (
|
|
762
|
+
if (ER22__namespace.isChildrenMap(context, node)) {
|
|
754
763
|
context.report({
|
|
755
764
|
messageId: "noChildrenMap",
|
|
756
765
|
node: node.property
|
|
@@ -780,7 +789,7 @@ var no_children_only_default = createRule({
|
|
|
780
789
|
function create12(context) {
|
|
781
790
|
return {
|
|
782
791
|
MemberExpression(node) {
|
|
783
|
-
if (
|
|
792
|
+
if (ER22__namespace.isChildrenOnly(context, node)) {
|
|
784
793
|
context.report({
|
|
785
794
|
messageId: "noChildrenOnly",
|
|
786
795
|
node: node.property
|
|
@@ -811,7 +820,7 @@ function create13(context) {
|
|
|
811
820
|
return {
|
|
812
821
|
JSXElement(node) {
|
|
813
822
|
const attributes = node.openingElement.attributes;
|
|
814
|
-
const childrenProp =
|
|
823
|
+
const childrenProp = JSX9__namespace.getAttribute("children", attributes, context.sourceCode.getScope(node));
|
|
815
824
|
if (childrenProp != null) {
|
|
816
825
|
context.report({
|
|
817
826
|
messageId: "noChildrenProp",
|
|
@@ -842,7 +851,7 @@ var no_children_to_array_default = createRule({
|
|
|
842
851
|
function create14(context) {
|
|
843
852
|
return {
|
|
844
853
|
MemberExpression(node) {
|
|
845
|
-
if (
|
|
854
|
+
if (ER22__namespace.isChildrenToArray(context, node)) {
|
|
846
855
|
context.report({
|
|
847
856
|
messageId: "noChildrenToArray",
|
|
848
857
|
node: node.property
|
|
@@ -857,11 +866,11 @@ var no_class_component_default = createRule({
|
|
|
857
866
|
meta: {
|
|
858
867
|
type: "problem",
|
|
859
868
|
docs: {
|
|
860
|
-
description: "Disallow class components.",
|
|
869
|
+
description: "Disallow class components except for error boundaries.",
|
|
861
870
|
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
862
871
|
},
|
|
863
872
|
messages: {
|
|
864
|
-
noClassComponent: "
|
|
873
|
+
noClassComponent: "Avoid using class components. Use function components instead."
|
|
865
874
|
},
|
|
866
875
|
schema: []
|
|
867
876
|
},
|
|
@@ -871,13 +880,13 @@ var no_class_component_default = createRule({
|
|
|
871
880
|
});
|
|
872
881
|
function create15(context) {
|
|
873
882
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
874
|
-
const { ctx, listeners } =
|
|
883
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
875
884
|
return {
|
|
876
885
|
...listeners,
|
|
877
|
-
"Program:exit"(
|
|
878
|
-
const components = ctx.getAllComponents(
|
|
886
|
+
"Program:exit"(program) {
|
|
887
|
+
const components = ctx.getAllComponents(program);
|
|
879
888
|
for (const { name: name5 = "anonymous", node: component } of components.values()) {
|
|
880
|
-
if (component.body.body.some((m) =>
|
|
889
|
+
if (component.body.body.some((m) => ER22__namespace.isComponentDidCatch(m) || ER22__namespace.isGetDerivedStateFromError(m))) {
|
|
881
890
|
continue;
|
|
882
891
|
}
|
|
883
892
|
context.report({
|
|
@@ -912,7 +921,7 @@ var no_clone_element_default = createRule({
|
|
|
912
921
|
function create16(context) {
|
|
913
922
|
return {
|
|
914
923
|
CallExpression(node) {
|
|
915
|
-
if (
|
|
924
|
+
if (ER22__namespace.isCloneElementCall(context, node)) {
|
|
916
925
|
context.report({
|
|
917
926
|
messageId: "noCloneElement",
|
|
918
927
|
node
|
|
@@ -1035,15 +1044,15 @@ var no_component_will_mount_default = createRule({
|
|
|
1035
1044
|
});
|
|
1036
1045
|
function create19(context) {
|
|
1037
1046
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
1038
|
-
const { ctx, listeners } =
|
|
1047
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
1039
1048
|
return {
|
|
1040
1049
|
...listeners,
|
|
1041
|
-
"Program:exit"(
|
|
1042
|
-
const components = ctx.getAllComponents(
|
|
1050
|
+
"Program:exit"(program) {
|
|
1051
|
+
const components = ctx.getAllComponents(program);
|
|
1043
1052
|
for (const { node: component } of components.values()) {
|
|
1044
1053
|
const { body } = component.body;
|
|
1045
1054
|
for (const member of body) {
|
|
1046
|
-
if (
|
|
1055
|
+
if (ER22__namespace.isComponentWillMount(member)) {
|
|
1047
1056
|
context.report({
|
|
1048
1057
|
messageId: "noComponentWillMount",
|
|
1049
1058
|
node: member,
|
|
@@ -1083,15 +1092,15 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1083
1092
|
});
|
|
1084
1093
|
function create20(context) {
|
|
1085
1094
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1086
|
-
const { ctx, listeners } =
|
|
1095
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
1087
1096
|
return {
|
|
1088
1097
|
...listeners,
|
|
1089
|
-
"Program:exit"(
|
|
1090
|
-
const components = ctx.getAllComponents(
|
|
1098
|
+
"Program:exit"(program) {
|
|
1099
|
+
const components = ctx.getAllComponents(program);
|
|
1091
1100
|
for (const { node: component } of components.values()) {
|
|
1092
1101
|
const { body } = component.body;
|
|
1093
1102
|
for (const member of body) {
|
|
1094
|
-
if (
|
|
1103
|
+
if (ER22__namespace.isComponentWillReceiveProps(member)) {
|
|
1095
1104
|
context.report({
|
|
1096
1105
|
messageId: "noComponentWillReceiveProps",
|
|
1097
1106
|
node: member,
|
|
@@ -1131,15 +1140,15 @@ var no_component_will_update_default = createRule({
|
|
|
1131
1140
|
});
|
|
1132
1141
|
function create21(context) {
|
|
1133
1142
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1134
|
-
const { ctx, listeners } =
|
|
1143
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
1135
1144
|
return {
|
|
1136
1145
|
...listeners,
|
|
1137
|
-
"Program:exit"(
|
|
1138
|
-
const components = ctx.getAllComponents(
|
|
1146
|
+
"Program:exit"(program) {
|
|
1147
|
+
const components = ctx.getAllComponents(program);
|
|
1139
1148
|
for (const { node: component } of components.values()) {
|
|
1140
1149
|
const { body } = component.body;
|
|
1141
1150
|
for (const member of body) {
|
|
1142
|
-
if (
|
|
1151
|
+
if (ER22__namespace.isComponentWillUpdate(member)) {
|
|
1143
1152
|
context.report({
|
|
1144
1153
|
messageId: "noComponentWillUpdate",
|
|
1145
1154
|
node: member,
|
|
@@ -1183,7 +1192,7 @@ function create22(context) {
|
|
|
1183
1192
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
1184
1193
|
return {
|
|
1185
1194
|
JSXElement(node) {
|
|
1186
|
-
const fullName =
|
|
1195
|
+
const fullName = JSX9__namespace.getElementType(node);
|
|
1187
1196
|
const parts = fullName.split(".");
|
|
1188
1197
|
const selfName = parts.pop();
|
|
1189
1198
|
const contextFullName = parts.join(".");
|
|
@@ -1194,7 +1203,7 @@ function create22(context) {
|
|
|
1194
1203
|
messageId: "noContextProvider",
|
|
1195
1204
|
node,
|
|
1196
1205
|
fix(fixer) {
|
|
1197
|
-
if (!
|
|
1206
|
+
if (!ER22__namespace.isComponentNameLoose(contextSelfName)) return null;
|
|
1198
1207
|
const openingElement = node.openingElement;
|
|
1199
1208
|
const closingElement = node.closingElement;
|
|
1200
1209
|
if (closingElement == null) {
|
|
@@ -1230,7 +1239,7 @@ var no_create_ref_default = createRule({
|
|
|
1230
1239
|
function create23(context) {
|
|
1231
1240
|
return {
|
|
1232
1241
|
CallExpression(node) {
|
|
1233
|
-
if (
|
|
1242
|
+
if (ER22__namespace.isCreateRefCall(context, node) && AST8__namespace.findParentNode(node, ER22__namespace.isClassComponent) == null) {
|
|
1234
1243
|
context.report({ messageId: "noCreateRef", node });
|
|
1235
1244
|
}
|
|
1236
1245
|
}
|
|
@@ -1268,17 +1277,17 @@ function create24(context) {
|
|
|
1268
1277
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
|
|
1269
1278
|
return;
|
|
1270
1279
|
}
|
|
1271
|
-
if (!
|
|
1280
|
+
if (!ER22__namespace.isComponentNameLoose(object.name)) {
|
|
1272
1281
|
return;
|
|
1273
1282
|
}
|
|
1274
1283
|
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1275
1284
|
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
1276
1285
|
if (variableNode == null) return;
|
|
1277
|
-
if (!AST8__namespace.isFunction(variableNode) && !
|
|
1286
|
+
if (!AST8__namespace.isFunction(variableNode) && !ER22__namespace.isClassComponent(variableNode)) return;
|
|
1278
1287
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
1279
1288
|
},
|
|
1280
1289
|
PropertyDefinition(node) {
|
|
1281
|
-
if (!
|
|
1290
|
+
if (!ER22__namespace.isClassComponent(node.parent.parent)) {
|
|
1282
1291
|
return;
|
|
1283
1292
|
}
|
|
1284
1293
|
if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") {
|
|
@@ -1312,7 +1321,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1312
1321
|
function create25(context) {
|
|
1313
1322
|
return {
|
|
1314
1323
|
AssignmentExpression(node) {
|
|
1315
|
-
if (!
|
|
1324
|
+
if (!ER22__namespace.isAssignmentToThisState(node)) return;
|
|
1316
1325
|
const parentClass = AST8__namespace.findParentNode(
|
|
1317
1326
|
node,
|
|
1318
1327
|
AST8__namespace.isOneOf([
|
|
@@ -1321,7 +1330,7 @@ function create25(context) {
|
|
|
1321
1330
|
])
|
|
1322
1331
|
);
|
|
1323
1332
|
if (parentClass == null) return;
|
|
1324
|
-
if (
|
|
1333
|
+
if (ER22__namespace.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST8__namespace.findParentNode(node, isConstructorFunction)) {
|
|
1325
1334
|
context.report({
|
|
1326
1335
|
messageId: "noDirectMutationState",
|
|
1327
1336
|
node
|
|
@@ -1443,7 +1452,7 @@ function create27(context) {
|
|
|
1443
1452
|
}
|
|
1444
1453
|
return {
|
|
1445
1454
|
CallExpression(node) {
|
|
1446
|
-
if (!
|
|
1455
|
+
if (!ER22__namespace.isForwardRefCall(context, node)) {
|
|
1447
1456
|
return;
|
|
1448
1457
|
}
|
|
1449
1458
|
context.report({
|
|
@@ -1545,7 +1554,7 @@ function create28(context) {
|
|
|
1545
1554
|
return {
|
|
1546
1555
|
JSXOpeningElement(node) {
|
|
1547
1556
|
const initialScope = context.sourceCode.getScope(node);
|
|
1548
|
-
const keyPropFound =
|
|
1557
|
+
const keyPropFound = JSX9__namespace.getAttribute("key", node.attributes, initialScope);
|
|
1549
1558
|
const keyPropOnElement = node.attributes.some(
|
|
1550
1559
|
(n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1551
1560
|
);
|
|
@@ -1733,21 +1742,21 @@ function create30(context) {
|
|
|
1733
1742
|
const {
|
|
1734
1743
|
ctx,
|
|
1735
1744
|
listeners
|
|
1736
|
-
} =
|
|
1745
|
+
} = ER22__namespace.useComponentCollector(
|
|
1737
1746
|
context,
|
|
1738
1747
|
{
|
|
1739
1748
|
collectDisplayName: true,
|
|
1740
1749
|
collectHookCalls: false,
|
|
1741
|
-
hint:
|
|
1750
|
+
hint: ER22__namespace.DEFAULT_COMPONENT_DETECTION_HINT
|
|
1742
1751
|
}
|
|
1743
1752
|
);
|
|
1744
1753
|
return {
|
|
1745
1754
|
...listeners,
|
|
1746
|
-
"Program:exit"(
|
|
1747
|
-
const components = ctx.getAllComponents(
|
|
1748
|
-
for (const { node
|
|
1749
|
-
const isMemoOrForwardRef = (flag & (
|
|
1750
|
-
if (AST8__namespace.getFunctionIdentifier(
|
|
1755
|
+
"Program:exit"(program) {
|
|
1756
|
+
const components = ctx.getAllComponents(program);
|
|
1757
|
+
for (const { node, displayName, flag } of components.values()) {
|
|
1758
|
+
const isMemoOrForwardRef = (flag & (ER22__namespace.ComponentFlag.ForwardRef | ER22__namespace.ComponentFlag.Memo)) > 0n;
|
|
1759
|
+
if (AST8__namespace.getFunctionIdentifier(node) != null) {
|
|
1751
1760
|
continue;
|
|
1752
1761
|
}
|
|
1753
1762
|
if (!isMemoOrForwardRef) {
|
|
@@ -1756,7 +1765,7 @@ function create30(context) {
|
|
|
1756
1765
|
if (displayName == null) {
|
|
1757
1766
|
context.report({
|
|
1758
1767
|
messageId: "noMissingComponentDisplayName",
|
|
1759
|
-
node
|
|
1768
|
+
node
|
|
1760
1769
|
});
|
|
1761
1770
|
}
|
|
1762
1771
|
}
|
|
@@ -1787,12 +1796,12 @@ function create31(context) {
|
|
|
1787
1796
|
const displayNameAssignments = [];
|
|
1788
1797
|
return {
|
|
1789
1798
|
CallExpression(node) {
|
|
1790
|
-
if (!
|
|
1799
|
+
if (!ER22__namespace.isCreateContextCall(context, node)) return;
|
|
1791
1800
|
createCalls.push(node);
|
|
1792
1801
|
},
|
|
1793
1802
|
"Program:exit"() {
|
|
1794
1803
|
for (const call of createCalls) {
|
|
1795
|
-
const id =
|
|
1804
|
+
const id = ER22__namespace.getInstanceId(call);
|
|
1796
1805
|
if (id == null) {
|
|
1797
1806
|
context.report({
|
|
1798
1807
|
messageId: "noMissingContextDisplayName",
|
|
@@ -1804,7 +1813,7 @@ function create31(context) {
|
|
|
1804
1813
|
const left = node.left;
|
|
1805
1814
|
if (left.type !== types.AST_NODE_TYPES.MemberExpression) return false;
|
|
1806
1815
|
const object = left.object;
|
|
1807
|
-
return
|
|
1816
|
+
return ER22__namespace.isInstanceIdEqual(context, id, object);
|
|
1808
1817
|
});
|
|
1809
1818
|
if (!hasDisplayNameAssignment) {
|
|
1810
1819
|
context.report({
|
|
@@ -1845,7 +1854,7 @@ function create32(context) {
|
|
|
1845
1854
|
switch (node.type) {
|
|
1846
1855
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1847
1856
|
const initialScope = context.sourceCode.getScope(node);
|
|
1848
|
-
if (!
|
|
1857
|
+
if (!JSX9__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1849
1858
|
return {
|
|
1850
1859
|
messageId: "missingKey",
|
|
1851
1860
|
node
|
|
@@ -1902,7 +1911,7 @@ function create32(context) {
|
|
|
1902
1911
|
}
|
|
1903
1912
|
const initialScope = context.sourceCode.getScope(node);
|
|
1904
1913
|
for (const element of elements) {
|
|
1905
|
-
if (!
|
|
1914
|
+
if (!JSX9__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1906
1915
|
report({
|
|
1907
1916
|
messageId: "missingKey",
|
|
1908
1917
|
node: element
|
|
@@ -1911,7 +1920,7 @@ function create32(context) {
|
|
|
1911
1920
|
}
|
|
1912
1921
|
},
|
|
1913
1922
|
CallExpression(node) {
|
|
1914
|
-
state.isWithinChildrenToArray ||=
|
|
1923
|
+
state.isWithinChildrenToArray ||= ER22__namespace.isChildrenToArrayCall(context, node);
|
|
1915
1924
|
if (state.isWithinChildrenToArray) return;
|
|
1916
1925
|
const callback = tsPattern.match(node).when(AST8__namespace.isArrayMapCall, (n) => n.arguments[0]).when(AST8__namespace.isArrayFromCall, (n) => n.arguments[1]).otherwise(() => null);
|
|
1917
1926
|
if (!AST8__namespace.isFunction(callback)) return;
|
|
@@ -1923,7 +1932,7 @@ function create32(context) {
|
|
|
1923
1932
|
report(checkExpression(body));
|
|
1924
1933
|
},
|
|
1925
1934
|
"CallExpression:exit"(node) {
|
|
1926
|
-
if (!
|
|
1935
|
+
if (!ER22__namespace.isChildrenToArrayCall(context, node)) {
|
|
1927
1936
|
return;
|
|
1928
1937
|
}
|
|
1929
1938
|
state.isWithinChildrenToArray = false;
|
|
@@ -1941,17 +1950,22 @@ function create32(context) {
|
|
|
1941
1950
|
}
|
|
1942
1951
|
};
|
|
1943
1952
|
}
|
|
1944
|
-
var RULE_NAME33 = "no-
|
|
1945
|
-
var RULE_FEATURES33 = [
|
|
1946
|
-
|
|
1953
|
+
var RULE_NAME33 = "no-misused-capture-owner-stack";
|
|
1954
|
+
var RULE_FEATURES33 = [
|
|
1955
|
+
"EXP"
|
|
1956
|
+
];
|
|
1957
|
+
var no_misused_capture_owner_stack_default = createRule({
|
|
1947
1958
|
meta: {
|
|
1948
1959
|
type: "problem",
|
|
1949
1960
|
docs: {
|
|
1950
|
-
description: "
|
|
1961
|
+
description: "Prevents incorrect usage of `captureOwnerStack`.",
|
|
1951
1962
|
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1952
1963
|
},
|
|
1964
|
+
fixable: "code",
|
|
1953
1965
|
messages: {
|
|
1954
|
-
|
|
1966
|
+
useNamespaceImport: "Don't use named imports of 'captureOwnerStack' in files that are bundled for development and production. Use a namespace import instead.",
|
|
1967
|
+
// eslint-disable-next-line perfectionist/sort-objects
|
|
1968
|
+
missingDevelopmentOnlyCheck: `Don't call 'captureOwnerStack' directly. Use 'if (process.env.NODE_ENV !== "production") {...}' to conditionally access it.`
|
|
1955
1969
|
},
|
|
1956
1970
|
schema: []
|
|
1957
1971
|
},
|
|
@@ -1960,30 +1974,81 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1960
1974
|
defaultOptions: []
|
|
1961
1975
|
});
|
|
1962
1976
|
function create33(context) {
|
|
1963
|
-
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1977
|
+
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
1978
|
+
const { importSource } = shared.getSettingsFromContext(context);
|
|
1979
|
+
return {
|
|
1980
|
+
CallExpression(node) {
|
|
1981
|
+
if (!ER22__namespace.isCaptureOwnerStackCall(context, node)) return;
|
|
1982
|
+
if (AST8__namespace.findParentNode(node, isDevelopmentOnlyCheck) == null) {
|
|
1983
|
+
context.report({
|
|
1984
|
+
messageId: "missingDevelopmentOnlyCheck",
|
|
1985
|
+
node
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
},
|
|
1989
|
+
ImportDeclaration(node) {
|
|
1990
|
+
if (node.source.value !== importSource) return;
|
|
1991
|
+
for (const specifier of node.specifiers) {
|
|
1992
|
+
if (specifier.type !== types.AST_NODE_TYPES.ImportSpecifier) continue;
|
|
1993
|
+
if (specifier.imported.type !== types.AST_NODE_TYPES.Identifier) continue;
|
|
1994
|
+
if (specifier.imported.name === "captureOwnerStack") {
|
|
1995
|
+
context.report({
|
|
1996
|
+
messageId: "useNamespaceImport",
|
|
1997
|
+
node: specifier
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
function isDevelopmentOnlyCheck(node) {
|
|
2005
|
+
if (node.type !== types.AST_NODE_TYPES.IfStatement) return false;
|
|
2006
|
+
if (AST8__namespace.isProcessEnvNodeEnvCompare(node.test, "!==", "production")) return true;
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
var RULE_NAME34 = "no-nested-component-definitions";
|
|
2010
|
+
var RULE_FEATURES34 = [];
|
|
2011
|
+
var no_nested_component_definitions_default = createRule({
|
|
2012
|
+
meta: {
|
|
2013
|
+
type: "problem",
|
|
2014
|
+
docs: {
|
|
2015
|
+
description: "Disallow nesting component definitions inside other components.",
|
|
2016
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2017
|
+
},
|
|
2018
|
+
messages: {
|
|
2019
|
+
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
2020
|
+
},
|
|
2021
|
+
schema: []
|
|
2022
|
+
},
|
|
2023
|
+
name: RULE_NAME34,
|
|
2024
|
+
create: create34,
|
|
2025
|
+
defaultOptions: []
|
|
2026
|
+
});
|
|
2027
|
+
function create34(context) {
|
|
2028
|
+
const hint = ER22__namespace.ComponentDetectionHint.SkipArrayMapArgument | ER22__namespace.ComponentDetectionHint.SkipNullLiteral | ER22__namespace.ComponentDetectionHint.SkipUndefined | ER22__namespace.ComponentDetectionHint.SkipBooleanLiteral | ER22__namespace.ComponentDetectionHint.SkipStringLiteral | ER22__namespace.ComponentDetectionHint.SkipNumberLiteral | ER22__namespace.ComponentDetectionHint.StrictLogical | ER22__namespace.ComponentDetectionHint.StrictConditional;
|
|
2029
|
+
const collector = ER22__namespace.useComponentCollector(context, { hint });
|
|
2030
|
+
const collectorLegacy = ER22__namespace.useComponentCollectorLegacy();
|
|
1966
2031
|
return {
|
|
1967
2032
|
...collector.listeners,
|
|
1968
2033
|
...collectorLegacy.listeners,
|
|
1969
|
-
"Program:exit"(
|
|
2034
|
+
"Program:exit"(program) {
|
|
1970
2035
|
const functionComponents = [
|
|
1971
|
-
...collector.ctx.getAllComponents(
|
|
2036
|
+
...collector.ctx.getAllComponents(program).values()
|
|
1972
2037
|
];
|
|
1973
2038
|
const classComponents = [
|
|
1974
|
-
...collectorLegacy.ctx.getAllComponents(
|
|
2039
|
+
...collectorLegacy.ctx.getAllComponents(program).values()
|
|
1975
2040
|
];
|
|
1976
|
-
const isFunctionComponent = (
|
|
1977
|
-
return AST8__namespace.isFunction(
|
|
2041
|
+
const isFunctionComponent = (node) => {
|
|
2042
|
+
return AST8__namespace.isFunction(node) && functionComponents.some((component) => component.node === node);
|
|
1978
2043
|
};
|
|
1979
|
-
const isClassComponent12 = (
|
|
1980
|
-
return AST8__namespace.isClass(
|
|
2044
|
+
const isClassComponent12 = (node) => {
|
|
2045
|
+
return AST8__namespace.isClass(node) && classComponents.some((component) => component.node === node);
|
|
1981
2046
|
};
|
|
1982
2047
|
for (const { name: name5, node: component } of functionComponents) {
|
|
1983
2048
|
if (name5 == null) continue;
|
|
1984
|
-
if (
|
|
2049
|
+
if (ER22__namespace.isDirectValueOfRenderPropertyLoose(component)) continue;
|
|
1985
2050
|
if (isInsideJSXAttributeValue(component)) {
|
|
1986
|
-
if (!
|
|
2051
|
+
if (!ER22__namespace.isDeclaredInRenderPropLoose(component)) {
|
|
1987
2052
|
context.report({
|
|
1988
2053
|
messageId: "noNestedComponentDefinitions",
|
|
1989
2054
|
node: component,
|
|
@@ -2007,7 +2072,7 @@ function create33(context) {
|
|
|
2007
2072
|
continue;
|
|
2008
2073
|
}
|
|
2009
2074
|
const parentComponent = AST8__namespace.findParentNode(component, isFunctionComponent);
|
|
2010
|
-
if (parentComponent != null && !
|
|
2075
|
+
if (parentComponent != null && !ER22__namespace.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
2011
2076
|
context.report({
|
|
2012
2077
|
messageId: "noNestedComponentDefinitions",
|
|
2013
2078
|
node: component,
|
|
@@ -2018,7 +2083,7 @@ function create33(context) {
|
|
|
2018
2083
|
});
|
|
2019
2084
|
continue;
|
|
2020
2085
|
}
|
|
2021
|
-
if (
|
|
2086
|
+
if (ER22__namespace.isInsideRenderMethod(component)) {
|
|
2022
2087
|
context.report({
|
|
2023
2088
|
messageId: "noNestedComponentDefinitions",
|
|
2024
2089
|
node: component,
|
|
@@ -2046,34 +2111,97 @@ function create33(context) {
|
|
|
2046
2111
|
};
|
|
2047
2112
|
}
|
|
2048
2113
|
function isInsideJSXAttributeValue(node) {
|
|
2049
|
-
return node.parent.type === types.AST_NODE_TYPES.JSXAttribute ||
|
|
2114
|
+
return node.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX9__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
2050
2115
|
}
|
|
2051
2116
|
function isInsideCreateElementProps(context, node) {
|
|
2052
|
-
const call = AST8__namespace.findParentNode(node,
|
|
2117
|
+
const call = AST8__namespace.findParentNode(node, ER22__namespace.isCreateElementCall(context));
|
|
2053
2118
|
if (call == null) return false;
|
|
2054
2119
|
const prop = AST8__namespace.findParentNode(node, AST8__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
|
|
2055
2120
|
if (prop == null) return false;
|
|
2056
2121
|
return prop === call.arguments[1];
|
|
2057
2122
|
}
|
|
2058
|
-
var
|
|
2059
|
-
var
|
|
2123
|
+
var RULE_NAME35 = "no-nested-component-definitions";
|
|
2124
|
+
var RULE_FEATURES35 = [];
|
|
2125
|
+
var no_nested_lazy_component_declarations_default = createRule({
|
|
2126
|
+
meta: {
|
|
2127
|
+
type: "problem",
|
|
2128
|
+
docs: {
|
|
2129
|
+
description: "Disallow nesting lazy component declarations inside other components.",
|
|
2130
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2131
|
+
},
|
|
2132
|
+
messages: {
|
|
2133
|
+
noNestedComponentDefinitions: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module."
|
|
2134
|
+
},
|
|
2135
|
+
schema: []
|
|
2136
|
+
},
|
|
2137
|
+
name: RULE_NAME35,
|
|
2138
|
+
create: create35,
|
|
2139
|
+
defaultOptions: []
|
|
2140
|
+
});
|
|
2141
|
+
function create35(context) {
|
|
2142
|
+
const hint = ER22__namespace.ComponentDetectionHint.None;
|
|
2143
|
+
const collector = ER22__namespace.useComponentCollector(context, { hint });
|
|
2144
|
+
const collectorLegacy = ER22__namespace.useComponentCollectorLegacy();
|
|
2145
|
+
const lazyComponentDeclarations = /* @__PURE__ */ new Set();
|
|
2146
|
+
return {
|
|
2147
|
+
...collector.listeners,
|
|
2148
|
+
...collectorLegacy.listeners,
|
|
2149
|
+
ImportExpression(node) {
|
|
2150
|
+
const lazyCall = AST8__namespace.findParentNode(node, (n) => ER22__namespace.isLazyCall(context, n));
|
|
2151
|
+
if (lazyCall != null) {
|
|
2152
|
+
lazyComponentDeclarations.add(lazyCall);
|
|
2153
|
+
}
|
|
2154
|
+
},
|
|
2155
|
+
"Program:exit"(program) {
|
|
2156
|
+
const functionComponents = [
|
|
2157
|
+
...collector.ctx.getAllComponents(program).values()
|
|
2158
|
+
];
|
|
2159
|
+
const classComponents = [
|
|
2160
|
+
...collectorLegacy.ctx.getAllComponents(program).values()
|
|
2161
|
+
];
|
|
2162
|
+
for (const lazy of lazyComponentDeclarations) {
|
|
2163
|
+
const significantParent = AST8__namespace.findParentNode(lazy, (n) => {
|
|
2164
|
+
if (JSX9__namespace.isJSX(n)) return true;
|
|
2165
|
+
if (n.type === types.AST_NODE_TYPES.CallExpression) {
|
|
2166
|
+
return ER22__namespace.isReactHookCall(n) || ER22__namespace.isCreateElementCall(context, n) || ER22__namespace.isCreateContextCall(context, n);
|
|
2167
|
+
}
|
|
2168
|
+
if (AST8__namespace.isFunction(n)) {
|
|
2169
|
+
return functionComponents.some((c) => c.node === n);
|
|
2170
|
+
}
|
|
2171
|
+
if (AST8__namespace.isClass(n)) {
|
|
2172
|
+
return classComponents.some((c) => c.node === n);
|
|
2173
|
+
}
|
|
2174
|
+
return false;
|
|
2175
|
+
});
|
|
2176
|
+
if (significantParent != null) {
|
|
2177
|
+
context.report({
|
|
2178
|
+
messageId: "noNestedComponentDefinitions",
|
|
2179
|
+
node: lazy
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
var RULE_NAME36 = "no-prop-types";
|
|
2187
|
+
var RULE_FEATURES36 = [];
|
|
2060
2188
|
var no_prop_types_default = createRule({
|
|
2061
2189
|
meta: {
|
|
2062
2190
|
type: "problem",
|
|
2063
2191
|
docs: {
|
|
2064
2192
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
2065
|
-
[Symbol.for("rule_features")]:
|
|
2193
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2066
2194
|
},
|
|
2067
2195
|
messages: {
|
|
2068
2196
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
2069
2197
|
},
|
|
2070
2198
|
schema: []
|
|
2071
2199
|
},
|
|
2072
|
-
name:
|
|
2073
|
-
create:
|
|
2200
|
+
name: RULE_NAME36,
|
|
2201
|
+
create: create36,
|
|
2074
2202
|
defaultOptions: []
|
|
2075
2203
|
});
|
|
2076
|
-
function
|
|
2204
|
+
function create36(context) {
|
|
2077
2205
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
2078
2206
|
return {};
|
|
2079
2207
|
}
|
|
@@ -2089,17 +2217,17 @@ function create34(context) {
|
|
|
2089
2217
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
|
|
2090
2218
|
return;
|
|
2091
2219
|
}
|
|
2092
|
-
if (!
|
|
2220
|
+
if (!ER22__namespace.isComponentNameLoose(object.name)) {
|
|
2093
2221
|
return;
|
|
2094
2222
|
}
|
|
2095
2223
|
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2096
2224
|
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
2097
|
-
if (variableNode != null && (AST8__namespace.isFunction(variableNode) ||
|
|
2225
|
+
if (variableNode != null && (AST8__namespace.isFunction(variableNode) || ER22__namespace.isClassComponent(variableNode))) {
|
|
2098
2226
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2099
2227
|
}
|
|
2100
2228
|
},
|
|
2101
2229
|
PropertyDefinition(node) {
|
|
2102
|
-
if (!
|
|
2230
|
+
if (!ER22__namespace.isClassComponent(node.parent.parent)) {
|
|
2103
2231
|
return;
|
|
2104
2232
|
}
|
|
2105
2233
|
if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") {
|
|
@@ -2109,8 +2237,8 @@ function create34(context) {
|
|
|
2109
2237
|
}
|
|
2110
2238
|
};
|
|
2111
2239
|
}
|
|
2112
|
-
var
|
|
2113
|
-
var
|
|
2240
|
+
var RULE_NAME37 = "no-redundant-should-component-update";
|
|
2241
|
+
var RULE_FEATURES37 = [];
|
|
2114
2242
|
function isShouldComponentUpdate(node) {
|
|
2115
2243
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2116
2244
|
}
|
|
@@ -2119,26 +2247,26 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2119
2247
|
type: "problem",
|
|
2120
2248
|
docs: {
|
|
2121
2249
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2122
|
-
[Symbol.for("rule_features")]:
|
|
2250
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2123
2251
|
},
|
|
2124
2252
|
messages: {
|
|
2125
2253
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2126
2254
|
},
|
|
2127
2255
|
schema: []
|
|
2128
2256
|
},
|
|
2129
|
-
name:
|
|
2130
|
-
create:
|
|
2257
|
+
name: RULE_NAME37,
|
|
2258
|
+
create: create37,
|
|
2131
2259
|
defaultOptions: []
|
|
2132
2260
|
});
|
|
2133
|
-
function
|
|
2261
|
+
function create37(context) {
|
|
2134
2262
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2135
|
-
const { ctx, listeners } =
|
|
2263
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
2136
2264
|
return {
|
|
2137
2265
|
...listeners,
|
|
2138
|
-
"Program:exit"(
|
|
2139
|
-
const components = ctx.getAllComponents(
|
|
2266
|
+
"Program:exit"(program) {
|
|
2267
|
+
const components = ctx.getAllComponents(program);
|
|
2140
2268
|
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
2141
|
-
if ((flag &
|
|
2269
|
+
if ((flag & ER22__namespace.ComponentFlag.PureComponent) === 0n) {
|
|
2142
2270
|
continue;
|
|
2143
2271
|
}
|
|
2144
2272
|
const { body } = component.body;
|
|
@@ -2157,33 +2285,33 @@ function create35(context) {
|
|
|
2157
2285
|
}
|
|
2158
2286
|
};
|
|
2159
2287
|
}
|
|
2160
|
-
var
|
|
2161
|
-
var
|
|
2288
|
+
var RULE_NAME38 = "no-set-state-in-component-did-mount";
|
|
2289
|
+
var RULE_FEATURES38 = [];
|
|
2162
2290
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2163
2291
|
meta: {
|
|
2164
2292
|
type: "problem",
|
|
2165
2293
|
docs: {
|
|
2166
2294
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2167
|
-
[Symbol.for("rule_features")]:
|
|
2295
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2168
2296
|
},
|
|
2169
2297
|
messages: {
|
|
2170
2298
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2171
2299
|
},
|
|
2172
2300
|
schema: []
|
|
2173
2301
|
},
|
|
2174
|
-
name:
|
|
2175
|
-
create:
|
|
2302
|
+
name: RULE_NAME38,
|
|
2303
|
+
create: create38,
|
|
2176
2304
|
defaultOptions: []
|
|
2177
2305
|
});
|
|
2178
|
-
function
|
|
2306
|
+
function create38(context) {
|
|
2179
2307
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2180
2308
|
return {
|
|
2181
2309
|
CallExpression(node) {
|
|
2182
|
-
if (!
|
|
2310
|
+
if (!ER22__namespace.isThisSetState(node)) {
|
|
2183
2311
|
return;
|
|
2184
2312
|
}
|
|
2185
|
-
const clazz = AST8__namespace.findParentNode(node,
|
|
2186
|
-
const method = AST8__namespace.findParentNode(node, (n) => n === clazz ||
|
|
2313
|
+
const clazz = AST8__namespace.findParentNode(node, ER22__namespace.isClassComponent);
|
|
2314
|
+
const method = AST8__namespace.findParentNode(node, (n) => n === clazz || ER22__namespace.isComponentDidMount(n));
|
|
2187
2315
|
if (clazz == null || method == null || method === clazz) return;
|
|
2188
2316
|
const methodScope = context.sourceCode.getScope(method);
|
|
2189
2317
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2196,33 +2324,33 @@ function create36(context) {
|
|
|
2196
2324
|
}
|
|
2197
2325
|
};
|
|
2198
2326
|
}
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
2327
|
+
var RULE_NAME39 = "no-set-state-in-component-did-update";
|
|
2328
|
+
var RULE_FEATURES39 = [];
|
|
2201
2329
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2202
2330
|
meta: {
|
|
2203
2331
|
type: "problem",
|
|
2204
2332
|
docs: {
|
|
2205
|
-
description: "
|
|
2206
|
-
[Symbol.for("rule_features")]:
|
|
2333
|
+
description: "Disallow calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2334
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2207
2335
|
},
|
|
2208
2336
|
messages: {
|
|
2209
2337
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2210
2338
|
},
|
|
2211
2339
|
schema: []
|
|
2212
2340
|
},
|
|
2213
|
-
name:
|
|
2214
|
-
create:
|
|
2341
|
+
name: RULE_NAME39,
|
|
2342
|
+
create: create39,
|
|
2215
2343
|
defaultOptions: []
|
|
2216
2344
|
});
|
|
2217
|
-
function
|
|
2345
|
+
function create39(context) {
|
|
2218
2346
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2219
2347
|
return {
|
|
2220
2348
|
CallExpression(node) {
|
|
2221
|
-
if (!
|
|
2349
|
+
if (!ER22__namespace.isThisSetState(node)) {
|
|
2222
2350
|
return;
|
|
2223
2351
|
}
|
|
2224
|
-
const clazz = AST8__namespace.findParentNode(node,
|
|
2225
|
-
const method = AST8__namespace.findParentNode(node, (n) => n === clazz ||
|
|
2352
|
+
const clazz = AST8__namespace.findParentNode(node, ER22__namespace.isClassComponent);
|
|
2353
|
+
const method = AST8__namespace.findParentNode(node, (n) => n === clazz || ER22__namespace.isComponentDidUpdate(n));
|
|
2226
2354
|
if (clazz == null || method == null || method === clazz) return;
|
|
2227
2355
|
const methodScope = context.sourceCode.getScope(method);
|
|
2228
2356
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2235,33 +2363,33 @@ function create37(context) {
|
|
|
2235
2363
|
}
|
|
2236
2364
|
};
|
|
2237
2365
|
}
|
|
2238
|
-
var
|
|
2239
|
-
var
|
|
2366
|
+
var RULE_NAME40 = "no-set-state-in-component-will-update";
|
|
2367
|
+
var RULE_FEATURES40 = [];
|
|
2240
2368
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2241
2369
|
meta: {
|
|
2242
2370
|
type: "problem",
|
|
2243
2371
|
docs: {
|
|
2244
2372
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2245
|
-
[Symbol.for("rule_features")]:
|
|
2373
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2246
2374
|
},
|
|
2247
2375
|
messages: {
|
|
2248
2376
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2249
2377
|
},
|
|
2250
2378
|
schema: []
|
|
2251
2379
|
},
|
|
2252
|
-
name:
|
|
2253
|
-
create:
|
|
2380
|
+
name: RULE_NAME40,
|
|
2381
|
+
create: create40,
|
|
2254
2382
|
defaultOptions: []
|
|
2255
2383
|
});
|
|
2256
|
-
function
|
|
2384
|
+
function create40(context) {
|
|
2257
2385
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2258
2386
|
return {
|
|
2259
2387
|
CallExpression(node) {
|
|
2260
|
-
if (!
|
|
2388
|
+
if (!ER22__namespace.isThisSetState(node)) {
|
|
2261
2389
|
return;
|
|
2262
2390
|
}
|
|
2263
|
-
const clazz = AST8__namespace.findParentNode(node,
|
|
2264
|
-
const method = AST8__namespace.findParentNode(node, (n) => n === clazz ||
|
|
2391
|
+
const clazz = AST8__namespace.findParentNode(node, ER22__namespace.isClassComponent);
|
|
2392
|
+
const method = AST8__namespace.findParentNode(node, (n) => n === clazz || ER22__namespace.isComponentWillUpdate(n));
|
|
2265
2393
|
if (clazz == null || method == null || method === clazz) return;
|
|
2266
2394
|
const methodScope = context.sourceCode.getScope(method);
|
|
2267
2395
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2274,8 +2402,8 @@ function create38(context) {
|
|
|
2274
2402
|
}
|
|
2275
2403
|
};
|
|
2276
2404
|
}
|
|
2277
|
-
var
|
|
2278
|
-
var
|
|
2405
|
+
var RULE_NAME41 = "no-string-refs";
|
|
2406
|
+
var RULE_FEATURES41 = [
|
|
2279
2407
|
"MOD"
|
|
2280
2408
|
];
|
|
2281
2409
|
var no_string_refs_default = createRule({
|
|
@@ -2283,7 +2411,7 @@ var no_string_refs_default = createRule({
|
|
|
2283
2411
|
type: "problem",
|
|
2284
2412
|
docs: {
|
|
2285
2413
|
description: "Replaces string refs with callback refs.",
|
|
2286
|
-
[Symbol.for("rule_features")]:
|
|
2414
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2287
2415
|
},
|
|
2288
2416
|
fixable: "code",
|
|
2289
2417
|
messages: {
|
|
@@ -2291,16 +2419,16 @@ var no_string_refs_default = createRule({
|
|
|
2291
2419
|
},
|
|
2292
2420
|
schema: []
|
|
2293
2421
|
},
|
|
2294
|
-
name:
|
|
2295
|
-
create:
|
|
2422
|
+
name: RULE_NAME41,
|
|
2423
|
+
create: create41,
|
|
2296
2424
|
defaultOptions: []
|
|
2297
2425
|
});
|
|
2298
|
-
function
|
|
2426
|
+
function create41(context) {
|
|
2299
2427
|
const state = {
|
|
2300
2428
|
isWithinClassComponent: false
|
|
2301
2429
|
};
|
|
2302
2430
|
function onClassBodyEnter(node) {
|
|
2303
|
-
if (
|
|
2431
|
+
if (ER22__namespace.isClassComponent(node.parent)) {
|
|
2304
2432
|
state.isWithinClassComponent = true;
|
|
2305
2433
|
}
|
|
2306
2434
|
}
|
|
@@ -2339,8 +2467,8 @@ function getAttributeValueText(context, node) {
|
|
|
2339
2467
|
return null;
|
|
2340
2468
|
}
|
|
2341
2469
|
}
|
|
2342
|
-
var
|
|
2343
|
-
var
|
|
2470
|
+
var RULE_NAME42 = "no-unsafe-component-will-mount";
|
|
2471
|
+
var RULE_FEATURES42 = [];
|
|
2344
2472
|
function isUnsafeComponentWillMount(node) {
|
|
2345
2473
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2346
2474
|
}
|
|
@@ -2349,24 +2477,24 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2349
2477
|
type: "problem",
|
|
2350
2478
|
docs: {
|
|
2351
2479
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2352
|
-
[Symbol.for("rule_features")]:
|
|
2480
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2353
2481
|
},
|
|
2354
2482
|
messages: {
|
|
2355
2483
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2356
2484
|
},
|
|
2357
2485
|
schema: []
|
|
2358
2486
|
},
|
|
2359
|
-
name:
|
|
2360
|
-
create:
|
|
2487
|
+
name: RULE_NAME42,
|
|
2488
|
+
create: create42,
|
|
2361
2489
|
defaultOptions: []
|
|
2362
2490
|
});
|
|
2363
|
-
function
|
|
2491
|
+
function create42(context) {
|
|
2364
2492
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2365
|
-
const { ctx, listeners } =
|
|
2493
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
2366
2494
|
return {
|
|
2367
2495
|
...listeners,
|
|
2368
|
-
"Program:exit"(
|
|
2369
|
-
const components = ctx.getAllComponents(
|
|
2496
|
+
"Program:exit"(program) {
|
|
2497
|
+
const components = ctx.getAllComponents(program);
|
|
2370
2498
|
for (const { node: component } of components.values()) {
|
|
2371
2499
|
const { body } = component.body;
|
|
2372
2500
|
for (const member of body) {
|
|
@@ -2381,8 +2509,8 @@ function create40(context) {
|
|
|
2381
2509
|
}
|
|
2382
2510
|
};
|
|
2383
2511
|
}
|
|
2384
|
-
var
|
|
2385
|
-
var
|
|
2512
|
+
var RULE_NAME43 = "no-unsafe-component-will-receive-props";
|
|
2513
|
+
var RULE_FEATURES43 = [];
|
|
2386
2514
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2387
2515
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2388
2516
|
}
|
|
@@ -2391,26 +2519,26 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2391
2519
|
type: "problem",
|
|
2392
2520
|
docs: {
|
|
2393
2521
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2394
|
-
[Symbol.for("rule_features")]:
|
|
2522
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2395
2523
|
},
|
|
2396
2524
|
messages: {
|
|
2397
2525
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2398
2526
|
},
|
|
2399
2527
|
schema: []
|
|
2400
2528
|
},
|
|
2401
|
-
name:
|
|
2402
|
-
create:
|
|
2529
|
+
name: RULE_NAME43,
|
|
2530
|
+
create: create43,
|
|
2403
2531
|
defaultOptions: []
|
|
2404
2532
|
});
|
|
2405
|
-
function
|
|
2533
|
+
function create43(context) {
|
|
2406
2534
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2407
2535
|
return {};
|
|
2408
2536
|
}
|
|
2409
|
-
const { ctx, listeners } =
|
|
2537
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
2410
2538
|
return {
|
|
2411
2539
|
...listeners,
|
|
2412
|
-
"Program:exit"(
|
|
2413
|
-
const components = ctx.getAllComponents(
|
|
2540
|
+
"Program:exit"(program) {
|
|
2541
|
+
const components = ctx.getAllComponents(program);
|
|
2414
2542
|
for (const { node: component } of components.values()) {
|
|
2415
2543
|
const { body } = component.body;
|
|
2416
2544
|
for (const member of body) {
|
|
@@ -2425,8 +2553,8 @@ function create41(context) {
|
|
|
2425
2553
|
}
|
|
2426
2554
|
};
|
|
2427
2555
|
}
|
|
2428
|
-
var
|
|
2429
|
-
var
|
|
2556
|
+
var RULE_NAME44 = "no-unsafe-component-will-update";
|
|
2557
|
+
var RULE_FEATURES44 = [];
|
|
2430
2558
|
function isUnsafeComponentWillUpdate(node) {
|
|
2431
2559
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2432
2560
|
}
|
|
@@ -2435,24 +2563,24 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2435
2563
|
type: "problem",
|
|
2436
2564
|
docs: {
|
|
2437
2565
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2438
|
-
[Symbol.for("rule_features")]:
|
|
2566
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2439
2567
|
},
|
|
2440
2568
|
messages: {
|
|
2441
2569
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2442
2570
|
},
|
|
2443
2571
|
schema: []
|
|
2444
2572
|
},
|
|
2445
|
-
name:
|
|
2446
|
-
create:
|
|
2573
|
+
name: RULE_NAME44,
|
|
2574
|
+
create: create44,
|
|
2447
2575
|
defaultOptions: []
|
|
2448
2576
|
});
|
|
2449
|
-
function
|
|
2577
|
+
function create44(context) {
|
|
2450
2578
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2451
|
-
const { ctx, listeners } =
|
|
2579
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollectorLegacy();
|
|
2452
2580
|
return {
|
|
2453
2581
|
...listeners,
|
|
2454
|
-
"Program:exit"(
|
|
2455
|
-
const components = ctx.getAllComponents(
|
|
2582
|
+
"Program:exit"(program) {
|
|
2583
|
+
const components = ctx.getAllComponents(program);
|
|
2456
2584
|
for (const { node: component } of components.values()) {
|
|
2457
2585
|
const { body } = component.body;
|
|
2458
2586
|
for (const member of body) {
|
|
@@ -2467,33 +2595,33 @@ function create42(context) {
|
|
|
2467
2595
|
}
|
|
2468
2596
|
};
|
|
2469
2597
|
}
|
|
2470
|
-
var
|
|
2471
|
-
var
|
|
2598
|
+
var RULE_NAME45 = "no-unstable-context-value";
|
|
2599
|
+
var RULE_FEATURES45 = [];
|
|
2472
2600
|
var no_unstable_context_value_default = createRule({
|
|
2473
2601
|
meta: {
|
|
2474
2602
|
type: "problem",
|
|
2475
2603
|
docs: {
|
|
2476
2604
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2477
|
-
[Symbol.for("rule_features")]:
|
|
2605
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2478
2606
|
},
|
|
2479
2607
|
messages: {
|
|
2480
2608
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2481
2609
|
},
|
|
2482
2610
|
schema: []
|
|
2483
2611
|
},
|
|
2484
|
-
name:
|
|
2485
|
-
create:
|
|
2612
|
+
name: RULE_NAME45,
|
|
2613
|
+
create: create45,
|
|
2486
2614
|
defaultOptions: []
|
|
2487
2615
|
});
|
|
2488
|
-
function
|
|
2616
|
+
function create45(context) {
|
|
2489
2617
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2490
2618
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2491
|
-
const { ctx, listeners } =
|
|
2619
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollector(context);
|
|
2492
2620
|
const constructions = /* @__PURE__ */ new Map();
|
|
2493
2621
|
return {
|
|
2494
2622
|
...listeners,
|
|
2495
2623
|
JSXOpeningElement(node) {
|
|
2496
|
-
const fullName =
|
|
2624
|
+
const fullName = JSX9__namespace.getElementType(node.parent);
|
|
2497
2625
|
const selfName = fullName.split(".").at(-1);
|
|
2498
2626
|
if (selfName == null) return;
|
|
2499
2627
|
if (!isContextName(selfName, isReact18OrBelow)) return;
|
|
@@ -2509,13 +2637,13 @@ function create43(context) {
|
|
|
2509
2637
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2510
2638
|
const construction = VAR2__namespace.getConstructionDetectionResult(valueExpression, initialScope);
|
|
2511
2639
|
if (construction == null) return;
|
|
2512
|
-
if (
|
|
2640
|
+
if (ER22__namespace.isReactHookCall(construction.node)) {
|
|
2513
2641
|
return;
|
|
2514
2642
|
}
|
|
2515
2643
|
eff.getOrUpdate(constructions, functionEntry.node, () => []).push(construction);
|
|
2516
2644
|
},
|
|
2517
|
-
"Program:exit"(
|
|
2518
|
-
const components = ctx.getAllComponents(
|
|
2645
|
+
"Program:exit"(program) {
|
|
2646
|
+
const components = ctx.getAllComponents(program).values();
|
|
2519
2647
|
for (const { node: component } of components) {
|
|
2520
2648
|
for (const construction of constructions.get(component) ?? []) {
|
|
2521
2649
|
const { kind, node: constructionNode } = construction;
|
|
@@ -2540,31 +2668,31 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2540
2668
|
}
|
|
2541
2669
|
return false;
|
|
2542
2670
|
}
|
|
2543
|
-
var
|
|
2544
|
-
var
|
|
2671
|
+
var RULE_NAME46 = "no-unstable-default-props";
|
|
2672
|
+
var RULE_FEATURES46 = [];
|
|
2545
2673
|
var no_unstable_default_props_default = createRule({
|
|
2546
2674
|
meta: {
|
|
2547
2675
|
type: "problem",
|
|
2548
2676
|
docs: {
|
|
2549
2677
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2550
|
-
[Symbol.for("rule_features")]:
|
|
2678
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2551
2679
|
},
|
|
2552
2680
|
messages: {
|
|
2553
2681
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2554
2682
|
},
|
|
2555
2683
|
schema: []
|
|
2556
2684
|
},
|
|
2557
|
-
name:
|
|
2558
|
-
create:
|
|
2685
|
+
name: RULE_NAME46,
|
|
2686
|
+
create: create46,
|
|
2559
2687
|
defaultOptions: []
|
|
2560
2688
|
});
|
|
2561
|
-
function
|
|
2562
|
-
const { ctx, listeners } =
|
|
2689
|
+
function create46(context) {
|
|
2690
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollector(context);
|
|
2563
2691
|
const declarators = /* @__PURE__ */ new Map();
|
|
2564
2692
|
return {
|
|
2565
2693
|
...listeners,
|
|
2566
|
-
"Program:exit"(
|
|
2567
|
-
const components = ctx.getAllComponents(
|
|
2694
|
+
"Program:exit"(program) {
|
|
2695
|
+
const components = ctx.getAllComponents(program);
|
|
2568
2696
|
for (const { node: component } of components.values()) {
|
|
2569
2697
|
const { params } = component;
|
|
2570
2698
|
const [props] = params;
|
|
@@ -2589,7 +2717,7 @@ function create44(context) {
|
|
|
2589
2717
|
if (construction == null) {
|
|
2590
2718
|
continue;
|
|
2591
2719
|
}
|
|
2592
|
-
if (
|
|
2720
|
+
if (ER22__namespace.isReactHookCall(construction.node)) {
|
|
2593
2721
|
continue;
|
|
2594
2722
|
}
|
|
2595
2723
|
const forbiddenType = AST8__namespace.toReadableNodeType(right);
|
|
@@ -2614,8 +2742,8 @@ function create44(context) {
|
|
|
2614
2742
|
}
|
|
2615
2743
|
};
|
|
2616
2744
|
}
|
|
2617
|
-
var
|
|
2618
|
-
var
|
|
2745
|
+
var RULE_NAME47 = "no-unused-class-component-members";
|
|
2746
|
+
var RULE_FEATURES47 = [];
|
|
2619
2747
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2620
2748
|
"componentDidCatch",
|
|
2621
2749
|
"componentDidMount",
|
|
@@ -2641,25 +2769,25 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2641
2769
|
type: "problem",
|
|
2642
2770
|
docs: {
|
|
2643
2771
|
description: "Warns unused class component methods and properties.",
|
|
2644
|
-
[Symbol.for("rule_features")]:
|
|
2772
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2645
2773
|
},
|
|
2646
2774
|
messages: {
|
|
2647
2775
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2648
2776
|
},
|
|
2649
2777
|
schema: []
|
|
2650
2778
|
},
|
|
2651
|
-
name:
|
|
2652
|
-
create:
|
|
2779
|
+
name: RULE_NAME47,
|
|
2780
|
+
create: create47,
|
|
2653
2781
|
defaultOptions: []
|
|
2654
2782
|
});
|
|
2655
|
-
function
|
|
2783
|
+
function create47(context) {
|
|
2656
2784
|
const classEntries = [];
|
|
2657
2785
|
const methodEntries = [];
|
|
2658
2786
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
2659
2787
|
const propertyUsages = /* @__PURE__ */ new WeakMap();
|
|
2660
2788
|
function classEnter(node) {
|
|
2661
2789
|
classEntries.push(node);
|
|
2662
|
-
if (!
|
|
2790
|
+
if (!ER22__namespace.isClassComponent(node)) {
|
|
2663
2791
|
return;
|
|
2664
2792
|
}
|
|
2665
2793
|
propertyDefs.set(node, /* @__PURE__ */ new Set());
|
|
@@ -2667,7 +2795,7 @@ function create45(context) {
|
|
|
2667
2795
|
}
|
|
2668
2796
|
function classExit() {
|
|
2669
2797
|
const currentClass = classEntries.pop();
|
|
2670
|
-
if (currentClass == null || !
|
|
2798
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2671
2799
|
return;
|
|
2672
2800
|
}
|
|
2673
2801
|
const className = AST8__namespace.getClassIdentifier(currentClass)?.name;
|
|
@@ -2697,7 +2825,7 @@ function create45(context) {
|
|
|
2697
2825
|
function methodEnter(node) {
|
|
2698
2826
|
methodEntries.push(node);
|
|
2699
2827
|
const currentClass = classEntries.at(-1);
|
|
2700
|
-
if (currentClass == null || !
|
|
2828
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2701
2829
|
return;
|
|
2702
2830
|
}
|
|
2703
2831
|
if (node.static) {
|
|
@@ -2721,7 +2849,7 @@ function create45(context) {
|
|
|
2721
2849
|
if (currentClass == null || currentMethod == null) {
|
|
2722
2850
|
return;
|
|
2723
2851
|
}
|
|
2724
|
-
if (!
|
|
2852
|
+
if (!ER22__namespace.isClassComponent(currentClass) || currentMethod.static) {
|
|
2725
2853
|
return;
|
|
2726
2854
|
}
|
|
2727
2855
|
if (!AST8__namespace.isThisExpression(node.object) || !isKeyLiteral2(node, node.property)) {
|
|
@@ -2746,7 +2874,7 @@ function create45(context) {
|
|
|
2746
2874
|
if (currentClass == null || currentMethod == null) {
|
|
2747
2875
|
return;
|
|
2748
2876
|
}
|
|
2749
|
-
if (!
|
|
2877
|
+
if (!ER22__namespace.isClassComponent(currentClass) || currentMethod.static) {
|
|
2750
2878
|
return;
|
|
2751
2879
|
}
|
|
2752
2880
|
if (node.init != null && AST8__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern) {
|
|
@@ -2762,8 +2890,8 @@ function create45(context) {
|
|
|
2762
2890
|
}
|
|
2763
2891
|
};
|
|
2764
2892
|
}
|
|
2765
|
-
var
|
|
2766
|
-
var
|
|
2893
|
+
var RULE_NAME48 = "no-unused-state";
|
|
2894
|
+
var RULE_FEATURES48 = [];
|
|
2767
2895
|
function isKeyLiteral3(node, key) {
|
|
2768
2896
|
return tsPattern.match(key).with({ type: types.AST_NODE_TYPES.Literal }, eff.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.constFalse);
|
|
2769
2897
|
}
|
|
@@ -2772,18 +2900,18 @@ var no_unused_state_default = createRule({
|
|
|
2772
2900
|
type: "problem",
|
|
2773
2901
|
docs: {
|
|
2774
2902
|
description: "Warns unused class component state.",
|
|
2775
|
-
[Symbol.for("rule_features")]:
|
|
2903
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
2776
2904
|
},
|
|
2777
2905
|
messages: {
|
|
2778
2906
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2779
2907
|
},
|
|
2780
2908
|
schema: []
|
|
2781
2909
|
},
|
|
2782
|
-
name:
|
|
2783
|
-
create:
|
|
2910
|
+
name: RULE_NAME48,
|
|
2911
|
+
create: create48,
|
|
2784
2912
|
defaultOptions: []
|
|
2785
2913
|
});
|
|
2786
|
-
function
|
|
2914
|
+
function create48(context) {
|
|
2787
2915
|
const classEntries = [];
|
|
2788
2916
|
const methodEntries = [];
|
|
2789
2917
|
const constructorEntries = [];
|
|
@@ -2793,7 +2921,7 @@ function create46(context) {
|
|
|
2793
2921
|
}
|
|
2794
2922
|
function classExit() {
|
|
2795
2923
|
const currentClass = classEntries.pop();
|
|
2796
|
-
if (currentClass == null || !
|
|
2924
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2797
2925
|
return;
|
|
2798
2926
|
}
|
|
2799
2927
|
const className = AST8__namespace.getClassIdentifier(currentClass)?.name;
|
|
@@ -2812,11 +2940,11 @@ function create46(context) {
|
|
|
2812
2940
|
function methodEnter(node) {
|
|
2813
2941
|
methodEntries.push(node);
|
|
2814
2942
|
const currentClass = classEntries.at(-1);
|
|
2815
|
-
if (currentClass == null || !
|
|
2943
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2816
2944
|
return;
|
|
2817
2945
|
}
|
|
2818
2946
|
if (node.static) {
|
|
2819
|
-
if (
|
|
2947
|
+
if (ER22__namespace.isGetDerivedStateFromProps(node) && tsPattern.isMatching({ params: [tsPattern.P.nonNullable, ...tsPattern.P.array()] })(node.value)) {
|
|
2820
2948
|
const defNode = stateDefs.get(currentClass)?.node;
|
|
2821
2949
|
stateDefs.set(currentClass, { node: defNode, isUsed: true });
|
|
2822
2950
|
}
|
|
@@ -2837,11 +2965,11 @@ function create46(context) {
|
|
|
2837
2965
|
}
|
|
2838
2966
|
return {
|
|
2839
2967
|
AssignmentExpression(node) {
|
|
2840
|
-
if (!
|
|
2968
|
+
if (!ER22__namespace.isAssignmentToThisState(node)) {
|
|
2841
2969
|
return;
|
|
2842
2970
|
}
|
|
2843
2971
|
const currentClass = classEntries.at(-1);
|
|
2844
|
-
if (currentClass == null || !
|
|
2972
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2845
2973
|
return;
|
|
2846
2974
|
}
|
|
2847
2975
|
const currentConstructor = constructorEntries.at(-1);
|
|
@@ -2863,7 +2991,7 @@ function create46(context) {
|
|
|
2863
2991
|
return;
|
|
2864
2992
|
}
|
|
2865
2993
|
const currentClass = classEntries.at(-1);
|
|
2866
|
-
if (currentClass == null || !
|
|
2994
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2867
2995
|
return;
|
|
2868
2996
|
}
|
|
2869
2997
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2887,7 +3015,7 @@ function create46(context) {
|
|
|
2887
3015
|
"PropertyDefinition:exit": methodExit,
|
|
2888
3016
|
VariableDeclarator(node) {
|
|
2889
3017
|
const currentClass = classEntries.at(-1);
|
|
2890
|
-
if (currentClass == null || !
|
|
3018
|
+
if (currentClass == null || !ER22__namespace.isClassComponent(currentClass)) {
|
|
2891
3019
|
return;
|
|
2892
3020
|
}
|
|
2893
3021
|
const currentMethod = methodEntries.at(-1);
|
|
@@ -2917,8 +3045,8 @@ function create46(context) {
|
|
|
2917
3045
|
}
|
|
2918
3046
|
};
|
|
2919
3047
|
}
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
3048
|
+
var RULE_NAME49 = "no-use-context";
|
|
3049
|
+
var RULE_FEATURES49 = [
|
|
2922
3050
|
"MOD"
|
|
2923
3051
|
];
|
|
2924
3052
|
var no_use_context_default = createRule({
|
|
@@ -2926,7 +3054,7 @@ var no_use_context_default = createRule({
|
|
|
2926
3054
|
type: "problem",
|
|
2927
3055
|
docs: {
|
|
2928
3056
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2929
|
-
[Symbol.for("rule_features")]:
|
|
3057
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
2930
3058
|
},
|
|
2931
3059
|
fixable: "code",
|
|
2932
3060
|
messages: {
|
|
@@ -2934,11 +3062,11 @@ var no_use_context_default = createRule({
|
|
|
2934
3062
|
},
|
|
2935
3063
|
schema: []
|
|
2936
3064
|
},
|
|
2937
|
-
name:
|
|
2938
|
-
create:
|
|
3065
|
+
name: RULE_NAME49,
|
|
3066
|
+
create: create49,
|
|
2939
3067
|
defaultOptions: []
|
|
2940
3068
|
});
|
|
2941
|
-
function
|
|
3069
|
+
function create49(context) {
|
|
2942
3070
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2943
3071
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2944
3072
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2947,10 +3075,10 @@ function create47(context) {
|
|
|
2947
3075
|
}
|
|
2948
3076
|
return {
|
|
2949
3077
|
CallExpression(node) {
|
|
2950
|
-
if (!
|
|
3078
|
+
if (!ER22__namespace.isReactHookCall(node)) {
|
|
2951
3079
|
return;
|
|
2952
3080
|
}
|
|
2953
|
-
if (!
|
|
3081
|
+
if (!ER22__namespace.isReactHookCallWithNameAlias(context, "useContext", [...useContextAlias])(node)) {
|
|
2954
3082
|
return;
|
|
2955
3083
|
}
|
|
2956
3084
|
context.report({
|
|
@@ -3016,28 +3144,28 @@ function getAssociatedTokens(context, node) {
|
|
|
3016
3144
|
return tokens;
|
|
3017
3145
|
}
|
|
3018
3146
|
}
|
|
3019
|
-
var
|
|
3020
|
-
var
|
|
3147
|
+
var RULE_NAME50 = "no-useless-forward-ref";
|
|
3148
|
+
var RULE_FEATURES50 = [];
|
|
3021
3149
|
var no_useless_forward_ref_default = createRule({
|
|
3022
3150
|
meta: {
|
|
3023
3151
|
type: "problem",
|
|
3024
3152
|
docs: {
|
|
3025
3153
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
3026
|
-
[Symbol.for("rule_features")]:
|
|
3154
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3027
3155
|
},
|
|
3028
3156
|
messages: {
|
|
3029
3157
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
3030
3158
|
},
|
|
3031
3159
|
schema: []
|
|
3032
3160
|
},
|
|
3033
|
-
name:
|
|
3034
|
-
create:
|
|
3161
|
+
name: RULE_NAME50,
|
|
3162
|
+
create: create50,
|
|
3035
3163
|
defaultOptions: []
|
|
3036
3164
|
});
|
|
3037
|
-
function
|
|
3165
|
+
function create50(context) {
|
|
3038
3166
|
return {
|
|
3039
3167
|
CallExpression(node) {
|
|
3040
|
-
if (!
|
|
3168
|
+
if (!ER22__namespace.isForwardRefCall(context, node)) {
|
|
3041
3169
|
return;
|
|
3042
3170
|
}
|
|
3043
3171
|
const [component] = node.arguments;
|
|
@@ -3055,7 +3183,7 @@ function create48(context) {
|
|
|
3055
3183
|
}
|
|
3056
3184
|
};
|
|
3057
3185
|
}
|
|
3058
|
-
var
|
|
3186
|
+
var RULE_NAME51 = "no-useless-fragment";
|
|
3059
3187
|
var defaultOptions = [{
|
|
3060
3188
|
allowExpressions: true
|
|
3061
3189
|
}];
|
|
@@ -3081,15 +3209,15 @@ var no_useless_fragment_default = createRule({
|
|
|
3081
3209
|
}
|
|
3082
3210
|
}]
|
|
3083
3211
|
},
|
|
3084
|
-
name:
|
|
3085
|
-
create:
|
|
3212
|
+
name: RULE_NAME51,
|
|
3213
|
+
create: create51,
|
|
3086
3214
|
defaultOptions
|
|
3087
3215
|
});
|
|
3088
|
-
function
|
|
3216
|
+
function create51(context, [option]) {
|
|
3089
3217
|
const { allowExpressions = true } = option;
|
|
3090
3218
|
return {
|
|
3091
3219
|
JSXElement(node) {
|
|
3092
|
-
if (!
|
|
3220
|
+
if (!JSX9__namespace.isFragmentElement(node)) return;
|
|
3093
3221
|
checkNode(context, node, allowExpressions);
|
|
3094
3222
|
},
|
|
3095
3223
|
JSXFragment(node) {
|
|
@@ -3101,7 +3229,7 @@ function isWhiteSpace(node) {
|
|
|
3101
3229
|
return typeof node.value === "string" && node.raw.trim() === "";
|
|
3102
3230
|
}
|
|
3103
3231
|
function isPaddingSpaces(node) {
|
|
3104
|
-
return
|
|
3232
|
+
return JSX9__namespace.isJsxText(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
3105
3233
|
}
|
|
3106
3234
|
function trimLikeReact(text) {
|
|
3107
3235
|
const leadingSpaces = /^\s*/.exec(text)?.[0] ?? "";
|
|
@@ -3112,10 +3240,10 @@ function trimLikeReact(text) {
|
|
|
3112
3240
|
}
|
|
3113
3241
|
function checkNode(context, node, allowExpressions) {
|
|
3114
3242
|
const initialScope = context.sourceCode.getScope(node);
|
|
3115
|
-
if (
|
|
3243
|
+
if (JSX9__namespace.isKeyedElement(node, initialScope)) {
|
|
3116
3244
|
return;
|
|
3117
3245
|
}
|
|
3118
|
-
if (
|
|
3246
|
+
if (JSX9__namespace.isHostElement(node.parent)) {
|
|
3119
3247
|
context.report({
|
|
3120
3248
|
messageId: "uselessFragment",
|
|
3121
3249
|
node,
|
|
@@ -3139,7 +3267,7 @@ function checkNode(context, node, allowExpressions) {
|
|
|
3139
3267
|
const isChildElement = AST8__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3140
3268
|
switch (true) {
|
|
3141
3269
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3142
|
-
case (allowExpressions && !isChildElement && node.children.length === 1 &&
|
|
3270
|
+
case (allowExpressions && !isChildElement && node.children.length === 1 && JSX9__namespace.isJsxText(node.children.at(0))): {
|
|
3143
3271
|
return;
|
|
3144
3272
|
}
|
|
3145
3273
|
// <Foo><>hello, world</></Foo>
|
|
@@ -3195,18 +3323,18 @@ function getFix2(context, node) {
|
|
|
3195
3323
|
}
|
|
3196
3324
|
function canFix(node) {
|
|
3197
3325
|
if (node.parent.type === types.AST_NODE_TYPES.JSXElement || node.parent.type === types.AST_NODE_TYPES.JSXFragment) {
|
|
3198
|
-
return
|
|
3326
|
+
return JSX9__namespace.isHostElement(node.parent);
|
|
3199
3327
|
}
|
|
3200
3328
|
if (node.children.length === 0) {
|
|
3201
3329
|
return false;
|
|
3202
3330
|
}
|
|
3203
|
-
if (node.children.some((child) =>
|
|
3331
|
+
if (node.children.some((child) => JSX9__namespace.isJsxText(child) && !isWhiteSpace(child) || AST8__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(child))) {
|
|
3204
3332
|
return false;
|
|
3205
3333
|
}
|
|
3206
3334
|
return true;
|
|
3207
3335
|
}
|
|
3208
|
-
var
|
|
3209
|
-
var
|
|
3336
|
+
var RULE_NAME52 = "prefer-destructuring-assignment";
|
|
3337
|
+
var RULE_FEATURES51 = [];
|
|
3210
3338
|
function isMemberExpressionWithObjectName(node) {
|
|
3211
3339
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3212
3340
|
}
|
|
@@ -3215,19 +3343,19 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3215
3343
|
type: "problem",
|
|
3216
3344
|
docs: {
|
|
3217
3345
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3218
|
-
[Symbol.for("rule_features")]:
|
|
3346
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3219
3347
|
},
|
|
3220
3348
|
messages: {
|
|
3221
3349
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3222
3350
|
},
|
|
3223
3351
|
schema: []
|
|
3224
3352
|
},
|
|
3225
|
-
name:
|
|
3226
|
-
create:
|
|
3353
|
+
name: RULE_NAME52,
|
|
3354
|
+
create: create52,
|
|
3227
3355
|
defaultOptions: []
|
|
3228
3356
|
});
|
|
3229
|
-
function
|
|
3230
|
-
const { ctx, listeners } =
|
|
3357
|
+
function create52(context) {
|
|
3358
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollector(context);
|
|
3231
3359
|
const memberExpressionWithNames = [];
|
|
3232
3360
|
return {
|
|
3233
3361
|
...listeners,
|
|
@@ -3237,16 +3365,16 @@ function create50(context) {
|
|
|
3237
3365
|
memberExpressionWithNames.push([scope, node]);
|
|
3238
3366
|
}
|
|
3239
3367
|
},
|
|
3240
|
-
"Program:exit"(
|
|
3368
|
+
"Program:exit"(program) {
|
|
3241
3369
|
const components = [
|
|
3242
|
-
...ctx.getAllComponents(
|
|
3370
|
+
...ctx.getAllComponents(program).values()
|
|
3243
3371
|
];
|
|
3244
3372
|
function isFunctionComponent(block) {
|
|
3245
3373
|
if (!AST8__namespace.isFunction(block)) {
|
|
3246
3374
|
return false;
|
|
3247
3375
|
}
|
|
3248
3376
|
const id = AST8__namespace.getFunctionIdentifier(block);
|
|
3249
|
-
return id != null &&
|
|
3377
|
+
return id != null && ER22__namespace.isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3250
3378
|
}
|
|
3251
3379
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
3252
3380
|
let scope = initialScope;
|
|
@@ -3263,7 +3391,7 @@ function create50(context) {
|
|
|
3263
3391
|
continue;
|
|
3264
3392
|
}
|
|
3265
3393
|
const [props, ctx2] = component.params;
|
|
3266
|
-
const isMatch = (
|
|
3394
|
+
const isMatch = (node) => node != null && node.type === types.AST_NODE_TYPES.Identifier && node.name === memberExpression.object.name;
|
|
3267
3395
|
if (isMatch(props)) {
|
|
3268
3396
|
context.report({
|
|
3269
3397
|
messageId: "preferDestructuringAssignment",
|
|
@@ -3286,8 +3414,8 @@ function create50(context) {
|
|
|
3286
3414
|
}
|
|
3287
3415
|
};
|
|
3288
3416
|
}
|
|
3289
|
-
var
|
|
3290
|
-
var
|
|
3417
|
+
var RULE_NAME53 = "prefer-react-namespace-import";
|
|
3418
|
+
var RULE_FEATURES52 = [
|
|
3291
3419
|
"FIX"
|
|
3292
3420
|
];
|
|
3293
3421
|
var prefer_react_namespace_import_default = createRule({
|
|
@@ -3295,7 +3423,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3295
3423
|
type: "problem",
|
|
3296
3424
|
docs: {
|
|
3297
3425
|
description: "Enforces React is imported via a namespace import.",
|
|
3298
|
-
[Symbol.for("rule_features")]:
|
|
3426
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3299
3427
|
},
|
|
3300
3428
|
fixable: "code",
|
|
3301
3429
|
messages: {
|
|
@@ -3303,11 +3431,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3303
3431
|
},
|
|
3304
3432
|
schema: []
|
|
3305
3433
|
},
|
|
3306
|
-
name:
|
|
3307
|
-
create:
|
|
3434
|
+
name: RULE_NAME53,
|
|
3435
|
+
create: create53,
|
|
3308
3436
|
defaultOptions: []
|
|
3309
3437
|
});
|
|
3310
|
-
function
|
|
3438
|
+
function create53(context) {
|
|
3311
3439
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3312
3440
|
return {
|
|
3313
3441
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3342,8 +3470,8 @@ function create51(context) {
|
|
|
3342
3470
|
}
|
|
3343
3471
|
};
|
|
3344
3472
|
}
|
|
3345
|
-
var
|
|
3346
|
-
var
|
|
3473
|
+
var RULE_NAME54 = "prefer-read-only-props";
|
|
3474
|
+
var RULE_FEATURES53 = [
|
|
3347
3475
|
"TSC",
|
|
3348
3476
|
"EXP"
|
|
3349
3477
|
];
|
|
@@ -3352,24 +3480,24 @@ var prefer_read_only_props_default = createRule({
|
|
|
3352
3480
|
type: "problem",
|
|
3353
3481
|
docs: {
|
|
3354
3482
|
description: "Enforces read-only props in components.",
|
|
3355
|
-
[Symbol.for("rule_features")]:
|
|
3483
|
+
[Symbol.for("rule_features")]: RULE_FEATURES53
|
|
3356
3484
|
},
|
|
3357
3485
|
messages: {
|
|
3358
3486
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3359
3487
|
},
|
|
3360
3488
|
schema: []
|
|
3361
3489
|
},
|
|
3362
|
-
name:
|
|
3363
|
-
create:
|
|
3490
|
+
name: RULE_NAME54,
|
|
3491
|
+
create: create54,
|
|
3364
3492
|
defaultOptions: []
|
|
3365
3493
|
});
|
|
3366
|
-
function
|
|
3494
|
+
function create54(context) {
|
|
3367
3495
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3368
|
-
const { ctx, listeners } =
|
|
3496
|
+
const { ctx, listeners } = ER22__namespace.useComponentCollector(context);
|
|
3369
3497
|
return {
|
|
3370
3498
|
...listeners,
|
|
3371
|
-
"Program:exit"(
|
|
3372
|
-
const components = ctx.getAllComponents(
|
|
3499
|
+
"Program:exit"(program) {
|
|
3500
|
+
const components = ctx.getAllComponents(program);
|
|
3373
3501
|
for (const [, component] of components) {
|
|
3374
3502
|
const [props] = component.node.params;
|
|
3375
3503
|
if (props == null) {
|
|
@@ -3393,8 +3521,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3393
3521
|
return true;
|
|
3394
3522
|
}
|
|
3395
3523
|
}
|
|
3396
|
-
var
|
|
3397
|
-
var
|
|
3524
|
+
var RULE_NAME55 = "prefer-shorthand-boolean";
|
|
3525
|
+
var RULE_FEATURES54 = [
|
|
3398
3526
|
"FIX"
|
|
3399
3527
|
];
|
|
3400
3528
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3402,7 +3530,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3402
3530
|
type: "problem",
|
|
3403
3531
|
docs: {
|
|
3404
3532
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3405
|
-
[Symbol.for("rule_features")]:
|
|
3533
|
+
[Symbol.for("rule_features")]: RULE_FEATURES54
|
|
3406
3534
|
},
|
|
3407
3535
|
fixable: "code",
|
|
3408
3536
|
messages: {
|
|
@@ -3410,15 +3538,15 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3410
3538
|
},
|
|
3411
3539
|
schema: []
|
|
3412
3540
|
},
|
|
3413
|
-
name:
|
|
3414
|
-
create:
|
|
3541
|
+
name: RULE_NAME55,
|
|
3542
|
+
create: create55,
|
|
3415
3543
|
defaultOptions: []
|
|
3416
3544
|
});
|
|
3417
|
-
function
|
|
3545
|
+
function create55(context) {
|
|
3418
3546
|
return {
|
|
3419
3547
|
JSXAttribute(node) {
|
|
3420
3548
|
const { value } = node;
|
|
3421
|
-
const propName =
|
|
3549
|
+
const propName = JSX9__namespace.getAttributeName(node);
|
|
3422
3550
|
const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
|
|
3423
3551
|
if (!hasValueTrue) {
|
|
3424
3552
|
return;
|
|
@@ -3434,8 +3562,8 @@ function create53(context) {
|
|
|
3434
3562
|
}
|
|
3435
3563
|
};
|
|
3436
3564
|
}
|
|
3437
|
-
var
|
|
3438
|
-
var
|
|
3565
|
+
var RULE_NAME56 = "prefer-shorthand-fragment";
|
|
3566
|
+
var RULE_FEATURES55 = [
|
|
3439
3567
|
"FIX"
|
|
3440
3568
|
];
|
|
3441
3569
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3443,7 +3571,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3443
3571
|
type: "problem",
|
|
3444
3572
|
docs: {
|
|
3445
3573
|
description: "Enforces shorthand syntax for fragments.",
|
|
3446
|
-
[Symbol.for("rule_features")]:
|
|
3574
|
+
[Symbol.for("rule_features")]: RULE_FEATURES55
|
|
3447
3575
|
},
|
|
3448
3576
|
fixable: "code",
|
|
3449
3577
|
messages: {
|
|
@@ -3451,14 +3579,14 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3451
3579
|
},
|
|
3452
3580
|
schema: []
|
|
3453
3581
|
},
|
|
3454
|
-
name:
|
|
3455
|
-
create:
|
|
3582
|
+
name: RULE_NAME56,
|
|
3583
|
+
create: create56,
|
|
3456
3584
|
defaultOptions: []
|
|
3457
3585
|
});
|
|
3458
|
-
function
|
|
3586
|
+
function create56(context) {
|
|
3459
3587
|
return {
|
|
3460
3588
|
JSXElement(node) {
|
|
3461
|
-
if (!
|
|
3589
|
+
if (!JSX9__namespace.isFragmentElement(node)) return;
|
|
3462
3590
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3463
3591
|
if (hasAttributes) {
|
|
3464
3592
|
return;
|
|
@@ -3516,7 +3644,9 @@ var plugin = {
|
|
|
3516
3644
|
"no-missing-component-display-name": no_missing_component_display_name_default,
|
|
3517
3645
|
"no-missing-context-display-name": no_missing_context_display_name_default,
|
|
3518
3646
|
"no-missing-key": no_missing_key_default,
|
|
3647
|
+
"no-misused-capture-owner-stack": no_misused_capture_owner_stack_default,
|
|
3519
3648
|
"no-nested-component-definitions": no_nested_component_definitions_default,
|
|
3649
|
+
"no-nested-lazy-component-declarations": no_nested_lazy_component_declarations_default,
|
|
3520
3650
|
"no-prop-types": no_prop_types_default,
|
|
3521
3651
|
"no-redundant-should-component-update": no_redundant_should_component_update_default,
|
|
3522
3652
|
"no-set-state-in-component-did-mount": no_set_state_in_component_did_mount_default,
|