eslint-plugin-react-x 1.32.1 → 1.33.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +281 -279
- package/dist/index.mjs +281 -279
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var shared = require('@eslint-react/shared');
|
|
4
4
|
var JSX8 = require('@eslint-react/jsx');
|
|
5
|
-
var
|
|
5
|
+
var AST11 = require('@eslint-react/ast');
|
|
6
6
|
var core = require('@eslint-react/core');
|
|
7
7
|
var eff = require('@eslint-react/eff');
|
|
8
8
|
var types = require('@typescript-eslint/types');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
|
|
38
|
-
var
|
|
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
|
|
|
@@ -54,7 +54,6 @@ __export(recommended_exports, {
|
|
|
54
54
|
});
|
|
55
55
|
var name = "react-x/recommended";
|
|
56
56
|
var rules = {
|
|
57
|
-
"react-x/ensure-forward-ref-using-ref": "warn",
|
|
58
57
|
"react-x/no-access-state-in-setstate": "error",
|
|
59
58
|
"react-x/no-array-index-key": "warn",
|
|
60
59
|
"react-x/no-children-count": "warn",
|
|
@@ -91,6 +90,7 @@ var rules = {
|
|
|
91
90
|
"react-x/no-unused-class-component-members": "warn",
|
|
92
91
|
"react-x/no-unused-state": "warn",
|
|
93
92
|
"react-x/no-use-context": "warn",
|
|
93
|
+
"react-x/no-useless-forward-ref": "warn",
|
|
94
94
|
"react-x/use-jsx-vars": "warn"
|
|
95
95
|
};
|
|
96
96
|
var settings = {
|
|
@@ -136,7 +136,7 @@ var settings3 = {
|
|
|
136
136
|
|
|
137
137
|
// package.json
|
|
138
138
|
var name4 = "eslint-plugin-react-x";
|
|
139
|
-
var version = "1.
|
|
139
|
+
var version = "1.33.0-next.0";
|
|
140
140
|
var createRule = shared.createRuleForPlugin("x");
|
|
141
141
|
|
|
142
142
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -207,50 +207,10 @@ var avoid_shorthand_fragment_default = createRule({
|
|
|
207
207
|
},
|
|
208
208
|
defaultOptions: []
|
|
209
209
|
});
|
|
210
|
-
var RULE_NAME3 = "
|
|
210
|
+
var RULE_NAME3 = "no-access-state-in-setstate";
|
|
211
211
|
var RULE_FEATURES3 = [
|
|
212
212
|
"CHK"
|
|
213
213
|
];
|
|
214
|
-
var ensure_forward_ref_using_ref_default = createRule({
|
|
215
|
-
meta: {
|
|
216
|
-
type: "problem",
|
|
217
|
-
docs: {
|
|
218
|
-
description: "require a 'ref' parameter to be set when using 'forwardRef'",
|
|
219
|
-
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
220
|
-
},
|
|
221
|
-
messages: {
|
|
222
|
-
ensureForwardRefUsingRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
223
|
-
},
|
|
224
|
-
schema: []
|
|
225
|
-
},
|
|
226
|
-
name: RULE_NAME3,
|
|
227
|
-
create(context) {
|
|
228
|
-
return {
|
|
229
|
-
CallExpression(node) {
|
|
230
|
-
if (!core.isForwardRefCall(context, node)) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const [component] = node.arguments;
|
|
234
|
-
if (component == null || !AST12__namespace.isFunction(component)) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
const ref = component.params[1];
|
|
238
|
-
if (ref != null) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
context.report({
|
|
242
|
-
messageId: "ensureForwardRefUsingRef",
|
|
243
|
-
node: component
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
},
|
|
248
|
-
defaultOptions: []
|
|
249
|
-
});
|
|
250
|
-
var RULE_NAME4 = "no-access-state-in-setstate";
|
|
251
|
-
var RULE_FEATURES4 = [
|
|
252
|
-
"CHK"
|
|
253
|
-
];
|
|
254
214
|
function isKeyLiteral(node, key) {
|
|
255
215
|
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);
|
|
256
216
|
}
|
|
@@ -259,14 +219,14 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
259
219
|
type: "problem",
|
|
260
220
|
docs: {
|
|
261
221
|
description: "disallow accessing 'this.state' within 'setState'",
|
|
262
|
-
[Symbol.for("rule_features")]:
|
|
222
|
+
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
263
223
|
},
|
|
264
224
|
messages: {
|
|
265
225
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
266
226
|
},
|
|
267
227
|
schema: []
|
|
268
228
|
},
|
|
269
|
-
name:
|
|
229
|
+
name: RULE_NAME3,
|
|
270
230
|
create(context) {
|
|
271
231
|
if (!context.sourceCode.text.includes("setState")) {
|
|
272
232
|
return {};
|
|
@@ -300,7 +260,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
300
260
|
classEntries.pop();
|
|
301
261
|
},
|
|
302
262
|
MemberExpression(node) {
|
|
303
|
-
if (!
|
|
263
|
+
if (!AST11__namespace.isThisExpression(node.object)) {
|
|
304
264
|
return;
|
|
305
265
|
}
|
|
306
266
|
const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
|
|
@@ -315,7 +275,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
315
275
|
if (setState == null || hasThisState) {
|
|
316
276
|
return;
|
|
317
277
|
}
|
|
318
|
-
if (
|
|
278
|
+
if (AST11__namespace.getPropertyName(node.property) !== "state") {
|
|
319
279
|
return;
|
|
320
280
|
}
|
|
321
281
|
context.report({ messageId: "noAccessStateInSetstate", node });
|
|
@@ -345,11 +305,11 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
345
305
|
if (setState == null || hasThisState) {
|
|
346
306
|
return;
|
|
347
307
|
}
|
|
348
|
-
if (node.init == null || !
|
|
308
|
+
if (node.init == null || !AST11__namespace.isThisExpression(node.init) || node.id.type !== types.AST_NODE_TYPES.ObjectPattern) {
|
|
349
309
|
return;
|
|
350
310
|
}
|
|
351
311
|
const hasState = node.id.properties.some(
|
|
352
|
-
(prop) => prop.type === types.AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key) &&
|
|
312
|
+
(prop) => prop.type === types.AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key) && AST11__namespace.getPropertyName(prop.key) === "state"
|
|
353
313
|
);
|
|
354
314
|
if (!hasState) {
|
|
355
315
|
return;
|
|
@@ -360,8 +320,8 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
360
320
|
},
|
|
361
321
|
defaultOptions: []
|
|
362
322
|
});
|
|
363
|
-
var
|
|
364
|
-
var
|
|
323
|
+
var RULE_NAME4 = "no-array-index-key";
|
|
324
|
+
var RULE_FEATURES4 = [
|
|
365
325
|
"CHK"
|
|
366
326
|
];
|
|
367
327
|
var reactChildrenMethod = ["forEach", "map"];
|
|
@@ -416,7 +376,7 @@ function getMapIndexParamName(context, node) {
|
|
|
416
376
|
if (callbackArg == null) {
|
|
417
377
|
return eff._;
|
|
418
378
|
}
|
|
419
|
-
if (!
|
|
379
|
+
if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
|
|
420
380
|
return eff._;
|
|
421
381
|
}
|
|
422
382
|
const { params } = callbackArg;
|
|
@@ -435,14 +395,14 @@ var no_array_index_key_default = createRule({
|
|
|
435
395
|
type: "problem",
|
|
436
396
|
docs: {
|
|
437
397
|
description: "disallow using an item's index in the array as its key",
|
|
438
|
-
[Symbol.for("rule_features")]:
|
|
398
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
439
399
|
},
|
|
440
400
|
messages: {
|
|
441
401
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
442
402
|
},
|
|
443
403
|
schema: []
|
|
444
404
|
},
|
|
445
|
-
name:
|
|
405
|
+
name: RULE_NAME4,
|
|
446
406
|
create(context) {
|
|
447
407
|
const indexParamNames = [];
|
|
448
408
|
function isArrayIndex(node) {
|
|
@@ -560,8 +520,8 @@ function getIdentifiersFromBinaryExpression(side) {
|
|
|
560
520
|
}
|
|
561
521
|
return [];
|
|
562
522
|
}
|
|
563
|
-
var
|
|
564
|
-
var
|
|
523
|
+
var RULE_NAME5 = "no-children-count";
|
|
524
|
+
var RULE_FEATURES5 = [
|
|
565
525
|
"CHK"
|
|
566
526
|
];
|
|
567
527
|
var no_children_count_default = createRule({
|
|
@@ -569,14 +529,14 @@ var no_children_count_default = createRule({
|
|
|
569
529
|
type: "problem",
|
|
570
530
|
docs: {
|
|
571
531
|
description: "disallow using 'Children.count'",
|
|
572
|
-
[Symbol.for("rule_features")]:
|
|
532
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
573
533
|
},
|
|
574
534
|
messages: {
|
|
575
535
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
576
536
|
},
|
|
577
537
|
schema: []
|
|
578
538
|
},
|
|
579
|
-
name:
|
|
539
|
+
name: RULE_NAME5,
|
|
580
540
|
create(context) {
|
|
581
541
|
return {
|
|
582
542
|
MemberExpression(node) {
|
|
@@ -591,8 +551,8 @@ var no_children_count_default = createRule({
|
|
|
591
551
|
},
|
|
592
552
|
defaultOptions: []
|
|
593
553
|
});
|
|
594
|
-
var
|
|
595
|
-
var
|
|
554
|
+
var RULE_NAME6 = "no-children-for-each";
|
|
555
|
+
var RULE_FEATURES6 = [
|
|
596
556
|
"CHK"
|
|
597
557
|
];
|
|
598
558
|
var no_children_for_each_default = createRule({
|
|
@@ -600,14 +560,14 @@ var no_children_for_each_default = createRule({
|
|
|
600
560
|
type: "problem",
|
|
601
561
|
docs: {
|
|
602
562
|
description: "disallow using 'Children.forEach'",
|
|
603
|
-
[Symbol.for("rule_features")]:
|
|
563
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
604
564
|
},
|
|
605
565
|
messages: {
|
|
606
566
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
607
567
|
},
|
|
608
568
|
schema: []
|
|
609
569
|
},
|
|
610
|
-
name:
|
|
570
|
+
name: RULE_NAME6,
|
|
611
571
|
create(context) {
|
|
612
572
|
return {
|
|
613
573
|
MemberExpression(node) {
|
|
@@ -622,8 +582,8 @@ var no_children_for_each_default = createRule({
|
|
|
622
582
|
},
|
|
623
583
|
defaultOptions: []
|
|
624
584
|
});
|
|
625
|
-
var
|
|
626
|
-
var
|
|
585
|
+
var RULE_NAME7 = "no-children-map";
|
|
586
|
+
var RULE_FEATURES7 = [
|
|
627
587
|
"CHK"
|
|
628
588
|
];
|
|
629
589
|
var no_children_map_default = createRule({
|
|
@@ -631,14 +591,14 @@ var no_children_map_default = createRule({
|
|
|
631
591
|
type: "problem",
|
|
632
592
|
docs: {
|
|
633
593
|
description: "disallow using 'Children.map'",
|
|
634
|
-
[Symbol.for("rule_features")]:
|
|
594
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
635
595
|
},
|
|
636
596
|
messages: {
|
|
637
597
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
638
598
|
},
|
|
639
599
|
schema: []
|
|
640
600
|
},
|
|
641
|
-
name:
|
|
601
|
+
name: RULE_NAME7,
|
|
642
602
|
create(context) {
|
|
643
603
|
return {
|
|
644
604
|
MemberExpression(node) {
|
|
@@ -653,8 +613,8 @@ var no_children_map_default = createRule({
|
|
|
653
613
|
},
|
|
654
614
|
defaultOptions: []
|
|
655
615
|
});
|
|
656
|
-
var
|
|
657
|
-
var
|
|
616
|
+
var RULE_NAME8 = "no-children-only";
|
|
617
|
+
var RULE_FEATURES8 = [
|
|
658
618
|
"CHK"
|
|
659
619
|
];
|
|
660
620
|
var no_children_only_default = createRule({
|
|
@@ -662,14 +622,14 @@ var no_children_only_default = createRule({
|
|
|
662
622
|
type: "problem",
|
|
663
623
|
docs: {
|
|
664
624
|
description: "disallow using 'Children.only'",
|
|
665
|
-
[Symbol.for("rule_features")]:
|
|
625
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
666
626
|
},
|
|
667
627
|
messages: {
|
|
668
628
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
669
629
|
},
|
|
670
630
|
schema: []
|
|
671
631
|
},
|
|
672
|
-
name:
|
|
632
|
+
name: RULE_NAME8,
|
|
673
633
|
create(context) {
|
|
674
634
|
return {
|
|
675
635
|
MemberExpression(node) {
|
|
@@ -684,8 +644,8 @@ var no_children_only_default = createRule({
|
|
|
684
644
|
},
|
|
685
645
|
defaultOptions: []
|
|
686
646
|
});
|
|
687
|
-
var
|
|
688
|
-
var
|
|
647
|
+
var RULE_NAME9 = "no-children-prop";
|
|
648
|
+
var RULE_FEATURES9 = [
|
|
689
649
|
"CHK"
|
|
690
650
|
];
|
|
691
651
|
var no_children_prop_default = createRule({
|
|
@@ -693,14 +653,14 @@ var no_children_prop_default = createRule({
|
|
|
693
653
|
type: "problem",
|
|
694
654
|
docs: {
|
|
695
655
|
description: "disallow passing 'children' as props",
|
|
696
|
-
[Symbol.for("rule_features")]:
|
|
656
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
697
657
|
},
|
|
698
658
|
messages: {
|
|
699
659
|
noChildrenProp: "Do not pass 'children' as props."
|
|
700
660
|
},
|
|
701
661
|
schema: []
|
|
702
662
|
},
|
|
703
|
-
name:
|
|
663
|
+
name: RULE_NAME9,
|
|
704
664
|
create(context) {
|
|
705
665
|
return {
|
|
706
666
|
JSXElement(node) {
|
|
@@ -720,8 +680,8 @@ var no_children_prop_default = createRule({
|
|
|
720
680
|
},
|
|
721
681
|
defaultOptions: []
|
|
722
682
|
});
|
|
723
|
-
var
|
|
724
|
-
var
|
|
683
|
+
var RULE_NAME10 = "no-children-to-array";
|
|
684
|
+
var RULE_FEATURES10 = [
|
|
725
685
|
"CHK"
|
|
726
686
|
];
|
|
727
687
|
var no_children_to_array_default = createRule({
|
|
@@ -729,14 +689,14 @@ var no_children_to_array_default = createRule({
|
|
|
729
689
|
type: "problem",
|
|
730
690
|
docs: {
|
|
731
691
|
description: "disallow using 'Children.toArray'",
|
|
732
|
-
[Symbol.for("rule_features")]:
|
|
692
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
733
693
|
},
|
|
734
694
|
messages: {
|
|
735
695
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
736
696
|
},
|
|
737
697
|
schema: []
|
|
738
698
|
},
|
|
739
|
-
name:
|
|
699
|
+
name: RULE_NAME10,
|
|
740
700
|
create(context) {
|
|
741
701
|
return {
|
|
742
702
|
MemberExpression(node) {
|
|
@@ -751,8 +711,8 @@ var no_children_to_array_default = createRule({
|
|
|
751
711
|
},
|
|
752
712
|
defaultOptions: []
|
|
753
713
|
});
|
|
754
|
-
var
|
|
755
|
-
var
|
|
714
|
+
var RULE_NAME11 = "no-class-component";
|
|
715
|
+
var RULE_FEATURES11 = [
|
|
756
716
|
"CHK"
|
|
757
717
|
];
|
|
758
718
|
var no_class_component_default = createRule({
|
|
@@ -760,14 +720,14 @@ var no_class_component_default = createRule({
|
|
|
760
720
|
type: "problem",
|
|
761
721
|
docs: {
|
|
762
722
|
description: "disallow using class components",
|
|
763
|
-
[Symbol.for("rule_features")]:
|
|
723
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
764
724
|
},
|
|
765
725
|
messages: {
|
|
766
726
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
767
727
|
},
|
|
768
728
|
schema: []
|
|
769
729
|
},
|
|
770
|
-
name:
|
|
730
|
+
name: RULE_NAME11,
|
|
771
731
|
create(context) {
|
|
772
732
|
if (!context.sourceCode.text.includes("Component")) {
|
|
773
733
|
return {};
|
|
@@ -794,8 +754,8 @@ var no_class_component_default = createRule({
|
|
|
794
754
|
},
|
|
795
755
|
defaultOptions: []
|
|
796
756
|
});
|
|
797
|
-
var
|
|
798
|
-
var
|
|
757
|
+
var RULE_NAME12 = "no-clone-element";
|
|
758
|
+
var RULE_FEATURES12 = [
|
|
799
759
|
"CHK"
|
|
800
760
|
];
|
|
801
761
|
var no_clone_element_default = createRule({
|
|
@@ -803,14 +763,14 @@ var no_clone_element_default = createRule({
|
|
|
803
763
|
type: "problem",
|
|
804
764
|
docs: {
|
|
805
765
|
description: "disallow using 'cloneElement'",
|
|
806
|
-
[Symbol.for("rule_features")]:
|
|
766
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
807
767
|
},
|
|
808
768
|
messages: {
|
|
809
769
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
810
770
|
},
|
|
811
771
|
schema: []
|
|
812
772
|
},
|
|
813
|
-
name:
|
|
773
|
+
name: RULE_NAME12,
|
|
814
774
|
create(context) {
|
|
815
775
|
return {
|
|
816
776
|
CallExpression(node) {
|
|
@@ -826,8 +786,8 @@ var no_clone_element_default = createRule({
|
|
|
826
786
|
},
|
|
827
787
|
defaultOptions: []
|
|
828
788
|
});
|
|
829
|
-
var
|
|
830
|
-
var
|
|
789
|
+
var RULE_NAME13 = "no-comment-textnodes";
|
|
790
|
+
var RULE_FEATURES13 = [
|
|
831
791
|
"CHK"
|
|
832
792
|
];
|
|
833
793
|
var no_comment_textnodes_default = createRule({
|
|
@@ -835,24 +795,24 @@ var no_comment_textnodes_default = createRule({
|
|
|
835
795
|
type: "problem",
|
|
836
796
|
docs: {
|
|
837
797
|
description: "disallow comments from being inserted as text nodes",
|
|
838
|
-
[Symbol.for("rule_features")]:
|
|
798
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
839
799
|
},
|
|
840
800
|
messages: {
|
|
841
801
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
842
802
|
},
|
|
843
803
|
schema: []
|
|
844
804
|
},
|
|
845
|
-
name:
|
|
805
|
+
name: RULE_NAME13,
|
|
846
806
|
create(context) {
|
|
847
807
|
function hasCommentLike(node) {
|
|
848
|
-
if (
|
|
808
|
+
if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
849
809
|
return false;
|
|
850
810
|
}
|
|
851
811
|
const rawValue = context.sourceCode.getText(node);
|
|
852
812
|
return /^\s*\/(?:\/|\*)/mu.test(rawValue);
|
|
853
813
|
}
|
|
854
814
|
const visitorFunction = (node) => {
|
|
855
|
-
if (!
|
|
815
|
+
if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent)) {
|
|
856
816
|
return;
|
|
857
817
|
}
|
|
858
818
|
if (!hasCommentLike(node)) {
|
|
@@ -873,8 +833,8 @@ var no_comment_textnodes_default = createRule({
|
|
|
873
833
|
},
|
|
874
834
|
defaultOptions: []
|
|
875
835
|
});
|
|
876
|
-
var
|
|
877
|
-
var
|
|
836
|
+
var RULE_NAME14 = "no-complex-conditional-rendering";
|
|
837
|
+
var RULE_FEATURES14 = [
|
|
878
838
|
"CHK"
|
|
879
839
|
];
|
|
880
840
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -882,21 +842,21 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
882
842
|
type: "problem",
|
|
883
843
|
docs: {
|
|
884
844
|
description: "disallow complex conditional rendering",
|
|
885
|
-
[Symbol.for("rule_features")]:
|
|
845
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
886
846
|
},
|
|
887
847
|
messages: {
|
|
888
848
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
889
849
|
},
|
|
890
850
|
schema: []
|
|
891
851
|
},
|
|
892
|
-
name:
|
|
852
|
+
name: RULE_NAME14,
|
|
893
853
|
create(context) {
|
|
894
854
|
const visitorFunction = (node) => {
|
|
895
855
|
const jsxExpContainer = node.parent?.parent;
|
|
896
|
-
if (!
|
|
856
|
+
if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
897
857
|
return;
|
|
898
858
|
}
|
|
899
|
-
if (!
|
|
859
|
+
if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
|
|
900
860
|
return;
|
|
901
861
|
}
|
|
902
862
|
if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
|
|
@@ -917,20 +877,20 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
917
877
|
},
|
|
918
878
|
defaultOptions: []
|
|
919
879
|
});
|
|
920
|
-
var
|
|
921
|
-
var
|
|
880
|
+
var RULE_NAME15 = "no-component-will-mount";
|
|
881
|
+
var RULE_FEATURES15 = [
|
|
922
882
|
"CHK",
|
|
923
883
|
"MOD"
|
|
924
884
|
];
|
|
925
885
|
function isComponentWillMount(node) {
|
|
926
|
-
return
|
|
886
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
927
887
|
}
|
|
928
888
|
var no_component_will_mount_default = createRule({
|
|
929
889
|
meta: {
|
|
930
890
|
type: "problem",
|
|
931
891
|
docs: {
|
|
932
892
|
description: "replace usages of 'componentWillMount' with 'UNSAFE_componentWillMount'",
|
|
933
|
-
[Symbol.for("rule_features")]:
|
|
893
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
934
894
|
},
|
|
935
895
|
fixable: "code",
|
|
936
896
|
messages: {
|
|
@@ -938,7 +898,7 @@ var no_component_will_mount_default = createRule({
|
|
|
938
898
|
},
|
|
939
899
|
schema: []
|
|
940
900
|
},
|
|
941
|
-
name:
|
|
901
|
+
name: RULE_NAME15,
|
|
942
902
|
create(context) {
|
|
943
903
|
if (!context.sourceCode.text.includes("componentWillMount")) {
|
|
944
904
|
return {};
|
|
@@ -970,20 +930,20 @@ var no_component_will_mount_default = createRule({
|
|
|
970
930
|
},
|
|
971
931
|
defaultOptions: []
|
|
972
932
|
});
|
|
973
|
-
var
|
|
974
|
-
var
|
|
933
|
+
var RULE_NAME16 = "no-component-will-receive-props";
|
|
934
|
+
var RULE_FEATURES16 = [
|
|
975
935
|
"CHK",
|
|
976
936
|
"MOD"
|
|
977
937
|
];
|
|
978
938
|
function isComponentWillUpdate(node) {
|
|
979
|
-
return
|
|
939
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
980
940
|
}
|
|
981
941
|
var no_component_will_receive_props_default = createRule({
|
|
982
942
|
meta: {
|
|
983
943
|
type: "problem",
|
|
984
944
|
docs: {
|
|
985
945
|
description: "replace usages of 'componentWillReceiveProps' with 'UNSAFE_componentWillReceiveProps'",
|
|
986
|
-
[Symbol.for("rule_features")]:
|
|
946
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
987
947
|
},
|
|
988
948
|
fixable: "code",
|
|
989
949
|
messages: {
|
|
@@ -991,7 +951,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
991
951
|
},
|
|
992
952
|
schema: []
|
|
993
953
|
},
|
|
994
|
-
name:
|
|
954
|
+
name: RULE_NAME16,
|
|
995
955
|
create(context) {
|
|
996
956
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) {
|
|
997
957
|
return {};
|
|
@@ -1023,20 +983,20 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1023
983
|
},
|
|
1024
984
|
defaultOptions: []
|
|
1025
985
|
});
|
|
1026
|
-
var
|
|
1027
|
-
var
|
|
986
|
+
var RULE_NAME17 = "no-component-will-update";
|
|
987
|
+
var RULE_FEATURES17 = [
|
|
1028
988
|
"CHK",
|
|
1029
989
|
"MOD"
|
|
1030
990
|
];
|
|
1031
991
|
function isComponentWillUpdate2(node) {
|
|
1032
|
-
return
|
|
992
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
1033
993
|
}
|
|
1034
994
|
var no_component_will_update_default = createRule({
|
|
1035
995
|
meta: {
|
|
1036
996
|
type: "problem",
|
|
1037
997
|
docs: {
|
|
1038
998
|
description: "replace usages of 'componentWillUpdate' with 'UNSAFE_componentWillUpdate'",
|
|
1039
|
-
[Symbol.for("rule_features")]:
|
|
999
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
1040
1000
|
},
|
|
1041
1001
|
fixable: "code",
|
|
1042
1002
|
messages: {
|
|
@@ -1044,7 +1004,7 @@ var no_component_will_update_default = createRule({
|
|
|
1044
1004
|
},
|
|
1045
1005
|
schema: []
|
|
1046
1006
|
},
|
|
1047
|
-
name:
|
|
1007
|
+
name: RULE_NAME17,
|
|
1048
1008
|
create(context) {
|
|
1049
1009
|
if (!context.sourceCode.text.includes("componentWillUpdate")) {
|
|
1050
1010
|
return {};
|
|
@@ -1076,8 +1036,8 @@ var no_component_will_update_default = createRule({
|
|
|
1076
1036
|
},
|
|
1077
1037
|
defaultOptions: []
|
|
1078
1038
|
});
|
|
1079
|
-
var
|
|
1080
|
-
var
|
|
1039
|
+
var RULE_NAME18 = "no-context-provider";
|
|
1040
|
+
var RULE_FEATURES18 = [
|
|
1081
1041
|
"CHK",
|
|
1082
1042
|
"MOD"
|
|
1083
1043
|
];
|
|
@@ -1086,7 +1046,7 @@ var no_context_provider_default = createRule({
|
|
|
1086
1046
|
type: "problem",
|
|
1087
1047
|
docs: {
|
|
1088
1048
|
description: "replace usages of '<Context.Provider>' with '<Context>'",
|
|
1089
|
-
[Symbol.for("rule_features")]:
|
|
1049
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
1090
1050
|
},
|
|
1091
1051
|
fixable: "code",
|
|
1092
1052
|
messages: {
|
|
@@ -1094,7 +1054,7 @@ var no_context_provider_default = createRule({
|
|
|
1094
1054
|
},
|
|
1095
1055
|
schema: []
|
|
1096
1056
|
},
|
|
1097
|
-
name:
|
|
1057
|
+
name: RULE_NAME18,
|
|
1098
1058
|
create(context) {
|
|
1099
1059
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1100
1060
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
@@ -1129,8 +1089,8 @@ var no_context_provider_default = createRule({
|
|
|
1129
1089
|
},
|
|
1130
1090
|
defaultOptions: []
|
|
1131
1091
|
});
|
|
1132
|
-
var
|
|
1133
|
-
var
|
|
1092
|
+
var RULE_NAME19 = "no-create-ref";
|
|
1093
|
+
var RULE_FEATURES19 = [
|
|
1134
1094
|
"CHK"
|
|
1135
1095
|
];
|
|
1136
1096
|
var no_create_ref_default = createRule({
|
|
@@ -1138,18 +1098,18 @@ var no_create_ref_default = createRule({
|
|
|
1138
1098
|
type: "problem",
|
|
1139
1099
|
docs: {
|
|
1140
1100
|
description: "disallow using 'createRef' in function components",
|
|
1141
|
-
[Symbol.for("rule_features")]:
|
|
1101
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
1142
1102
|
},
|
|
1143
1103
|
messages: {
|
|
1144
1104
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1145
1105
|
},
|
|
1146
1106
|
schema: []
|
|
1147
1107
|
},
|
|
1148
|
-
name:
|
|
1108
|
+
name: RULE_NAME19,
|
|
1149
1109
|
create(context) {
|
|
1150
1110
|
return {
|
|
1151
1111
|
CallExpression(node) {
|
|
1152
|
-
if (core.isCreateRefCall(context, node) &&
|
|
1112
|
+
if (core.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
|
|
1153
1113
|
context.report({ messageId: "noCreateRef", node });
|
|
1154
1114
|
}
|
|
1155
1115
|
}
|
|
@@ -1157,8 +1117,8 @@ var no_create_ref_default = createRule({
|
|
|
1157
1117
|
},
|
|
1158
1118
|
defaultOptions: []
|
|
1159
1119
|
});
|
|
1160
|
-
var
|
|
1161
|
-
var
|
|
1120
|
+
var RULE_NAME20 = "no-default-props";
|
|
1121
|
+
var RULE_FEATURES20 = [
|
|
1162
1122
|
"CHK"
|
|
1163
1123
|
];
|
|
1164
1124
|
var no_default_props_default = createRule({
|
|
@@ -1166,14 +1126,14 @@ var no_default_props_default = createRule({
|
|
|
1166
1126
|
type: "problem",
|
|
1167
1127
|
docs: {
|
|
1168
1128
|
description: "disallow using 'defaultProps' property in components",
|
|
1169
|
-
[Symbol.for("rule_features")]:
|
|
1129
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1170
1130
|
},
|
|
1171
1131
|
messages: {
|
|
1172
1132
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1173
1133
|
},
|
|
1174
1134
|
schema: []
|
|
1175
1135
|
},
|
|
1176
|
-
name:
|
|
1136
|
+
name: RULE_NAME20,
|
|
1177
1137
|
create(context) {
|
|
1178
1138
|
if (!context.sourceCode.text.includes("defaultProps")) {
|
|
1179
1139
|
return {};
|
|
@@ -1196,7 +1156,7 @@ var no_default_props_default = createRule({
|
|
|
1196
1156
|
const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1197
1157
|
const variableNode = VAR__namespace.getVariableInitNode(variable, 0);
|
|
1198
1158
|
if (variableNode == null) return;
|
|
1199
|
-
if (!
|
|
1159
|
+
if (!AST11__namespace.isFunction(variableNode) && !core.isClassComponent(variableNode)) return;
|
|
1200
1160
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
1201
1161
|
},
|
|
1202
1162
|
PropertyDefinition(node) {
|
|
@@ -1212,41 +1172,41 @@ var no_default_props_default = createRule({
|
|
|
1212
1172
|
},
|
|
1213
1173
|
defaultOptions: []
|
|
1214
1174
|
});
|
|
1215
|
-
var
|
|
1216
|
-
var
|
|
1175
|
+
var RULE_NAME21 = "no-direct-mutation-state";
|
|
1176
|
+
var RULE_FEATURES21 = [
|
|
1217
1177
|
"CHK"
|
|
1218
1178
|
];
|
|
1219
1179
|
function isConstructorFunction(node) {
|
|
1220
|
-
return
|
|
1180
|
+
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.FunctionDeclaration, types.AST_NODE_TYPES.FunctionExpression])(node) && AST11__namespace.isMethodOrProperty(node.parent) && node.parent.key.type === types.AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1221
1181
|
}
|
|
1222
1182
|
var no_direct_mutation_state_default = createRule({
|
|
1223
1183
|
meta: {
|
|
1224
1184
|
type: "problem",
|
|
1225
1185
|
docs: {
|
|
1226
1186
|
description: "disallow direct mutation of state",
|
|
1227
|
-
[Symbol.for("rule_features")]:
|
|
1187
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1228
1188
|
},
|
|
1229
1189
|
messages: {
|
|
1230
1190
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1231
1191
|
},
|
|
1232
1192
|
schema: []
|
|
1233
1193
|
},
|
|
1234
|
-
name:
|
|
1194
|
+
name: RULE_NAME21,
|
|
1235
1195
|
create(context) {
|
|
1236
1196
|
return {
|
|
1237
1197
|
AssignmentExpression(node) {
|
|
1238
1198
|
if (!core.isAssignmentToThisState(node)) {
|
|
1239
1199
|
return;
|
|
1240
1200
|
}
|
|
1241
|
-
const parentClass =
|
|
1201
|
+
const parentClass = AST11__namespace.findParentNode(
|
|
1242
1202
|
node,
|
|
1243
|
-
|
|
1203
|
+
AST11__namespace.isOneOf([
|
|
1244
1204
|
types.AST_NODE_TYPES.ClassDeclaration,
|
|
1245
1205
|
types.AST_NODE_TYPES.ClassExpression
|
|
1246
1206
|
])
|
|
1247
1207
|
);
|
|
1248
1208
|
if (parentClass == null) return;
|
|
1249
|
-
if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !==
|
|
1209
|
+
if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNode(node, isConstructorFunction)) {
|
|
1250
1210
|
context.report({
|
|
1251
1211
|
messageId: "noDirectMutationState",
|
|
1252
1212
|
node
|
|
@@ -1257,8 +1217,8 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1257
1217
|
},
|
|
1258
1218
|
defaultOptions: []
|
|
1259
1219
|
});
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1220
|
+
var RULE_NAME22 = "no-duplicate-jsx-props";
|
|
1221
|
+
var RULE_FEATURES22 = [
|
|
1262
1222
|
"CHK"
|
|
1263
1223
|
];
|
|
1264
1224
|
var no_duplicate_jsx_props_default = createRule({
|
|
@@ -1266,14 +1226,14 @@ var no_duplicate_jsx_props_default = createRule({
|
|
|
1266
1226
|
type: "problem",
|
|
1267
1227
|
docs: {
|
|
1268
1228
|
description: "disallow duplicate props",
|
|
1269
|
-
[Symbol.for("rule_features")]:
|
|
1229
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1270
1230
|
},
|
|
1271
1231
|
messages: {
|
|
1272
1232
|
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1273
1233
|
},
|
|
1274
1234
|
schema: []
|
|
1275
1235
|
},
|
|
1276
|
-
name:
|
|
1236
|
+
name: RULE_NAME22,
|
|
1277
1237
|
create(context) {
|
|
1278
1238
|
return {
|
|
1279
1239
|
JSXOpeningElement(node) {
|
|
@@ -1300,8 +1260,8 @@ var no_duplicate_jsx_props_default = createRule({
|
|
|
1300
1260
|
},
|
|
1301
1261
|
defaultOptions: []
|
|
1302
1262
|
});
|
|
1303
|
-
var
|
|
1304
|
-
var
|
|
1263
|
+
var RULE_NAME23 = "no-duplicate-key";
|
|
1264
|
+
var RULE_FEATURES23 = [
|
|
1305
1265
|
"CHK"
|
|
1306
1266
|
];
|
|
1307
1267
|
var no_duplicate_key_default = createRule({
|
|
@@ -1309,14 +1269,14 @@ var no_duplicate_key_default = createRule({
|
|
|
1309
1269
|
type: "problem",
|
|
1310
1270
|
docs: {
|
|
1311
1271
|
description: "disallow duplicate keys when rendering list",
|
|
1312
|
-
[Symbol.for("rule_features")]:
|
|
1272
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1313
1273
|
},
|
|
1314
1274
|
messages: {
|
|
1315
1275
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1316
1276
|
},
|
|
1317
1277
|
schema: []
|
|
1318
1278
|
},
|
|
1319
|
-
name:
|
|
1279
|
+
name: RULE_NAME23,
|
|
1320
1280
|
create(context) {
|
|
1321
1281
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1322
1282
|
return {};
|
|
@@ -1328,7 +1288,7 @@ var no_duplicate_key_default = createRule({
|
|
|
1328
1288
|
if (aValue == null || bValue == null) {
|
|
1329
1289
|
return false;
|
|
1330
1290
|
}
|
|
1331
|
-
return
|
|
1291
|
+
return AST11__namespace.isNodeEqual(aValue, bValue);
|
|
1332
1292
|
}
|
|
1333
1293
|
return {
|
|
1334
1294
|
"JSXAttribute[name.name='key']"(node) {
|
|
@@ -1347,12 +1307,12 @@ var no_duplicate_key_default = createRule({
|
|
|
1347
1307
|
break;
|
|
1348
1308
|
}
|
|
1349
1309
|
default: {
|
|
1350
|
-
const call =
|
|
1351
|
-
const iter =
|
|
1352
|
-
if (!
|
|
1310
|
+
const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.isMapCallLoose);
|
|
1311
|
+
const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
|
|
1312
|
+
if (!AST11__namespace.isFunction(iter)) return;
|
|
1353
1313
|
const arg0 = call?.arguments[0];
|
|
1354
1314
|
if (call == null || arg0 == null) return;
|
|
1355
|
-
if (
|
|
1315
|
+
if (AST11__namespace.getEcmaExpression(arg0) !== iter) {
|
|
1356
1316
|
return;
|
|
1357
1317
|
}
|
|
1358
1318
|
keyedEntries.set(call, {
|
|
@@ -1383,8 +1343,8 @@ var no_duplicate_key_default = createRule({
|
|
|
1383
1343
|
},
|
|
1384
1344
|
defaultOptions: []
|
|
1385
1345
|
});
|
|
1386
|
-
var
|
|
1387
|
-
var
|
|
1346
|
+
var RULE_NAME24 = "no-forward-ref";
|
|
1347
|
+
var RULE_FEATURES24 = [
|
|
1388
1348
|
"CHK",
|
|
1389
1349
|
"MOD"
|
|
1390
1350
|
];
|
|
@@ -1393,7 +1353,7 @@ var no_forward_ref_default = createRule({
|
|
|
1393
1353
|
type: "problem",
|
|
1394
1354
|
docs: {
|
|
1395
1355
|
description: "replace usages of 'forwardRef' with passing 'ref' as a prop",
|
|
1396
|
-
[Symbol.for("rule_features")]:
|
|
1356
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1397
1357
|
},
|
|
1398
1358
|
fixable: "code",
|
|
1399
1359
|
messages: {
|
|
@@ -1401,7 +1361,7 @@ var no_forward_ref_default = createRule({
|
|
|
1401
1361
|
},
|
|
1402
1362
|
schema: []
|
|
1403
1363
|
},
|
|
1404
|
-
name:
|
|
1364
|
+
name: RULE_NAME24,
|
|
1405
1365
|
create(context) {
|
|
1406
1366
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1407
1367
|
return {};
|
|
@@ -1428,7 +1388,7 @@ var no_forward_ref_default = createRule({
|
|
|
1428
1388
|
function getFix(context, node) {
|
|
1429
1389
|
return (fixer) => {
|
|
1430
1390
|
const [componentNode] = node.arguments;
|
|
1431
|
-
if (componentNode == null || !
|
|
1391
|
+
if (componentNode == null || !AST11__namespace.isFunction(componentNode)) {
|
|
1432
1392
|
return [];
|
|
1433
1393
|
}
|
|
1434
1394
|
return [
|
|
@@ -1492,8 +1452,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1492
1452
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1493
1453
|
];
|
|
1494
1454
|
}
|
|
1495
|
-
var
|
|
1496
|
-
var
|
|
1455
|
+
var RULE_NAME25 = "no-implicit-key";
|
|
1456
|
+
var RULE_FEATURES25 = [
|
|
1497
1457
|
"CHK"
|
|
1498
1458
|
];
|
|
1499
1459
|
var no_implicit_key_default = createRule({
|
|
@@ -1501,14 +1461,14 @@ var no_implicit_key_default = createRule({
|
|
|
1501
1461
|
type: "problem",
|
|
1502
1462
|
docs: {
|
|
1503
1463
|
description: "disallow implicit 'key' props",
|
|
1504
|
-
[Symbol.for("rule_features")]:
|
|
1464
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1505
1465
|
},
|
|
1506
1466
|
messages: {
|
|
1507
1467
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1508
1468
|
},
|
|
1509
1469
|
schema: []
|
|
1510
1470
|
},
|
|
1511
|
-
name:
|
|
1471
|
+
name: RULE_NAME25,
|
|
1512
1472
|
create(context) {
|
|
1513
1473
|
return {
|
|
1514
1474
|
JSXOpeningElement(node) {
|
|
@@ -1525,8 +1485,8 @@ var no_implicit_key_default = createRule({
|
|
|
1525
1485
|
},
|
|
1526
1486
|
defaultOptions: []
|
|
1527
1487
|
});
|
|
1528
|
-
var
|
|
1529
|
-
var
|
|
1488
|
+
var RULE_NAME26 = "no-leaked-conditional-rendering";
|
|
1489
|
+
var RULE_FEATURES26 = [
|
|
1530
1490
|
"CHK",
|
|
1531
1491
|
"TSC"
|
|
1532
1492
|
];
|
|
@@ -1613,14 +1573,14 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1613
1573
|
type: "problem",
|
|
1614
1574
|
docs: {
|
|
1615
1575
|
description: "disallow problematic leaked values from being rendered",
|
|
1616
|
-
[Symbol.for("rule_features")]:
|
|
1576
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1617
1577
|
},
|
|
1618
1578
|
messages: {
|
|
1619
1579
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1620
1580
|
},
|
|
1621
1581
|
schema: []
|
|
1622
1582
|
},
|
|
1623
|
-
name:
|
|
1583
|
+
name: RULE_NAME26,
|
|
1624
1584
|
create(context) {
|
|
1625
1585
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) {
|
|
1626
1586
|
return {};
|
|
@@ -1641,7 +1601,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1641
1601
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
1642
1602
|
function getReportDescriptor(node) {
|
|
1643
1603
|
if (node == null) return eff._;
|
|
1644
|
-
return tsPattern.match(node).when(
|
|
1604
|
+
return tsPattern.match(node).when(AST11__namespace.isJSX, () => eff._).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
|
|
1645
1605
|
const isLeftUnaryNot = left.type === types.AST_NODE_TYPES.UnaryExpression && left.operator === "!";
|
|
1646
1606
|
if (isLeftUnaryNot) {
|
|
1647
1607
|
return getReportDescriptor(right);
|
|
@@ -1686,8 +1646,8 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1686
1646
|
},
|
|
1687
1647
|
defaultOptions: []
|
|
1688
1648
|
});
|
|
1689
|
-
var
|
|
1690
|
-
var
|
|
1649
|
+
var RULE_NAME27 = "no-missing-component-display-name";
|
|
1650
|
+
var RULE_FEATURES27 = [
|
|
1691
1651
|
"CHK"
|
|
1692
1652
|
];
|
|
1693
1653
|
var no_missing_component_display_name_default = createRule({
|
|
@@ -1695,14 +1655,14 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1695
1655
|
type: "problem",
|
|
1696
1656
|
docs: {
|
|
1697
1657
|
description: "require 'displayName' for 'memo' and 'forwardRef' components",
|
|
1698
|
-
[Symbol.for("rule_features")]:
|
|
1658
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1699
1659
|
},
|
|
1700
1660
|
messages: {
|
|
1701
1661
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1702
1662
|
},
|
|
1703
1663
|
schema: []
|
|
1704
1664
|
},
|
|
1705
|
-
name:
|
|
1665
|
+
name: RULE_NAME27,
|
|
1706
1666
|
create(context) {
|
|
1707
1667
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) {
|
|
1708
1668
|
return {};
|
|
@@ -1724,7 +1684,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1724
1684
|
const components = ctx.getAllComponents(node);
|
|
1725
1685
|
for (const { node: node2, displayName, flag } of components.values()) {
|
|
1726
1686
|
const isMemoOrForwardRef = (flag & (core.ERComponentFlag.ForwardRef | core.ERComponentFlag.Memo)) > 0n;
|
|
1727
|
-
if (
|
|
1687
|
+
if (AST11__namespace.getFunctionIdentifier(node2) != null) {
|
|
1728
1688
|
continue;
|
|
1729
1689
|
}
|
|
1730
1690
|
if (!isMemoOrForwardRef) {
|
|
@@ -1742,8 +1702,8 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1742
1702
|
},
|
|
1743
1703
|
defaultOptions: []
|
|
1744
1704
|
});
|
|
1745
|
-
var
|
|
1746
|
-
var
|
|
1705
|
+
var RULE_NAME28 = "no-missing-context-display-name";
|
|
1706
|
+
var RULE_FEATURES28 = [
|
|
1747
1707
|
"CHK"
|
|
1748
1708
|
];
|
|
1749
1709
|
var no_missing_context_display_name_default = createRule({
|
|
@@ -1751,14 +1711,14 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1751
1711
|
type: "problem",
|
|
1752
1712
|
docs: {
|
|
1753
1713
|
description: "require 'displayName' for contexts.",
|
|
1754
|
-
[Symbol.for("rule_features")]:
|
|
1714
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1755
1715
|
},
|
|
1756
1716
|
messages: {
|
|
1757
1717
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1758
1718
|
},
|
|
1759
1719
|
schema: []
|
|
1760
1720
|
},
|
|
1761
|
-
name:
|
|
1721
|
+
name: RULE_NAME28,
|
|
1762
1722
|
create(context) {
|
|
1763
1723
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1764
1724
|
const createCalls = [];
|
|
@@ -1799,8 +1759,8 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1799
1759
|
},
|
|
1800
1760
|
defaultOptions: []
|
|
1801
1761
|
});
|
|
1802
|
-
var
|
|
1803
|
-
var
|
|
1762
|
+
var RULE_NAME29 = "no-missing-key";
|
|
1763
|
+
var RULE_FEATURES29 = [
|
|
1804
1764
|
"CHK"
|
|
1805
1765
|
];
|
|
1806
1766
|
var no_missing_key_default = createRule({
|
|
@@ -1808,7 +1768,7 @@ var no_missing_key_default = createRule({
|
|
|
1808
1768
|
type: "problem",
|
|
1809
1769
|
docs: {
|
|
1810
1770
|
description: "require 'key' when rendering list",
|
|
1811
|
-
[Symbol.for("rule_features")]:
|
|
1771
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1812
1772
|
},
|
|
1813
1773
|
messages: {
|
|
1814
1774
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1816,7 +1776,7 @@ var no_missing_key_default = createRule({
|
|
|
1816
1776
|
},
|
|
1817
1777
|
schema: []
|
|
1818
1778
|
},
|
|
1819
|
-
name:
|
|
1779
|
+
name: RULE_NAME29,
|
|
1820
1780
|
create(context) {
|
|
1821
1781
|
const state = { isWithinChildrenToArray: false };
|
|
1822
1782
|
function checkIteratorElement(node) {
|
|
@@ -1862,7 +1822,7 @@ var no_missing_key_default = createRule({
|
|
|
1862
1822
|
}
|
|
1863
1823
|
function checkBlockStatement(node) {
|
|
1864
1824
|
const descriptors = [];
|
|
1865
|
-
for (const statement of
|
|
1825
|
+
for (const statement of AST11__namespace.getNestedReturnStatements(node)) {
|
|
1866
1826
|
if (statement.argument == null) {
|
|
1867
1827
|
continue;
|
|
1868
1828
|
}
|
|
@@ -1878,7 +1838,7 @@ var no_missing_key_default = createRule({
|
|
|
1878
1838
|
if (state.isWithinChildrenToArray) {
|
|
1879
1839
|
return;
|
|
1880
1840
|
}
|
|
1881
|
-
const elements = node.elements.filter(
|
|
1841
|
+
const elements = node.elements.filter(AST11__namespace.is(types.AST_NODE_TYPES.JSXElement));
|
|
1882
1842
|
if (elements.length === 0) {
|
|
1883
1843
|
return;
|
|
1884
1844
|
}
|
|
@@ -1897,7 +1857,7 @@ var no_missing_key_default = createRule({
|
|
|
1897
1857
|
if (state.isWithinChildrenToArray) {
|
|
1898
1858
|
return;
|
|
1899
1859
|
}
|
|
1900
|
-
const isMapCallLike =
|
|
1860
|
+
const isMapCallLike = AST11__namespace.isMapCallLoose(node);
|
|
1901
1861
|
if (!isMapCallLike && !isArrayFromCall(node)) {
|
|
1902
1862
|
return;
|
|
1903
1863
|
}
|
|
@@ -1940,8 +1900,8 @@ var no_missing_key_default = createRule({
|
|
|
1940
1900
|
function isArrayFromCall(node) {
|
|
1941
1901
|
return node.type === types.AST_NODE_TYPES.CallExpression && node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1942
1902
|
}
|
|
1943
|
-
var
|
|
1944
|
-
var
|
|
1903
|
+
var RULE_NAME30 = "no-nested-components";
|
|
1904
|
+
var RULE_FEATURES30 = [
|
|
1945
1905
|
"CHK"
|
|
1946
1906
|
];
|
|
1947
1907
|
var no_nested_components_default = createRule({
|
|
@@ -1949,7 +1909,7 @@ var no_nested_components_default = createRule({
|
|
|
1949
1909
|
type: "problem",
|
|
1950
1910
|
docs: {
|
|
1951
1911
|
description: "disallow using unstable nested components",
|
|
1952
|
-
[Symbol.for("rule_features")]:
|
|
1912
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1953
1913
|
},
|
|
1954
1914
|
messages: {
|
|
1955
1915
|
nestedComponent: "Do not nest components inside other components. Move it to the top level.",
|
|
@@ -1957,7 +1917,7 @@ var no_nested_components_default = createRule({
|
|
|
1957
1917
|
},
|
|
1958
1918
|
schema: []
|
|
1959
1919
|
},
|
|
1960
|
-
name:
|
|
1920
|
+
name: RULE_NAME30,
|
|
1961
1921
|
create(context) {
|
|
1962
1922
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1963
1923
|
const collector = core.useComponentCollector(context, { hint });
|
|
@@ -1973,10 +1933,10 @@ var no_nested_components_default = createRule({
|
|
|
1973
1933
|
...collectorLegacy.ctx.getAllComponents(node).values()
|
|
1974
1934
|
];
|
|
1975
1935
|
const isFunctionComponent = (node2) => {
|
|
1976
|
-
return
|
|
1936
|
+
return AST11__namespace.isFunction(node2) && functionComponents.some((component) => component.node === node2);
|
|
1977
1937
|
};
|
|
1978
1938
|
const isClassComponent11 = (node2) => {
|
|
1979
|
-
return
|
|
1939
|
+
return AST11__namespace.isClass(node2) && classComponents.some((component) => component.node === node2);
|
|
1980
1940
|
};
|
|
1981
1941
|
for (const { name: name5, node: component } of functionComponents) {
|
|
1982
1942
|
if (core.isDirectValueOfRenderPropertyLoose(component)) {
|
|
@@ -2009,7 +1969,7 @@ var no_nested_components_default = createRule({
|
|
|
2009
1969
|
});
|
|
2010
1970
|
continue;
|
|
2011
1971
|
}
|
|
2012
|
-
const parentComponent =
|
|
1972
|
+
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
2013
1973
|
const isParentComponentNotDirectValueOfRenderProperty = parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
|
|
2014
1974
|
if (isParentComponentNotDirectValueOfRenderProperty) {
|
|
2015
1975
|
context.report({
|
|
@@ -2032,7 +1992,7 @@ var no_nested_components_default = createRule({
|
|
|
2032
1992
|
}
|
|
2033
1993
|
}
|
|
2034
1994
|
for (const { name: name5 = "unknown", node: component } of classComponents) {
|
|
2035
|
-
if (
|
|
1995
|
+
if (AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
|
|
2036
1996
|
continue;
|
|
2037
1997
|
}
|
|
2038
1998
|
context.report({
|
|
@@ -2049,14 +2009,14 @@ var no_nested_components_default = createRule({
|
|
|
2049
2009
|
defaultOptions: []
|
|
2050
2010
|
});
|
|
2051
2011
|
function isInsideCreateElementProps(context, node) {
|
|
2052
|
-
const call =
|
|
2012
|
+
const call = AST11__namespace.findParentNode(node, core.isCreateElementCall(context));
|
|
2053
2013
|
if (call == null) return false;
|
|
2054
|
-
const prop =
|
|
2014
|
+
const prop = AST11__namespace.findParentNode(node, AST11__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
|
|
2055
2015
|
if (prop == null) return false;
|
|
2056
2016
|
return prop === call.arguments[1];
|
|
2057
2017
|
}
|
|
2058
|
-
var
|
|
2059
|
-
var
|
|
2018
|
+
var RULE_NAME31 = "no-prop-types";
|
|
2019
|
+
var RULE_FEATURES31 = [
|
|
2060
2020
|
"CHK"
|
|
2061
2021
|
];
|
|
2062
2022
|
var no_prop_types_default = createRule({
|
|
@@ -2064,14 +2024,14 @@ var no_prop_types_default = createRule({
|
|
|
2064
2024
|
type: "problem",
|
|
2065
2025
|
docs: {
|
|
2066
2026
|
description: "disallow using 'propTypes' property in components",
|
|
2067
|
-
[Symbol.for("rule_features")]:
|
|
2027
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
2068
2028
|
},
|
|
2069
2029
|
messages: {
|
|
2070
2030
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
2071
2031
|
},
|
|
2072
2032
|
schema: []
|
|
2073
2033
|
},
|
|
2074
|
-
name:
|
|
2034
|
+
name: RULE_NAME31,
|
|
2075
2035
|
create(context) {
|
|
2076
2036
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
2077
2037
|
return {};
|
|
@@ -2093,7 +2053,7 @@ var no_prop_types_default = createRule({
|
|
|
2093
2053
|
}
|
|
2094
2054
|
const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2095
2055
|
const variableNode = VAR__namespace.getVariableInitNode(variable, 0);
|
|
2096
|
-
if (variableNode != null && (
|
|
2056
|
+
if (variableNode != null && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
|
|
2097
2057
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2098
2058
|
}
|
|
2099
2059
|
},
|
|
@@ -2110,26 +2070,26 @@ var no_prop_types_default = createRule({
|
|
|
2110
2070
|
},
|
|
2111
2071
|
defaultOptions: []
|
|
2112
2072
|
});
|
|
2113
|
-
var
|
|
2114
|
-
var
|
|
2073
|
+
var RULE_NAME32 = "no-redundant-should-component-update";
|
|
2074
|
+
var RULE_FEATURES32 = [
|
|
2115
2075
|
"CHK"
|
|
2116
2076
|
];
|
|
2117
2077
|
function isShouldComponentUpdate(node) {
|
|
2118
|
-
return
|
|
2078
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2119
2079
|
}
|
|
2120
2080
|
var no_redundant_should_component_update_default = createRule({
|
|
2121
2081
|
meta: {
|
|
2122
2082
|
type: "problem",
|
|
2123
2083
|
docs: {
|
|
2124
2084
|
description: "disallow using 'shouldComponentUpdate' in class component extends 'React.PureComponent'",
|
|
2125
|
-
[Symbol.for("rule_features")]:
|
|
2085
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
2126
2086
|
},
|
|
2127
2087
|
messages: {
|
|
2128
2088
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2129
2089
|
},
|
|
2130
2090
|
schema: []
|
|
2131
2091
|
},
|
|
2132
|
-
name:
|
|
2092
|
+
name: RULE_NAME32,
|
|
2133
2093
|
create(context) {
|
|
2134
2094
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) {
|
|
2135
2095
|
return {};
|
|
@@ -2161,26 +2121,26 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2161
2121
|
},
|
|
2162
2122
|
defaultOptions: []
|
|
2163
2123
|
});
|
|
2164
|
-
var
|
|
2165
|
-
var
|
|
2124
|
+
var RULE_NAME33 = "no-set-state-in-component-did-mount";
|
|
2125
|
+
var RULE_FEATURES33 = [
|
|
2166
2126
|
"CHK"
|
|
2167
2127
|
];
|
|
2168
2128
|
function isComponentDidMount(node) {
|
|
2169
|
-
return
|
|
2129
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2170
2130
|
}
|
|
2171
2131
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2172
2132
|
meta: {
|
|
2173
2133
|
type: "problem",
|
|
2174
2134
|
docs: {
|
|
2175
2135
|
description: "disallow using 'setState' in 'componentDidMount'",
|
|
2176
|
-
[Symbol.for("rule_features")]:
|
|
2136
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
2177
2137
|
},
|
|
2178
2138
|
messages: {
|
|
2179
2139
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2180
2140
|
},
|
|
2181
2141
|
schema: []
|
|
2182
2142
|
},
|
|
2183
|
-
name:
|
|
2143
|
+
name: RULE_NAME33,
|
|
2184
2144
|
create(context) {
|
|
2185
2145
|
if (!context.sourceCode.text.includes("componentDidMount")) {
|
|
2186
2146
|
return {};
|
|
@@ -2190,8 +2150,8 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2190
2150
|
if (!core.isThisSetState(node)) {
|
|
2191
2151
|
return;
|
|
2192
2152
|
}
|
|
2193
|
-
const clazz =
|
|
2194
|
-
const method =
|
|
2153
|
+
const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
|
|
2154
|
+
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
|
|
2195
2155
|
if (clazz == null || method == null || method === clazz) return;
|
|
2196
2156
|
const methodScope = context.sourceCode.getScope(method);
|
|
2197
2157
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2206,26 +2166,26 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2206
2166
|
},
|
|
2207
2167
|
defaultOptions: []
|
|
2208
2168
|
});
|
|
2209
|
-
var
|
|
2210
|
-
var
|
|
2169
|
+
var RULE_NAME34 = "no-set-state-in-component-did-update";
|
|
2170
|
+
var RULE_FEATURES34 = [
|
|
2211
2171
|
"CHK"
|
|
2212
2172
|
];
|
|
2213
2173
|
function isComponentDidUpdate(node) {
|
|
2214
|
-
return
|
|
2174
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2215
2175
|
}
|
|
2216
2176
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2217
2177
|
meta: {
|
|
2218
2178
|
type: "problem",
|
|
2219
2179
|
docs: {
|
|
2220
2180
|
description: "disallow using 'setState' in 'componentDidUpdate'",
|
|
2221
|
-
[Symbol.for("rule_features")]:
|
|
2181
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2222
2182
|
},
|
|
2223
2183
|
messages: {
|
|
2224
2184
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2225
2185
|
},
|
|
2226
2186
|
schema: []
|
|
2227
2187
|
},
|
|
2228
|
-
name:
|
|
2188
|
+
name: RULE_NAME34,
|
|
2229
2189
|
create(context) {
|
|
2230
2190
|
if (!context.sourceCode.text.includes("componentDidUpdate")) {
|
|
2231
2191
|
return {};
|
|
@@ -2235,8 +2195,8 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2235
2195
|
if (!core.isThisSetState(node)) {
|
|
2236
2196
|
return;
|
|
2237
2197
|
}
|
|
2238
|
-
const clazz =
|
|
2239
|
-
const method =
|
|
2198
|
+
const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
|
|
2199
|
+
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
|
|
2240
2200
|
if (clazz == null || method == null || method === clazz) return;
|
|
2241
2201
|
const methodScope = context.sourceCode.getScope(method);
|
|
2242
2202
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2251,26 +2211,26 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2251
2211
|
},
|
|
2252
2212
|
defaultOptions: []
|
|
2253
2213
|
});
|
|
2254
|
-
var
|
|
2255
|
-
var
|
|
2214
|
+
var RULE_NAME35 = "no-set-state-in-component-will-update";
|
|
2215
|
+
var RULE_FEATURES35 = [
|
|
2256
2216
|
"CHK"
|
|
2257
2217
|
];
|
|
2258
2218
|
function isComponentWillUpdate3(node) {
|
|
2259
|
-
return
|
|
2219
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2260
2220
|
}
|
|
2261
2221
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2262
2222
|
meta: {
|
|
2263
2223
|
type: "problem",
|
|
2264
2224
|
docs: {
|
|
2265
2225
|
description: "disallow using 'setState' in 'componentWillUpdate'",
|
|
2266
|
-
[Symbol.for("rule_features")]:
|
|
2226
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2267
2227
|
},
|
|
2268
2228
|
messages: {
|
|
2269
2229
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2270
2230
|
},
|
|
2271
2231
|
schema: []
|
|
2272
2232
|
},
|
|
2273
|
-
name:
|
|
2233
|
+
name: RULE_NAME35,
|
|
2274
2234
|
create(context) {
|
|
2275
2235
|
if (!context.sourceCode.text.includes("componentWillUpdate")) {
|
|
2276
2236
|
return {};
|
|
@@ -2280,8 +2240,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2280
2240
|
if (!core.isThisSetState(node)) {
|
|
2281
2241
|
return;
|
|
2282
2242
|
}
|
|
2283
|
-
const clazz =
|
|
2284
|
-
const method =
|
|
2243
|
+
const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
|
|
2244
|
+
const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
|
|
2285
2245
|
if (clazz == null || method == null || method === clazz) return;
|
|
2286
2246
|
const methodScope = context.sourceCode.getScope(method);
|
|
2287
2247
|
const upperScope = context.sourceCode.getScope(node).upper;
|
|
@@ -2296,8 +2256,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2296
2256
|
},
|
|
2297
2257
|
defaultOptions: []
|
|
2298
2258
|
});
|
|
2299
|
-
var
|
|
2300
|
-
var
|
|
2259
|
+
var RULE_NAME36 = "no-string-refs";
|
|
2260
|
+
var RULE_FEATURES36 = [
|
|
2301
2261
|
"CHK"
|
|
2302
2262
|
];
|
|
2303
2263
|
function containsStringLiteral({ value }) {
|
|
@@ -2317,14 +2277,14 @@ var no_string_refs_default = createRule({
|
|
|
2317
2277
|
type: "problem",
|
|
2318
2278
|
docs: {
|
|
2319
2279
|
description: "disallow using deprecated string refs",
|
|
2320
|
-
[Symbol.for("rule_features")]:
|
|
2280
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2321
2281
|
},
|
|
2322
2282
|
messages: {
|
|
2323
2283
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2324
2284
|
},
|
|
2325
2285
|
schema: []
|
|
2326
2286
|
},
|
|
2327
|
-
name:
|
|
2287
|
+
name: RULE_NAME36,
|
|
2328
2288
|
create(context) {
|
|
2329
2289
|
return {
|
|
2330
2290
|
JSXAttribute(node) {
|
|
@@ -2342,26 +2302,26 @@ var no_string_refs_default = createRule({
|
|
|
2342
2302
|
},
|
|
2343
2303
|
defaultOptions: []
|
|
2344
2304
|
});
|
|
2345
|
-
var
|
|
2346
|
-
var
|
|
2305
|
+
var RULE_NAME37 = "no-unsafe-component-will-mount";
|
|
2306
|
+
var RULE_FEATURES37 = [
|
|
2347
2307
|
"CHK"
|
|
2348
2308
|
];
|
|
2349
2309
|
function isUnsafeComponentWillMount(node) {
|
|
2350
|
-
return
|
|
2310
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2351
2311
|
}
|
|
2352
2312
|
var no_unsafe_component_will_mount_default = createRule({
|
|
2353
2313
|
meta: {
|
|
2354
2314
|
type: "problem",
|
|
2355
2315
|
docs: {
|
|
2356
2316
|
description: "disallow using 'UNSAFE_componentWillMount'",
|
|
2357
|
-
[Symbol.for("rule_features")]:
|
|
2317
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2358
2318
|
},
|
|
2359
2319
|
messages: {
|
|
2360
2320
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2361
2321
|
},
|
|
2362
2322
|
schema: []
|
|
2363
2323
|
},
|
|
2364
|
-
name:
|
|
2324
|
+
name: RULE_NAME37,
|
|
2365
2325
|
create(context) {
|
|
2366
2326
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) {
|
|
2367
2327
|
return {};
|
|
@@ -2387,26 +2347,26 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2387
2347
|
},
|
|
2388
2348
|
defaultOptions: []
|
|
2389
2349
|
});
|
|
2390
|
-
var
|
|
2391
|
-
var
|
|
2350
|
+
var RULE_NAME38 = "no-unsafe-component-will-receive-props";
|
|
2351
|
+
var RULE_FEATURES38 = [
|
|
2392
2352
|
"CHK"
|
|
2393
2353
|
];
|
|
2394
2354
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2395
|
-
return
|
|
2355
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2396
2356
|
}
|
|
2397
2357
|
var no_unsafe_component_will_receive_props_default = createRule({
|
|
2398
2358
|
meta: {
|
|
2399
2359
|
type: "problem",
|
|
2400
2360
|
docs: {
|
|
2401
2361
|
description: "disallow using 'UNSAFE_componentWillReceiveProps'",
|
|
2402
|
-
[Symbol.for("rule_features")]:
|
|
2362
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2403
2363
|
},
|
|
2404
2364
|
messages: {
|
|
2405
2365
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2406
2366
|
},
|
|
2407
2367
|
schema: []
|
|
2408
2368
|
},
|
|
2409
|
-
name:
|
|
2369
|
+
name: RULE_NAME38,
|
|
2410
2370
|
create(context) {
|
|
2411
2371
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2412
2372
|
return {};
|
|
@@ -2432,26 +2392,26 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2432
2392
|
},
|
|
2433
2393
|
defaultOptions: []
|
|
2434
2394
|
});
|
|
2435
|
-
var
|
|
2436
|
-
var
|
|
2395
|
+
var RULE_NAME39 = "no-unsafe-component-will-update";
|
|
2396
|
+
var RULE_FEATURES39 = [
|
|
2437
2397
|
"CHK"
|
|
2438
2398
|
];
|
|
2439
2399
|
function isUnsafeComponentWillUpdate(node) {
|
|
2440
|
-
return
|
|
2400
|
+
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2441
2401
|
}
|
|
2442
2402
|
var no_unsafe_component_will_update_default = createRule({
|
|
2443
2403
|
meta: {
|
|
2444
2404
|
type: "problem",
|
|
2445
2405
|
docs: {
|
|
2446
2406
|
description: "disallow using 'UNSAFE_componentWillUpdate'",
|
|
2447
|
-
[Symbol.for("rule_features")]:
|
|
2407
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2448
2408
|
},
|
|
2449
2409
|
messages: {
|
|
2450
2410
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2451
2411
|
},
|
|
2452
2412
|
schema: []
|
|
2453
2413
|
},
|
|
2454
|
-
name:
|
|
2414
|
+
name: RULE_NAME39,
|
|
2455
2415
|
create(context) {
|
|
2456
2416
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) {
|
|
2457
2417
|
return {};
|
|
@@ -2477,8 +2437,8 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2477
2437
|
},
|
|
2478
2438
|
defaultOptions: []
|
|
2479
2439
|
});
|
|
2480
|
-
var
|
|
2481
|
-
var
|
|
2440
|
+
var RULE_NAME40 = "no-unstable-context-value";
|
|
2441
|
+
var RULE_FEATURES40 = [
|
|
2482
2442
|
"CHK"
|
|
2483
2443
|
];
|
|
2484
2444
|
var no_unstable_context_value_default = createRule({
|
|
@@ -2486,14 +2446,14 @@ var no_unstable_context_value_default = createRule({
|
|
|
2486
2446
|
type: "problem",
|
|
2487
2447
|
docs: {
|
|
2488
2448
|
description: "disallow passing constructed values to context providers",
|
|
2489
|
-
[Symbol.for("rule_features")]:
|
|
2449
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2490
2450
|
},
|
|
2491
2451
|
messages: {
|
|
2492
2452
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2493
2453
|
},
|
|
2494
2454
|
schema: []
|
|
2495
2455
|
},
|
|
2496
|
-
name:
|
|
2456
|
+
name: RULE_NAME40,
|
|
2497
2457
|
create(context) {
|
|
2498
2458
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2499
2459
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
@@ -2533,7 +2493,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2533
2493
|
messageId: "unstableContextValue",
|
|
2534
2494
|
node: constructionNode,
|
|
2535
2495
|
data: {
|
|
2536
|
-
type:
|
|
2496
|
+
type: AST11__namespace.toReadableNodeType(constructionNode),
|
|
2537
2497
|
suggestion
|
|
2538
2498
|
}
|
|
2539
2499
|
});
|
|
@@ -2551,8 +2511,8 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2551
2511
|
}
|
|
2552
2512
|
return false;
|
|
2553
2513
|
}
|
|
2554
|
-
var
|
|
2555
|
-
var
|
|
2514
|
+
var RULE_NAME41 = "no-unstable-default-props";
|
|
2515
|
+
var RULE_FEATURES41 = [
|
|
2556
2516
|
"CHK"
|
|
2557
2517
|
];
|
|
2558
2518
|
var no_unstable_default_props_default = createRule({
|
|
@@ -2560,14 +2520,14 @@ var no_unstable_default_props_default = createRule({
|
|
|
2560
2520
|
type: "problem",
|
|
2561
2521
|
docs: {
|
|
2562
2522
|
description: "disallow using unstable value as default param in function component",
|
|
2563
|
-
[Symbol.for("rule_features")]:
|
|
2523
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2564
2524
|
},
|
|
2565
2525
|
messages: {
|
|
2566
2526
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2567
2527
|
},
|
|
2568
2528
|
schema: []
|
|
2569
2529
|
},
|
|
2570
|
-
name:
|
|
2530
|
+
name: RULE_NAME41,
|
|
2571
2531
|
create(context) {
|
|
2572
2532
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2573
2533
|
const declarators = /* @__PURE__ */ new Map();
|
|
@@ -2602,7 +2562,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2602
2562
|
if (core.isReactHookCall(construction.node)) {
|
|
2603
2563
|
continue;
|
|
2604
2564
|
}
|
|
2605
|
-
const forbiddenType =
|
|
2565
|
+
const forbiddenType = AST11__namespace.toReadableNodeType(right);
|
|
2606
2566
|
context.report({
|
|
2607
2567
|
messageId: "noUnstableDefaultProps",
|
|
2608
2568
|
node: right,
|
|
@@ -2626,8 +2586,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2626
2586
|
},
|
|
2627
2587
|
defaultOptions: []
|
|
2628
2588
|
});
|
|
2629
|
-
var
|
|
2630
|
-
var
|
|
2589
|
+
var RULE_NAME42 = "no-unused-class-component-members";
|
|
2590
|
+
var RULE_FEATURES42 = [
|
|
2631
2591
|
"CHK"
|
|
2632
2592
|
];
|
|
2633
2593
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -2655,14 +2615,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2655
2615
|
type: "problem",
|
|
2656
2616
|
docs: {
|
|
2657
2617
|
description: "disallow unused class component members",
|
|
2658
|
-
[Symbol.for("rule_features")]:
|
|
2618
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2659
2619
|
},
|
|
2660
2620
|
messages: {
|
|
2661
2621
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2662
2622
|
},
|
|
2663
2623
|
schema: []
|
|
2664
2624
|
},
|
|
2665
|
-
name:
|
|
2625
|
+
name: RULE_NAME42,
|
|
2666
2626
|
create(context) {
|
|
2667
2627
|
const classEntries = [];
|
|
2668
2628
|
const methodEntries = [];
|
|
@@ -2681,14 +2641,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2681
2641
|
if (currentClass == null || !core.isClassComponent(currentClass)) {
|
|
2682
2642
|
return;
|
|
2683
2643
|
}
|
|
2684
|
-
const className =
|
|
2644
|
+
const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
|
|
2685
2645
|
const defs = propertyDefs.get(currentClass);
|
|
2686
2646
|
const usages = propertyUsages.get(currentClass);
|
|
2687
2647
|
if (defs == null) {
|
|
2688
2648
|
return;
|
|
2689
2649
|
}
|
|
2690
2650
|
for (const def of defs) {
|
|
2691
|
-
const methodName =
|
|
2651
|
+
const methodName = AST11__namespace.getPropertyName(def);
|
|
2692
2652
|
if (methodName == null) {
|
|
2693
2653
|
continue;
|
|
2694
2654
|
}
|
|
@@ -2735,14 +2695,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2735
2695
|
if (!core.isClassComponent(currentClass) || currentMethod.static) {
|
|
2736
2696
|
return;
|
|
2737
2697
|
}
|
|
2738
|
-
if (!
|
|
2698
|
+
if (!AST11__namespace.isThisExpression(node.object) || !isKeyLiteral2(node, node.property)) {
|
|
2739
2699
|
return;
|
|
2740
2700
|
}
|
|
2741
2701
|
if (node.parent.type === types.AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
|
|
2742
2702
|
propertyDefs.get(currentClass)?.add(node.property);
|
|
2743
2703
|
return;
|
|
2744
2704
|
}
|
|
2745
|
-
const propertyName =
|
|
2705
|
+
const propertyName = AST11__namespace.getPropertyName(node.property);
|
|
2746
2706
|
if (propertyName != null) {
|
|
2747
2707
|
propertyUsages.get(currentClass)?.add(propertyName);
|
|
2748
2708
|
}
|
|
@@ -2760,10 +2720,10 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2760
2720
|
if (!core.isClassComponent(currentClass) || currentMethod.static) {
|
|
2761
2721
|
return;
|
|
2762
2722
|
}
|
|
2763
|
-
if (node.init != null &&
|
|
2723
|
+
if (node.init != null && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern) {
|
|
2764
2724
|
for (const prop of node.id.properties) {
|
|
2765
2725
|
if (prop.type === types.AST_NODE_TYPES.Property && isKeyLiteral2(prop, prop.key)) {
|
|
2766
|
-
const keyName =
|
|
2726
|
+
const keyName = AST11__namespace.getPropertyName(prop.key);
|
|
2767
2727
|
if (keyName != null) {
|
|
2768
2728
|
propertyUsages.get(currentClass)?.add(keyName);
|
|
2769
2729
|
}
|
|
@@ -2775,8 +2735,8 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2775
2735
|
},
|
|
2776
2736
|
defaultOptions: []
|
|
2777
2737
|
});
|
|
2778
|
-
var
|
|
2779
|
-
var
|
|
2738
|
+
var RULE_NAME43 = "no-unused-state";
|
|
2739
|
+
var RULE_FEATURES43 = [
|
|
2780
2740
|
"CHK"
|
|
2781
2741
|
];
|
|
2782
2742
|
function isKeyLiteral3(node, key) {
|
|
@@ -2787,14 +2747,14 @@ var no_unused_state_default = createRule({
|
|
|
2787
2747
|
type: "problem",
|
|
2788
2748
|
docs: {
|
|
2789
2749
|
description: "disallow unused state of class component",
|
|
2790
|
-
[Symbol.for("rule_features")]:
|
|
2750
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2791
2751
|
},
|
|
2792
2752
|
messages: {
|
|
2793
2753
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2794
2754
|
},
|
|
2795
2755
|
schema: []
|
|
2796
2756
|
},
|
|
2797
|
-
name:
|
|
2757
|
+
name: RULE_NAME43,
|
|
2798
2758
|
create(context) {
|
|
2799
2759
|
const classEntries = [];
|
|
2800
2760
|
const methodEntries = [];
|
|
@@ -2808,7 +2768,7 @@ var no_unused_state_default = createRule({
|
|
|
2808
2768
|
if (currentClass == null || !core.isClassComponent(currentClass)) {
|
|
2809
2769
|
return;
|
|
2810
2770
|
}
|
|
2811
|
-
const className =
|
|
2771
|
+
const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
|
|
2812
2772
|
const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
|
|
2813
2773
|
if (defNode == null || isUsed) {
|
|
2814
2774
|
return;
|
|
@@ -2834,7 +2794,7 @@ var no_unused_state_default = createRule({
|
|
|
2834
2794
|
}
|
|
2835
2795
|
return;
|
|
2836
2796
|
}
|
|
2837
|
-
if (
|
|
2797
|
+
if (AST11__namespace.getPropertyName(node.key) === "state") {
|
|
2838
2798
|
stateDefs.set(currentClass, { node: node.key, isUsed: false });
|
|
2839
2799
|
}
|
|
2840
2800
|
}
|
|
@@ -2868,10 +2828,10 @@ var no_unused_state_default = createRule({
|
|
|
2868
2828
|
ClassExpression: classEnter,
|
|
2869
2829
|
"ClassExpression:exit": classExit,
|
|
2870
2830
|
MemberExpression(node) {
|
|
2871
|
-
if (!
|
|
2831
|
+
if (!AST11__namespace.isThisExpression(node.object)) {
|
|
2872
2832
|
return;
|
|
2873
2833
|
}
|
|
2874
|
-
if (
|
|
2834
|
+
if (AST11__namespace.getPropertyName(node.property) !== "state") {
|
|
2875
2835
|
return;
|
|
2876
2836
|
}
|
|
2877
2837
|
const currentClass = classEntries.at(-1);
|
|
@@ -2912,12 +2872,12 @@ var no_unused_state_default = createRule({
|
|
|
2912
2872
|
if (!currentClass.body.body.includes(currentMethod)) {
|
|
2913
2873
|
return;
|
|
2914
2874
|
}
|
|
2915
|
-
if (node.init == null || !
|
|
2875
|
+
if (node.init == null || !AST11__namespace.isThisExpression(node.init) || node.id.type !== types.AST_NODE_TYPES.ObjectPattern) {
|
|
2916
2876
|
return;
|
|
2917
2877
|
}
|
|
2918
2878
|
const hasState = node.id.properties.some((prop) => {
|
|
2919
2879
|
if (prop.type === types.AST_NODE_TYPES.Property && isKeyLiteral3(prop, prop.key)) {
|
|
2920
|
-
return
|
|
2880
|
+
return AST11__namespace.getPropertyName(prop.key) === "state";
|
|
2921
2881
|
}
|
|
2922
2882
|
return false;
|
|
2923
2883
|
});
|
|
@@ -2931,8 +2891,8 @@ var no_unused_state_default = createRule({
|
|
|
2931
2891
|
},
|
|
2932
2892
|
defaultOptions: []
|
|
2933
2893
|
});
|
|
2934
|
-
var
|
|
2935
|
-
var
|
|
2894
|
+
var RULE_NAME44 = "no-use-context";
|
|
2895
|
+
var RULE_FEATURES44 = [
|
|
2936
2896
|
"CHK",
|
|
2937
2897
|
"MOD"
|
|
2938
2898
|
];
|
|
@@ -2941,7 +2901,7 @@ var no_use_context_default = createRule({
|
|
|
2941
2901
|
type: "problem",
|
|
2942
2902
|
docs: {
|
|
2943
2903
|
description: "replace usages of 'useContext' with 'use'",
|
|
2944
|
-
[Symbol.for("rule_features")]:
|
|
2904
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2945
2905
|
},
|
|
2946
2906
|
fixable: "code",
|
|
2947
2907
|
messages: {
|
|
@@ -2949,7 +2909,7 @@ var no_use_context_default = createRule({
|
|
|
2949
2909
|
},
|
|
2950
2910
|
schema: []
|
|
2951
2911
|
},
|
|
2952
|
-
name:
|
|
2912
|
+
name: RULE_NAME44,
|
|
2953
2913
|
create(context) {
|
|
2954
2914
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2955
2915
|
const settings4 = shared.getSettingsFromContext(context);
|
|
@@ -3030,6 +2990,46 @@ function getAssociatedTokens(context, node) {
|
|
|
3030
2990
|
return tokens;
|
|
3031
2991
|
}
|
|
3032
2992
|
}
|
|
2993
|
+
var RULE_NAME45 = "no-useless-forward-ref";
|
|
2994
|
+
var RULE_FEATURES45 = [
|
|
2995
|
+
"CHK"
|
|
2996
|
+
];
|
|
2997
|
+
var no_useless_forward_ref_default = createRule({
|
|
2998
|
+
meta: {
|
|
2999
|
+
type: "problem",
|
|
3000
|
+
docs: {
|
|
3001
|
+
description: "require a 'ref' parameter to be set when using 'forwardRef'",
|
|
3002
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
3003
|
+
},
|
|
3004
|
+
messages: {
|
|
3005
|
+
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
3006
|
+
},
|
|
3007
|
+
schema: []
|
|
3008
|
+
},
|
|
3009
|
+
name: RULE_NAME45,
|
|
3010
|
+
create(context) {
|
|
3011
|
+
return {
|
|
3012
|
+
CallExpression(node) {
|
|
3013
|
+
if (!core.isForwardRefCall(context, node)) {
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
const [component] = node.arguments;
|
|
3017
|
+
if (component == null || !AST11__namespace.isFunction(component)) {
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
3020
|
+
const ref = component.params[1];
|
|
3021
|
+
if (ref != null) {
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
context.report({
|
|
3025
|
+
messageId: "noUselessForwardRef",
|
|
3026
|
+
node: component
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
};
|
|
3030
|
+
},
|
|
3031
|
+
defaultOptions: []
|
|
3032
|
+
});
|
|
3033
3033
|
var RULE_NAME46 = "no-useless-fragment";
|
|
3034
3034
|
var defaultOptions = [{
|
|
3035
3035
|
allowExpressions: true
|
|
@@ -3048,7 +3048,7 @@ function checkAndReport(context, node, allowExpressions) {
|
|
|
3048
3048
|
return null;
|
|
3049
3049
|
}
|
|
3050
3050
|
if (node.children.some(
|
|
3051
|
-
(child) => JSX8__namespace.isLiteral(child) && !JSX8__namespace.isWhiteSpace(child) ||
|
|
3051
|
+
(child) => JSX8__namespace.isLiteral(child) && !JSX8__namespace.isWhiteSpace(child) || AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(child)
|
|
3052
3052
|
)) {
|
|
3053
3053
|
return null;
|
|
3054
3054
|
}
|
|
@@ -3086,7 +3086,7 @@ function checkAndReport(context, node, allowExpressions) {
|
|
|
3086
3086
|
});
|
|
3087
3087
|
return;
|
|
3088
3088
|
}
|
|
3089
|
-
const isChildElement =
|
|
3089
|
+
const isChildElement = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3090
3090
|
switch (true) {
|
|
3091
3091
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3092
3092
|
case (allowExpressions && !isChildElement && node.children.length === 1 && JSX8__namespace.isLiteral(node.children.at(0))): {
|
|
@@ -3207,10 +3207,10 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3207
3207
|
...ctx.getAllComponents(node).values()
|
|
3208
3208
|
];
|
|
3209
3209
|
function isFunctionComponent(block) {
|
|
3210
|
-
if (!
|
|
3210
|
+
if (!AST11__namespace.isFunction(block)) {
|
|
3211
3211
|
return false;
|
|
3212
3212
|
}
|
|
3213
|
-
const id =
|
|
3213
|
+
const id = AST11__namespace.getFunctionIdentifier(block);
|
|
3214
3214
|
return id != null && core.isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3215
3215
|
}
|
|
3216
3216
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
@@ -3484,7 +3484,6 @@ var plugin = {
|
|
|
3484
3484
|
rules: {
|
|
3485
3485
|
"avoid-shorthand-boolean": avoid_shorthand_boolean_default,
|
|
3486
3486
|
"avoid-shorthand-fragment": avoid_shorthand_fragment_default,
|
|
3487
|
-
"ensure-forward-ref-using-ref": ensure_forward_ref_using_ref_default,
|
|
3488
3487
|
"no-access-state-in-setstate": no_access_state_in_setstate_default,
|
|
3489
3488
|
"no-array-index-key": no_array_index_key_default,
|
|
3490
3489
|
"no-children-count": no_children_count_default,
|
|
@@ -3527,6 +3526,7 @@ var plugin = {
|
|
|
3527
3526
|
"no-unused-class-component-members": no_unused_class_component_members_default,
|
|
3528
3527
|
"no-unused-state": no_unused_state_default,
|
|
3529
3528
|
"no-use-context": no_use_context_default,
|
|
3529
|
+
"no-useless-forward-ref": no_useless_forward_ref_default,
|
|
3530
3530
|
"no-useless-fragment": no_useless_fragment_default,
|
|
3531
3531
|
"prefer-destructuring-assignment": prefer_destructuring_assignment_default,
|
|
3532
3532
|
"prefer-react-namespace-import": prefer_react_namespace_import_default,
|
|
@@ -3535,6 +3535,8 @@ var plugin = {
|
|
|
3535
3535
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3536
3536
|
"use-jsx-vars": use_jsx_vars_default,
|
|
3537
3537
|
// Part: deprecated rules
|
|
3538
|
+
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3539
|
+
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3538
3540
|
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3539
3541
|
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3540
3542
|
/** @deprecated Use `use-jsx-vars` instead */
|