eslint-plugin-react-x 1.50.0 → 1.50.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +354 -315
- package/dist/index.mjs +354 -315
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ var settings3 = {
|
|
|
142
142
|
|
|
143
143
|
// package.json
|
|
144
144
|
var name4 = "eslint-plugin-react-x";
|
|
145
|
-
var version = "1.50.
|
|
145
|
+
var version = "1.50.1-beta.1";
|
|
146
146
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
147
147
|
|
|
148
148
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -299,17 +299,17 @@ function create4(context) {
|
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
}
|
|
302
|
-
var RULE_NAME5 = "jsx-no-
|
|
302
|
+
var RULE_NAME5 = "jsx-no-iife";
|
|
303
303
|
var RULE_FEATURES5 = [];
|
|
304
|
-
var
|
|
304
|
+
var jsx_no_iife_default = createRule({
|
|
305
305
|
meta: {
|
|
306
306
|
type: "problem",
|
|
307
307
|
docs: {
|
|
308
|
-
description: "
|
|
308
|
+
description: "Disallows 'IIFE' in JSX elements.",
|
|
309
309
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
310
310
|
},
|
|
311
311
|
messages: {
|
|
312
|
-
|
|
312
|
+
jsxNoIife: ""
|
|
313
313
|
},
|
|
314
314
|
schema: []
|
|
315
315
|
},
|
|
@@ -318,6 +318,44 @@ var jsx_no_undef_default = createRule({
|
|
|
318
318
|
defaultOptions: []
|
|
319
319
|
});
|
|
320
320
|
function create5(context) {
|
|
321
|
+
return {
|
|
322
|
+
"JSXElement :function"(node) {
|
|
323
|
+
if (node.parent.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee === node) {
|
|
324
|
+
context.report({
|
|
325
|
+
messageId: "jsxNoIife",
|
|
326
|
+
node: node.parent
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"JSXFragment :function"(node) {
|
|
331
|
+
if (node.parent.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee === node) {
|
|
332
|
+
context.report({
|
|
333
|
+
messageId: "jsxNoIife",
|
|
334
|
+
node: node.parent
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
var RULE_NAME6 = "jsx-no-undef";
|
|
341
|
+
var RULE_FEATURES6 = [];
|
|
342
|
+
var jsx_no_undef_default = createRule({
|
|
343
|
+
meta: {
|
|
344
|
+
type: "problem",
|
|
345
|
+
docs: {
|
|
346
|
+
description: "Disallow undefined variables in JSX.",
|
|
347
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
348
|
+
},
|
|
349
|
+
messages: {
|
|
350
|
+
jsxNoUndef: "JSX variable '{{name}}' is not defined."
|
|
351
|
+
},
|
|
352
|
+
schema: []
|
|
353
|
+
},
|
|
354
|
+
name: RULE_NAME6,
|
|
355
|
+
create: create6,
|
|
356
|
+
defaultOptions: []
|
|
357
|
+
});
|
|
358
|
+
function create6(context) {
|
|
321
359
|
return {
|
|
322
360
|
JSXOpeningElement(node) {
|
|
323
361
|
const name5 = tsPattern.match(node.name).with({ type: types.AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({ type: types.AST_NODE_TYPES.JSXMemberExpression, object: { type: types.AST_NODE_TYPES.JSXIdentifier } }, (n) => n.object.name).otherwise(() => null);
|
|
@@ -337,25 +375,25 @@ function create5(context) {
|
|
|
337
375
|
};
|
|
338
376
|
}
|
|
339
377
|
var { JsxEmit } = kit.JsxConfig;
|
|
340
|
-
var
|
|
341
|
-
var
|
|
378
|
+
var RULE_NAME7 = "jsx-uses-react";
|
|
379
|
+
var RULE_FEATURES7 = [];
|
|
342
380
|
var jsx_uses_react_default = createRule({
|
|
343
381
|
meta: {
|
|
344
382
|
type: "problem",
|
|
345
383
|
docs: {
|
|
346
384
|
description: "Marks React variables as used when JSX is used.",
|
|
347
|
-
[Symbol.for("rule_features")]:
|
|
385
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
348
386
|
},
|
|
349
387
|
messages: {
|
|
350
388
|
jsxUsesReact: "Marked {{name}} as used."
|
|
351
389
|
},
|
|
352
390
|
schema: []
|
|
353
391
|
},
|
|
354
|
-
name:
|
|
355
|
-
create:
|
|
392
|
+
name: RULE_NAME7,
|
|
393
|
+
create: create7,
|
|
356
394
|
defaultOptions: []
|
|
357
395
|
});
|
|
358
|
-
function
|
|
396
|
+
function create7(context) {
|
|
359
397
|
const jsxConfig = {
|
|
360
398
|
...kit.JsxConfig.getFromContext(context),
|
|
361
399
|
...kit.JsxConfig.getFromAnnotation(context)
|
|
@@ -384,25 +422,25 @@ function debugReport(context, node, name5) {
|
|
|
384
422
|
data: { name: name5 }
|
|
385
423
|
});
|
|
386
424
|
}
|
|
387
|
-
var
|
|
388
|
-
var
|
|
425
|
+
var RULE_NAME8 = "jsx-uses-vars";
|
|
426
|
+
var RULE_FEATURES8 = [];
|
|
389
427
|
var jsx_uses_vars_default = createRule({
|
|
390
428
|
meta: {
|
|
391
429
|
type: "problem",
|
|
392
430
|
docs: {
|
|
393
431
|
description: "Marks variables used in JSX elements as used.",
|
|
394
|
-
[Symbol.for("rule_features")]:
|
|
432
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
395
433
|
},
|
|
396
434
|
messages: {
|
|
397
435
|
jsxUsesVars: ""
|
|
398
436
|
},
|
|
399
437
|
schema: []
|
|
400
438
|
},
|
|
401
|
-
name:
|
|
402
|
-
create:
|
|
439
|
+
name: RULE_NAME8,
|
|
440
|
+
create: create8,
|
|
403
441
|
defaultOptions: []
|
|
404
442
|
});
|
|
405
|
-
function
|
|
443
|
+
function create8(context) {
|
|
406
444
|
return {
|
|
407
445
|
JSXOpeningElement(node) {
|
|
408
446
|
switch (node.name.type) {
|
|
@@ -424,8 +462,8 @@ function create7(context) {
|
|
|
424
462
|
}
|
|
425
463
|
};
|
|
426
464
|
}
|
|
427
|
-
var
|
|
428
|
-
var
|
|
465
|
+
var RULE_NAME9 = "no-access-state-in-setstate";
|
|
466
|
+
var RULE_FEATURES9 = [];
|
|
429
467
|
function isKeyLiteral(node, key) {
|
|
430
468
|
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);
|
|
431
469
|
}
|
|
@@ -434,18 +472,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
434
472
|
type: "problem",
|
|
435
473
|
docs: {
|
|
436
474
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
437
|
-
[Symbol.for("rule_features")]:
|
|
475
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
438
476
|
},
|
|
439
477
|
messages: {
|
|
440
478
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
441
479
|
},
|
|
442
480
|
schema: []
|
|
443
481
|
},
|
|
444
|
-
name:
|
|
445
|
-
create:
|
|
482
|
+
name: RULE_NAME9,
|
|
483
|
+
create: create9,
|
|
446
484
|
defaultOptions: []
|
|
447
485
|
});
|
|
448
|
-
function
|
|
486
|
+
function create9(context) {
|
|
449
487
|
if (!context.sourceCode.text.includes("setState")) {
|
|
450
488
|
return {};
|
|
451
489
|
}
|
|
@@ -536,8 +574,8 @@ function create8(context) {
|
|
|
536
574
|
}
|
|
537
575
|
};
|
|
538
576
|
}
|
|
539
|
-
var
|
|
540
|
-
var
|
|
577
|
+
var RULE_NAME10 = "no-array-index-key";
|
|
578
|
+
var RULE_FEATURES10 = [];
|
|
541
579
|
var reactChildrenMethod = ["forEach", "map"];
|
|
542
580
|
function isReactChildrenMethod(name5) {
|
|
543
581
|
return reactChildrenMethod.some((method) => method === name5);
|
|
@@ -604,18 +642,18 @@ var no_array_index_key_default = createRule({
|
|
|
604
642
|
type: "problem",
|
|
605
643
|
docs: {
|
|
606
644
|
description: "Disallow an item's index in the array as its key.",
|
|
607
|
-
[Symbol.for("rule_features")]:
|
|
645
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
608
646
|
},
|
|
609
647
|
messages: {
|
|
610
648
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
611
649
|
},
|
|
612
650
|
schema: []
|
|
613
651
|
},
|
|
614
|
-
name:
|
|
615
|
-
create:
|
|
652
|
+
name: RULE_NAME10,
|
|
653
|
+
create: create10,
|
|
616
654
|
defaultOptions: []
|
|
617
655
|
});
|
|
618
|
-
function
|
|
656
|
+
function create10(context) {
|
|
619
657
|
const report = kit.Reporter.make(context);
|
|
620
658
|
const indexParamNames = [];
|
|
621
659
|
function isArrayIndex(node) {
|
|
@@ -717,25 +755,25 @@ function create9(context) {
|
|
|
717
755
|
}
|
|
718
756
|
};
|
|
719
757
|
}
|
|
720
|
-
var
|
|
721
|
-
var
|
|
758
|
+
var RULE_NAME11 = "no-children-count";
|
|
759
|
+
var RULE_FEATURES11 = [];
|
|
722
760
|
var no_children_count_default = createRule({
|
|
723
761
|
meta: {
|
|
724
762
|
type: "problem",
|
|
725
763
|
docs: {
|
|
726
764
|
description: "Disallow `Children.count`.",
|
|
727
|
-
[Symbol.for("rule_features")]:
|
|
765
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
728
766
|
},
|
|
729
767
|
messages: {
|
|
730
768
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
731
769
|
},
|
|
732
770
|
schema: []
|
|
733
771
|
},
|
|
734
|
-
name:
|
|
735
|
-
create:
|
|
772
|
+
name: RULE_NAME11,
|
|
773
|
+
create: create11,
|
|
736
774
|
defaultOptions: []
|
|
737
775
|
});
|
|
738
|
-
function
|
|
776
|
+
function create11(context) {
|
|
739
777
|
return {
|
|
740
778
|
MemberExpression(node) {
|
|
741
779
|
if (ER25__namespace.isChildrenCount(context, node)) {
|
|
@@ -747,25 +785,25 @@ function create10(context) {
|
|
|
747
785
|
}
|
|
748
786
|
};
|
|
749
787
|
}
|
|
750
|
-
var
|
|
751
|
-
var
|
|
788
|
+
var RULE_NAME12 = "no-children-for-each";
|
|
789
|
+
var RULE_FEATURES12 = [];
|
|
752
790
|
var no_children_for_each_default = createRule({
|
|
753
791
|
meta: {
|
|
754
792
|
type: "problem",
|
|
755
793
|
docs: {
|
|
756
794
|
description: "Disallow 'Children.forEach'.",
|
|
757
|
-
[Symbol.for("rule_features")]:
|
|
795
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
758
796
|
},
|
|
759
797
|
messages: {
|
|
760
798
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
761
799
|
},
|
|
762
800
|
schema: []
|
|
763
801
|
},
|
|
764
|
-
name:
|
|
765
|
-
create:
|
|
802
|
+
name: RULE_NAME12,
|
|
803
|
+
create: create12,
|
|
766
804
|
defaultOptions: []
|
|
767
805
|
});
|
|
768
|
-
function
|
|
806
|
+
function create12(context) {
|
|
769
807
|
return {
|
|
770
808
|
MemberExpression(node) {
|
|
771
809
|
if (ER25__namespace.isChildrenForEach(context, node)) {
|
|
@@ -777,25 +815,25 @@ function create11(context) {
|
|
|
777
815
|
}
|
|
778
816
|
};
|
|
779
817
|
}
|
|
780
|
-
var
|
|
781
|
-
var
|
|
818
|
+
var RULE_NAME13 = "no-children-map";
|
|
819
|
+
var RULE_FEATURES13 = [];
|
|
782
820
|
var no_children_map_default = createRule({
|
|
783
821
|
meta: {
|
|
784
822
|
type: "problem",
|
|
785
823
|
docs: {
|
|
786
824
|
description: "Disallow `Children.map`.",
|
|
787
|
-
[Symbol.for("rule_features")]:
|
|
825
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
788
826
|
},
|
|
789
827
|
messages: {
|
|
790
828
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
791
829
|
},
|
|
792
830
|
schema: []
|
|
793
831
|
},
|
|
794
|
-
name:
|
|
795
|
-
create:
|
|
832
|
+
name: RULE_NAME13,
|
|
833
|
+
create: create13,
|
|
796
834
|
defaultOptions: []
|
|
797
835
|
});
|
|
798
|
-
function
|
|
836
|
+
function create13(context) {
|
|
799
837
|
return {
|
|
800
838
|
MemberExpression(node) {
|
|
801
839
|
if (ER25__namespace.isChildrenMap(context, node)) {
|
|
@@ -807,25 +845,25 @@ function create12(context) {
|
|
|
807
845
|
}
|
|
808
846
|
};
|
|
809
847
|
}
|
|
810
|
-
var
|
|
811
|
-
var
|
|
848
|
+
var RULE_NAME14 = "no-children-only";
|
|
849
|
+
var RULE_FEATURES14 = [];
|
|
812
850
|
var no_children_only_default = createRule({
|
|
813
851
|
meta: {
|
|
814
852
|
type: "problem",
|
|
815
853
|
docs: {
|
|
816
854
|
description: "Disallow `Children.only`.",
|
|
817
|
-
[Symbol.for("rule_features")]:
|
|
855
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
818
856
|
},
|
|
819
857
|
messages: {
|
|
820
858
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
821
859
|
},
|
|
822
860
|
schema: []
|
|
823
861
|
},
|
|
824
|
-
name:
|
|
825
|
-
create:
|
|
862
|
+
name: RULE_NAME14,
|
|
863
|
+
create: create14,
|
|
826
864
|
defaultOptions: []
|
|
827
865
|
});
|
|
828
|
-
function
|
|
866
|
+
function create14(context) {
|
|
829
867
|
return {
|
|
830
868
|
MemberExpression(node) {
|
|
831
869
|
if (ER25__namespace.isChildrenOnly(context, node)) {
|
|
@@ -837,25 +875,25 @@ function create13(context) {
|
|
|
837
875
|
}
|
|
838
876
|
};
|
|
839
877
|
}
|
|
840
|
-
var
|
|
841
|
-
var
|
|
878
|
+
var RULE_NAME15 = "no-children-prop";
|
|
879
|
+
var RULE_FEATURES15 = [];
|
|
842
880
|
var no_children_prop_default = createRule({
|
|
843
881
|
meta: {
|
|
844
882
|
type: "problem",
|
|
845
883
|
docs: {
|
|
846
884
|
description: "Disallow passing `children` as a prop.",
|
|
847
|
-
[Symbol.for("rule_features")]:
|
|
885
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
848
886
|
},
|
|
849
887
|
messages: {
|
|
850
888
|
noChildrenProp: "Do not pass 'children' as props."
|
|
851
889
|
},
|
|
852
890
|
schema: []
|
|
853
891
|
},
|
|
854
|
-
name:
|
|
855
|
-
create:
|
|
892
|
+
name: RULE_NAME15,
|
|
893
|
+
create: create15,
|
|
856
894
|
defaultOptions: []
|
|
857
895
|
});
|
|
858
|
-
function
|
|
896
|
+
function create15(context) {
|
|
859
897
|
return {
|
|
860
898
|
JSXElement(node) {
|
|
861
899
|
const attributes = node.openingElement.attributes;
|
|
@@ -869,25 +907,25 @@ function create14(context) {
|
|
|
869
907
|
}
|
|
870
908
|
};
|
|
871
909
|
}
|
|
872
|
-
var
|
|
873
|
-
var
|
|
910
|
+
var RULE_NAME16 = "no-children-to-array";
|
|
911
|
+
var RULE_FEATURES16 = [];
|
|
874
912
|
var no_children_to_array_default = createRule({
|
|
875
913
|
meta: {
|
|
876
914
|
type: "problem",
|
|
877
915
|
docs: {
|
|
878
916
|
description: "Disallow `Children.toArray`.",
|
|
879
|
-
[Symbol.for("rule_features")]:
|
|
917
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
880
918
|
},
|
|
881
919
|
messages: {
|
|
882
920
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
883
921
|
},
|
|
884
922
|
schema: []
|
|
885
923
|
},
|
|
886
|
-
name:
|
|
887
|
-
create:
|
|
924
|
+
name: RULE_NAME16,
|
|
925
|
+
create: create16,
|
|
888
926
|
defaultOptions: []
|
|
889
927
|
});
|
|
890
|
-
function
|
|
928
|
+
function create16(context) {
|
|
891
929
|
return {
|
|
892
930
|
MemberExpression(node) {
|
|
893
931
|
if (ER25__namespace.isChildrenToArray(context, node)) {
|
|
@@ -899,25 +937,25 @@ function create15(context) {
|
|
|
899
937
|
}
|
|
900
938
|
};
|
|
901
939
|
}
|
|
902
|
-
var
|
|
903
|
-
var
|
|
940
|
+
var RULE_NAME17 = "no-class-component";
|
|
941
|
+
var RULE_FEATURES17 = [];
|
|
904
942
|
var no_class_component_default = createRule({
|
|
905
943
|
meta: {
|
|
906
944
|
type: "problem",
|
|
907
945
|
docs: {
|
|
908
946
|
description: "Disallow class components except for error boundaries.",
|
|
909
|
-
[Symbol.for("rule_features")]:
|
|
947
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
910
948
|
},
|
|
911
949
|
messages: {
|
|
912
950
|
noClassComponent: "Avoid using class components. Use function components instead."
|
|
913
951
|
},
|
|
914
952
|
schema: []
|
|
915
953
|
},
|
|
916
|
-
name:
|
|
917
|
-
create:
|
|
954
|
+
name: RULE_NAME17,
|
|
955
|
+
create: create17,
|
|
918
956
|
defaultOptions: []
|
|
919
957
|
});
|
|
920
|
-
function
|
|
958
|
+
function create17(context) {
|
|
921
959
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
922
960
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
923
961
|
return {
|
|
@@ -939,25 +977,25 @@ function create16(context) {
|
|
|
939
977
|
}
|
|
940
978
|
};
|
|
941
979
|
}
|
|
942
|
-
var
|
|
943
|
-
var
|
|
980
|
+
var RULE_NAME18 = "no-clone-element";
|
|
981
|
+
var RULE_FEATURES18 = [];
|
|
944
982
|
var no_clone_element_default = createRule({
|
|
945
983
|
meta: {
|
|
946
984
|
type: "problem",
|
|
947
985
|
docs: {
|
|
948
986
|
description: "Disallow `cloneElement`.",
|
|
949
|
-
[Symbol.for("rule_features")]:
|
|
987
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
950
988
|
},
|
|
951
989
|
messages: {
|
|
952
990
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
953
991
|
},
|
|
954
992
|
schema: []
|
|
955
993
|
},
|
|
956
|
-
name:
|
|
957
|
-
create:
|
|
994
|
+
name: RULE_NAME18,
|
|
995
|
+
create: create18,
|
|
958
996
|
defaultOptions: []
|
|
959
997
|
});
|
|
960
|
-
function
|
|
998
|
+
function create18(context) {
|
|
961
999
|
return {
|
|
962
1000
|
CallExpression(node) {
|
|
963
1001
|
if (ER25__namespace.isCloneElementCall(context, node)) {
|
|
@@ -969,25 +1007,25 @@ function create17(context) {
|
|
|
969
1007
|
}
|
|
970
1008
|
};
|
|
971
1009
|
}
|
|
972
|
-
var
|
|
973
|
-
var
|
|
1010
|
+
var RULE_NAME19 = "no-comment-textnodes";
|
|
1011
|
+
var RULE_FEATURES19 = [];
|
|
974
1012
|
var no_comment_textnodes_default = createRule({
|
|
975
1013
|
meta: {
|
|
976
1014
|
type: "problem",
|
|
977
1015
|
docs: {
|
|
978
1016
|
description: "Prevents comments from being inserted as text nodes.",
|
|
979
|
-
[Symbol.for("rule_features")]:
|
|
1017
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
980
1018
|
},
|
|
981
1019
|
messages: {
|
|
982
1020
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
983
1021
|
},
|
|
984
1022
|
schema: []
|
|
985
1023
|
},
|
|
986
|
-
name:
|
|
987
|
-
create:
|
|
1024
|
+
name: RULE_NAME19,
|
|
1025
|
+
create: create19,
|
|
988
1026
|
defaultOptions: []
|
|
989
1027
|
});
|
|
990
|
-
function
|
|
1028
|
+
function create19(context) {
|
|
991
1029
|
function hasCommentLike(node) {
|
|
992
1030
|
if (AST8__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
993
1031
|
return false;
|
|
@@ -1015,8 +1053,8 @@ function create18(context) {
|
|
|
1015
1053
|
Literal: visitorFunction
|
|
1016
1054
|
};
|
|
1017
1055
|
}
|
|
1018
|
-
var
|
|
1019
|
-
var
|
|
1056
|
+
var RULE_NAME20 = "no-complex-conditional-rendering";
|
|
1057
|
+
var RULE_FEATURES20 = [
|
|
1020
1058
|
"EXP"
|
|
1021
1059
|
];
|
|
1022
1060
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -1024,18 +1062,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
1024
1062
|
type: "problem",
|
|
1025
1063
|
docs: {
|
|
1026
1064
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
1027
|
-
[Symbol.for("rule_features")]:
|
|
1065
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1028
1066
|
},
|
|
1029
1067
|
messages: {
|
|
1030
1068
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
1031
1069
|
},
|
|
1032
1070
|
schema: []
|
|
1033
1071
|
},
|
|
1034
|
-
name:
|
|
1035
|
-
create:
|
|
1072
|
+
name: RULE_NAME20,
|
|
1073
|
+
create: create20,
|
|
1036
1074
|
defaultOptions: []
|
|
1037
1075
|
});
|
|
1038
|
-
function
|
|
1076
|
+
function create20(context) {
|
|
1039
1077
|
const visitorFunction = (node) => {
|
|
1040
1078
|
const jsxExpContainer = node.parent?.parent;
|
|
1041
1079
|
if (!AST8__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -1060,8 +1098,8 @@ function create19(context) {
|
|
|
1060
1098
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
1061
1099
|
};
|
|
1062
1100
|
}
|
|
1063
|
-
var
|
|
1064
|
-
var
|
|
1101
|
+
var RULE_NAME21 = "no-component-will-mount";
|
|
1102
|
+
var RULE_FEATURES21 = [
|
|
1065
1103
|
"MOD"
|
|
1066
1104
|
];
|
|
1067
1105
|
var no_component_will_mount_default = createRule({
|
|
@@ -1069,7 +1107,7 @@ var no_component_will_mount_default = createRule({
|
|
|
1069
1107
|
type: "problem",
|
|
1070
1108
|
docs: {
|
|
1071
1109
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
1072
|
-
[Symbol.for("rule_features")]:
|
|
1110
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1073
1111
|
},
|
|
1074
1112
|
fixable: "code",
|
|
1075
1113
|
messages: {
|
|
@@ -1077,11 +1115,11 @@ var no_component_will_mount_default = createRule({
|
|
|
1077
1115
|
},
|
|
1078
1116
|
schema: []
|
|
1079
1117
|
},
|
|
1080
|
-
name:
|
|
1081
|
-
create:
|
|
1118
|
+
name: RULE_NAME21,
|
|
1119
|
+
create: create21,
|
|
1082
1120
|
defaultOptions: []
|
|
1083
1121
|
});
|
|
1084
|
-
function
|
|
1122
|
+
function create21(context) {
|
|
1085
1123
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
1086
1124
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
1087
1125
|
return {
|
|
@@ -1108,8 +1146,8 @@ function create20(context) {
|
|
|
1108
1146
|
}
|
|
1109
1147
|
};
|
|
1110
1148
|
}
|
|
1111
|
-
var
|
|
1112
|
-
var
|
|
1149
|
+
var RULE_NAME22 = "no-component-will-receive-props";
|
|
1150
|
+
var RULE_FEATURES22 = [
|
|
1113
1151
|
"MOD"
|
|
1114
1152
|
];
|
|
1115
1153
|
var no_component_will_receive_props_default = createRule({
|
|
@@ -1117,7 +1155,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1117
1155
|
type: "problem",
|
|
1118
1156
|
docs: {
|
|
1119
1157
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
1120
|
-
[Symbol.for("rule_features")]:
|
|
1158
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1121
1159
|
},
|
|
1122
1160
|
fixable: "code",
|
|
1123
1161
|
messages: {
|
|
@@ -1125,11 +1163,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1125
1163
|
},
|
|
1126
1164
|
schema: []
|
|
1127
1165
|
},
|
|
1128
|
-
name:
|
|
1129
|
-
create:
|
|
1166
|
+
name: RULE_NAME22,
|
|
1167
|
+
create: create22,
|
|
1130
1168
|
defaultOptions: []
|
|
1131
1169
|
});
|
|
1132
|
-
function
|
|
1170
|
+
function create22(context) {
|
|
1133
1171
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1134
1172
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
1135
1173
|
return {
|
|
@@ -1156,8 +1194,8 @@ function create21(context) {
|
|
|
1156
1194
|
}
|
|
1157
1195
|
};
|
|
1158
1196
|
}
|
|
1159
|
-
var
|
|
1160
|
-
var
|
|
1197
|
+
var RULE_NAME23 = "no-component-will-update";
|
|
1198
|
+
var RULE_FEATURES23 = [
|
|
1161
1199
|
"MOD"
|
|
1162
1200
|
];
|
|
1163
1201
|
var no_component_will_update_default = createRule({
|
|
@@ -1165,7 +1203,7 @@ var no_component_will_update_default = createRule({
|
|
|
1165
1203
|
type: "problem",
|
|
1166
1204
|
docs: {
|
|
1167
1205
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
1168
|
-
[Symbol.for("rule_features")]:
|
|
1206
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1169
1207
|
},
|
|
1170
1208
|
fixable: "code",
|
|
1171
1209
|
messages: {
|
|
@@ -1173,11 +1211,11 @@ var no_component_will_update_default = createRule({
|
|
|
1173
1211
|
},
|
|
1174
1212
|
schema: []
|
|
1175
1213
|
},
|
|
1176
|
-
name:
|
|
1177
|
-
create:
|
|
1214
|
+
name: RULE_NAME23,
|
|
1215
|
+
create: create23,
|
|
1178
1216
|
defaultOptions: []
|
|
1179
1217
|
});
|
|
1180
|
-
function
|
|
1218
|
+
function create23(context) {
|
|
1181
1219
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1182
1220
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
1183
1221
|
return {
|
|
@@ -1204,8 +1242,8 @@ function create22(context) {
|
|
|
1204
1242
|
}
|
|
1205
1243
|
};
|
|
1206
1244
|
}
|
|
1207
|
-
var
|
|
1208
|
-
var
|
|
1245
|
+
var RULE_NAME24 = "no-context-provider";
|
|
1246
|
+
var RULE_FEATURES24 = [
|
|
1209
1247
|
"MOD"
|
|
1210
1248
|
];
|
|
1211
1249
|
var no_context_provider_default = createRule({
|
|
@@ -1213,7 +1251,7 @@ var no_context_provider_default = createRule({
|
|
|
1213
1251
|
type: "problem",
|
|
1214
1252
|
docs: {
|
|
1215
1253
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1216
|
-
[Symbol.for("rule_features")]:
|
|
1254
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1217
1255
|
},
|
|
1218
1256
|
fixable: "code",
|
|
1219
1257
|
messages: {
|
|
@@ -1221,11 +1259,11 @@ var no_context_provider_default = createRule({
|
|
|
1221
1259
|
},
|
|
1222
1260
|
schema: []
|
|
1223
1261
|
},
|
|
1224
|
-
name:
|
|
1225
|
-
create:
|
|
1262
|
+
name: RULE_NAME24,
|
|
1263
|
+
create: create24,
|
|
1226
1264
|
defaultOptions: []
|
|
1227
1265
|
});
|
|
1228
|
-
function
|
|
1266
|
+
function create24(context) {
|
|
1229
1267
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1230
1268
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1231
1269
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1257,25 +1295,25 @@ function create23(context) {
|
|
|
1257
1295
|
}
|
|
1258
1296
|
};
|
|
1259
1297
|
}
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1298
|
+
var RULE_NAME25 = "no-create-ref";
|
|
1299
|
+
var RULE_FEATURES25 = [];
|
|
1262
1300
|
var no_create_ref_default = createRule({
|
|
1263
1301
|
meta: {
|
|
1264
1302
|
type: "problem",
|
|
1265
1303
|
docs: {
|
|
1266
1304
|
description: "Disallow `createRef` in function components.",
|
|
1267
|
-
[Symbol.for("rule_features")]:
|
|
1305
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1268
1306
|
},
|
|
1269
1307
|
messages: {
|
|
1270
1308
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1271
1309
|
},
|
|
1272
1310
|
schema: []
|
|
1273
1311
|
},
|
|
1274
|
-
name:
|
|
1275
|
-
create:
|
|
1312
|
+
name: RULE_NAME25,
|
|
1313
|
+
create: create25,
|
|
1276
1314
|
defaultOptions: []
|
|
1277
1315
|
});
|
|
1278
|
-
function
|
|
1316
|
+
function create25(context) {
|
|
1279
1317
|
return {
|
|
1280
1318
|
CallExpression(node) {
|
|
1281
1319
|
if (ER25__namespace.isCreateRefCall(context, node) && AST8__namespace.findParentNode(node, ER25__namespace.isClassComponent) == null) {
|
|
@@ -1284,25 +1322,25 @@ function create24(context) {
|
|
|
1284
1322
|
}
|
|
1285
1323
|
};
|
|
1286
1324
|
}
|
|
1287
|
-
var
|
|
1288
|
-
var
|
|
1325
|
+
var RULE_NAME26 = "no-default-props";
|
|
1326
|
+
var RULE_FEATURES26 = [];
|
|
1289
1327
|
var no_default_props_default = createRule({
|
|
1290
1328
|
meta: {
|
|
1291
1329
|
type: "problem",
|
|
1292
1330
|
docs: {
|
|
1293
1331
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1294
|
-
[Symbol.for("rule_features")]:
|
|
1332
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1295
1333
|
},
|
|
1296
1334
|
messages: {
|
|
1297
1335
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1298
1336
|
},
|
|
1299
1337
|
schema: []
|
|
1300
1338
|
},
|
|
1301
|
-
name:
|
|
1302
|
-
create:
|
|
1339
|
+
name: RULE_NAME26,
|
|
1340
|
+
create: create26,
|
|
1303
1341
|
defaultOptions: []
|
|
1304
1342
|
});
|
|
1305
|
-
function
|
|
1343
|
+
function create26(context) {
|
|
1306
1344
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1307
1345
|
return {
|
|
1308
1346
|
AssignmentExpression(node) {
|
|
@@ -1336,8 +1374,8 @@ function create25(context) {
|
|
|
1336
1374
|
}
|
|
1337
1375
|
};
|
|
1338
1376
|
}
|
|
1339
|
-
var
|
|
1340
|
-
var
|
|
1377
|
+
var RULE_NAME27 = "no-direct-mutation-state";
|
|
1378
|
+
var RULE_FEATURES27 = [];
|
|
1341
1379
|
function isConstructorFunction(node) {
|
|
1342
1380
|
return AST8__namespace.isOneOf([types.AST_NODE_TYPES.FunctionDeclaration, types.AST_NODE_TYPES.FunctionExpression])(node) && AST8__namespace.isMethodOrProperty(node.parent) && node.parent.key.type === types.AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1343
1381
|
}
|
|
@@ -1346,18 +1384,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1346
1384
|
type: "problem",
|
|
1347
1385
|
docs: {
|
|
1348
1386
|
description: "Disallow direct mutation of `this.state`.",
|
|
1349
|
-
[Symbol.for("rule_features")]:
|
|
1387
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1350
1388
|
},
|
|
1351
1389
|
messages: {
|
|
1352
1390
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1353
1391
|
},
|
|
1354
1392
|
schema: []
|
|
1355
1393
|
},
|
|
1356
|
-
name:
|
|
1357
|
-
create:
|
|
1394
|
+
name: RULE_NAME27,
|
|
1395
|
+
create: create27,
|
|
1358
1396
|
defaultOptions: []
|
|
1359
1397
|
});
|
|
1360
|
-
function
|
|
1398
|
+
function create27(context) {
|
|
1361
1399
|
return {
|
|
1362
1400
|
AssignmentExpression(node) {
|
|
1363
1401
|
if (!ER25__namespace.isAssignmentToThisState(node)) return;
|
|
@@ -1378,25 +1416,25 @@ function create26(context) {
|
|
|
1378
1416
|
}
|
|
1379
1417
|
};
|
|
1380
1418
|
}
|
|
1381
|
-
var
|
|
1382
|
-
var
|
|
1419
|
+
var RULE_NAME28 = "no-duplicate-key";
|
|
1420
|
+
var RULE_FEATURES28 = [];
|
|
1383
1421
|
var no_duplicate_key_default = createRule({
|
|
1384
1422
|
meta: {
|
|
1385
1423
|
type: "problem",
|
|
1386
1424
|
docs: {
|
|
1387
1425
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1388
|
-
[Symbol.for("rule_features")]:
|
|
1426
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1389
1427
|
},
|
|
1390
1428
|
messages: {
|
|
1391
1429
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1392
1430
|
},
|
|
1393
1431
|
schema: []
|
|
1394
1432
|
},
|
|
1395
|
-
name:
|
|
1396
|
-
create:
|
|
1433
|
+
name: RULE_NAME28,
|
|
1434
|
+
create: create28,
|
|
1397
1435
|
defaultOptions: []
|
|
1398
1436
|
});
|
|
1399
|
-
function
|
|
1437
|
+
function create28(context) {
|
|
1400
1438
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1401
1439
|
return {};
|
|
1402
1440
|
}
|
|
@@ -1460,8 +1498,8 @@ function create27(context) {
|
|
|
1460
1498
|
}
|
|
1461
1499
|
};
|
|
1462
1500
|
}
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1501
|
+
var RULE_NAME29 = "no-forward-ref";
|
|
1502
|
+
var RULE_FEATURES29 = [
|
|
1465
1503
|
"MOD"
|
|
1466
1504
|
];
|
|
1467
1505
|
var no_forward_ref_default = createRule({
|
|
@@ -1469,7 +1507,7 @@ var no_forward_ref_default = createRule({
|
|
|
1469
1507
|
type: "problem",
|
|
1470
1508
|
docs: {
|
|
1471
1509
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1472
|
-
[Symbol.for("rule_features")]:
|
|
1510
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1473
1511
|
},
|
|
1474
1512
|
fixable: "code",
|
|
1475
1513
|
messages: {
|
|
@@ -1477,11 +1515,11 @@ var no_forward_ref_default = createRule({
|
|
|
1477
1515
|
},
|
|
1478
1516
|
schema: []
|
|
1479
1517
|
},
|
|
1480
|
-
name:
|
|
1481
|
-
create:
|
|
1518
|
+
name: RULE_NAME29,
|
|
1519
|
+
create: create29,
|
|
1482
1520
|
defaultOptions: []
|
|
1483
1521
|
});
|
|
1484
|
-
function
|
|
1522
|
+
function create29(context) {
|
|
1485
1523
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1486
1524
|
return {};
|
|
1487
1525
|
}
|
|
@@ -1570,8 +1608,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1570
1608
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1571
1609
|
];
|
|
1572
1610
|
}
|
|
1573
|
-
var
|
|
1574
|
-
var
|
|
1611
|
+
var RULE_NAME30 = "no-implicit-key";
|
|
1612
|
+
var RULE_FEATURES30 = [
|
|
1575
1613
|
"EXP"
|
|
1576
1614
|
];
|
|
1577
1615
|
var no_implicit_key_default = createRule({
|
|
@@ -1579,18 +1617,18 @@ var no_implicit_key_default = createRule({
|
|
|
1579
1617
|
type: "problem",
|
|
1580
1618
|
docs: {
|
|
1581
1619
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1582
|
-
[Symbol.for("rule_features")]:
|
|
1620
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1583
1621
|
},
|
|
1584
1622
|
messages: {
|
|
1585
1623
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1586
1624
|
},
|
|
1587
1625
|
schema: []
|
|
1588
1626
|
},
|
|
1589
|
-
name:
|
|
1590
|
-
create:
|
|
1627
|
+
name: RULE_NAME30,
|
|
1628
|
+
create: create30,
|
|
1591
1629
|
defaultOptions: []
|
|
1592
1630
|
});
|
|
1593
|
-
function
|
|
1631
|
+
function create30(context) {
|
|
1594
1632
|
return {
|
|
1595
1633
|
JSXOpeningElement(node) {
|
|
1596
1634
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1604,8 +1642,8 @@ function create29(context) {
|
|
|
1604
1642
|
}
|
|
1605
1643
|
};
|
|
1606
1644
|
}
|
|
1607
|
-
var
|
|
1608
|
-
var
|
|
1645
|
+
var RULE_NAME31 = "no-leaked-conditional-rendering";
|
|
1646
|
+
var RULE_FEATURES31 = [
|
|
1609
1647
|
"TSC"
|
|
1610
1648
|
];
|
|
1611
1649
|
var tsHelpers = {
|
|
@@ -1691,18 +1729,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1691
1729
|
type: "problem",
|
|
1692
1730
|
docs: {
|
|
1693
1731
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1694
|
-
[Symbol.for("rule_features")]:
|
|
1732
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1695
1733
|
},
|
|
1696
1734
|
messages: {
|
|
1697
1735
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1698
1736
|
},
|
|
1699
1737
|
schema: []
|
|
1700
1738
|
},
|
|
1701
|
-
name:
|
|
1702
|
-
create:
|
|
1739
|
+
name: RULE_NAME31,
|
|
1740
|
+
create: create31,
|
|
1703
1741
|
defaultOptions: []
|
|
1704
1742
|
});
|
|
1705
|
-
function
|
|
1743
|
+
function create31(context) {
|
|
1706
1744
|
if (!context.sourceCode.text.includes("&&")) return {};
|
|
1707
1745
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1708
1746
|
const allowedVariants = [
|
|
@@ -1760,25 +1798,25 @@ function create30(context) {
|
|
|
1760
1798
|
JSXExpressionContainer: eff.flow(getReportDescriptor, kit.Reporter.make(context).send)
|
|
1761
1799
|
};
|
|
1762
1800
|
}
|
|
1763
|
-
var
|
|
1764
|
-
var
|
|
1801
|
+
var RULE_NAME32 = "no-missing-component-display-name";
|
|
1802
|
+
var RULE_FEATURES32 = [];
|
|
1765
1803
|
var no_missing_component_display_name_default = createRule({
|
|
1766
1804
|
meta: {
|
|
1767
1805
|
type: "problem",
|
|
1768
1806
|
docs: {
|
|
1769
1807
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1770
|
-
[Symbol.for("rule_features")]:
|
|
1808
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1771
1809
|
},
|
|
1772
1810
|
messages: {
|
|
1773
1811
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1774
1812
|
},
|
|
1775
1813
|
schema: []
|
|
1776
1814
|
},
|
|
1777
|
-
name:
|
|
1778
|
-
create:
|
|
1815
|
+
name: RULE_NAME32,
|
|
1816
|
+
create: create32,
|
|
1779
1817
|
defaultOptions: []
|
|
1780
1818
|
});
|
|
1781
|
-
function
|
|
1819
|
+
function create32(context) {
|
|
1782
1820
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1783
1821
|
const {
|
|
1784
1822
|
ctx,
|
|
@@ -1814,25 +1852,25 @@ function create31(context) {
|
|
|
1814
1852
|
}
|
|
1815
1853
|
};
|
|
1816
1854
|
}
|
|
1817
|
-
var
|
|
1818
|
-
var
|
|
1855
|
+
var RULE_NAME33 = "no-missing-context-display-name";
|
|
1856
|
+
var RULE_FEATURES33 = [];
|
|
1819
1857
|
var no_missing_context_display_name_default = createRule({
|
|
1820
1858
|
meta: {
|
|
1821
1859
|
type: "problem",
|
|
1822
1860
|
docs: {
|
|
1823
1861
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1824
|
-
[Symbol.for("rule_features")]:
|
|
1862
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1825
1863
|
},
|
|
1826
1864
|
messages: {
|
|
1827
1865
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1828
1866
|
},
|
|
1829
1867
|
schema: []
|
|
1830
1868
|
},
|
|
1831
|
-
name:
|
|
1832
|
-
create:
|
|
1869
|
+
name: RULE_NAME33,
|
|
1870
|
+
create: create33,
|
|
1833
1871
|
defaultOptions: []
|
|
1834
1872
|
});
|
|
1835
|
-
function
|
|
1873
|
+
function create33(context) {
|
|
1836
1874
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1837
1875
|
const createCalls = [];
|
|
1838
1876
|
const displayNameAssignments = [];
|
|
@@ -1870,14 +1908,14 @@ function create32(context) {
|
|
|
1870
1908
|
}
|
|
1871
1909
|
};
|
|
1872
1910
|
}
|
|
1873
|
-
var
|
|
1874
|
-
var
|
|
1911
|
+
var RULE_NAME34 = "no-missing-key";
|
|
1912
|
+
var RULE_FEATURES34 = [];
|
|
1875
1913
|
var no_missing_key_default = createRule({
|
|
1876
1914
|
meta: {
|
|
1877
1915
|
type: "problem",
|
|
1878
1916
|
docs: {
|
|
1879
1917
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1880
|
-
[Symbol.for("rule_features")]:
|
|
1918
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
1881
1919
|
},
|
|
1882
1920
|
messages: {
|
|
1883
1921
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1885,11 +1923,11 @@ var no_missing_key_default = createRule({
|
|
|
1885
1923
|
},
|
|
1886
1924
|
schema: []
|
|
1887
1925
|
},
|
|
1888
|
-
name:
|
|
1889
|
-
create:
|
|
1926
|
+
name: RULE_NAME34,
|
|
1927
|
+
create: create34,
|
|
1890
1928
|
defaultOptions: []
|
|
1891
1929
|
});
|
|
1892
|
-
function
|
|
1930
|
+
function create34(context) {
|
|
1893
1931
|
const report = kit.Reporter.make(context);
|
|
1894
1932
|
const state = { isWithinChildrenToArray: false };
|
|
1895
1933
|
function checkIteratorElement(node) {
|
|
@@ -1992,8 +2030,8 @@ function create33(context) {
|
|
|
1992
2030
|
}
|
|
1993
2031
|
};
|
|
1994
2032
|
}
|
|
1995
|
-
var
|
|
1996
|
-
var
|
|
2033
|
+
var RULE_NAME35 = "no-misused-capture-owner-stack";
|
|
2034
|
+
var RULE_FEATURES35 = [
|
|
1997
2035
|
"EXP"
|
|
1998
2036
|
];
|
|
1999
2037
|
var no_misused_capture_owner_stack_default = createRule({
|
|
@@ -2001,7 +2039,7 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2001
2039
|
type: "problem",
|
|
2002
2040
|
docs: {
|
|
2003
2041
|
description: "Prevents incorrect usage of `captureOwnerStack`.",
|
|
2004
|
-
[Symbol.for("rule_features")]:
|
|
2042
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2005
2043
|
},
|
|
2006
2044
|
fixable: "code",
|
|
2007
2045
|
messages: {
|
|
@@ -2011,11 +2049,11 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2011
2049
|
},
|
|
2012
2050
|
schema: []
|
|
2013
2051
|
},
|
|
2014
|
-
name:
|
|
2015
|
-
create:
|
|
2052
|
+
name: RULE_NAME35,
|
|
2053
|
+
create: create35,
|
|
2016
2054
|
defaultOptions: []
|
|
2017
2055
|
});
|
|
2018
|
-
function
|
|
2056
|
+
function create35(context) {
|
|
2019
2057
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
2020
2058
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
2021
2059
|
return {
|
|
@@ -2048,25 +2086,25 @@ function isDevelopmentOnlyCheck(node) {
|
|
|
2048
2086
|
if (AST8__namespace.isProcessEnvNodeEnvCompare(node.test, "!==", "production")) return true;
|
|
2049
2087
|
return false;
|
|
2050
2088
|
}
|
|
2051
|
-
var
|
|
2052
|
-
var
|
|
2089
|
+
var RULE_NAME36 = "no-nested-component-definitions";
|
|
2090
|
+
var RULE_FEATURES36 = [];
|
|
2053
2091
|
var no_nested_component_definitions_default = createRule({
|
|
2054
2092
|
meta: {
|
|
2055
2093
|
type: "problem",
|
|
2056
2094
|
docs: {
|
|
2057
2095
|
description: "Disallow nesting component definitions inside other components.",
|
|
2058
|
-
[Symbol.for("rule_features")]:
|
|
2096
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2059
2097
|
},
|
|
2060
2098
|
messages: {
|
|
2061
2099
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
2062
2100
|
},
|
|
2063
2101
|
schema: []
|
|
2064
2102
|
},
|
|
2065
|
-
name:
|
|
2066
|
-
create:
|
|
2103
|
+
name: RULE_NAME36,
|
|
2104
|
+
create: create36,
|
|
2067
2105
|
defaultOptions: []
|
|
2068
2106
|
});
|
|
2069
|
-
function
|
|
2107
|
+
function create36(context) {
|
|
2070
2108
|
const hint = ER25__namespace.ComponentDetectionHint.SkipArrayMapArgument | ER25__namespace.ComponentDetectionHint.SkipNullLiteral | ER25__namespace.ComponentDetectionHint.SkipUndefined | ER25__namespace.ComponentDetectionHint.SkipBooleanLiteral | ER25__namespace.ComponentDetectionHint.SkipStringLiteral | ER25__namespace.ComponentDetectionHint.SkipNumberLiteral | ER25__namespace.ComponentDetectionHint.StrictLogical | ER25__namespace.ComponentDetectionHint.StrictConditional;
|
|
2071
2109
|
const collector = ER25__namespace.useComponentCollector(context, { hint });
|
|
2072
2110
|
const collectorLegacy = ER25__namespace.useComponentCollectorLegacy();
|
|
@@ -2162,25 +2200,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
2162
2200
|
if (prop == null) return false;
|
|
2163
2201
|
return prop === call.arguments[1];
|
|
2164
2202
|
}
|
|
2165
|
-
var
|
|
2166
|
-
var
|
|
2203
|
+
var RULE_NAME37 = "no-nested-component-definitions";
|
|
2204
|
+
var RULE_FEATURES37 = [];
|
|
2167
2205
|
var no_nested_lazy_component_declarations_default = createRule({
|
|
2168
2206
|
meta: {
|
|
2169
2207
|
type: "problem",
|
|
2170
2208
|
docs: {
|
|
2171
2209
|
description: "Disallow nesting lazy component declarations inside other components.",
|
|
2172
|
-
[Symbol.for("rule_features")]:
|
|
2210
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2173
2211
|
},
|
|
2174
2212
|
messages: {
|
|
2175
2213
|
noNestedComponentDefinitions: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module."
|
|
2176
2214
|
},
|
|
2177
2215
|
schema: []
|
|
2178
2216
|
},
|
|
2179
|
-
name:
|
|
2180
|
-
create:
|
|
2217
|
+
name: RULE_NAME37,
|
|
2218
|
+
create: create37,
|
|
2181
2219
|
defaultOptions: []
|
|
2182
2220
|
});
|
|
2183
|
-
function
|
|
2221
|
+
function create37(context) {
|
|
2184
2222
|
const hint = ER25__namespace.ComponentDetectionHint.None;
|
|
2185
2223
|
const collector = ER25__namespace.useComponentCollector(context, { hint });
|
|
2186
2224
|
const collectorLegacy = ER25__namespace.useComponentCollectorLegacy();
|
|
@@ -2225,25 +2263,25 @@ function create36(context) {
|
|
|
2225
2263
|
}
|
|
2226
2264
|
};
|
|
2227
2265
|
}
|
|
2228
|
-
var
|
|
2229
|
-
var
|
|
2266
|
+
var RULE_NAME38 = "no-prop-types";
|
|
2267
|
+
var RULE_FEATURES38 = [];
|
|
2230
2268
|
var no_prop_types_default = createRule({
|
|
2231
2269
|
meta: {
|
|
2232
2270
|
type: "problem",
|
|
2233
2271
|
docs: {
|
|
2234
2272
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
2235
|
-
[Symbol.for("rule_features")]:
|
|
2273
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2236
2274
|
},
|
|
2237
2275
|
messages: {
|
|
2238
2276
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
2239
2277
|
},
|
|
2240
2278
|
schema: []
|
|
2241
2279
|
},
|
|
2242
|
-
name:
|
|
2243
|
-
create:
|
|
2280
|
+
name: RULE_NAME38,
|
|
2281
|
+
create: create38,
|
|
2244
2282
|
defaultOptions: []
|
|
2245
2283
|
});
|
|
2246
|
-
function
|
|
2284
|
+
function create38(context) {
|
|
2247
2285
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
2248
2286
|
return {};
|
|
2249
2287
|
}
|
|
@@ -2279,8 +2317,8 @@ function create37(context) {
|
|
|
2279
2317
|
}
|
|
2280
2318
|
};
|
|
2281
2319
|
}
|
|
2282
|
-
var
|
|
2283
|
-
var
|
|
2320
|
+
var RULE_NAME39 = "no-redundant-should-component-update";
|
|
2321
|
+
var RULE_FEATURES39 = [];
|
|
2284
2322
|
function isShouldComponentUpdate(node) {
|
|
2285
2323
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2286
2324
|
}
|
|
@@ -2289,18 +2327,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2289
2327
|
type: "problem",
|
|
2290
2328
|
docs: {
|
|
2291
2329
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2292
|
-
[Symbol.for("rule_features")]:
|
|
2330
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2293
2331
|
},
|
|
2294
2332
|
messages: {
|
|
2295
2333
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2296
2334
|
},
|
|
2297
2335
|
schema: []
|
|
2298
2336
|
},
|
|
2299
|
-
name:
|
|
2300
|
-
create:
|
|
2337
|
+
name: RULE_NAME39,
|
|
2338
|
+
create: create39,
|
|
2301
2339
|
defaultOptions: []
|
|
2302
2340
|
});
|
|
2303
|
-
function
|
|
2341
|
+
function create39(context) {
|
|
2304
2342
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2305
2343
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
2306
2344
|
return {
|
|
@@ -2327,25 +2365,25 @@ function create38(context) {
|
|
|
2327
2365
|
}
|
|
2328
2366
|
};
|
|
2329
2367
|
}
|
|
2330
|
-
var
|
|
2331
|
-
var
|
|
2368
|
+
var RULE_NAME40 = "no-set-state-in-component-did-mount";
|
|
2369
|
+
var RULE_FEATURES40 = [];
|
|
2332
2370
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2333
2371
|
meta: {
|
|
2334
2372
|
type: "problem",
|
|
2335
2373
|
docs: {
|
|
2336
2374
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2337
|
-
[Symbol.for("rule_features")]:
|
|
2375
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2338
2376
|
},
|
|
2339
2377
|
messages: {
|
|
2340
2378
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2341
2379
|
},
|
|
2342
2380
|
schema: []
|
|
2343
2381
|
},
|
|
2344
|
-
name:
|
|
2345
|
-
create:
|
|
2382
|
+
name: RULE_NAME40,
|
|
2383
|
+
create: create40,
|
|
2346
2384
|
defaultOptions: []
|
|
2347
2385
|
});
|
|
2348
|
-
function
|
|
2386
|
+
function create40(context) {
|
|
2349
2387
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2350
2388
|
return {
|
|
2351
2389
|
CallExpression(node) {
|
|
@@ -2366,25 +2404,25 @@ function create39(context) {
|
|
|
2366
2404
|
}
|
|
2367
2405
|
};
|
|
2368
2406
|
}
|
|
2369
|
-
var
|
|
2370
|
-
var
|
|
2407
|
+
var RULE_NAME41 = "no-set-state-in-component-did-update";
|
|
2408
|
+
var RULE_FEATURES41 = [];
|
|
2371
2409
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2372
2410
|
meta: {
|
|
2373
2411
|
type: "problem",
|
|
2374
2412
|
docs: {
|
|
2375
2413
|
description: "Disallow calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2376
|
-
[Symbol.for("rule_features")]:
|
|
2414
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2377
2415
|
},
|
|
2378
2416
|
messages: {
|
|
2379
2417
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2380
2418
|
},
|
|
2381
2419
|
schema: []
|
|
2382
2420
|
},
|
|
2383
|
-
name:
|
|
2384
|
-
create:
|
|
2421
|
+
name: RULE_NAME41,
|
|
2422
|
+
create: create41,
|
|
2385
2423
|
defaultOptions: []
|
|
2386
2424
|
});
|
|
2387
|
-
function
|
|
2425
|
+
function create41(context) {
|
|
2388
2426
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2389
2427
|
return {
|
|
2390
2428
|
CallExpression(node) {
|
|
@@ -2405,25 +2443,25 @@ function create40(context) {
|
|
|
2405
2443
|
}
|
|
2406
2444
|
};
|
|
2407
2445
|
}
|
|
2408
|
-
var
|
|
2409
|
-
var
|
|
2446
|
+
var RULE_NAME42 = "no-set-state-in-component-will-update";
|
|
2447
|
+
var RULE_FEATURES42 = [];
|
|
2410
2448
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2411
2449
|
meta: {
|
|
2412
2450
|
type: "problem",
|
|
2413
2451
|
docs: {
|
|
2414
2452
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2415
|
-
[Symbol.for("rule_features")]:
|
|
2453
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2416
2454
|
},
|
|
2417
2455
|
messages: {
|
|
2418
2456
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2419
2457
|
},
|
|
2420
2458
|
schema: []
|
|
2421
2459
|
},
|
|
2422
|
-
name:
|
|
2423
|
-
create:
|
|
2460
|
+
name: RULE_NAME42,
|
|
2461
|
+
create: create42,
|
|
2424
2462
|
defaultOptions: []
|
|
2425
2463
|
});
|
|
2426
|
-
function
|
|
2464
|
+
function create42(context) {
|
|
2427
2465
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2428
2466
|
return {
|
|
2429
2467
|
CallExpression(node) {
|
|
@@ -2444,8 +2482,8 @@ function create41(context) {
|
|
|
2444
2482
|
}
|
|
2445
2483
|
};
|
|
2446
2484
|
}
|
|
2447
|
-
var
|
|
2448
|
-
var
|
|
2485
|
+
var RULE_NAME43 = "no-string-refs";
|
|
2486
|
+
var RULE_FEATURES43 = [
|
|
2449
2487
|
"MOD"
|
|
2450
2488
|
];
|
|
2451
2489
|
var no_string_refs_default = createRule({
|
|
@@ -2453,7 +2491,7 @@ var no_string_refs_default = createRule({
|
|
|
2453
2491
|
type: "problem",
|
|
2454
2492
|
docs: {
|
|
2455
2493
|
description: "Replaces string refs with callback refs.",
|
|
2456
|
-
[Symbol.for("rule_features")]:
|
|
2494
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2457
2495
|
},
|
|
2458
2496
|
fixable: "code",
|
|
2459
2497
|
messages: {
|
|
@@ -2461,11 +2499,11 @@ var no_string_refs_default = createRule({
|
|
|
2461
2499
|
},
|
|
2462
2500
|
schema: []
|
|
2463
2501
|
},
|
|
2464
|
-
name:
|
|
2465
|
-
create:
|
|
2502
|
+
name: RULE_NAME43,
|
|
2503
|
+
create: create43,
|
|
2466
2504
|
defaultOptions: []
|
|
2467
2505
|
});
|
|
2468
|
-
function
|
|
2506
|
+
function create43(context) {
|
|
2469
2507
|
const state = {
|
|
2470
2508
|
isWithinClassComponent: false
|
|
2471
2509
|
};
|
|
@@ -2509,8 +2547,8 @@ function getAttributeValueText(context, node) {
|
|
|
2509
2547
|
return null;
|
|
2510
2548
|
}
|
|
2511
2549
|
}
|
|
2512
|
-
var
|
|
2513
|
-
var
|
|
2550
|
+
var RULE_NAME44 = "no-unsafe-component-will-mount";
|
|
2551
|
+
var RULE_FEATURES44 = [];
|
|
2514
2552
|
function isUnsafeComponentWillMount(node) {
|
|
2515
2553
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2516
2554
|
}
|
|
@@ -2519,18 +2557,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2519
2557
|
type: "problem",
|
|
2520
2558
|
docs: {
|
|
2521
2559
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2522
|
-
[Symbol.for("rule_features")]:
|
|
2560
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2523
2561
|
},
|
|
2524
2562
|
messages: {
|
|
2525
2563
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2526
2564
|
},
|
|
2527
2565
|
schema: []
|
|
2528
2566
|
},
|
|
2529
|
-
name:
|
|
2530
|
-
create:
|
|
2567
|
+
name: RULE_NAME44,
|
|
2568
|
+
create: create44,
|
|
2531
2569
|
defaultOptions: []
|
|
2532
2570
|
});
|
|
2533
|
-
function
|
|
2571
|
+
function create44(context) {
|
|
2534
2572
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2535
2573
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
2536
2574
|
return {
|
|
@@ -2551,8 +2589,8 @@ function create43(context) {
|
|
|
2551
2589
|
}
|
|
2552
2590
|
};
|
|
2553
2591
|
}
|
|
2554
|
-
var
|
|
2555
|
-
var
|
|
2592
|
+
var RULE_NAME45 = "no-unsafe-component-will-receive-props";
|
|
2593
|
+
var RULE_FEATURES45 = [];
|
|
2556
2594
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2557
2595
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2558
2596
|
}
|
|
@@ -2561,18 +2599,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2561
2599
|
type: "problem",
|
|
2562
2600
|
docs: {
|
|
2563
2601
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2564
|
-
[Symbol.for("rule_features")]:
|
|
2602
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2565
2603
|
},
|
|
2566
2604
|
messages: {
|
|
2567
2605
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2568
2606
|
},
|
|
2569
2607
|
schema: []
|
|
2570
2608
|
},
|
|
2571
|
-
name:
|
|
2572
|
-
create:
|
|
2609
|
+
name: RULE_NAME45,
|
|
2610
|
+
create: create45,
|
|
2573
2611
|
defaultOptions: []
|
|
2574
2612
|
});
|
|
2575
|
-
function
|
|
2613
|
+
function create45(context) {
|
|
2576
2614
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2577
2615
|
return {};
|
|
2578
2616
|
}
|
|
@@ -2595,8 +2633,8 @@ function create44(context) {
|
|
|
2595
2633
|
}
|
|
2596
2634
|
};
|
|
2597
2635
|
}
|
|
2598
|
-
var
|
|
2599
|
-
var
|
|
2636
|
+
var RULE_NAME46 = "no-unsafe-component-will-update";
|
|
2637
|
+
var RULE_FEATURES46 = [];
|
|
2600
2638
|
function isUnsafeComponentWillUpdate(node) {
|
|
2601
2639
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2602
2640
|
}
|
|
@@ -2605,18 +2643,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2605
2643
|
type: "problem",
|
|
2606
2644
|
docs: {
|
|
2607
2645
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2608
|
-
[Symbol.for("rule_features")]:
|
|
2646
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2609
2647
|
},
|
|
2610
2648
|
messages: {
|
|
2611
2649
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2612
2650
|
},
|
|
2613
2651
|
schema: []
|
|
2614
2652
|
},
|
|
2615
|
-
name:
|
|
2616
|
-
create:
|
|
2653
|
+
name: RULE_NAME46,
|
|
2654
|
+
create: create46,
|
|
2617
2655
|
defaultOptions: []
|
|
2618
2656
|
});
|
|
2619
|
-
function
|
|
2657
|
+
function create46(context) {
|
|
2620
2658
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2621
2659
|
const { ctx, listeners } = ER25__namespace.useComponentCollectorLegacy();
|
|
2622
2660
|
return {
|
|
@@ -2637,25 +2675,25 @@ function create45(context) {
|
|
|
2637
2675
|
}
|
|
2638
2676
|
};
|
|
2639
2677
|
}
|
|
2640
|
-
var
|
|
2641
|
-
var
|
|
2678
|
+
var RULE_NAME47 = "no-unstable-context-value";
|
|
2679
|
+
var RULE_FEATURES47 = [];
|
|
2642
2680
|
var no_unstable_context_value_default = createRule({
|
|
2643
2681
|
meta: {
|
|
2644
2682
|
type: "problem",
|
|
2645
2683
|
docs: {
|
|
2646
2684
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2647
|
-
[Symbol.for("rule_features")]:
|
|
2685
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2648
2686
|
},
|
|
2649
2687
|
messages: {
|
|
2650
2688
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2651
2689
|
},
|
|
2652
2690
|
schema: []
|
|
2653
2691
|
},
|
|
2654
|
-
name:
|
|
2655
|
-
create:
|
|
2692
|
+
name: RULE_NAME47,
|
|
2693
|
+
create: create47,
|
|
2656
2694
|
defaultOptions: []
|
|
2657
2695
|
});
|
|
2658
|
-
function
|
|
2696
|
+
function create47(context) {
|
|
2659
2697
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2660
2698
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2661
2699
|
const { ctx, listeners } = ER25__namespace.useComponentCollector(context);
|
|
@@ -2710,25 +2748,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2710
2748
|
}
|
|
2711
2749
|
return false;
|
|
2712
2750
|
}
|
|
2713
|
-
var
|
|
2714
|
-
var
|
|
2751
|
+
var RULE_NAME48 = "no-unstable-default-props";
|
|
2752
|
+
var RULE_FEATURES48 = [];
|
|
2715
2753
|
var no_unstable_default_props_default = createRule({
|
|
2716
2754
|
meta: {
|
|
2717
2755
|
type: "problem",
|
|
2718
2756
|
docs: {
|
|
2719
2757
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2720
|
-
[Symbol.for("rule_features")]:
|
|
2758
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
2721
2759
|
},
|
|
2722
2760
|
messages: {
|
|
2723
2761
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2724
2762
|
},
|
|
2725
2763
|
schema: []
|
|
2726
2764
|
},
|
|
2727
|
-
name:
|
|
2728
|
-
create:
|
|
2765
|
+
name: RULE_NAME48,
|
|
2766
|
+
create: create48,
|
|
2729
2767
|
defaultOptions: []
|
|
2730
2768
|
});
|
|
2731
|
-
function
|
|
2769
|
+
function create48(context) {
|
|
2732
2770
|
const { ctx, listeners } = ER25__namespace.useComponentCollector(context);
|
|
2733
2771
|
const declarators = /* @__PURE__ */ new WeakMap();
|
|
2734
2772
|
return {
|
|
@@ -2784,8 +2822,8 @@ function create47(context) {
|
|
|
2784
2822
|
}
|
|
2785
2823
|
};
|
|
2786
2824
|
}
|
|
2787
|
-
var
|
|
2788
|
-
var
|
|
2825
|
+
var RULE_NAME49 = "no-unused-class-component-members";
|
|
2826
|
+
var RULE_FEATURES49 = [];
|
|
2789
2827
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2790
2828
|
"componentDidCatch",
|
|
2791
2829
|
"componentDidMount",
|
|
@@ -2811,18 +2849,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2811
2849
|
type: "problem",
|
|
2812
2850
|
docs: {
|
|
2813
2851
|
description: "Warns unused class component methods and properties.",
|
|
2814
|
-
[Symbol.for("rule_features")]:
|
|
2852
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
2815
2853
|
},
|
|
2816
2854
|
messages: {
|
|
2817
2855
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2818
2856
|
},
|
|
2819
2857
|
schema: []
|
|
2820
2858
|
},
|
|
2821
|
-
name:
|
|
2822
|
-
create:
|
|
2859
|
+
name: RULE_NAME49,
|
|
2860
|
+
create: create49,
|
|
2823
2861
|
defaultOptions: []
|
|
2824
2862
|
});
|
|
2825
|
-
function
|
|
2863
|
+
function create49(context) {
|
|
2826
2864
|
const classEntries = [];
|
|
2827
2865
|
const methodEntries = [];
|
|
2828
2866
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2932,8 +2970,8 @@ function create48(context) {
|
|
|
2932
2970
|
}
|
|
2933
2971
|
};
|
|
2934
2972
|
}
|
|
2935
|
-
var
|
|
2936
|
-
var
|
|
2973
|
+
var RULE_NAME50 = "no-unused-state";
|
|
2974
|
+
var RULE_FEATURES50 = [];
|
|
2937
2975
|
function isKeyLiteral3(node, key) {
|
|
2938
2976
|
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);
|
|
2939
2977
|
}
|
|
@@ -2942,18 +2980,18 @@ var no_unused_state_default = createRule({
|
|
|
2942
2980
|
type: "problem",
|
|
2943
2981
|
docs: {
|
|
2944
2982
|
description: "Warns unused class component state.",
|
|
2945
|
-
[Symbol.for("rule_features")]:
|
|
2983
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
2946
2984
|
},
|
|
2947
2985
|
messages: {
|
|
2948
2986
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2949
2987
|
},
|
|
2950
2988
|
schema: []
|
|
2951
2989
|
},
|
|
2952
|
-
name:
|
|
2953
|
-
create:
|
|
2990
|
+
name: RULE_NAME50,
|
|
2991
|
+
create: create50,
|
|
2954
2992
|
defaultOptions: []
|
|
2955
2993
|
});
|
|
2956
|
-
function
|
|
2994
|
+
function create50(context) {
|
|
2957
2995
|
const classEntries = [];
|
|
2958
2996
|
const methodEntries = [];
|
|
2959
2997
|
const constructorEntries = [];
|
|
@@ -3087,8 +3125,8 @@ function create49(context) {
|
|
|
3087
3125
|
}
|
|
3088
3126
|
};
|
|
3089
3127
|
}
|
|
3090
|
-
var
|
|
3091
|
-
var
|
|
3128
|
+
var RULE_NAME51 = "no-use-context";
|
|
3129
|
+
var RULE_FEATURES51 = [
|
|
3092
3130
|
"MOD"
|
|
3093
3131
|
];
|
|
3094
3132
|
var no_use_context_default = createRule({
|
|
@@ -3096,7 +3134,7 @@ var no_use_context_default = createRule({
|
|
|
3096
3134
|
type: "problem",
|
|
3097
3135
|
docs: {
|
|
3098
3136
|
description: "Replaces usages of `useContext` with `use`.",
|
|
3099
|
-
[Symbol.for("rule_features")]:
|
|
3137
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3100
3138
|
},
|
|
3101
3139
|
fixable: "code",
|
|
3102
3140
|
messages: {
|
|
@@ -3104,11 +3142,11 @@ var no_use_context_default = createRule({
|
|
|
3104
3142
|
},
|
|
3105
3143
|
schema: []
|
|
3106
3144
|
},
|
|
3107
|
-
name:
|
|
3108
|
-
create:
|
|
3145
|
+
name: RULE_NAME51,
|
|
3146
|
+
create: create51,
|
|
3109
3147
|
defaultOptions: []
|
|
3110
3148
|
});
|
|
3111
|
-
function
|
|
3149
|
+
function create51(context) {
|
|
3112
3150
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
3113
3151
|
const settings4 = shared.getSettingsFromContext(context);
|
|
3114
3152
|
if (compareVersions.compare(settings4.version, "19.0.0", "<")) {
|
|
@@ -3191,25 +3229,25 @@ function getCorrelativeTokens(context, node) {
|
|
|
3191
3229
|
}
|
|
3192
3230
|
return tokens;
|
|
3193
3231
|
}
|
|
3194
|
-
var
|
|
3195
|
-
var
|
|
3232
|
+
var RULE_NAME52 = "no-useless-forward-ref";
|
|
3233
|
+
var RULE_FEATURES52 = [];
|
|
3196
3234
|
var no_useless_forward_ref_default = createRule({
|
|
3197
3235
|
meta: {
|
|
3198
3236
|
type: "problem",
|
|
3199
3237
|
docs: {
|
|
3200
3238
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
3201
|
-
[Symbol.for("rule_features")]:
|
|
3239
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3202
3240
|
},
|
|
3203
3241
|
messages: {
|
|
3204
3242
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
3205
3243
|
},
|
|
3206
3244
|
schema: []
|
|
3207
3245
|
},
|
|
3208
|
-
name:
|
|
3209
|
-
create:
|
|
3246
|
+
name: RULE_NAME52,
|
|
3247
|
+
create: create52,
|
|
3210
3248
|
defaultOptions: []
|
|
3211
3249
|
});
|
|
3212
|
-
function
|
|
3250
|
+
function create52(context) {
|
|
3213
3251
|
return {
|
|
3214
3252
|
CallExpression(node) {
|
|
3215
3253
|
if (!ER25__namespace.isForwardRefCall(context, node)) {
|
|
@@ -3230,7 +3268,7 @@ function create51(context) {
|
|
|
3230
3268
|
}
|
|
3231
3269
|
};
|
|
3232
3270
|
}
|
|
3233
|
-
var
|
|
3271
|
+
var RULE_NAME53 = "no-useless-fragment";
|
|
3234
3272
|
var defaultOptions = [{
|
|
3235
3273
|
allowExpressions: true
|
|
3236
3274
|
}];
|
|
@@ -3256,11 +3294,11 @@ var no_useless_fragment_default = createRule({
|
|
|
3256
3294
|
}
|
|
3257
3295
|
}]
|
|
3258
3296
|
},
|
|
3259
|
-
name:
|
|
3260
|
-
create:
|
|
3297
|
+
name: RULE_NAME53,
|
|
3298
|
+
create: create53,
|
|
3261
3299
|
defaultOptions
|
|
3262
3300
|
});
|
|
3263
|
-
function
|
|
3301
|
+
function create53(context, [option]) {
|
|
3264
3302
|
const { allowExpressions = true } = option;
|
|
3265
3303
|
return {
|
|
3266
3304
|
JSXElement(node) {
|
|
@@ -3380,8 +3418,8 @@ function canFix(context, node) {
|
|
|
3380
3418
|
}
|
|
3381
3419
|
return true;
|
|
3382
3420
|
}
|
|
3383
|
-
var
|
|
3384
|
-
var
|
|
3421
|
+
var RULE_NAME54 = "prefer-destructuring-assignment";
|
|
3422
|
+
var RULE_FEATURES53 = [];
|
|
3385
3423
|
function isMemberExpressionWithObjectName(node) {
|
|
3386
3424
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3387
3425
|
}
|
|
@@ -3390,18 +3428,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3390
3428
|
type: "problem",
|
|
3391
3429
|
docs: {
|
|
3392
3430
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3393
|
-
[Symbol.for("rule_features")]:
|
|
3431
|
+
[Symbol.for("rule_features")]: RULE_FEATURES53
|
|
3394
3432
|
},
|
|
3395
3433
|
messages: {
|
|
3396
3434
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3397
3435
|
},
|
|
3398
3436
|
schema: []
|
|
3399
3437
|
},
|
|
3400
|
-
name:
|
|
3401
|
-
create:
|
|
3438
|
+
name: RULE_NAME54,
|
|
3439
|
+
create: create54,
|
|
3402
3440
|
defaultOptions: []
|
|
3403
3441
|
});
|
|
3404
|
-
function
|
|
3442
|
+
function create54(context) {
|
|
3405
3443
|
const { ctx, listeners } = ER25__namespace.useComponentCollector(context);
|
|
3406
3444
|
const memberExpressionWithNames = [];
|
|
3407
3445
|
return {
|
|
@@ -3461,8 +3499,8 @@ function create53(context) {
|
|
|
3461
3499
|
}
|
|
3462
3500
|
};
|
|
3463
3501
|
}
|
|
3464
|
-
var
|
|
3465
|
-
var
|
|
3502
|
+
var RULE_NAME55 = "prefer-react-namespace-import";
|
|
3503
|
+
var RULE_FEATURES54 = [
|
|
3466
3504
|
"FIX"
|
|
3467
3505
|
];
|
|
3468
3506
|
var prefer_react_namespace_import_default = createRule({
|
|
@@ -3470,7 +3508,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3470
3508
|
type: "problem",
|
|
3471
3509
|
docs: {
|
|
3472
3510
|
description: "Enforces React is imported via a namespace import.",
|
|
3473
|
-
[Symbol.for("rule_features")]:
|
|
3511
|
+
[Symbol.for("rule_features")]: RULE_FEATURES54
|
|
3474
3512
|
},
|
|
3475
3513
|
fixable: "code",
|
|
3476
3514
|
messages: {
|
|
@@ -3478,11 +3516,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3478
3516
|
},
|
|
3479
3517
|
schema: []
|
|
3480
3518
|
},
|
|
3481
|
-
name:
|
|
3482
|
-
create:
|
|
3519
|
+
name: RULE_NAME55,
|
|
3520
|
+
create: create55,
|
|
3483
3521
|
defaultOptions: []
|
|
3484
3522
|
});
|
|
3485
|
-
function
|
|
3523
|
+
function create55(context) {
|
|
3486
3524
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3487
3525
|
return {
|
|
3488
3526
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3517,8 +3555,8 @@ function create54(context) {
|
|
|
3517
3555
|
}
|
|
3518
3556
|
};
|
|
3519
3557
|
}
|
|
3520
|
-
var
|
|
3521
|
-
var
|
|
3558
|
+
var RULE_NAME56 = "prefer-read-only-props";
|
|
3559
|
+
var RULE_FEATURES55 = [
|
|
3522
3560
|
"TSC",
|
|
3523
3561
|
"EXP"
|
|
3524
3562
|
];
|
|
@@ -3527,18 +3565,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3527
3565
|
type: "problem",
|
|
3528
3566
|
docs: {
|
|
3529
3567
|
description: "Enforces read-only props in components.",
|
|
3530
|
-
[Symbol.for("rule_features")]:
|
|
3568
|
+
[Symbol.for("rule_features")]: RULE_FEATURES55
|
|
3531
3569
|
},
|
|
3532
3570
|
messages: {
|
|
3533
3571
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3534
3572
|
},
|
|
3535
3573
|
schema: []
|
|
3536
3574
|
},
|
|
3537
|
-
name:
|
|
3538
|
-
create:
|
|
3575
|
+
name: RULE_NAME56,
|
|
3576
|
+
create: create56,
|
|
3539
3577
|
defaultOptions: []
|
|
3540
3578
|
});
|
|
3541
|
-
function
|
|
3579
|
+
function create56(context) {
|
|
3542
3580
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3543
3581
|
const { ctx, listeners } = ER25__namespace.useComponentCollector(context);
|
|
3544
3582
|
return {
|
|
@@ -3568,8 +3606,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3568
3606
|
return true;
|
|
3569
3607
|
}
|
|
3570
3608
|
}
|
|
3571
|
-
var
|
|
3572
|
-
var
|
|
3609
|
+
var RULE_NAME57 = "prefer-shorthand-boolean";
|
|
3610
|
+
var RULE_FEATURES56 = [
|
|
3573
3611
|
"FIX"
|
|
3574
3612
|
];
|
|
3575
3613
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3577,7 +3615,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3577
3615
|
type: "problem",
|
|
3578
3616
|
docs: {
|
|
3579
3617
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3580
|
-
[Symbol.for("rule_features")]:
|
|
3618
|
+
[Symbol.for("rule_features")]: RULE_FEATURES56
|
|
3581
3619
|
},
|
|
3582
3620
|
fixable: "code",
|
|
3583
3621
|
messages: {
|
|
@@ -3585,11 +3623,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3585
3623
|
},
|
|
3586
3624
|
schema: []
|
|
3587
3625
|
},
|
|
3588
|
-
name:
|
|
3589
|
-
create:
|
|
3626
|
+
name: RULE_NAME57,
|
|
3627
|
+
create: create57,
|
|
3590
3628
|
defaultOptions: []
|
|
3591
3629
|
});
|
|
3592
|
-
function
|
|
3630
|
+
function create57(context) {
|
|
3593
3631
|
return {
|
|
3594
3632
|
JSXAttribute(node) {
|
|
3595
3633
|
const { value } = node;
|
|
@@ -3609,8 +3647,8 @@ function create56(context) {
|
|
|
3609
3647
|
}
|
|
3610
3648
|
};
|
|
3611
3649
|
}
|
|
3612
|
-
var
|
|
3613
|
-
var
|
|
3650
|
+
var RULE_NAME58 = "prefer-shorthand-fragment";
|
|
3651
|
+
var RULE_FEATURES57 = [
|
|
3614
3652
|
"FIX"
|
|
3615
3653
|
];
|
|
3616
3654
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3618,7 +3656,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3618
3656
|
type: "problem",
|
|
3619
3657
|
docs: {
|
|
3620
3658
|
description: "Enforces shorthand syntax for fragments.",
|
|
3621
|
-
[Symbol.for("rule_features")]:
|
|
3659
|
+
[Symbol.for("rule_features")]: RULE_FEATURES57
|
|
3622
3660
|
},
|
|
3623
3661
|
fixable: "code",
|
|
3624
3662
|
messages: {
|
|
@@ -3626,11 +3664,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3626
3664
|
},
|
|
3627
3665
|
schema: []
|
|
3628
3666
|
},
|
|
3629
|
-
name:
|
|
3630
|
-
create:
|
|
3667
|
+
name: RULE_NAME58,
|
|
3668
|
+
create: create58,
|
|
3631
3669
|
defaultOptions: []
|
|
3632
3670
|
});
|
|
3633
|
-
function
|
|
3671
|
+
function create58(context) {
|
|
3634
3672
|
return {
|
|
3635
3673
|
JSXElement(node) {
|
|
3636
3674
|
if (!ER25__namespace.isFragmentElement(context, node)) return;
|
|
@@ -3718,6 +3756,7 @@ var plugin = {
|
|
|
3718
3756
|
// Part: JSX only rules
|
|
3719
3757
|
"jsx-key-before-spread": jsx_key_before_spread_default,
|
|
3720
3758
|
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3759
|
+
"jsx-no-iife": jsx_no_iife_default,
|
|
3721
3760
|
"jsx-no-undef": jsx_no_undef_default,
|
|
3722
3761
|
"jsx-uses-react": jsx_uses_react_default,
|
|
3723
3762
|
"jsx-uses-vars": jsx_uses_vars_default,
|