eslint-plugin-react-x 1.40.0-next.2 → 1.40.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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +332 -294
- package/dist/index.mjs +331 -293
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -7,13 +7,13 @@ var types = require('@typescript-eslint/types');
|
|
|
7
7
|
var eff = require('@eslint-react/eff');
|
|
8
8
|
var VAR2 = require('@eslint-react/var');
|
|
9
9
|
var tsPattern = require('ts-pattern');
|
|
10
|
+
var kit = require('@eslint-react/kit');
|
|
11
|
+
var ts = require('typescript');
|
|
10
12
|
var AST11 = require('@eslint-react/ast');
|
|
11
13
|
var ER21 = require('@eslint-react/core');
|
|
12
|
-
var kit = require('@eslint-react/kit');
|
|
13
14
|
var compareVersions = require('compare-versions');
|
|
14
15
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
15
16
|
var tsApiUtils = require('ts-api-utils');
|
|
16
|
-
var ts = require('typescript');
|
|
17
17
|
var isImmutableType = require('is-immutable-type');
|
|
18
18
|
|
|
19
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -38,9 +38,9 @@ function _interopNamespace(e) {
|
|
|
38
38
|
|
|
39
39
|
var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
|
|
40
40
|
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
41
|
+
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
41
42
|
var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
42
43
|
var ER21__namespace = /*#__PURE__*/_interopNamespace(ER21);
|
|
43
|
-
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
44
44
|
|
|
45
45
|
var __defProp = Object.defineProperty;
|
|
46
46
|
var __export = (target, all) => {
|
|
@@ -58,6 +58,7 @@ __export(recommended_exports, {
|
|
|
58
58
|
var name = "react-x/recommended";
|
|
59
59
|
var rules = {
|
|
60
60
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
61
|
+
"react-x/jsx-uses-react": "warn",
|
|
61
62
|
"react-x/jsx-uses-vars": "warn",
|
|
62
63
|
"react-x/no-access-state-in-setstate": "error",
|
|
63
64
|
"react-x/no-array-index-key": "warn",
|
|
@@ -120,6 +121,7 @@ var rules2 = {
|
|
|
120
121
|
...rules,
|
|
121
122
|
"react-x/jsx-no-duplicate-props": "off",
|
|
122
123
|
"react-x/jsx-no-undef": "off",
|
|
124
|
+
"react-x/jsx-uses-react": "off",
|
|
123
125
|
"react-x/jsx-uses-vars": "off"
|
|
124
126
|
};
|
|
125
127
|
var settings2 = {
|
|
@@ -139,7 +141,7 @@ var settings3 = {
|
|
|
139
141
|
|
|
140
142
|
// package.json
|
|
141
143
|
var name4 = "eslint-plugin-react-x";
|
|
142
|
-
var version = "1.40.0
|
|
144
|
+
var version = "1.40.0";
|
|
143
145
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
144
146
|
|
|
145
147
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -287,17 +289,17 @@ function create4(context) {
|
|
|
287
289
|
}
|
|
288
290
|
};
|
|
289
291
|
}
|
|
290
|
-
var RULE_NAME5 = "jsx-uses-
|
|
292
|
+
var RULE_NAME5 = "jsx-uses-react";
|
|
291
293
|
var RULE_FEATURES5 = [];
|
|
292
|
-
var
|
|
294
|
+
var jsx_uses_react_default = createRule({
|
|
293
295
|
meta: {
|
|
294
296
|
type: "problem",
|
|
295
297
|
docs: {
|
|
296
|
-
description: "Marks variables used
|
|
298
|
+
description: "Marks React variables as used when JSX is used in the file.",
|
|
297
299
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
298
300
|
},
|
|
299
301
|
messages: {
|
|
300
|
-
|
|
302
|
+
jsxUsesReact: ""
|
|
301
303
|
},
|
|
302
304
|
schema: []
|
|
303
305
|
},
|
|
@@ -306,6 +308,41 @@ var jsx_uses_vars_default = createRule({
|
|
|
306
308
|
defaultOptions: []
|
|
307
309
|
});
|
|
308
310
|
function create5(context) {
|
|
311
|
+
const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = kit.JsxRuntime.getJsxRuntimeOptionsFromContext(context);
|
|
312
|
+
if (jsx === ts.JsxEmit.ReactJSX || jsx === ts.JsxEmit.ReactJSXDev) return {};
|
|
313
|
+
return {
|
|
314
|
+
JSXFragment(node) {
|
|
315
|
+
context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
|
|
316
|
+
},
|
|
317
|
+
JSXOpeningElement(node) {
|
|
318
|
+
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
319
|
+
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
320
|
+
},
|
|
321
|
+
JSXOpeningFragment(node) {
|
|
322
|
+
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
323
|
+
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
var RULE_NAME6 = "jsx-uses-vars";
|
|
328
|
+
var RULE_FEATURES6 = [];
|
|
329
|
+
var jsx_uses_vars_default = createRule({
|
|
330
|
+
meta: {
|
|
331
|
+
type: "problem",
|
|
332
|
+
docs: {
|
|
333
|
+
description: "Marks variables used in JSX elements as used.",
|
|
334
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
335
|
+
},
|
|
336
|
+
messages: {
|
|
337
|
+
jsxUsesVars: ""
|
|
338
|
+
},
|
|
339
|
+
schema: []
|
|
340
|
+
},
|
|
341
|
+
name: RULE_NAME6,
|
|
342
|
+
create: create6,
|
|
343
|
+
defaultOptions: []
|
|
344
|
+
});
|
|
345
|
+
function create6(context) {
|
|
309
346
|
return {
|
|
310
347
|
JSXOpeningElement(node) {
|
|
311
348
|
switch (node.name.type) {
|
|
@@ -327,8 +364,8 @@ function create5(context) {
|
|
|
327
364
|
}
|
|
328
365
|
};
|
|
329
366
|
}
|
|
330
|
-
var
|
|
331
|
-
var
|
|
367
|
+
var RULE_NAME7 = "no-access-state-in-setstate";
|
|
368
|
+
var RULE_FEATURES7 = [];
|
|
332
369
|
function isKeyLiteral(node, key) {
|
|
333
370
|
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);
|
|
334
371
|
}
|
|
@@ -337,18 +374,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
337
374
|
type: "problem",
|
|
338
375
|
docs: {
|
|
339
376
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
340
|
-
[Symbol.for("rule_features")]:
|
|
377
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
341
378
|
},
|
|
342
379
|
messages: {
|
|
343
380
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
344
381
|
},
|
|
345
382
|
schema: []
|
|
346
383
|
},
|
|
347
|
-
name:
|
|
348
|
-
create:
|
|
384
|
+
name: RULE_NAME7,
|
|
385
|
+
create: create7,
|
|
349
386
|
defaultOptions: []
|
|
350
387
|
});
|
|
351
|
-
function
|
|
388
|
+
function create7(context) {
|
|
352
389
|
if (!context.sourceCode.text.includes("setState")) {
|
|
353
390
|
return {};
|
|
354
391
|
}
|
|
@@ -439,8 +476,8 @@ function create6(context) {
|
|
|
439
476
|
}
|
|
440
477
|
};
|
|
441
478
|
}
|
|
442
|
-
var
|
|
443
|
-
var
|
|
479
|
+
var RULE_NAME8 = "no-array-index-key";
|
|
480
|
+
var RULE_FEATURES8 = [];
|
|
444
481
|
var reactChildrenMethod = ["forEach", "map"];
|
|
445
482
|
function isReactChildrenMethod(name5) {
|
|
446
483
|
return reactChildrenMethod.some((method) => method === name5);
|
|
@@ -510,18 +547,18 @@ var no_array_index_key_default = createRule({
|
|
|
510
547
|
type: "problem",
|
|
511
548
|
docs: {
|
|
512
549
|
description: "Disallow an item's index in the array as its key.",
|
|
513
|
-
[Symbol.for("rule_features")]:
|
|
550
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
514
551
|
},
|
|
515
552
|
messages: {
|
|
516
553
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
517
554
|
},
|
|
518
555
|
schema: []
|
|
519
556
|
},
|
|
520
|
-
name:
|
|
521
|
-
create:
|
|
557
|
+
name: RULE_NAME8,
|
|
558
|
+
create: create8,
|
|
522
559
|
defaultOptions: []
|
|
523
560
|
});
|
|
524
|
-
function
|
|
561
|
+
function create8(context) {
|
|
525
562
|
const report = kit.createReport(context);
|
|
526
563
|
const indexParamNames = [];
|
|
527
564
|
function isArrayIndex(node) {
|
|
@@ -619,25 +656,25 @@ function create7(context) {
|
|
|
619
656
|
}
|
|
620
657
|
};
|
|
621
658
|
}
|
|
622
|
-
var
|
|
623
|
-
var
|
|
659
|
+
var RULE_NAME9 = "no-children-count";
|
|
660
|
+
var RULE_FEATURES9 = [];
|
|
624
661
|
var no_children_count_default = createRule({
|
|
625
662
|
meta: {
|
|
626
663
|
type: "problem",
|
|
627
664
|
docs: {
|
|
628
665
|
description: "Disallow `Children.count`.",
|
|
629
|
-
[Symbol.for("rule_features")]:
|
|
666
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
630
667
|
},
|
|
631
668
|
messages: {
|
|
632
669
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
633
670
|
},
|
|
634
671
|
schema: []
|
|
635
672
|
},
|
|
636
|
-
name:
|
|
637
|
-
create:
|
|
673
|
+
name: RULE_NAME9,
|
|
674
|
+
create: create9,
|
|
638
675
|
defaultOptions: []
|
|
639
676
|
});
|
|
640
|
-
function
|
|
677
|
+
function create9(context) {
|
|
641
678
|
return {
|
|
642
679
|
MemberExpression(node) {
|
|
643
680
|
if (ER21__namespace.isChildrenCount(context, node)) {
|
|
@@ -649,25 +686,25 @@ function create8(context) {
|
|
|
649
686
|
}
|
|
650
687
|
};
|
|
651
688
|
}
|
|
652
|
-
var
|
|
653
|
-
var
|
|
689
|
+
var RULE_NAME10 = "no-children-for-each";
|
|
690
|
+
var RULE_FEATURES10 = [];
|
|
654
691
|
var no_children_for_each_default = createRule({
|
|
655
692
|
meta: {
|
|
656
693
|
type: "problem",
|
|
657
694
|
docs: {
|
|
658
695
|
description: "Disallow 'Children.forEach'.",
|
|
659
|
-
[Symbol.for("rule_features")]:
|
|
696
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
660
697
|
},
|
|
661
698
|
messages: {
|
|
662
699
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
663
700
|
},
|
|
664
701
|
schema: []
|
|
665
702
|
},
|
|
666
|
-
name:
|
|
667
|
-
create:
|
|
703
|
+
name: RULE_NAME10,
|
|
704
|
+
create: create10,
|
|
668
705
|
defaultOptions: []
|
|
669
706
|
});
|
|
670
|
-
function
|
|
707
|
+
function create10(context) {
|
|
671
708
|
return {
|
|
672
709
|
MemberExpression(node) {
|
|
673
710
|
if (ER21__namespace.isChildrenForEach(context, node)) {
|
|
@@ -679,25 +716,25 @@ function create9(context) {
|
|
|
679
716
|
}
|
|
680
717
|
};
|
|
681
718
|
}
|
|
682
|
-
var
|
|
683
|
-
var
|
|
719
|
+
var RULE_NAME11 = "no-children-map";
|
|
720
|
+
var RULE_FEATURES11 = [];
|
|
684
721
|
var no_children_map_default = createRule({
|
|
685
722
|
meta: {
|
|
686
723
|
type: "problem",
|
|
687
724
|
docs: {
|
|
688
725
|
description: "Disallow `Children.map`.",
|
|
689
|
-
[Symbol.for("rule_features")]:
|
|
726
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
690
727
|
},
|
|
691
728
|
messages: {
|
|
692
729
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
693
730
|
},
|
|
694
731
|
schema: []
|
|
695
732
|
},
|
|
696
|
-
name:
|
|
697
|
-
create:
|
|
733
|
+
name: RULE_NAME11,
|
|
734
|
+
create: create11,
|
|
698
735
|
defaultOptions: []
|
|
699
736
|
});
|
|
700
|
-
function
|
|
737
|
+
function create11(context) {
|
|
701
738
|
return {
|
|
702
739
|
MemberExpression(node) {
|
|
703
740
|
if (ER21__namespace.isChildrenMap(context, node)) {
|
|
@@ -709,25 +746,25 @@ function create10(context) {
|
|
|
709
746
|
}
|
|
710
747
|
};
|
|
711
748
|
}
|
|
712
|
-
var
|
|
713
|
-
var
|
|
749
|
+
var RULE_NAME12 = "no-children-only";
|
|
750
|
+
var RULE_FEATURES12 = [];
|
|
714
751
|
var no_children_only_default = createRule({
|
|
715
752
|
meta: {
|
|
716
753
|
type: "problem",
|
|
717
754
|
docs: {
|
|
718
755
|
description: "Disallow `Children.only`.",
|
|
719
|
-
[Symbol.for("rule_features")]:
|
|
756
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
720
757
|
},
|
|
721
758
|
messages: {
|
|
722
759
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
723
760
|
},
|
|
724
761
|
schema: []
|
|
725
762
|
},
|
|
726
|
-
name:
|
|
727
|
-
create:
|
|
763
|
+
name: RULE_NAME12,
|
|
764
|
+
create: create12,
|
|
728
765
|
defaultOptions: []
|
|
729
766
|
});
|
|
730
|
-
function
|
|
767
|
+
function create12(context) {
|
|
731
768
|
return {
|
|
732
769
|
MemberExpression(node) {
|
|
733
770
|
if (ER21__namespace.isChildrenOnly(context, node)) {
|
|
@@ -739,25 +776,25 @@ function create11(context) {
|
|
|
739
776
|
}
|
|
740
777
|
};
|
|
741
778
|
}
|
|
742
|
-
var
|
|
743
|
-
var
|
|
779
|
+
var RULE_NAME13 = "no-children-prop";
|
|
780
|
+
var RULE_FEATURES13 = [];
|
|
744
781
|
var no_children_prop_default = createRule({
|
|
745
782
|
meta: {
|
|
746
783
|
type: "problem",
|
|
747
784
|
docs: {
|
|
748
785
|
description: "Disallow passing `children` as a prop.",
|
|
749
|
-
[Symbol.for("rule_features")]:
|
|
786
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
750
787
|
},
|
|
751
788
|
messages: {
|
|
752
789
|
noChildrenProp: "Do not pass 'children' as props."
|
|
753
790
|
},
|
|
754
791
|
schema: []
|
|
755
792
|
},
|
|
756
|
-
name:
|
|
757
|
-
create:
|
|
793
|
+
name: RULE_NAME13,
|
|
794
|
+
create: create13,
|
|
758
795
|
defaultOptions: []
|
|
759
796
|
});
|
|
760
|
-
function
|
|
797
|
+
function create13(context) {
|
|
761
798
|
return {
|
|
762
799
|
JSXElement(node) {
|
|
763
800
|
const attribute = JSX8__namespace.getAttribute(
|
|
@@ -774,25 +811,25 @@ function create12(context) {
|
|
|
774
811
|
}
|
|
775
812
|
};
|
|
776
813
|
}
|
|
777
|
-
var
|
|
778
|
-
var
|
|
814
|
+
var RULE_NAME14 = "no-children-to-array";
|
|
815
|
+
var RULE_FEATURES14 = [];
|
|
779
816
|
var no_children_to_array_default = createRule({
|
|
780
817
|
meta: {
|
|
781
818
|
type: "problem",
|
|
782
819
|
docs: {
|
|
783
820
|
description: "Disallow `Children.toArray`.",
|
|
784
|
-
[Symbol.for("rule_features")]:
|
|
821
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
785
822
|
},
|
|
786
823
|
messages: {
|
|
787
824
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
788
825
|
},
|
|
789
826
|
schema: []
|
|
790
827
|
},
|
|
791
|
-
name:
|
|
792
|
-
create:
|
|
828
|
+
name: RULE_NAME14,
|
|
829
|
+
create: create14,
|
|
793
830
|
defaultOptions: []
|
|
794
831
|
});
|
|
795
|
-
function
|
|
832
|
+
function create14(context) {
|
|
796
833
|
return {
|
|
797
834
|
MemberExpression(node) {
|
|
798
835
|
if (ER21__namespace.isChildrenToArray(context, node)) {
|
|
@@ -804,25 +841,25 @@ function create13(context) {
|
|
|
804
841
|
}
|
|
805
842
|
};
|
|
806
843
|
}
|
|
807
|
-
var
|
|
808
|
-
var
|
|
844
|
+
var RULE_NAME15 = "no-class-component";
|
|
845
|
+
var RULE_FEATURES15 = [];
|
|
809
846
|
var no_class_component_default = createRule({
|
|
810
847
|
meta: {
|
|
811
848
|
type: "problem",
|
|
812
849
|
docs: {
|
|
813
850
|
description: "Disallow class components.",
|
|
814
|
-
[Symbol.for("rule_features")]:
|
|
851
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
815
852
|
},
|
|
816
853
|
messages: {
|
|
817
854
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
818
855
|
},
|
|
819
856
|
schema: []
|
|
820
857
|
},
|
|
821
|
-
name:
|
|
822
|
-
create:
|
|
858
|
+
name: RULE_NAME15,
|
|
859
|
+
create: create15,
|
|
823
860
|
defaultOptions: []
|
|
824
861
|
});
|
|
825
|
-
function
|
|
862
|
+
function create15(context) {
|
|
826
863
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
827
864
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
828
865
|
return {
|
|
@@ -844,25 +881,25 @@ function create14(context) {
|
|
|
844
881
|
}
|
|
845
882
|
};
|
|
846
883
|
}
|
|
847
|
-
var
|
|
848
|
-
var
|
|
884
|
+
var RULE_NAME16 = "no-clone-element";
|
|
885
|
+
var RULE_FEATURES16 = [];
|
|
849
886
|
var no_clone_element_default = createRule({
|
|
850
887
|
meta: {
|
|
851
888
|
type: "problem",
|
|
852
889
|
docs: {
|
|
853
890
|
description: "Disallow `cloneElement`.",
|
|
854
|
-
[Symbol.for("rule_features")]:
|
|
891
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
855
892
|
},
|
|
856
893
|
messages: {
|
|
857
894
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
858
895
|
},
|
|
859
896
|
schema: []
|
|
860
897
|
},
|
|
861
|
-
name:
|
|
862
|
-
create:
|
|
898
|
+
name: RULE_NAME16,
|
|
899
|
+
create: create16,
|
|
863
900
|
defaultOptions: []
|
|
864
901
|
});
|
|
865
|
-
function
|
|
902
|
+
function create16(context) {
|
|
866
903
|
return {
|
|
867
904
|
CallExpression(node) {
|
|
868
905
|
if (!ER21__namespace.isCloneElementCall(context, node)) {
|
|
@@ -875,25 +912,25 @@ function create15(context) {
|
|
|
875
912
|
}
|
|
876
913
|
};
|
|
877
914
|
}
|
|
878
|
-
var
|
|
879
|
-
var
|
|
915
|
+
var RULE_NAME17 = "no-comment-textnodes";
|
|
916
|
+
var RULE_FEATURES17 = [];
|
|
880
917
|
var no_comment_textnodes_default = createRule({
|
|
881
918
|
meta: {
|
|
882
919
|
type: "problem",
|
|
883
920
|
docs: {
|
|
884
921
|
description: "Prevents comments from being inserted as text nodes.",
|
|
885
|
-
[Symbol.for("rule_features")]:
|
|
922
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
886
923
|
},
|
|
887
924
|
messages: {
|
|
888
925
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
889
926
|
},
|
|
890
927
|
schema: []
|
|
891
928
|
},
|
|
892
|
-
name:
|
|
893
|
-
create:
|
|
929
|
+
name: RULE_NAME17,
|
|
930
|
+
create: create17,
|
|
894
931
|
defaultOptions: []
|
|
895
932
|
});
|
|
896
|
-
function
|
|
933
|
+
function create17(context) {
|
|
897
934
|
function hasCommentLike(node) {
|
|
898
935
|
if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
899
936
|
return false;
|
|
@@ -921,8 +958,8 @@ function create16(context) {
|
|
|
921
958
|
Literal: visitorFunction
|
|
922
959
|
};
|
|
923
960
|
}
|
|
924
|
-
var
|
|
925
|
-
var
|
|
961
|
+
var RULE_NAME18 = "no-complex-conditional-rendering";
|
|
962
|
+
var RULE_FEATURES18 = [
|
|
926
963
|
"EXP"
|
|
927
964
|
];
|
|
928
965
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -930,18 +967,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
930
967
|
type: "problem",
|
|
931
968
|
docs: {
|
|
932
969
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
933
|
-
[Symbol.for("rule_features")]:
|
|
970
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
934
971
|
},
|
|
935
972
|
messages: {
|
|
936
973
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
937
974
|
},
|
|
938
975
|
schema: []
|
|
939
976
|
},
|
|
940
|
-
name:
|
|
941
|
-
create:
|
|
977
|
+
name: RULE_NAME18,
|
|
978
|
+
create: create18,
|
|
942
979
|
defaultOptions: []
|
|
943
980
|
});
|
|
944
|
-
function
|
|
981
|
+
function create18(context) {
|
|
945
982
|
const visitorFunction = (node) => {
|
|
946
983
|
const jsxExpContainer = node.parent?.parent;
|
|
947
984
|
if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -966,8 +1003,8 @@ function create17(context) {
|
|
|
966
1003
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
967
1004
|
};
|
|
968
1005
|
}
|
|
969
|
-
var
|
|
970
|
-
var
|
|
1006
|
+
var RULE_NAME19 = "no-component-will-mount";
|
|
1007
|
+
var RULE_FEATURES19 = [
|
|
971
1008
|
"MOD"
|
|
972
1009
|
];
|
|
973
1010
|
function isComponentWillMount(node) {
|
|
@@ -978,7 +1015,7 @@ var no_component_will_mount_default = createRule({
|
|
|
978
1015
|
type: "problem",
|
|
979
1016
|
docs: {
|
|
980
1017
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
981
|
-
[Symbol.for("rule_features")]:
|
|
1018
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
982
1019
|
},
|
|
983
1020
|
fixable: "code",
|
|
984
1021
|
messages: {
|
|
@@ -986,11 +1023,11 @@ var no_component_will_mount_default = createRule({
|
|
|
986
1023
|
},
|
|
987
1024
|
schema: []
|
|
988
1025
|
},
|
|
989
|
-
name:
|
|
990
|
-
create:
|
|
1026
|
+
name: RULE_NAME19,
|
|
1027
|
+
create: create19,
|
|
991
1028
|
defaultOptions: []
|
|
992
1029
|
});
|
|
993
|
-
function
|
|
1030
|
+
function create19(context) {
|
|
994
1031
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
995
1032
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
996
1033
|
return {
|
|
@@ -1017,8 +1054,8 @@ function create18(context) {
|
|
|
1017
1054
|
}
|
|
1018
1055
|
};
|
|
1019
1056
|
}
|
|
1020
|
-
var
|
|
1021
|
-
var
|
|
1057
|
+
var RULE_NAME20 = "no-component-will-receive-props";
|
|
1058
|
+
var RULE_FEATURES20 = [
|
|
1022
1059
|
"MOD"
|
|
1023
1060
|
];
|
|
1024
1061
|
function isComponentWillUpdate(node) {
|
|
@@ -1029,7 +1066,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1029
1066
|
type: "problem",
|
|
1030
1067
|
docs: {
|
|
1031
1068
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
1032
|
-
[Symbol.for("rule_features")]:
|
|
1069
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1033
1070
|
},
|
|
1034
1071
|
fixable: "code",
|
|
1035
1072
|
messages: {
|
|
@@ -1037,11 +1074,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1037
1074
|
},
|
|
1038
1075
|
schema: []
|
|
1039
1076
|
},
|
|
1040
|
-
name:
|
|
1041
|
-
create:
|
|
1077
|
+
name: RULE_NAME20,
|
|
1078
|
+
create: create20,
|
|
1042
1079
|
defaultOptions: []
|
|
1043
1080
|
});
|
|
1044
|
-
function
|
|
1081
|
+
function create20(context) {
|
|
1045
1082
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1046
1083
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
1047
1084
|
return {
|
|
@@ -1068,8 +1105,8 @@ function create19(context) {
|
|
|
1068
1105
|
}
|
|
1069
1106
|
};
|
|
1070
1107
|
}
|
|
1071
|
-
var
|
|
1072
|
-
var
|
|
1108
|
+
var RULE_NAME21 = "no-component-will-update";
|
|
1109
|
+
var RULE_FEATURES21 = [
|
|
1073
1110
|
"MOD"
|
|
1074
1111
|
];
|
|
1075
1112
|
function isComponentWillUpdate2(node) {
|
|
@@ -1080,7 +1117,7 @@ var no_component_will_update_default = createRule({
|
|
|
1080
1117
|
type: "problem",
|
|
1081
1118
|
docs: {
|
|
1082
1119
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
1083
|
-
[Symbol.for("rule_features")]:
|
|
1120
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1084
1121
|
},
|
|
1085
1122
|
fixable: "code",
|
|
1086
1123
|
messages: {
|
|
@@ -1088,11 +1125,11 @@ var no_component_will_update_default = createRule({
|
|
|
1088
1125
|
},
|
|
1089
1126
|
schema: []
|
|
1090
1127
|
},
|
|
1091
|
-
name:
|
|
1092
|
-
create:
|
|
1128
|
+
name: RULE_NAME21,
|
|
1129
|
+
create: create21,
|
|
1093
1130
|
defaultOptions: []
|
|
1094
1131
|
});
|
|
1095
|
-
function
|
|
1132
|
+
function create21(context) {
|
|
1096
1133
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1097
1134
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
1098
1135
|
return {
|
|
@@ -1119,8 +1156,8 @@ function create20(context) {
|
|
|
1119
1156
|
}
|
|
1120
1157
|
};
|
|
1121
1158
|
}
|
|
1122
|
-
var
|
|
1123
|
-
var
|
|
1159
|
+
var RULE_NAME22 = "no-context-provider";
|
|
1160
|
+
var RULE_FEATURES22 = [
|
|
1124
1161
|
"MOD"
|
|
1125
1162
|
];
|
|
1126
1163
|
var no_context_provider_default = createRule({
|
|
@@ -1128,7 +1165,7 @@ var no_context_provider_default = createRule({
|
|
|
1128
1165
|
type: "problem",
|
|
1129
1166
|
docs: {
|
|
1130
1167
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1131
|
-
[Symbol.for("rule_features")]:
|
|
1168
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1132
1169
|
},
|
|
1133
1170
|
fixable: "code",
|
|
1134
1171
|
messages: {
|
|
@@ -1136,11 +1173,11 @@ var no_context_provider_default = createRule({
|
|
|
1136
1173
|
},
|
|
1137
1174
|
schema: []
|
|
1138
1175
|
},
|
|
1139
|
-
name:
|
|
1140
|
-
create:
|
|
1176
|
+
name: RULE_NAME22,
|
|
1177
|
+
create: create22,
|
|
1141
1178
|
defaultOptions: []
|
|
1142
1179
|
});
|
|
1143
|
-
function
|
|
1180
|
+
function create22(context) {
|
|
1144
1181
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1145
1182
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1146
1183
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1172,25 +1209,25 @@ function create21(context) {
|
|
|
1172
1209
|
}
|
|
1173
1210
|
};
|
|
1174
1211
|
}
|
|
1175
|
-
var
|
|
1176
|
-
var
|
|
1212
|
+
var RULE_NAME23 = "no-create-ref";
|
|
1213
|
+
var RULE_FEATURES23 = [];
|
|
1177
1214
|
var no_create_ref_default = createRule({
|
|
1178
1215
|
meta: {
|
|
1179
1216
|
type: "problem",
|
|
1180
1217
|
docs: {
|
|
1181
1218
|
description: "Disallow `createRef` in function components.",
|
|
1182
|
-
[Symbol.for("rule_features")]:
|
|
1219
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1183
1220
|
},
|
|
1184
1221
|
messages: {
|
|
1185
1222
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1186
1223
|
},
|
|
1187
1224
|
schema: []
|
|
1188
1225
|
},
|
|
1189
|
-
name:
|
|
1190
|
-
create:
|
|
1226
|
+
name: RULE_NAME23,
|
|
1227
|
+
create: create23,
|
|
1191
1228
|
defaultOptions: []
|
|
1192
1229
|
});
|
|
1193
|
-
function
|
|
1230
|
+
function create23(context) {
|
|
1194
1231
|
return {
|
|
1195
1232
|
CallExpression(node) {
|
|
1196
1233
|
if (ER21__namespace.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, ER21__namespace.isClassComponent) == null) {
|
|
@@ -1199,25 +1236,25 @@ function create22(context) {
|
|
|
1199
1236
|
}
|
|
1200
1237
|
};
|
|
1201
1238
|
}
|
|
1202
|
-
var
|
|
1203
|
-
var
|
|
1239
|
+
var RULE_NAME24 = "no-default-props";
|
|
1240
|
+
var RULE_FEATURES24 = [];
|
|
1204
1241
|
var no_default_props_default = createRule({
|
|
1205
1242
|
meta: {
|
|
1206
1243
|
type: "problem",
|
|
1207
1244
|
docs: {
|
|
1208
1245
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1209
|
-
[Symbol.for("rule_features")]:
|
|
1246
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1210
1247
|
},
|
|
1211
1248
|
messages: {
|
|
1212
1249
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1213
1250
|
},
|
|
1214
1251
|
schema: []
|
|
1215
1252
|
},
|
|
1216
|
-
name:
|
|
1217
|
-
create:
|
|
1253
|
+
name: RULE_NAME24,
|
|
1254
|
+
create: create24,
|
|
1218
1255
|
defaultOptions: []
|
|
1219
1256
|
});
|
|
1220
|
-
function
|
|
1257
|
+
function create24(context) {
|
|
1221
1258
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1222
1259
|
return {
|
|
1223
1260
|
AssignmentExpression(node) {
|
|
@@ -1251,8 +1288,8 @@ function create23(context) {
|
|
|
1251
1288
|
}
|
|
1252
1289
|
};
|
|
1253
1290
|
}
|
|
1254
|
-
var
|
|
1255
|
-
var
|
|
1291
|
+
var RULE_NAME25 = "no-direct-mutation-state";
|
|
1292
|
+
var RULE_FEATURES25 = [];
|
|
1256
1293
|
function isConstructorFunction(node) {
|
|
1257
1294
|
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";
|
|
1258
1295
|
}
|
|
@@ -1261,18 +1298,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1261
1298
|
type: "problem",
|
|
1262
1299
|
docs: {
|
|
1263
1300
|
description: "Disallow direct mutation of `this.state`.",
|
|
1264
|
-
[Symbol.for("rule_features")]:
|
|
1301
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1265
1302
|
},
|
|
1266
1303
|
messages: {
|
|
1267
1304
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1268
1305
|
},
|
|
1269
1306
|
schema: []
|
|
1270
1307
|
},
|
|
1271
|
-
name:
|
|
1272
|
-
create:
|
|
1308
|
+
name: RULE_NAME25,
|
|
1309
|
+
create: create25,
|
|
1273
1310
|
defaultOptions: []
|
|
1274
1311
|
});
|
|
1275
|
-
function
|
|
1312
|
+
function create25(context) {
|
|
1276
1313
|
return {
|
|
1277
1314
|
AssignmentExpression(node) {
|
|
1278
1315
|
if (!ER21__namespace.isAssignmentToThisState(node)) return;
|
|
@@ -1293,25 +1330,25 @@ function create24(context) {
|
|
|
1293
1330
|
}
|
|
1294
1331
|
};
|
|
1295
1332
|
}
|
|
1296
|
-
var
|
|
1297
|
-
var
|
|
1333
|
+
var RULE_NAME26 = "no-duplicate-key";
|
|
1334
|
+
var RULE_FEATURES26 = [];
|
|
1298
1335
|
var no_duplicate_key_default = createRule({
|
|
1299
1336
|
meta: {
|
|
1300
1337
|
type: "problem",
|
|
1301
1338
|
docs: {
|
|
1302
1339
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1303
|
-
[Symbol.for("rule_features")]:
|
|
1340
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1304
1341
|
},
|
|
1305
1342
|
messages: {
|
|
1306
1343
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1307
1344
|
},
|
|
1308
1345
|
schema: []
|
|
1309
1346
|
},
|
|
1310
|
-
name:
|
|
1311
|
-
create:
|
|
1347
|
+
name: RULE_NAME26,
|
|
1348
|
+
create: create26,
|
|
1312
1349
|
defaultOptions: []
|
|
1313
1350
|
});
|
|
1314
|
-
function
|
|
1351
|
+
function create26(context) {
|
|
1315
1352
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1316
1353
|
return {};
|
|
1317
1354
|
}
|
|
@@ -1375,8 +1412,8 @@ function create25(context) {
|
|
|
1375
1412
|
}
|
|
1376
1413
|
};
|
|
1377
1414
|
}
|
|
1378
|
-
var
|
|
1379
|
-
var
|
|
1415
|
+
var RULE_NAME27 = "no-forward-ref";
|
|
1416
|
+
var RULE_FEATURES27 = [
|
|
1380
1417
|
"MOD"
|
|
1381
1418
|
];
|
|
1382
1419
|
var no_forward_ref_default = createRule({
|
|
@@ -1384,7 +1421,7 @@ var no_forward_ref_default = createRule({
|
|
|
1384
1421
|
type: "problem",
|
|
1385
1422
|
docs: {
|
|
1386
1423
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1387
|
-
[Symbol.for("rule_features")]:
|
|
1424
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1388
1425
|
},
|
|
1389
1426
|
fixable: "code",
|
|
1390
1427
|
messages: {
|
|
@@ -1392,11 +1429,11 @@ var no_forward_ref_default = createRule({
|
|
|
1392
1429
|
},
|
|
1393
1430
|
schema: []
|
|
1394
1431
|
},
|
|
1395
|
-
name:
|
|
1396
|
-
create:
|
|
1432
|
+
name: RULE_NAME27,
|
|
1433
|
+
create: create27,
|
|
1397
1434
|
defaultOptions: []
|
|
1398
1435
|
});
|
|
1399
|
-
function
|
|
1436
|
+
function create27(context) {
|
|
1400
1437
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1401
1438
|
return {};
|
|
1402
1439
|
}
|
|
@@ -1484,8 +1521,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1484
1521
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1485
1522
|
];
|
|
1486
1523
|
}
|
|
1487
|
-
var
|
|
1488
|
-
var
|
|
1524
|
+
var RULE_NAME28 = "no-implicit-key";
|
|
1525
|
+
var RULE_FEATURES28 = [
|
|
1489
1526
|
"EXP"
|
|
1490
1527
|
];
|
|
1491
1528
|
var no_implicit_key_default = createRule({
|
|
@@ -1493,18 +1530,18 @@ var no_implicit_key_default = createRule({
|
|
|
1493
1530
|
type: "problem",
|
|
1494
1531
|
docs: {
|
|
1495
1532
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1496
|
-
[Symbol.for("rule_features")]:
|
|
1533
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1497
1534
|
},
|
|
1498
1535
|
messages: {
|
|
1499
1536
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1500
1537
|
},
|
|
1501
1538
|
schema: []
|
|
1502
1539
|
},
|
|
1503
|
-
name:
|
|
1504
|
-
create:
|
|
1540
|
+
name: RULE_NAME28,
|
|
1541
|
+
create: create28,
|
|
1505
1542
|
defaultOptions: []
|
|
1506
1543
|
});
|
|
1507
|
-
function
|
|
1544
|
+
function create28(context) {
|
|
1508
1545
|
return {
|
|
1509
1546
|
JSXOpeningElement(node) {
|
|
1510
1547
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1518,8 +1555,8 @@ function create27(context) {
|
|
|
1518
1555
|
}
|
|
1519
1556
|
};
|
|
1520
1557
|
}
|
|
1521
|
-
var
|
|
1522
|
-
var
|
|
1558
|
+
var RULE_NAME29 = "no-leaked-conditional-rendering";
|
|
1559
|
+
var RULE_FEATURES29 = [
|
|
1523
1560
|
"TSC"
|
|
1524
1561
|
];
|
|
1525
1562
|
var tsHelpers = {
|
|
@@ -1605,18 +1642,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1605
1642
|
type: "problem",
|
|
1606
1643
|
docs: {
|
|
1607
1644
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1608
|
-
[Symbol.for("rule_features")]:
|
|
1645
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1609
1646
|
},
|
|
1610
1647
|
messages: {
|
|
1611
1648
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1612
1649
|
},
|
|
1613
1650
|
schema: []
|
|
1614
1651
|
},
|
|
1615
|
-
name:
|
|
1616
|
-
create:
|
|
1652
|
+
name: RULE_NAME29,
|
|
1653
|
+
create: create29,
|
|
1617
1654
|
defaultOptions: []
|
|
1618
1655
|
});
|
|
1619
|
-
function
|
|
1656
|
+
function create29(context) {
|
|
1620
1657
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1621
1658
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1622
1659
|
const allowedVariants = [
|
|
@@ -1673,25 +1710,25 @@ function create28(context) {
|
|
|
1673
1710
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1674
1711
|
};
|
|
1675
1712
|
}
|
|
1676
|
-
var
|
|
1677
|
-
var
|
|
1713
|
+
var RULE_NAME30 = "no-missing-component-display-name";
|
|
1714
|
+
var RULE_FEATURES30 = [];
|
|
1678
1715
|
var no_missing_component_display_name_default = createRule({
|
|
1679
1716
|
meta: {
|
|
1680
1717
|
type: "problem",
|
|
1681
1718
|
docs: {
|
|
1682
1719
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1683
|
-
[Symbol.for("rule_features")]:
|
|
1720
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1684
1721
|
},
|
|
1685
1722
|
messages: {
|
|
1686
1723
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1687
1724
|
},
|
|
1688
1725
|
schema: []
|
|
1689
1726
|
},
|
|
1690
|
-
name:
|
|
1691
|
-
create:
|
|
1727
|
+
name: RULE_NAME30,
|
|
1728
|
+
create: create30,
|
|
1692
1729
|
defaultOptions: []
|
|
1693
1730
|
});
|
|
1694
|
-
function
|
|
1731
|
+
function create30(context) {
|
|
1695
1732
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1696
1733
|
const {
|
|
1697
1734
|
ctx,
|
|
@@ -1726,25 +1763,25 @@ function create29(context) {
|
|
|
1726
1763
|
}
|
|
1727
1764
|
};
|
|
1728
1765
|
}
|
|
1729
|
-
var
|
|
1730
|
-
var
|
|
1766
|
+
var RULE_NAME31 = "no-missing-context-display-name";
|
|
1767
|
+
var RULE_FEATURES31 = [];
|
|
1731
1768
|
var no_missing_context_display_name_default = createRule({
|
|
1732
1769
|
meta: {
|
|
1733
1770
|
type: "problem",
|
|
1734
1771
|
docs: {
|
|
1735
1772
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1736
|
-
[Symbol.for("rule_features")]:
|
|
1773
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1737
1774
|
},
|
|
1738
1775
|
messages: {
|
|
1739
1776
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1740
1777
|
},
|
|
1741
1778
|
schema: []
|
|
1742
1779
|
},
|
|
1743
|
-
name:
|
|
1744
|
-
create:
|
|
1780
|
+
name: RULE_NAME31,
|
|
1781
|
+
create: create31,
|
|
1745
1782
|
defaultOptions: []
|
|
1746
1783
|
});
|
|
1747
|
-
function
|
|
1784
|
+
function create31(context) {
|
|
1748
1785
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1749
1786
|
const createCalls = [];
|
|
1750
1787
|
const displayNameAssignments = [];
|
|
@@ -1782,14 +1819,14 @@ function create30(context) {
|
|
|
1782
1819
|
}
|
|
1783
1820
|
};
|
|
1784
1821
|
}
|
|
1785
|
-
var
|
|
1786
|
-
var
|
|
1822
|
+
var RULE_NAME32 = "no-missing-key";
|
|
1823
|
+
var RULE_FEATURES32 = [];
|
|
1787
1824
|
var no_missing_key_default = createRule({
|
|
1788
1825
|
meta: {
|
|
1789
1826
|
type: "problem",
|
|
1790
1827
|
docs: {
|
|
1791
1828
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1792
|
-
[Symbol.for("rule_features")]:
|
|
1829
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1793
1830
|
},
|
|
1794
1831
|
messages: {
|
|
1795
1832
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1797,11 +1834,11 @@ var no_missing_key_default = createRule({
|
|
|
1797
1834
|
},
|
|
1798
1835
|
schema: []
|
|
1799
1836
|
},
|
|
1800
|
-
name:
|
|
1801
|
-
create:
|
|
1837
|
+
name: RULE_NAME32,
|
|
1838
|
+
create: create32,
|
|
1802
1839
|
defaultOptions: []
|
|
1803
1840
|
});
|
|
1804
|
-
function
|
|
1841
|
+
function create32(context) {
|
|
1805
1842
|
const report = kit.createReport(context);
|
|
1806
1843
|
const state = { isWithinChildrenToArray: false };
|
|
1807
1844
|
function checkIteratorElement(node) {
|
|
@@ -1914,25 +1951,25 @@ function create31(context) {
|
|
|
1914
1951
|
function isArrayFromCall(node) {
|
|
1915
1952
|
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";
|
|
1916
1953
|
}
|
|
1917
|
-
var
|
|
1918
|
-
var
|
|
1954
|
+
var RULE_NAME33 = "no-nested-component-definitions";
|
|
1955
|
+
var RULE_FEATURES33 = [];
|
|
1919
1956
|
var no_nested_component_definitions_default = createRule({
|
|
1920
1957
|
meta: {
|
|
1921
1958
|
type: "problem",
|
|
1922
1959
|
docs: {
|
|
1923
1960
|
description: "Disallow nesting component definitions inside other components.",
|
|
1924
|
-
[Symbol.for("rule_features")]:
|
|
1961
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1925
1962
|
},
|
|
1926
1963
|
messages: {
|
|
1927
1964
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1928
1965
|
},
|
|
1929
1966
|
schema: []
|
|
1930
1967
|
},
|
|
1931
|
-
name:
|
|
1932
|
-
create:
|
|
1968
|
+
name: RULE_NAME33,
|
|
1969
|
+
create: create33,
|
|
1933
1970
|
defaultOptions: []
|
|
1934
1971
|
});
|
|
1935
|
-
function
|
|
1972
|
+
function create33(context) {
|
|
1936
1973
|
const hint = ER21__namespace.ComponentCollectorHint.SkipArrayMapArgument | ER21__namespace.ComponentCollectorHint.SkipNullLiteral | ER21__namespace.ComponentCollectorHint.SkipUndefined | ER21__namespace.ComponentCollectorHint.SkipBooleanLiteral | ER21__namespace.ComponentCollectorHint.SkipStringLiteral | ER21__namespace.ComponentCollectorHint.SkipNumberLiteral | ER21__namespace.ComponentCollectorHint.StrictLogical | ER21__namespace.ComponentCollectorHint.StrictConditional;
|
|
1937
1974
|
const collector = ER21__namespace.useComponentCollector(context, { hint });
|
|
1938
1975
|
const collectorLegacy = ER21__namespace.useComponentCollectorLegacy();
|
|
@@ -2028,25 +2065,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
2028
2065
|
if (prop == null) return false;
|
|
2029
2066
|
return prop === call.arguments[1];
|
|
2030
2067
|
}
|
|
2031
|
-
var
|
|
2032
|
-
var
|
|
2068
|
+
var RULE_NAME34 = "no-prop-types";
|
|
2069
|
+
var RULE_FEATURES34 = [];
|
|
2033
2070
|
var no_prop_types_default = createRule({
|
|
2034
2071
|
meta: {
|
|
2035
2072
|
type: "problem",
|
|
2036
2073
|
docs: {
|
|
2037
2074
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
2038
|
-
[Symbol.for("rule_features")]:
|
|
2075
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2039
2076
|
},
|
|
2040
2077
|
messages: {
|
|
2041
2078
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
2042
2079
|
},
|
|
2043
2080
|
schema: []
|
|
2044
2081
|
},
|
|
2045
|
-
name:
|
|
2046
|
-
create:
|
|
2082
|
+
name: RULE_NAME34,
|
|
2083
|
+
create: create34,
|
|
2047
2084
|
defaultOptions: []
|
|
2048
2085
|
});
|
|
2049
|
-
function
|
|
2086
|
+
function create34(context) {
|
|
2050
2087
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
2051
2088
|
return {};
|
|
2052
2089
|
}
|
|
@@ -2082,8 +2119,8 @@ function create33(context) {
|
|
|
2082
2119
|
}
|
|
2083
2120
|
};
|
|
2084
2121
|
}
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2122
|
+
var RULE_NAME35 = "no-redundant-should-component-update";
|
|
2123
|
+
var RULE_FEATURES35 = [];
|
|
2087
2124
|
function isShouldComponentUpdate(node) {
|
|
2088
2125
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2089
2126
|
}
|
|
@@ -2092,18 +2129,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2092
2129
|
type: "problem",
|
|
2093
2130
|
docs: {
|
|
2094
2131
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2095
|
-
[Symbol.for("rule_features")]:
|
|
2132
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2096
2133
|
},
|
|
2097
2134
|
messages: {
|
|
2098
2135
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2099
2136
|
},
|
|
2100
2137
|
schema: []
|
|
2101
2138
|
},
|
|
2102
|
-
name:
|
|
2103
|
-
create:
|
|
2139
|
+
name: RULE_NAME35,
|
|
2140
|
+
create: create35,
|
|
2104
2141
|
defaultOptions: []
|
|
2105
2142
|
});
|
|
2106
|
-
function
|
|
2143
|
+
function create35(context) {
|
|
2107
2144
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2108
2145
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2109
2146
|
return {
|
|
@@ -2130,8 +2167,8 @@ function create34(context) {
|
|
|
2130
2167
|
}
|
|
2131
2168
|
};
|
|
2132
2169
|
}
|
|
2133
|
-
var
|
|
2134
|
-
var
|
|
2170
|
+
var RULE_NAME36 = "no-set-state-in-component-did-mount";
|
|
2171
|
+
var RULE_FEATURES36 = [];
|
|
2135
2172
|
function isComponentDidMount(node) {
|
|
2136
2173
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2137
2174
|
}
|
|
@@ -2140,18 +2177,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2140
2177
|
type: "problem",
|
|
2141
2178
|
docs: {
|
|
2142
2179
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2143
|
-
[Symbol.for("rule_features")]:
|
|
2180
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2144
2181
|
},
|
|
2145
2182
|
messages: {
|
|
2146
2183
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2147
2184
|
},
|
|
2148
2185
|
schema: []
|
|
2149
2186
|
},
|
|
2150
|
-
name:
|
|
2151
|
-
create:
|
|
2187
|
+
name: RULE_NAME36,
|
|
2188
|
+
create: create36,
|
|
2152
2189
|
defaultOptions: []
|
|
2153
2190
|
});
|
|
2154
|
-
function
|
|
2191
|
+
function create36(context) {
|
|
2155
2192
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2156
2193
|
return {
|
|
2157
2194
|
CallExpression(node) {
|
|
@@ -2172,8 +2209,8 @@ function create35(context) {
|
|
|
2172
2209
|
}
|
|
2173
2210
|
};
|
|
2174
2211
|
}
|
|
2175
|
-
var
|
|
2176
|
-
var
|
|
2212
|
+
var RULE_NAME37 = "no-set-state-in-component-did-update";
|
|
2213
|
+
var RULE_FEATURES37 = [];
|
|
2177
2214
|
function isComponentDidUpdate(node) {
|
|
2178
2215
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2179
2216
|
}
|
|
@@ -2182,18 +2219,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2182
2219
|
type: "problem",
|
|
2183
2220
|
docs: {
|
|
2184
2221
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2185
|
-
[Symbol.for("rule_features")]:
|
|
2222
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2186
2223
|
},
|
|
2187
2224
|
messages: {
|
|
2188
2225
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2189
2226
|
},
|
|
2190
2227
|
schema: []
|
|
2191
2228
|
},
|
|
2192
|
-
name:
|
|
2193
|
-
create:
|
|
2229
|
+
name: RULE_NAME37,
|
|
2230
|
+
create: create37,
|
|
2194
2231
|
defaultOptions: []
|
|
2195
2232
|
});
|
|
2196
|
-
function
|
|
2233
|
+
function create37(context) {
|
|
2197
2234
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2198
2235
|
return {
|
|
2199
2236
|
CallExpression(node) {
|
|
@@ -2214,8 +2251,8 @@ function create36(context) {
|
|
|
2214
2251
|
}
|
|
2215
2252
|
};
|
|
2216
2253
|
}
|
|
2217
|
-
var
|
|
2218
|
-
var
|
|
2254
|
+
var RULE_NAME38 = "no-set-state-in-component-will-update";
|
|
2255
|
+
var RULE_FEATURES38 = [];
|
|
2219
2256
|
function isComponentWillUpdate3(node) {
|
|
2220
2257
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2221
2258
|
}
|
|
@@ -2224,18 +2261,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2224
2261
|
type: "problem",
|
|
2225
2262
|
docs: {
|
|
2226
2263
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2227
|
-
[Symbol.for("rule_features")]:
|
|
2264
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2228
2265
|
},
|
|
2229
2266
|
messages: {
|
|
2230
2267
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2231
2268
|
},
|
|
2232
2269
|
schema: []
|
|
2233
2270
|
},
|
|
2234
|
-
name:
|
|
2235
|
-
create:
|
|
2271
|
+
name: RULE_NAME38,
|
|
2272
|
+
create: create38,
|
|
2236
2273
|
defaultOptions: []
|
|
2237
2274
|
});
|
|
2238
|
-
function
|
|
2275
|
+
function create38(context) {
|
|
2239
2276
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2240
2277
|
return {
|
|
2241
2278
|
CallExpression(node) {
|
|
@@ -2256,8 +2293,8 @@ function create37(context) {
|
|
|
2256
2293
|
}
|
|
2257
2294
|
};
|
|
2258
2295
|
}
|
|
2259
|
-
var
|
|
2260
|
-
var
|
|
2296
|
+
var RULE_NAME39 = "no-string-refs";
|
|
2297
|
+
var RULE_FEATURES39 = [];
|
|
2261
2298
|
function containsStringLiteral({ value }) {
|
|
2262
2299
|
return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2263
2300
|
}
|
|
@@ -2275,18 +2312,18 @@ var no_string_refs_default = createRule({
|
|
|
2275
2312
|
type: "problem",
|
|
2276
2313
|
docs: {
|
|
2277
2314
|
description: "Disallow deprecated string `refs`.",
|
|
2278
|
-
[Symbol.for("rule_features")]:
|
|
2315
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2279
2316
|
},
|
|
2280
2317
|
messages: {
|
|
2281
2318
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2282
2319
|
},
|
|
2283
2320
|
schema: []
|
|
2284
2321
|
},
|
|
2285
|
-
name:
|
|
2286
|
-
create:
|
|
2322
|
+
name: RULE_NAME39,
|
|
2323
|
+
create: create39,
|
|
2287
2324
|
defaultOptions: []
|
|
2288
2325
|
});
|
|
2289
|
-
function
|
|
2326
|
+
function create39(context) {
|
|
2290
2327
|
return {
|
|
2291
2328
|
JSXAttribute(node) {
|
|
2292
2329
|
if (node.name.name !== "ref") {
|
|
@@ -2301,8 +2338,8 @@ function create38(context) {
|
|
|
2301
2338
|
}
|
|
2302
2339
|
};
|
|
2303
2340
|
}
|
|
2304
|
-
var
|
|
2305
|
-
var
|
|
2341
|
+
var RULE_NAME40 = "no-unsafe-component-will-mount";
|
|
2342
|
+
var RULE_FEATURES40 = [];
|
|
2306
2343
|
function isUnsafeComponentWillMount(node) {
|
|
2307
2344
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2308
2345
|
}
|
|
@@ -2311,18 +2348,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2311
2348
|
type: "problem",
|
|
2312
2349
|
docs: {
|
|
2313
2350
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2314
|
-
[Symbol.for("rule_features")]:
|
|
2351
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2315
2352
|
},
|
|
2316
2353
|
messages: {
|
|
2317
2354
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2318
2355
|
},
|
|
2319
2356
|
schema: []
|
|
2320
2357
|
},
|
|
2321
|
-
name:
|
|
2322
|
-
create:
|
|
2358
|
+
name: RULE_NAME40,
|
|
2359
|
+
create: create40,
|
|
2323
2360
|
defaultOptions: []
|
|
2324
2361
|
});
|
|
2325
|
-
function
|
|
2362
|
+
function create40(context) {
|
|
2326
2363
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2327
2364
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2328
2365
|
return {
|
|
@@ -2343,8 +2380,8 @@ function create39(context) {
|
|
|
2343
2380
|
}
|
|
2344
2381
|
};
|
|
2345
2382
|
}
|
|
2346
|
-
var
|
|
2347
|
-
var
|
|
2383
|
+
var RULE_NAME41 = "no-unsafe-component-will-receive-props";
|
|
2384
|
+
var RULE_FEATURES41 = [];
|
|
2348
2385
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2349
2386
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2350
2387
|
}
|
|
@@ -2353,18 +2390,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2353
2390
|
type: "problem",
|
|
2354
2391
|
docs: {
|
|
2355
2392
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2356
|
-
[Symbol.for("rule_features")]:
|
|
2393
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2357
2394
|
},
|
|
2358
2395
|
messages: {
|
|
2359
2396
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2360
2397
|
},
|
|
2361
2398
|
schema: []
|
|
2362
2399
|
},
|
|
2363
|
-
name:
|
|
2364
|
-
create:
|
|
2400
|
+
name: RULE_NAME41,
|
|
2401
|
+
create: create41,
|
|
2365
2402
|
defaultOptions: []
|
|
2366
2403
|
});
|
|
2367
|
-
function
|
|
2404
|
+
function create41(context) {
|
|
2368
2405
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2369
2406
|
return {};
|
|
2370
2407
|
}
|
|
@@ -2387,8 +2424,8 @@ function create40(context) {
|
|
|
2387
2424
|
}
|
|
2388
2425
|
};
|
|
2389
2426
|
}
|
|
2390
|
-
var
|
|
2391
|
-
var
|
|
2427
|
+
var RULE_NAME42 = "no-unsafe-component-will-update";
|
|
2428
|
+
var RULE_FEATURES42 = [];
|
|
2392
2429
|
function isUnsafeComponentWillUpdate(node) {
|
|
2393
2430
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2394
2431
|
}
|
|
@@ -2397,18 +2434,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2397
2434
|
type: "problem",
|
|
2398
2435
|
docs: {
|
|
2399
2436
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2400
|
-
[Symbol.for("rule_features")]:
|
|
2437
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2401
2438
|
},
|
|
2402
2439
|
messages: {
|
|
2403
2440
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2404
2441
|
},
|
|
2405
2442
|
schema: []
|
|
2406
2443
|
},
|
|
2407
|
-
name:
|
|
2408
|
-
create:
|
|
2444
|
+
name: RULE_NAME42,
|
|
2445
|
+
create: create42,
|
|
2409
2446
|
defaultOptions: []
|
|
2410
2447
|
});
|
|
2411
|
-
function
|
|
2448
|
+
function create42(context) {
|
|
2412
2449
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2413
2450
|
const { ctx, listeners } = ER21__namespace.useComponentCollectorLegacy();
|
|
2414
2451
|
return {
|
|
@@ -2429,25 +2466,25 @@ function create41(context) {
|
|
|
2429
2466
|
}
|
|
2430
2467
|
};
|
|
2431
2468
|
}
|
|
2432
|
-
var
|
|
2433
|
-
var
|
|
2469
|
+
var RULE_NAME43 = "no-unstable-context-value";
|
|
2470
|
+
var RULE_FEATURES43 = [];
|
|
2434
2471
|
var no_unstable_context_value_default = createRule({
|
|
2435
2472
|
meta: {
|
|
2436
2473
|
type: "problem",
|
|
2437
2474
|
docs: {
|
|
2438
2475
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2439
|
-
[Symbol.for("rule_features")]:
|
|
2476
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2440
2477
|
},
|
|
2441
2478
|
messages: {
|
|
2442
2479
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2443
2480
|
},
|
|
2444
2481
|
schema: []
|
|
2445
2482
|
},
|
|
2446
|
-
name:
|
|
2447
|
-
create:
|
|
2483
|
+
name: RULE_NAME43,
|
|
2484
|
+
create: create43,
|
|
2448
2485
|
defaultOptions: []
|
|
2449
2486
|
});
|
|
2450
|
-
function
|
|
2487
|
+
function create43(context) {
|
|
2451
2488
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2452
2489
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2453
2490
|
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
@@ -2502,25 +2539,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2502
2539
|
}
|
|
2503
2540
|
return false;
|
|
2504
2541
|
}
|
|
2505
|
-
var
|
|
2506
|
-
var
|
|
2542
|
+
var RULE_NAME44 = "no-unstable-default-props";
|
|
2543
|
+
var RULE_FEATURES44 = [];
|
|
2507
2544
|
var no_unstable_default_props_default = createRule({
|
|
2508
2545
|
meta: {
|
|
2509
2546
|
type: "problem",
|
|
2510
2547
|
docs: {
|
|
2511
2548
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2512
|
-
[Symbol.for("rule_features")]:
|
|
2549
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2513
2550
|
},
|
|
2514
2551
|
messages: {
|
|
2515
2552
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2516
2553
|
},
|
|
2517
2554
|
schema: []
|
|
2518
2555
|
},
|
|
2519
|
-
name:
|
|
2520
|
-
create:
|
|
2556
|
+
name: RULE_NAME44,
|
|
2557
|
+
create: create44,
|
|
2521
2558
|
defaultOptions: []
|
|
2522
2559
|
});
|
|
2523
|
-
function
|
|
2560
|
+
function create44(context) {
|
|
2524
2561
|
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
2525
2562
|
const declarators = /* @__PURE__ */ new Map();
|
|
2526
2563
|
return {
|
|
@@ -2576,8 +2613,8 @@ function create43(context) {
|
|
|
2576
2613
|
}
|
|
2577
2614
|
};
|
|
2578
2615
|
}
|
|
2579
|
-
var
|
|
2580
|
-
var
|
|
2616
|
+
var RULE_NAME45 = "no-unused-class-component-members";
|
|
2617
|
+
var RULE_FEATURES45 = [];
|
|
2581
2618
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2582
2619
|
"componentDidCatch",
|
|
2583
2620
|
"componentDidMount",
|
|
@@ -2603,18 +2640,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2603
2640
|
type: "problem",
|
|
2604
2641
|
docs: {
|
|
2605
2642
|
description: "Warns unused class component methods and properties.",
|
|
2606
|
-
[Symbol.for("rule_features")]:
|
|
2643
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2607
2644
|
},
|
|
2608
2645
|
messages: {
|
|
2609
2646
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2610
2647
|
},
|
|
2611
2648
|
schema: []
|
|
2612
2649
|
},
|
|
2613
|
-
name:
|
|
2614
|
-
create:
|
|
2650
|
+
name: RULE_NAME45,
|
|
2651
|
+
create: create45,
|
|
2615
2652
|
defaultOptions: []
|
|
2616
2653
|
});
|
|
2617
|
-
function
|
|
2654
|
+
function create45(context) {
|
|
2618
2655
|
const classEntries = [];
|
|
2619
2656
|
const methodEntries = [];
|
|
2620
2657
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2724,8 +2761,8 @@ function create44(context) {
|
|
|
2724
2761
|
}
|
|
2725
2762
|
};
|
|
2726
2763
|
}
|
|
2727
|
-
var
|
|
2728
|
-
var
|
|
2764
|
+
var RULE_NAME46 = "no-unused-state";
|
|
2765
|
+
var RULE_FEATURES46 = [];
|
|
2729
2766
|
function isKeyLiteral3(node, key) {
|
|
2730
2767
|
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);
|
|
2731
2768
|
}
|
|
@@ -2734,18 +2771,18 @@ var no_unused_state_default = createRule({
|
|
|
2734
2771
|
type: "problem",
|
|
2735
2772
|
docs: {
|
|
2736
2773
|
description: "Warns unused class component state.",
|
|
2737
|
-
[Symbol.for("rule_features")]:
|
|
2774
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2738
2775
|
},
|
|
2739
2776
|
messages: {
|
|
2740
2777
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2741
2778
|
},
|
|
2742
2779
|
schema: []
|
|
2743
2780
|
},
|
|
2744
|
-
name:
|
|
2745
|
-
create:
|
|
2781
|
+
name: RULE_NAME46,
|
|
2782
|
+
create: create46,
|
|
2746
2783
|
defaultOptions: []
|
|
2747
2784
|
});
|
|
2748
|
-
function
|
|
2785
|
+
function create46(context) {
|
|
2749
2786
|
const classEntries = [];
|
|
2750
2787
|
const methodEntries = [];
|
|
2751
2788
|
const constructorEntries = [];
|
|
@@ -2879,8 +2916,8 @@ function create45(context) {
|
|
|
2879
2916
|
}
|
|
2880
2917
|
};
|
|
2881
2918
|
}
|
|
2882
|
-
var
|
|
2883
|
-
var
|
|
2919
|
+
var RULE_NAME47 = "no-use-context";
|
|
2920
|
+
var RULE_FEATURES47 = [
|
|
2884
2921
|
"MOD"
|
|
2885
2922
|
];
|
|
2886
2923
|
var no_use_context_default = createRule({
|
|
@@ -2888,7 +2925,7 @@ var no_use_context_default = createRule({
|
|
|
2888
2925
|
type: "problem",
|
|
2889
2926
|
docs: {
|
|
2890
2927
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2891
|
-
[Symbol.for("rule_features")]:
|
|
2928
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2892
2929
|
},
|
|
2893
2930
|
fixable: "code",
|
|
2894
2931
|
messages: {
|
|
@@ -2896,11 +2933,11 @@ var no_use_context_default = createRule({
|
|
|
2896
2933
|
},
|
|
2897
2934
|
schema: []
|
|
2898
2935
|
},
|
|
2899
|
-
name:
|
|
2900
|
-
create:
|
|
2936
|
+
name: RULE_NAME47,
|
|
2937
|
+
create: create47,
|
|
2901
2938
|
defaultOptions: []
|
|
2902
2939
|
});
|
|
2903
|
-
function
|
|
2940
|
+
function create47(context) {
|
|
2904
2941
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2905
2942
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2906
2943
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2978,25 +3015,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2978
3015
|
return tokens;
|
|
2979
3016
|
}
|
|
2980
3017
|
}
|
|
2981
|
-
var
|
|
2982
|
-
var
|
|
3018
|
+
var RULE_NAME48 = "no-useless-forward-ref";
|
|
3019
|
+
var RULE_FEATURES48 = [];
|
|
2983
3020
|
var no_useless_forward_ref_default = createRule({
|
|
2984
3021
|
meta: {
|
|
2985
3022
|
type: "problem",
|
|
2986
3023
|
docs: {
|
|
2987
3024
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2988
|
-
[Symbol.for("rule_features")]:
|
|
3025
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
2989
3026
|
},
|
|
2990
3027
|
messages: {
|
|
2991
3028
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2992
3029
|
},
|
|
2993
3030
|
schema: []
|
|
2994
3031
|
},
|
|
2995
|
-
name:
|
|
2996
|
-
create:
|
|
3032
|
+
name: RULE_NAME48,
|
|
3033
|
+
create: create48,
|
|
2997
3034
|
defaultOptions: []
|
|
2998
3035
|
});
|
|
2999
|
-
function
|
|
3036
|
+
function create48(context) {
|
|
3000
3037
|
return {
|
|
3001
3038
|
CallExpression(node) {
|
|
3002
3039
|
if (!ER21__namespace.isForwardRefCall(context, node)) {
|
|
@@ -3017,7 +3054,7 @@ function create47(context) {
|
|
|
3017
3054
|
}
|
|
3018
3055
|
};
|
|
3019
3056
|
}
|
|
3020
|
-
var
|
|
3057
|
+
var RULE_NAME49 = "no-useless-fragment";
|
|
3021
3058
|
var defaultOptions = [{
|
|
3022
3059
|
allowExpressions: true
|
|
3023
3060
|
}];
|
|
@@ -3043,11 +3080,11 @@ var no_useless_fragment_default = createRule({
|
|
|
3043
3080
|
}
|
|
3044
3081
|
}]
|
|
3045
3082
|
},
|
|
3046
|
-
name:
|
|
3047
|
-
create:
|
|
3083
|
+
name: RULE_NAME49,
|
|
3084
|
+
create: create49,
|
|
3048
3085
|
defaultOptions
|
|
3049
3086
|
});
|
|
3050
|
-
function
|
|
3087
|
+
function create49(context, [option]) {
|
|
3051
3088
|
const { allowExpressions = true } = option;
|
|
3052
3089
|
return {
|
|
3053
3090
|
JSXElement(node) {
|
|
@@ -3159,8 +3196,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3159
3196
|
}
|
|
3160
3197
|
return;
|
|
3161
3198
|
}
|
|
3162
|
-
var
|
|
3163
|
-
var
|
|
3199
|
+
var RULE_NAME50 = "prefer-destructuring-assignment";
|
|
3200
|
+
var RULE_FEATURES49 = [];
|
|
3164
3201
|
function isMemberExpressionWithObjectName(node) {
|
|
3165
3202
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3166
3203
|
}
|
|
@@ -3169,18 +3206,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3169
3206
|
type: "problem",
|
|
3170
3207
|
docs: {
|
|
3171
3208
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3172
|
-
[Symbol.for("rule_features")]:
|
|
3209
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3173
3210
|
},
|
|
3174
3211
|
messages: {
|
|
3175
3212
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3176
3213
|
},
|
|
3177
3214
|
schema: []
|
|
3178
3215
|
},
|
|
3179
|
-
name:
|
|
3180
|
-
create:
|
|
3216
|
+
name: RULE_NAME50,
|
|
3217
|
+
create: create50,
|
|
3181
3218
|
defaultOptions: []
|
|
3182
3219
|
});
|
|
3183
|
-
function
|
|
3220
|
+
function create50(context) {
|
|
3184
3221
|
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
3185
3222
|
const memberExpressionWithNames = [];
|
|
3186
3223
|
return {
|
|
@@ -3240,8 +3277,8 @@ function create49(context) {
|
|
|
3240
3277
|
}
|
|
3241
3278
|
};
|
|
3242
3279
|
}
|
|
3243
|
-
var
|
|
3244
|
-
var
|
|
3280
|
+
var RULE_NAME51 = "prefer-react-namespace-import";
|
|
3281
|
+
var RULE_FEATURES50 = [
|
|
3245
3282
|
"FIX"
|
|
3246
3283
|
];
|
|
3247
3284
|
var prefer_react_namespace_import_default = createRule({
|
|
@@ -3249,7 +3286,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3249
3286
|
type: "problem",
|
|
3250
3287
|
docs: {
|
|
3251
3288
|
description: "Enforces React is imported via a namespace import.",
|
|
3252
|
-
[Symbol.for("rule_features")]:
|
|
3289
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3253
3290
|
},
|
|
3254
3291
|
fixable: "code",
|
|
3255
3292
|
messages: {
|
|
@@ -3257,11 +3294,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3257
3294
|
},
|
|
3258
3295
|
schema: []
|
|
3259
3296
|
},
|
|
3260
|
-
name:
|
|
3261
|
-
create:
|
|
3297
|
+
name: RULE_NAME51,
|
|
3298
|
+
create: create51,
|
|
3262
3299
|
defaultOptions: []
|
|
3263
3300
|
});
|
|
3264
|
-
function
|
|
3301
|
+
function create51(context) {
|
|
3265
3302
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3266
3303
|
return {
|
|
3267
3304
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3294,8 +3331,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3294
3331
|
}
|
|
3295
3332
|
};
|
|
3296
3333
|
}
|
|
3297
|
-
var
|
|
3298
|
-
var
|
|
3334
|
+
var RULE_NAME52 = "prefer-read-only-props";
|
|
3335
|
+
var RULE_FEATURES51 = [
|
|
3299
3336
|
"TSC",
|
|
3300
3337
|
"EXP"
|
|
3301
3338
|
];
|
|
@@ -3304,18 +3341,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3304
3341
|
type: "problem",
|
|
3305
3342
|
docs: {
|
|
3306
3343
|
description: "Enforces read-only props in components.",
|
|
3307
|
-
[Symbol.for("rule_features")]:
|
|
3344
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3308
3345
|
},
|
|
3309
3346
|
messages: {
|
|
3310
3347
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3311
3348
|
},
|
|
3312
3349
|
schema: []
|
|
3313
3350
|
},
|
|
3314
|
-
name:
|
|
3315
|
-
create:
|
|
3351
|
+
name: RULE_NAME52,
|
|
3352
|
+
create: create52,
|
|
3316
3353
|
defaultOptions: []
|
|
3317
3354
|
});
|
|
3318
|
-
function
|
|
3355
|
+
function create52(context) {
|
|
3319
3356
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3320
3357
|
const { ctx, listeners } = ER21__namespace.useComponentCollector(context);
|
|
3321
3358
|
return {
|
|
@@ -3345,8 +3382,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3345
3382
|
return true;
|
|
3346
3383
|
}
|
|
3347
3384
|
}
|
|
3348
|
-
var
|
|
3349
|
-
var
|
|
3385
|
+
var RULE_NAME53 = "prefer-shorthand-boolean";
|
|
3386
|
+
var RULE_FEATURES52 = [
|
|
3350
3387
|
"FIX"
|
|
3351
3388
|
];
|
|
3352
3389
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3354,7 +3391,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3354
3391
|
type: "problem",
|
|
3355
3392
|
docs: {
|
|
3356
3393
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3357
|
-
[Symbol.for("rule_features")]:
|
|
3394
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3358
3395
|
},
|
|
3359
3396
|
fixable: "code",
|
|
3360
3397
|
messages: {
|
|
@@ -3362,11 +3399,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3362
3399
|
},
|
|
3363
3400
|
schema: []
|
|
3364
3401
|
},
|
|
3365
|
-
name:
|
|
3366
|
-
create:
|
|
3402
|
+
name: RULE_NAME53,
|
|
3403
|
+
create: create53,
|
|
3367
3404
|
defaultOptions: []
|
|
3368
3405
|
});
|
|
3369
|
-
function
|
|
3406
|
+
function create53(context) {
|
|
3370
3407
|
return {
|
|
3371
3408
|
JSXAttribute(node) {
|
|
3372
3409
|
const { value } = node;
|
|
@@ -3386,8 +3423,8 @@ function create52(context) {
|
|
|
3386
3423
|
}
|
|
3387
3424
|
};
|
|
3388
3425
|
}
|
|
3389
|
-
var
|
|
3390
|
-
var
|
|
3426
|
+
var RULE_NAME54 = "prefer-shorthand-fragment";
|
|
3427
|
+
var RULE_FEATURES53 = [
|
|
3391
3428
|
"FIX"
|
|
3392
3429
|
];
|
|
3393
3430
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3395,7 +3432,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3395
3432
|
type: "problem",
|
|
3396
3433
|
docs: {
|
|
3397
3434
|
description: "Enforces shorthand syntax for fragments.",
|
|
3398
|
-
[Symbol.for("rule_features")]:
|
|
3435
|
+
[Symbol.for("rule_features")]: RULE_FEATURES53
|
|
3399
3436
|
},
|
|
3400
3437
|
fixable: "code",
|
|
3401
3438
|
messages: {
|
|
@@ -3403,11 +3440,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3403
3440
|
},
|
|
3404
3441
|
schema: []
|
|
3405
3442
|
},
|
|
3406
|
-
name:
|
|
3407
|
-
create:
|
|
3443
|
+
name: RULE_NAME54,
|
|
3444
|
+
create: create54,
|
|
3408
3445
|
defaultOptions: []
|
|
3409
3446
|
});
|
|
3410
|
-
function
|
|
3447
|
+
function create54(context) {
|
|
3411
3448
|
return {
|
|
3412
3449
|
JSXElement(node) {
|
|
3413
3450
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
@@ -3493,6 +3530,7 @@ var plugin = {
|
|
|
3493
3530
|
// Part: JSX only rules
|
|
3494
3531
|
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3495
3532
|
"jsx-no-undef": jsx_no_undef_default,
|
|
3533
|
+
"jsx-uses-react": jsx_uses_react_default,
|
|
3496
3534
|
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3497
3535
|
// Part: deprecated rules
|
|
3498
3536
|
/** @deprecated Use `no-useless-forward-ref` instead */
|