eslint-plugin-react-x 1.40.0-beta.2 → 1.40.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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.mjs
CHANGED
|
@@ -5,13 +5,13 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
|
5
5
|
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
6
6
|
import * as VAR2 from '@eslint-react/var';
|
|
7
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
8
|
+
import { JsxRuntime, createReport } from '@eslint-react/kit';
|
|
9
|
+
import ts, { JsxEmit } from 'typescript';
|
|
8
10
|
import * as AST11 from '@eslint-react/ast';
|
|
9
11
|
import * as ER21 from '@eslint-react/core';
|
|
10
|
-
import { createReport } from '@eslint-react/kit';
|
|
11
12
|
import { compare } from 'compare-versions';
|
|
12
13
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
13
14
|
import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
14
|
-
import ts from 'typescript';
|
|
15
15
|
import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
|
|
16
16
|
|
|
17
17
|
var __defProp = Object.defineProperty;
|
|
@@ -30,6 +30,7 @@ __export(recommended_exports, {
|
|
|
30
30
|
var name = "react-x/recommended";
|
|
31
31
|
var rules = {
|
|
32
32
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
33
|
+
"react-x/jsx-uses-react": "warn",
|
|
33
34
|
"react-x/jsx-uses-vars": "warn",
|
|
34
35
|
"react-x/no-access-state-in-setstate": "error",
|
|
35
36
|
"react-x/no-array-index-key": "warn",
|
|
@@ -92,6 +93,7 @@ var rules2 = {
|
|
|
92
93
|
...rules,
|
|
93
94
|
"react-x/jsx-no-duplicate-props": "off",
|
|
94
95
|
"react-x/jsx-no-undef": "off",
|
|
96
|
+
"react-x/jsx-uses-react": "off",
|
|
95
97
|
"react-x/jsx-uses-vars": "off"
|
|
96
98
|
};
|
|
97
99
|
var settings2 = {
|
|
@@ -111,7 +113,7 @@ var settings3 = {
|
|
|
111
113
|
|
|
112
114
|
// package.json
|
|
113
115
|
var name4 = "eslint-plugin-react-x";
|
|
114
|
-
var version = "1.40.0-beta.
|
|
116
|
+
var version = "1.40.0-beta.3";
|
|
115
117
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
116
118
|
|
|
117
119
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -259,17 +261,17 @@ function create4(context) {
|
|
|
259
261
|
}
|
|
260
262
|
};
|
|
261
263
|
}
|
|
262
|
-
var RULE_NAME5 = "jsx-uses-
|
|
264
|
+
var RULE_NAME5 = "jsx-uses-react";
|
|
263
265
|
var RULE_FEATURES5 = [];
|
|
264
|
-
var
|
|
266
|
+
var jsx_uses_react_default = createRule({
|
|
265
267
|
meta: {
|
|
266
268
|
type: "problem",
|
|
267
269
|
docs: {
|
|
268
|
-
description: "Marks variables used
|
|
270
|
+
description: "Marks React variables as used when JSX is used in the file.",
|
|
269
271
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
270
272
|
},
|
|
271
273
|
messages: {
|
|
272
|
-
|
|
274
|
+
jsxUsesReact: ""
|
|
273
275
|
},
|
|
274
276
|
schema: []
|
|
275
277
|
},
|
|
@@ -278,6 +280,41 @@ var jsx_uses_vars_default = createRule({
|
|
|
278
280
|
defaultOptions: []
|
|
279
281
|
});
|
|
280
282
|
function create5(context) {
|
|
283
|
+
const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = JsxRuntime.getJsxRuntimeOptionsFromContext(context);
|
|
284
|
+
if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev) return {};
|
|
285
|
+
return {
|
|
286
|
+
JSXFragment(node) {
|
|
287
|
+
context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
|
|
288
|
+
},
|
|
289
|
+
JSXOpeningElement(node) {
|
|
290
|
+
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
291
|
+
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
292
|
+
},
|
|
293
|
+
JSXOpeningFragment(node) {
|
|
294
|
+
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
295
|
+
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
var RULE_NAME6 = "jsx-uses-vars";
|
|
300
|
+
var RULE_FEATURES6 = [];
|
|
301
|
+
var jsx_uses_vars_default = createRule({
|
|
302
|
+
meta: {
|
|
303
|
+
type: "problem",
|
|
304
|
+
docs: {
|
|
305
|
+
description: "Marks variables used in JSX elements as used.",
|
|
306
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
307
|
+
},
|
|
308
|
+
messages: {
|
|
309
|
+
jsxUsesVars: ""
|
|
310
|
+
},
|
|
311
|
+
schema: []
|
|
312
|
+
},
|
|
313
|
+
name: RULE_NAME6,
|
|
314
|
+
create: create6,
|
|
315
|
+
defaultOptions: []
|
|
316
|
+
});
|
|
317
|
+
function create6(context) {
|
|
281
318
|
return {
|
|
282
319
|
JSXOpeningElement(node) {
|
|
283
320
|
switch (node.name.type) {
|
|
@@ -299,8 +336,8 @@ function create5(context) {
|
|
|
299
336
|
}
|
|
300
337
|
};
|
|
301
338
|
}
|
|
302
|
-
var
|
|
303
|
-
var
|
|
339
|
+
var RULE_NAME7 = "no-access-state-in-setstate";
|
|
340
|
+
var RULE_FEATURES7 = [];
|
|
304
341
|
function isKeyLiteral(node, key) {
|
|
305
342
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
306
343
|
}
|
|
@@ -309,18 +346,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
309
346
|
type: "problem",
|
|
310
347
|
docs: {
|
|
311
348
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
312
|
-
[Symbol.for("rule_features")]:
|
|
349
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
313
350
|
},
|
|
314
351
|
messages: {
|
|
315
352
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
316
353
|
},
|
|
317
354
|
schema: []
|
|
318
355
|
},
|
|
319
|
-
name:
|
|
320
|
-
create:
|
|
356
|
+
name: RULE_NAME7,
|
|
357
|
+
create: create7,
|
|
321
358
|
defaultOptions: []
|
|
322
359
|
});
|
|
323
|
-
function
|
|
360
|
+
function create7(context) {
|
|
324
361
|
if (!context.sourceCode.text.includes("setState")) {
|
|
325
362
|
return {};
|
|
326
363
|
}
|
|
@@ -411,8 +448,8 @@ function create6(context) {
|
|
|
411
448
|
}
|
|
412
449
|
};
|
|
413
450
|
}
|
|
414
|
-
var
|
|
415
|
-
var
|
|
451
|
+
var RULE_NAME8 = "no-array-index-key";
|
|
452
|
+
var RULE_FEATURES8 = [];
|
|
416
453
|
var reactChildrenMethod = ["forEach", "map"];
|
|
417
454
|
function isReactChildrenMethod(name5) {
|
|
418
455
|
return reactChildrenMethod.some((method) => method === name5);
|
|
@@ -482,18 +519,18 @@ var no_array_index_key_default = createRule({
|
|
|
482
519
|
type: "problem",
|
|
483
520
|
docs: {
|
|
484
521
|
description: "Disallow an item's index in the array as its key.",
|
|
485
|
-
[Symbol.for("rule_features")]:
|
|
522
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
486
523
|
},
|
|
487
524
|
messages: {
|
|
488
525
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
489
526
|
},
|
|
490
527
|
schema: []
|
|
491
528
|
},
|
|
492
|
-
name:
|
|
493
|
-
create:
|
|
529
|
+
name: RULE_NAME8,
|
|
530
|
+
create: create8,
|
|
494
531
|
defaultOptions: []
|
|
495
532
|
});
|
|
496
|
-
function
|
|
533
|
+
function create8(context) {
|
|
497
534
|
const report = createReport(context);
|
|
498
535
|
const indexParamNames = [];
|
|
499
536
|
function isArrayIndex(node) {
|
|
@@ -591,25 +628,25 @@ function create7(context) {
|
|
|
591
628
|
}
|
|
592
629
|
};
|
|
593
630
|
}
|
|
594
|
-
var
|
|
595
|
-
var
|
|
631
|
+
var RULE_NAME9 = "no-children-count";
|
|
632
|
+
var RULE_FEATURES9 = [];
|
|
596
633
|
var no_children_count_default = createRule({
|
|
597
634
|
meta: {
|
|
598
635
|
type: "problem",
|
|
599
636
|
docs: {
|
|
600
637
|
description: "Disallow `Children.count`.",
|
|
601
|
-
[Symbol.for("rule_features")]:
|
|
638
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
602
639
|
},
|
|
603
640
|
messages: {
|
|
604
641
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
605
642
|
},
|
|
606
643
|
schema: []
|
|
607
644
|
},
|
|
608
|
-
name:
|
|
609
|
-
create:
|
|
645
|
+
name: RULE_NAME9,
|
|
646
|
+
create: create9,
|
|
610
647
|
defaultOptions: []
|
|
611
648
|
});
|
|
612
|
-
function
|
|
649
|
+
function create9(context) {
|
|
613
650
|
return {
|
|
614
651
|
MemberExpression(node) {
|
|
615
652
|
if (ER21.isChildrenCount(context, node)) {
|
|
@@ -621,25 +658,25 @@ function create8(context) {
|
|
|
621
658
|
}
|
|
622
659
|
};
|
|
623
660
|
}
|
|
624
|
-
var
|
|
625
|
-
var
|
|
661
|
+
var RULE_NAME10 = "no-children-for-each";
|
|
662
|
+
var RULE_FEATURES10 = [];
|
|
626
663
|
var no_children_for_each_default = createRule({
|
|
627
664
|
meta: {
|
|
628
665
|
type: "problem",
|
|
629
666
|
docs: {
|
|
630
667
|
description: "Disallow 'Children.forEach'.",
|
|
631
|
-
[Symbol.for("rule_features")]:
|
|
668
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
632
669
|
},
|
|
633
670
|
messages: {
|
|
634
671
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
635
672
|
},
|
|
636
673
|
schema: []
|
|
637
674
|
},
|
|
638
|
-
name:
|
|
639
|
-
create:
|
|
675
|
+
name: RULE_NAME10,
|
|
676
|
+
create: create10,
|
|
640
677
|
defaultOptions: []
|
|
641
678
|
});
|
|
642
|
-
function
|
|
679
|
+
function create10(context) {
|
|
643
680
|
return {
|
|
644
681
|
MemberExpression(node) {
|
|
645
682
|
if (ER21.isChildrenForEach(context, node)) {
|
|
@@ -651,25 +688,25 @@ function create9(context) {
|
|
|
651
688
|
}
|
|
652
689
|
};
|
|
653
690
|
}
|
|
654
|
-
var
|
|
655
|
-
var
|
|
691
|
+
var RULE_NAME11 = "no-children-map";
|
|
692
|
+
var RULE_FEATURES11 = [];
|
|
656
693
|
var no_children_map_default = createRule({
|
|
657
694
|
meta: {
|
|
658
695
|
type: "problem",
|
|
659
696
|
docs: {
|
|
660
697
|
description: "Disallow `Children.map`.",
|
|
661
|
-
[Symbol.for("rule_features")]:
|
|
698
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
662
699
|
},
|
|
663
700
|
messages: {
|
|
664
701
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
665
702
|
},
|
|
666
703
|
schema: []
|
|
667
704
|
},
|
|
668
|
-
name:
|
|
669
|
-
create:
|
|
705
|
+
name: RULE_NAME11,
|
|
706
|
+
create: create11,
|
|
670
707
|
defaultOptions: []
|
|
671
708
|
});
|
|
672
|
-
function
|
|
709
|
+
function create11(context) {
|
|
673
710
|
return {
|
|
674
711
|
MemberExpression(node) {
|
|
675
712
|
if (ER21.isChildrenMap(context, node)) {
|
|
@@ -681,25 +718,25 @@ function create10(context) {
|
|
|
681
718
|
}
|
|
682
719
|
};
|
|
683
720
|
}
|
|
684
|
-
var
|
|
685
|
-
var
|
|
721
|
+
var RULE_NAME12 = "no-children-only";
|
|
722
|
+
var RULE_FEATURES12 = [];
|
|
686
723
|
var no_children_only_default = createRule({
|
|
687
724
|
meta: {
|
|
688
725
|
type: "problem",
|
|
689
726
|
docs: {
|
|
690
727
|
description: "Disallow `Children.only`.",
|
|
691
|
-
[Symbol.for("rule_features")]:
|
|
728
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
692
729
|
},
|
|
693
730
|
messages: {
|
|
694
731
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
695
732
|
},
|
|
696
733
|
schema: []
|
|
697
734
|
},
|
|
698
|
-
name:
|
|
699
|
-
create:
|
|
735
|
+
name: RULE_NAME12,
|
|
736
|
+
create: create12,
|
|
700
737
|
defaultOptions: []
|
|
701
738
|
});
|
|
702
|
-
function
|
|
739
|
+
function create12(context) {
|
|
703
740
|
return {
|
|
704
741
|
MemberExpression(node) {
|
|
705
742
|
if (ER21.isChildrenOnly(context, node)) {
|
|
@@ -711,25 +748,25 @@ function create11(context) {
|
|
|
711
748
|
}
|
|
712
749
|
};
|
|
713
750
|
}
|
|
714
|
-
var
|
|
715
|
-
var
|
|
751
|
+
var RULE_NAME13 = "no-children-prop";
|
|
752
|
+
var RULE_FEATURES13 = [];
|
|
716
753
|
var no_children_prop_default = createRule({
|
|
717
754
|
meta: {
|
|
718
755
|
type: "problem",
|
|
719
756
|
docs: {
|
|
720
757
|
description: "Disallow passing `children` as a prop.",
|
|
721
|
-
[Symbol.for("rule_features")]:
|
|
758
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
722
759
|
},
|
|
723
760
|
messages: {
|
|
724
761
|
noChildrenProp: "Do not pass 'children' as props."
|
|
725
762
|
},
|
|
726
763
|
schema: []
|
|
727
764
|
},
|
|
728
|
-
name:
|
|
729
|
-
create:
|
|
765
|
+
name: RULE_NAME13,
|
|
766
|
+
create: create13,
|
|
730
767
|
defaultOptions: []
|
|
731
768
|
});
|
|
732
|
-
function
|
|
769
|
+
function create13(context) {
|
|
733
770
|
return {
|
|
734
771
|
JSXElement(node) {
|
|
735
772
|
const attribute = JSX8.getAttribute(
|
|
@@ -746,25 +783,25 @@ function create12(context) {
|
|
|
746
783
|
}
|
|
747
784
|
};
|
|
748
785
|
}
|
|
749
|
-
var
|
|
750
|
-
var
|
|
786
|
+
var RULE_NAME14 = "no-children-to-array";
|
|
787
|
+
var RULE_FEATURES14 = [];
|
|
751
788
|
var no_children_to_array_default = createRule({
|
|
752
789
|
meta: {
|
|
753
790
|
type: "problem",
|
|
754
791
|
docs: {
|
|
755
792
|
description: "Disallow `Children.toArray`.",
|
|
756
|
-
[Symbol.for("rule_features")]:
|
|
793
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
757
794
|
},
|
|
758
795
|
messages: {
|
|
759
796
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
760
797
|
},
|
|
761
798
|
schema: []
|
|
762
799
|
},
|
|
763
|
-
name:
|
|
764
|
-
create:
|
|
800
|
+
name: RULE_NAME14,
|
|
801
|
+
create: create14,
|
|
765
802
|
defaultOptions: []
|
|
766
803
|
});
|
|
767
|
-
function
|
|
804
|
+
function create14(context) {
|
|
768
805
|
return {
|
|
769
806
|
MemberExpression(node) {
|
|
770
807
|
if (ER21.isChildrenToArray(context, node)) {
|
|
@@ -776,25 +813,25 @@ function create13(context) {
|
|
|
776
813
|
}
|
|
777
814
|
};
|
|
778
815
|
}
|
|
779
|
-
var
|
|
780
|
-
var
|
|
816
|
+
var RULE_NAME15 = "no-class-component";
|
|
817
|
+
var RULE_FEATURES15 = [];
|
|
781
818
|
var no_class_component_default = createRule({
|
|
782
819
|
meta: {
|
|
783
820
|
type: "problem",
|
|
784
821
|
docs: {
|
|
785
822
|
description: "Disallow class components.",
|
|
786
|
-
[Symbol.for("rule_features")]:
|
|
823
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
787
824
|
},
|
|
788
825
|
messages: {
|
|
789
826
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
790
827
|
},
|
|
791
828
|
schema: []
|
|
792
829
|
},
|
|
793
|
-
name:
|
|
794
|
-
create:
|
|
830
|
+
name: RULE_NAME15,
|
|
831
|
+
create: create15,
|
|
795
832
|
defaultOptions: []
|
|
796
833
|
});
|
|
797
|
-
function
|
|
834
|
+
function create15(context) {
|
|
798
835
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
799
836
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
800
837
|
return {
|
|
@@ -816,25 +853,25 @@ function create14(context) {
|
|
|
816
853
|
}
|
|
817
854
|
};
|
|
818
855
|
}
|
|
819
|
-
var
|
|
820
|
-
var
|
|
856
|
+
var RULE_NAME16 = "no-clone-element";
|
|
857
|
+
var RULE_FEATURES16 = [];
|
|
821
858
|
var no_clone_element_default = createRule({
|
|
822
859
|
meta: {
|
|
823
860
|
type: "problem",
|
|
824
861
|
docs: {
|
|
825
862
|
description: "Disallow `cloneElement`.",
|
|
826
|
-
[Symbol.for("rule_features")]:
|
|
863
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
827
864
|
},
|
|
828
865
|
messages: {
|
|
829
866
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
830
867
|
},
|
|
831
868
|
schema: []
|
|
832
869
|
},
|
|
833
|
-
name:
|
|
834
|
-
create:
|
|
870
|
+
name: RULE_NAME16,
|
|
871
|
+
create: create16,
|
|
835
872
|
defaultOptions: []
|
|
836
873
|
});
|
|
837
|
-
function
|
|
874
|
+
function create16(context) {
|
|
838
875
|
return {
|
|
839
876
|
CallExpression(node) {
|
|
840
877
|
if (!ER21.isCloneElementCall(context, node)) {
|
|
@@ -847,25 +884,25 @@ function create15(context) {
|
|
|
847
884
|
}
|
|
848
885
|
};
|
|
849
886
|
}
|
|
850
|
-
var
|
|
851
|
-
var
|
|
887
|
+
var RULE_NAME17 = "no-comment-textnodes";
|
|
888
|
+
var RULE_FEATURES17 = [];
|
|
852
889
|
var no_comment_textnodes_default = createRule({
|
|
853
890
|
meta: {
|
|
854
891
|
type: "problem",
|
|
855
892
|
docs: {
|
|
856
893
|
description: "Prevents comments from being inserted as text nodes.",
|
|
857
|
-
[Symbol.for("rule_features")]:
|
|
894
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
858
895
|
},
|
|
859
896
|
messages: {
|
|
860
897
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
861
898
|
},
|
|
862
899
|
schema: []
|
|
863
900
|
},
|
|
864
|
-
name:
|
|
865
|
-
create:
|
|
901
|
+
name: RULE_NAME17,
|
|
902
|
+
create: create17,
|
|
866
903
|
defaultOptions: []
|
|
867
904
|
});
|
|
868
|
-
function
|
|
905
|
+
function create17(context) {
|
|
869
906
|
function hasCommentLike(node) {
|
|
870
907
|
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
871
908
|
return false;
|
|
@@ -893,8 +930,8 @@ function create16(context) {
|
|
|
893
930
|
Literal: visitorFunction
|
|
894
931
|
};
|
|
895
932
|
}
|
|
896
|
-
var
|
|
897
|
-
var
|
|
933
|
+
var RULE_NAME18 = "no-complex-conditional-rendering";
|
|
934
|
+
var RULE_FEATURES18 = [
|
|
898
935
|
"EXP"
|
|
899
936
|
];
|
|
900
937
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -902,18 +939,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
902
939
|
type: "problem",
|
|
903
940
|
docs: {
|
|
904
941
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
905
|
-
[Symbol.for("rule_features")]:
|
|
942
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
906
943
|
},
|
|
907
944
|
messages: {
|
|
908
945
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
909
946
|
},
|
|
910
947
|
schema: []
|
|
911
948
|
},
|
|
912
|
-
name:
|
|
913
|
-
create:
|
|
949
|
+
name: RULE_NAME18,
|
|
950
|
+
create: create18,
|
|
914
951
|
defaultOptions: []
|
|
915
952
|
});
|
|
916
|
-
function
|
|
953
|
+
function create18(context) {
|
|
917
954
|
const visitorFunction = (node) => {
|
|
918
955
|
const jsxExpContainer = node.parent?.parent;
|
|
919
956
|
if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -938,8 +975,8 @@ function create17(context) {
|
|
|
938
975
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
939
976
|
};
|
|
940
977
|
}
|
|
941
|
-
var
|
|
942
|
-
var
|
|
978
|
+
var RULE_NAME19 = "no-component-will-mount";
|
|
979
|
+
var RULE_FEATURES19 = [
|
|
943
980
|
"MOD"
|
|
944
981
|
];
|
|
945
982
|
function isComponentWillMount(node) {
|
|
@@ -950,7 +987,7 @@ var no_component_will_mount_default = createRule({
|
|
|
950
987
|
type: "problem",
|
|
951
988
|
docs: {
|
|
952
989
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
953
|
-
[Symbol.for("rule_features")]:
|
|
990
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
954
991
|
},
|
|
955
992
|
fixable: "code",
|
|
956
993
|
messages: {
|
|
@@ -958,11 +995,11 @@ var no_component_will_mount_default = createRule({
|
|
|
958
995
|
},
|
|
959
996
|
schema: []
|
|
960
997
|
},
|
|
961
|
-
name:
|
|
962
|
-
create:
|
|
998
|
+
name: RULE_NAME19,
|
|
999
|
+
create: create19,
|
|
963
1000
|
defaultOptions: []
|
|
964
1001
|
});
|
|
965
|
-
function
|
|
1002
|
+
function create19(context) {
|
|
966
1003
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
967
1004
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
968
1005
|
return {
|
|
@@ -989,8 +1026,8 @@ function create18(context) {
|
|
|
989
1026
|
}
|
|
990
1027
|
};
|
|
991
1028
|
}
|
|
992
|
-
var
|
|
993
|
-
var
|
|
1029
|
+
var RULE_NAME20 = "no-component-will-receive-props";
|
|
1030
|
+
var RULE_FEATURES20 = [
|
|
994
1031
|
"MOD"
|
|
995
1032
|
];
|
|
996
1033
|
function isComponentWillUpdate(node) {
|
|
@@ -1001,7 +1038,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1001
1038
|
type: "problem",
|
|
1002
1039
|
docs: {
|
|
1003
1040
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
1004
|
-
[Symbol.for("rule_features")]:
|
|
1041
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1005
1042
|
},
|
|
1006
1043
|
fixable: "code",
|
|
1007
1044
|
messages: {
|
|
@@ -1009,11 +1046,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1009
1046
|
},
|
|
1010
1047
|
schema: []
|
|
1011
1048
|
},
|
|
1012
|
-
name:
|
|
1013
|
-
create:
|
|
1049
|
+
name: RULE_NAME20,
|
|
1050
|
+
create: create20,
|
|
1014
1051
|
defaultOptions: []
|
|
1015
1052
|
});
|
|
1016
|
-
function
|
|
1053
|
+
function create20(context) {
|
|
1017
1054
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1018
1055
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
1019
1056
|
return {
|
|
@@ -1040,8 +1077,8 @@ function create19(context) {
|
|
|
1040
1077
|
}
|
|
1041
1078
|
};
|
|
1042
1079
|
}
|
|
1043
|
-
var
|
|
1044
|
-
var
|
|
1080
|
+
var RULE_NAME21 = "no-component-will-update";
|
|
1081
|
+
var RULE_FEATURES21 = [
|
|
1045
1082
|
"MOD"
|
|
1046
1083
|
];
|
|
1047
1084
|
function isComponentWillUpdate2(node) {
|
|
@@ -1052,7 +1089,7 @@ var no_component_will_update_default = createRule({
|
|
|
1052
1089
|
type: "problem",
|
|
1053
1090
|
docs: {
|
|
1054
1091
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
1055
|
-
[Symbol.for("rule_features")]:
|
|
1092
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1056
1093
|
},
|
|
1057
1094
|
fixable: "code",
|
|
1058
1095
|
messages: {
|
|
@@ -1060,11 +1097,11 @@ var no_component_will_update_default = createRule({
|
|
|
1060
1097
|
},
|
|
1061
1098
|
schema: []
|
|
1062
1099
|
},
|
|
1063
|
-
name:
|
|
1064
|
-
create:
|
|
1100
|
+
name: RULE_NAME21,
|
|
1101
|
+
create: create21,
|
|
1065
1102
|
defaultOptions: []
|
|
1066
1103
|
});
|
|
1067
|
-
function
|
|
1104
|
+
function create21(context) {
|
|
1068
1105
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1069
1106
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
1070
1107
|
return {
|
|
@@ -1091,8 +1128,8 @@ function create20(context) {
|
|
|
1091
1128
|
}
|
|
1092
1129
|
};
|
|
1093
1130
|
}
|
|
1094
|
-
var
|
|
1095
|
-
var
|
|
1131
|
+
var RULE_NAME22 = "no-context-provider";
|
|
1132
|
+
var RULE_FEATURES22 = [
|
|
1096
1133
|
"MOD"
|
|
1097
1134
|
];
|
|
1098
1135
|
var no_context_provider_default = createRule({
|
|
@@ -1100,7 +1137,7 @@ var no_context_provider_default = createRule({
|
|
|
1100
1137
|
type: "problem",
|
|
1101
1138
|
docs: {
|
|
1102
1139
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1103
|
-
[Symbol.for("rule_features")]:
|
|
1140
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1104
1141
|
},
|
|
1105
1142
|
fixable: "code",
|
|
1106
1143
|
messages: {
|
|
@@ -1108,11 +1145,11 @@ var no_context_provider_default = createRule({
|
|
|
1108
1145
|
},
|
|
1109
1146
|
schema: []
|
|
1110
1147
|
},
|
|
1111
|
-
name:
|
|
1112
|
-
create:
|
|
1148
|
+
name: RULE_NAME22,
|
|
1149
|
+
create: create22,
|
|
1113
1150
|
defaultOptions: []
|
|
1114
1151
|
});
|
|
1115
|
-
function
|
|
1152
|
+
function create22(context) {
|
|
1116
1153
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1117
1154
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1118
1155
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1144,25 +1181,25 @@ function create21(context) {
|
|
|
1144
1181
|
}
|
|
1145
1182
|
};
|
|
1146
1183
|
}
|
|
1147
|
-
var
|
|
1148
|
-
var
|
|
1184
|
+
var RULE_NAME23 = "no-create-ref";
|
|
1185
|
+
var RULE_FEATURES23 = [];
|
|
1149
1186
|
var no_create_ref_default = createRule({
|
|
1150
1187
|
meta: {
|
|
1151
1188
|
type: "problem",
|
|
1152
1189
|
docs: {
|
|
1153
1190
|
description: "Disallow `createRef` in function components.",
|
|
1154
|
-
[Symbol.for("rule_features")]:
|
|
1191
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1155
1192
|
},
|
|
1156
1193
|
messages: {
|
|
1157
1194
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1158
1195
|
},
|
|
1159
1196
|
schema: []
|
|
1160
1197
|
},
|
|
1161
|
-
name:
|
|
1162
|
-
create:
|
|
1198
|
+
name: RULE_NAME23,
|
|
1199
|
+
create: create23,
|
|
1163
1200
|
defaultOptions: []
|
|
1164
1201
|
});
|
|
1165
|
-
function
|
|
1202
|
+
function create23(context) {
|
|
1166
1203
|
return {
|
|
1167
1204
|
CallExpression(node) {
|
|
1168
1205
|
if (ER21.isCreateRefCall(context, node) && AST11.findParentNode(node, ER21.isClassComponent) == null) {
|
|
@@ -1171,25 +1208,25 @@ function create22(context) {
|
|
|
1171
1208
|
}
|
|
1172
1209
|
};
|
|
1173
1210
|
}
|
|
1174
|
-
var
|
|
1175
|
-
var
|
|
1211
|
+
var RULE_NAME24 = "no-default-props";
|
|
1212
|
+
var RULE_FEATURES24 = [];
|
|
1176
1213
|
var no_default_props_default = createRule({
|
|
1177
1214
|
meta: {
|
|
1178
1215
|
type: "problem",
|
|
1179
1216
|
docs: {
|
|
1180
1217
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1181
|
-
[Symbol.for("rule_features")]:
|
|
1218
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1182
1219
|
},
|
|
1183
1220
|
messages: {
|
|
1184
1221
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1185
1222
|
},
|
|
1186
1223
|
schema: []
|
|
1187
1224
|
},
|
|
1188
|
-
name:
|
|
1189
|
-
create:
|
|
1225
|
+
name: RULE_NAME24,
|
|
1226
|
+
create: create24,
|
|
1190
1227
|
defaultOptions: []
|
|
1191
1228
|
});
|
|
1192
|
-
function
|
|
1229
|
+
function create24(context) {
|
|
1193
1230
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1194
1231
|
return {
|
|
1195
1232
|
AssignmentExpression(node) {
|
|
@@ -1223,8 +1260,8 @@ function create23(context) {
|
|
|
1223
1260
|
}
|
|
1224
1261
|
};
|
|
1225
1262
|
}
|
|
1226
|
-
var
|
|
1227
|
-
var
|
|
1263
|
+
var RULE_NAME25 = "no-direct-mutation-state";
|
|
1264
|
+
var RULE_FEATURES25 = [];
|
|
1228
1265
|
function isConstructorFunction(node) {
|
|
1229
1266
|
return AST11.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && AST11.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1230
1267
|
}
|
|
@@ -1233,18 +1270,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1233
1270
|
type: "problem",
|
|
1234
1271
|
docs: {
|
|
1235
1272
|
description: "Disallow direct mutation of `this.state`.",
|
|
1236
|
-
[Symbol.for("rule_features")]:
|
|
1273
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1237
1274
|
},
|
|
1238
1275
|
messages: {
|
|
1239
1276
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1240
1277
|
},
|
|
1241
1278
|
schema: []
|
|
1242
1279
|
},
|
|
1243
|
-
name:
|
|
1244
|
-
create:
|
|
1280
|
+
name: RULE_NAME25,
|
|
1281
|
+
create: create25,
|
|
1245
1282
|
defaultOptions: []
|
|
1246
1283
|
});
|
|
1247
|
-
function
|
|
1284
|
+
function create25(context) {
|
|
1248
1285
|
return {
|
|
1249
1286
|
AssignmentExpression(node) {
|
|
1250
1287
|
if (!ER21.isAssignmentToThisState(node)) return;
|
|
@@ -1265,25 +1302,25 @@ function create24(context) {
|
|
|
1265
1302
|
}
|
|
1266
1303
|
};
|
|
1267
1304
|
}
|
|
1268
|
-
var
|
|
1269
|
-
var
|
|
1305
|
+
var RULE_NAME26 = "no-duplicate-key";
|
|
1306
|
+
var RULE_FEATURES26 = [];
|
|
1270
1307
|
var no_duplicate_key_default = createRule({
|
|
1271
1308
|
meta: {
|
|
1272
1309
|
type: "problem",
|
|
1273
1310
|
docs: {
|
|
1274
1311
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1275
|
-
[Symbol.for("rule_features")]:
|
|
1312
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1276
1313
|
},
|
|
1277
1314
|
messages: {
|
|
1278
1315
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1279
1316
|
},
|
|
1280
1317
|
schema: []
|
|
1281
1318
|
},
|
|
1282
|
-
name:
|
|
1283
|
-
create:
|
|
1319
|
+
name: RULE_NAME26,
|
|
1320
|
+
create: create26,
|
|
1284
1321
|
defaultOptions: []
|
|
1285
1322
|
});
|
|
1286
|
-
function
|
|
1323
|
+
function create26(context) {
|
|
1287
1324
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1288
1325
|
return {};
|
|
1289
1326
|
}
|
|
@@ -1347,8 +1384,8 @@ function create25(context) {
|
|
|
1347
1384
|
}
|
|
1348
1385
|
};
|
|
1349
1386
|
}
|
|
1350
|
-
var
|
|
1351
|
-
var
|
|
1387
|
+
var RULE_NAME27 = "no-forward-ref";
|
|
1388
|
+
var RULE_FEATURES27 = [
|
|
1352
1389
|
"MOD"
|
|
1353
1390
|
];
|
|
1354
1391
|
var no_forward_ref_default = createRule({
|
|
@@ -1356,7 +1393,7 @@ var no_forward_ref_default = createRule({
|
|
|
1356
1393
|
type: "problem",
|
|
1357
1394
|
docs: {
|
|
1358
1395
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1359
|
-
[Symbol.for("rule_features")]:
|
|
1396
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1360
1397
|
},
|
|
1361
1398
|
fixable: "code",
|
|
1362
1399
|
messages: {
|
|
@@ -1364,11 +1401,11 @@ var no_forward_ref_default = createRule({
|
|
|
1364
1401
|
},
|
|
1365
1402
|
schema: []
|
|
1366
1403
|
},
|
|
1367
|
-
name:
|
|
1368
|
-
create:
|
|
1404
|
+
name: RULE_NAME27,
|
|
1405
|
+
create: create27,
|
|
1369
1406
|
defaultOptions: []
|
|
1370
1407
|
});
|
|
1371
|
-
function
|
|
1408
|
+
function create27(context) {
|
|
1372
1409
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1373
1410
|
return {};
|
|
1374
1411
|
}
|
|
@@ -1456,8 +1493,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1456
1493
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1457
1494
|
];
|
|
1458
1495
|
}
|
|
1459
|
-
var
|
|
1460
|
-
var
|
|
1496
|
+
var RULE_NAME28 = "no-implicit-key";
|
|
1497
|
+
var RULE_FEATURES28 = [
|
|
1461
1498
|
"EXP"
|
|
1462
1499
|
];
|
|
1463
1500
|
var no_implicit_key_default = createRule({
|
|
@@ -1465,18 +1502,18 @@ var no_implicit_key_default = createRule({
|
|
|
1465
1502
|
type: "problem",
|
|
1466
1503
|
docs: {
|
|
1467
1504
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1468
|
-
[Symbol.for("rule_features")]:
|
|
1505
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1469
1506
|
},
|
|
1470
1507
|
messages: {
|
|
1471
1508
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1472
1509
|
},
|
|
1473
1510
|
schema: []
|
|
1474
1511
|
},
|
|
1475
|
-
name:
|
|
1476
|
-
create:
|
|
1512
|
+
name: RULE_NAME28,
|
|
1513
|
+
create: create28,
|
|
1477
1514
|
defaultOptions: []
|
|
1478
1515
|
});
|
|
1479
|
-
function
|
|
1516
|
+
function create28(context) {
|
|
1480
1517
|
return {
|
|
1481
1518
|
JSXOpeningElement(node) {
|
|
1482
1519
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1490,8 +1527,8 @@ function create27(context) {
|
|
|
1490
1527
|
}
|
|
1491
1528
|
};
|
|
1492
1529
|
}
|
|
1493
|
-
var
|
|
1494
|
-
var
|
|
1530
|
+
var RULE_NAME29 = "no-leaked-conditional-rendering";
|
|
1531
|
+
var RULE_FEATURES29 = [
|
|
1495
1532
|
"TSC"
|
|
1496
1533
|
];
|
|
1497
1534
|
var tsHelpers = {
|
|
@@ -1577,18 +1614,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1577
1614
|
type: "problem",
|
|
1578
1615
|
docs: {
|
|
1579
1616
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1580
|
-
[Symbol.for("rule_features")]:
|
|
1617
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1581
1618
|
},
|
|
1582
1619
|
messages: {
|
|
1583
1620
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1584
1621
|
},
|
|
1585
1622
|
schema: []
|
|
1586
1623
|
},
|
|
1587
|
-
name:
|
|
1588
|
-
create:
|
|
1624
|
+
name: RULE_NAME29,
|
|
1625
|
+
create: create29,
|
|
1589
1626
|
defaultOptions: []
|
|
1590
1627
|
});
|
|
1591
|
-
function
|
|
1628
|
+
function create29(context) {
|
|
1592
1629
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1593
1630
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1594
1631
|
const allowedVariants = [
|
|
@@ -1645,25 +1682,25 @@ function create28(context) {
|
|
|
1645
1682
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1646
1683
|
};
|
|
1647
1684
|
}
|
|
1648
|
-
var
|
|
1649
|
-
var
|
|
1685
|
+
var RULE_NAME30 = "no-missing-component-display-name";
|
|
1686
|
+
var RULE_FEATURES30 = [];
|
|
1650
1687
|
var no_missing_component_display_name_default = createRule({
|
|
1651
1688
|
meta: {
|
|
1652
1689
|
type: "problem",
|
|
1653
1690
|
docs: {
|
|
1654
1691
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1655
|
-
[Symbol.for("rule_features")]:
|
|
1692
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1656
1693
|
},
|
|
1657
1694
|
messages: {
|
|
1658
1695
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1659
1696
|
},
|
|
1660
1697
|
schema: []
|
|
1661
1698
|
},
|
|
1662
|
-
name:
|
|
1663
|
-
create:
|
|
1699
|
+
name: RULE_NAME30,
|
|
1700
|
+
create: create30,
|
|
1664
1701
|
defaultOptions: []
|
|
1665
1702
|
});
|
|
1666
|
-
function
|
|
1703
|
+
function create30(context) {
|
|
1667
1704
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1668
1705
|
const {
|
|
1669
1706
|
ctx,
|
|
@@ -1698,25 +1735,25 @@ function create29(context) {
|
|
|
1698
1735
|
}
|
|
1699
1736
|
};
|
|
1700
1737
|
}
|
|
1701
|
-
var
|
|
1702
|
-
var
|
|
1738
|
+
var RULE_NAME31 = "no-missing-context-display-name";
|
|
1739
|
+
var RULE_FEATURES31 = [];
|
|
1703
1740
|
var no_missing_context_display_name_default = createRule({
|
|
1704
1741
|
meta: {
|
|
1705
1742
|
type: "problem",
|
|
1706
1743
|
docs: {
|
|
1707
1744
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1708
|
-
[Symbol.for("rule_features")]:
|
|
1745
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1709
1746
|
},
|
|
1710
1747
|
messages: {
|
|
1711
1748
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1712
1749
|
},
|
|
1713
1750
|
schema: []
|
|
1714
1751
|
},
|
|
1715
|
-
name:
|
|
1716
|
-
create:
|
|
1752
|
+
name: RULE_NAME31,
|
|
1753
|
+
create: create31,
|
|
1717
1754
|
defaultOptions: []
|
|
1718
1755
|
});
|
|
1719
|
-
function
|
|
1756
|
+
function create31(context) {
|
|
1720
1757
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1721
1758
|
const createCalls = [];
|
|
1722
1759
|
const displayNameAssignments = [];
|
|
@@ -1754,14 +1791,14 @@ function create30(context) {
|
|
|
1754
1791
|
}
|
|
1755
1792
|
};
|
|
1756
1793
|
}
|
|
1757
|
-
var
|
|
1758
|
-
var
|
|
1794
|
+
var RULE_NAME32 = "no-missing-key";
|
|
1795
|
+
var RULE_FEATURES32 = [];
|
|
1759
1796
|
var no_missing_key_default = createRule({
|
|
1760
1797
|
meta: {
|
|
1761
1798
|
type: "problem",
|
|
1762
1799
|
docs: {
|
|
1763
1800
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1764
|
-
[Symbol.for("rule_features")]:
|
|
1801
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1765
1802
|
},
|
|
1766
1803
|
messages: {
|
|
1767
1804
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1769,11 +1806,11 @@ var no_missing_key_default = createRule({
|
|
|
1769
1806
|
},
|
|
1770
1807
|
schema: []
|
|
1771
1808
|
},
|
|
1772
|
-
name:
|
|
1773
|
-
create:
|
|
1809
|
+
name: RULE_NAME32,
|
|
1810
|
+
create: create32,
|
|
1774
1811
|
defaultOptions: []
|
|
1775
1812
|
});
|
|
1776
|
-
function
|
|
1813
|
+
function create32(context) {
|
|
1777
1814
|
const report = createReport(context);
|
|
1778
1815
|
const state = { isWithinChildrenToArray: false };
|
|
1779
1816
|
function checkIteratorElement(node) {
|
|
@@ -1886,25 +1923,25 @@ function create31(context) {
|
|
|
1886
1923
|
function isArrayFromCall(node) {
|
|
1887
1924
|
return node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1888
1925
|
}
|
|
1889
|
-
var
|
|
1890
|
-
var
|
|
1926
|
+
var RULE_NAME33 = "no-nested-component-definitions";
|
|
1927
|
+
var RULE_FEATURES33 = [];
|
|
1891
1928
|
var no_nested_component_definitions_default = createRule({
|
|
1892
1929
|
meta: {
|
|
1893
1930
|
type: "problem",
|
|
1894
1931
|
docs: {
|
|
1895
1932
|
description: "Disallow nesting component definitions inside other components.",
|
|
1896
|
-
[Symbol.for("rule_features")]:
|
|
1933
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1897
1934
|
},
|
|
1898
1935
|
messages: {
|
|
1899
1936
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1900
1937
|
},
|
|
1901
1938
|
schema: []
|
|
1902
1939
|
},
|
|
1903
|
-
name:
|
|
1904
|
-
create:
|
|
1940
|
+
name: RULE_NAME33,
|
|
1941
|
+
create: create33,
|
|
1905
1942
|
defaultOptions: []
|
|
1906
1943
|
});
|
|
1907
|
-
function
|
|
1944
|
+
function create33(context) {
|
|
1908
1945
|
const hint = ER21.ComponentCollectorHint.SkipArrayMapArgument | ER21.ComponentCollectorHint.SkipNullLiteral | ER21.ComponentCollectorHint.SkipUndefined | ER21.ComponentCollectorHint.SkipBooleanLiteral | ER21.ComponentCollectorHint.SkipStringLiteral | ER21.ComponentCollectorHint.SkipNumberLiteral | ER21.ComponentCollectorHint.StrictLogical | ER21.ComponentCollectorHint.StrictConditional;
|
|
1909
1946
|
const collector = ER21.useComponentCollector(context, { hint });
|
|
1910
1947
|
const collectorLegacy = ER21.useComponentCollectorLegacy();
|
|
@@ -2000,25 +2037,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
2000
2037
|
if (prop == null) return false;
|
|
2001
2038
|
return prop === call.arguments[1];
|
|
2002
2039
|
}
|
|
2003
|
-
var
|
|
2004
|
-
var
|
|
2040
|
+
var RULE_NAME34 = "no-prop-types";
|
|
2041
|
+
var RULE_FEATURES34 = [];
|
|
2005
2042
|
var no_prop_types_default = createRule({
|
|
2006
2043
|
meta: {
|
|
2007
2044
|
type: "problem",
|
|
2008
2045
|
docs: {
|
|
2009
2046
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
2010
|
-
[Symbol.for("rule_features")]:
|
|
2047
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2011
2048
|
},
|
|
2012
2049
|
messages: {
|
|
2013
2050
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
2014
2051
|
},
|
|
2015
2052
|
schema: []
|
|
2016
2053
|
},
|
|
2017
|
-
name:
|
|
2018
|
-
create:
|
|
2054
|
+
name: RULE_NAME34,
|
|
2055
|
+
create: create34,
|
|
2019
2056
|
defaultOptions: []
|
|
2020
2057
|
});
|
|
2021
|
-
function
|
|
2058
|
+
function create34(context) {
|
|
2022
2059
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
2023
2060
|
return {};
|
|
2024
2061
|
}
|
|
@@ -2054,8 +2091,8 @@ function create33(context) {
|
|
|
2054
2091
|
}
|
|
2055
2092
|
};
|
|
2056
2093
|
}
|
|
2057
|
-
var
|
|
2058
|
-
var
|
|
2094
|
+
var RULE_NAME35 = "no-redundant-should-component-update";
|
|
2095
|
+
var RULE_FEATURES35 = [];
|
|
2059
2096
|
function isShouldComponentUpdate(node) {
|
|
2060
2097
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2061
2098
|
}
|
|
@@ -2064,18 +2101,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2064
2101
|
type: "problem",
|
|
2065
2102
|
docs: {
|
|
2066
2103
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2067
|
-
[Symbol.for("rule_features")]:
|
|
2104
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2068
2105
|
},
|
|
2069
2106
|
messages: {
|
|
2070
2107
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2071
2108
|
},
|
|
2072
2109
|
schema: []
|
|
2073
2110
|
},
|
|
2074
|
-
name:
|
|
2075
|
-
create:
|
|
2111
|
+
name: RULE_NAME35,
|
|
2112
|
+
create: create35,
|
|
2076
2113
|
defaultOptions: []
|
|
2077
2114
|
});
|
|
2078
|
-
function
|
|
2115
|
+
function create35(context) {
|
|
2079
2116
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2080
2117
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2081
2118
|
return {
|
|
@@ -2102,8 +2139,8 @@ function create34(context) {
|
|
|
2102
2139
|
}
|
|
2103
2140
|
};
|
|
2104
2141
|
}
|
|
2105
|
-
var
|
|
2106
|
-
var
|
|
2142
|
+
var RULE_NAME36 = "no-set-state-in-component-did-mount";
|
|
2143
|
+
var RULE_FEATURES36 = [];
|
|
2107
2144
|
function isComponentDidMount(node) {
|
|
2108
2145
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2109
2146
|
}
|
|
@@ -2112,18 +2149,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2112
2149
|
type: "problem",
|
|
2113
2150
|
docs: {
|
|
2114
2151
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2115
|
-
[Symbol.for("rule_features")]:
|
|
2152
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2116
2153
|
},
|
|
2117
2154
|
messages: {
|
|
2118
2155
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2119
2156
|
},
|
|
2120
2157
|
schema: []
|
|
2121
2158
|
},
|
|
2122
|
-
name:
|
|
2123
|
-
create:
|
|
2159
|
+
name: RULE_NAME36,
|
|
2160
|
+
create: create36,
|
|
2124
2161
|
defaultOptions: []
|
|
2125
2162
|
});
|
|
2126
|
-
function
|
|
2163
|
+
function create36(context) {
|
|
2127
2164
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2128
2165
|
return {
|
|
2129
2166
|
CallExpression(node) {
|
|
@@ -2144,8 +2181,8 @@ function create35(context) {
|
|
|
2144
2181
|
}
|
|
2145
2182
|
};
|
|
2146
2183
|
}
|
|
2147
|
-
var
|
|
2148
|
-
var
|
|
2184
|
+
var RULE_NAME37 = "no-set-state-in-component-did-update";
|
|
2185
|
+
var RULE_FEATURES37 = [];
|
|
2149
2186
|
function isComponentDidUpdate(node) {
|
|
2150
2187
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2151
2188
|
}
|
|
@@ -2154,18 +2191,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2154
2191
|
type: "problem",
|
|
2155
2192
|
docs: {
|
|
2156
2193
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2157
|
-
[Symbol.for("rule_features")]:
|
|
2194
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2158
2195
|
},
|
|
2159
2196
|
messages: {
|
|
2160
2197
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2161
2198
|
},
|
|
2162
2199
|
schema: []
|
|
2163
2200
|
},
|
|
2164
|
-
name:
|
|
2165
|
-
create:
|
|
2201
|
+
name: RULE_NAME37,
|
|
2202
|
+
create: create37,
|
|
2166
2203
|
defaultOptions: []
|
|
2167
2204
|
});
|
|
2168
|
-
function
|
|
2205
|
+
function create37(context) {
|
|
2169
2206
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2170
2207
|
return {
|
|
2171
2208
|
CallExpression(node) {
|
|
@@ -2186,8 +2223,8 @@ function create36(context) {
|
|
|
2186
2223
|
}
|
|
2187
2224
|
};
|
|
2188
2225
|
}
|
|
2189
|
-
var
|
|
2190
|
-
var
|
|
2226
|
+
var RULE_NAME38 = "no-set-state-in-component-will-update";
|
|
2227
|
+
var RULE_FEATURES38 = [];
|
|
2191
2228
|
function isComponentWillUpdate3(node) {
|
|
2192
2229
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2193
2230
|
}
|
|
@@ -2196,18 +2233,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2196
2233
|
type: "problem",
|
|
2197
2234
|
docs: {
|
|
2198
2235
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2199
|
-
[Symbol.for("rule_features")]:
|
|
2236
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2200
2237
|
},
|
|
2201
2238
|
messages: {
|
|
2202
2239
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2203
2240
|
},
|
|
2204
2241
|
schema: []
|
|
2205
2242
|
},
|
|
2206
|
-
name:
|
|
2207
|
-
create:
|
|
2243
|
+
name: RULE_NAME38,
|
|
2244
|
+
create: create38,
|
|
2208
2245
|
defaultOptions: []
|
|
2209
2246
|
});
|
|
2210
|
-
function
|
|
2247
|
+
function create38(context) {
|
|
2211
2248
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2212
2249
|
return {
|
|
2213
2250
|
CallExpression(node) {
|
|
@@ -2228,8 +2265,8 @@ function create37(context) {
|
|
|
2228
2265
|
}
|
|
2229
2266
|
};
|
|
2230
2267
|
}
|
|
2231
|
-
var
|
|
2232
|
-
var
|
|
2268
|
+
var RULE_NAME39 = "no-string-refs";
|
|
2269
|
+
var RULE_FEATURES39 = [];
|
|
2233
2270
|
function containsStringLiteral({ value }) {
|
|
2234
2271
|
return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2235
2272
|
}
|
|
@@ -2247,18 +2284,18 @@ var no_string_refs_default = createRule({
|
|
|
2247
2284
|
type: "problem",
|
|
2248
2285
|
docs: {
|
|
2249
2286
|
description: "Disallow deprecated string `refs`.",
|
|
2250
|
-
[Symbol.for("rule_features")]:
|
|
2287
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2251
2288
|
},
|
|
2252
2289
|
messages: {
|
|
2253
2290
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2254
2291
|
},
|
|
2255
2292
|
schema: []
|
|
2256
2293
|
},
|
|
2257
|
-
name:
|
|
2258
|
-
create:
|
|
2294
|
+
name: RULE_NAME39,
|
|
2295
|
+
create: create39,
|
|
2259
2296
|
defaultOptions: []
|
|
2260
2297
|
});
|
|
2261
|
-
function
|
|
2298
|
+
function create39(context) {
|
|
2262
2299
|
return {
|
|
2263
2300
|
JSXAttribute(node) {
|
|
2264
2301
|
if (node.name.name !== "ref") {
|
|
@@ -2273,8 +2310,8 @@ function create38(context) {
|
|
|
2273
2310
|
}
|
|
2274
2311
|
};
|
|
2275
2312
|
}
|
|
2276
|
-
var
|
|
2277
|
-
var
|
|
2313
|
+
var RULE_NAME40 = "no-unsafe-component-will-mount";
|
|
2314
|
+
var RULE_FEATURES40 = [];
|
|
2278
2315
|
function isUnsafeComponentWillMount(node) {
|
|
2279
2316
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2280
2317
|
}
|
|
@@ -2283,18 +2320,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2283
2320
|
type: "problem",
|
|
2284
2321
|
docs: {
|
|
2285
2322
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2286
|
-
[Symbol.for("rule_features")]:
|
|
2323
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2287
2324
|
},
|
|
2288
2325
|
messages: {
|
|
2289
2326
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2290
2327
|
},
|
|
2291
2328
|
schema: []
|
|
2292
2329
|
},
|
|
2293
|
-
name:
|
|
2294
|
-
create:
|
|
2330
|
+
name: RULE_NAME40,
|
|
2331
|
+
create: create40,
|
|
2295
2332
|
defaultOptions: []
|
|
2296
2333
|
});
|
|
2297
|
-
function
|
|
2334
|
+
function create40(context) {
|
|
2298
2335
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2299
2336
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2300
2337
|
return {
|
|
@@ -2315,8 +2352,8 @@ function create39(context) {
|
|
|
2315
2352
|
}
|
|
2316
2353
|
};
|
|
2317
2354
|
}
|
|
2318
|
-
var
|
|
2319
|
-
var
|
|
2355
|
+
var RULE_NAME41 = "no-unsafe-component-will-receive-props";
|
|
2356
|
+
var RULE_FEATURES41 = [];
|
|
2320
2357
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2321
2358
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2322
2359
|
}
|
|
@@ -2325,18 +2362,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2325
2362
|
type: "problem",
|
|
2326
2363
|
docs: {
|
|
2327
2364
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2328
|
-
[Symbol.for("rule_features")]:
|
|
2365
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2329
2366
|
},
|
|
2330
2367
|
messages: {
|
|
2331
2368
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2332
2369
|
},
|
|
2333
2370
|
schema: []
|
|
2334
2371
|
},
|
|
2335
|
-
name:
|
|
2336
|
-
create:
|
|
2372
|
+
name: RULE_NAME41,
|
|
2373
|
+
create: create41,
|
|
2337
2374
|
defaultOptions: []
|
|
2338
2375
|
});
|
|
2339
|
-
function
|
|
2376
|
+
function create41(context) {
|
|
2340
2377
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2341
2378
|
return {};
|
|
2342
2379
|
}
|
|
@@ -2359,8 +2396,8 @@ function create40(context) {
|
|
|
2359
2396
|
}
|
|
2360
2397
|
};
|
|
2361
2398
|
}
|
|
2362
|
-
var
|
|
2363
|
-
var
|
|
2399
|
+
var RULE_NAME42 = "no-unsafe-component-will-update";
|
|
2400
|
+
var RULE_FEATURES42 = [];
|
|
2364
2401
|
function isUnsafeComponentWillUpdate(node) {
|
|
2365
2402
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2366
2403
|
}
|
|
@@ -2369,18 +2406,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2369
2406
|
type: "problem",
|
|
2370
2407
|
docs: {
|
|
2371
2408
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2372
|
-
[Symbol.for("rule_features")]:
|
|
2409
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2373
2410
|
},
|
|
2374
2411
|
messages: {
|
|
2375
2412
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2376
2413
|
},
|
|
2377
2414
|
schema: []
|
|
2378
2415
|
},
|
|
2379
|
-
name:
|
|
2380
|
-
create:
|
|
2416
|
+
name: RULE_NAME42,
|
|
2417
|
+
create: create42,
|
|
2381
2418
|
defaultOptions: []
|
|
2382
2419
|
});
|
|
2383
|
-
function
|
|
2420
|
+
function create42(context) {
|
|
2384
2421
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2385
2422
|
const { ctx, listeners } = ER21.useComponentCollectorLegacy();
|
|
2386
2423
|
return {
|
|
@@ -2401,25 +2438,25 @@ function create41(context) {
|
|
|
2401
2438
|
}
|
|
2402
2439
|
};
|
|
2403
2440
|
}
|
|
2404
|
-
var
|
|
2405
|
-
var
|
|
2441
|
+
var RULE_NAME43 = "no-unstable-context-value";
|
|
2442
|
+
var RULE_FEATURES43 = [];
|
|
2406
2443
|
var no_unstable_context_value_default = createRule({
|
|
2407
2444
|
meta: {
|
|
2408
2445
|
type: "problem",
|
|
2409
2446
|
docs: {
|
|
2410
2447
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2411
|
-
[Symbol.for("rule_features")]:
|
|
2448
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2412
2449
|
},
|
|
2413
2450
|
messages: {
|
|
2414
2451
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2415
2452
|
},
|
|
2416
2453
|
schema: []
|
|
2417
2454
|
},
|
|
2418
|
-
name:
|
|
2419
|
-
create:
|
|
2455
|
+
name: RULE_NAME43,
|
|
2456
|
+
create: create43,
|
|
2420
2457
|
defaultOptions: []
|
|
2421
2458
|
});
|
|
2422
|
-
function
|
|
2459
|
+
function create43(context) {
|
|
2423
2460
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2424
2461
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2425
2462
|
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
@@ -2474,25 +2511,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2474
2511
|
}
|
|
2475
2512
|
return false;
|
|
2476
2513
|
}
|
|
2477
|
-
var
|
|
2478
|
-
var
|
|
2514
|
+
var RULE_NAME44 = "no-unstable-default-props";
|
|
2515
|
+
var RULE_FEATURES44 = [];
|
|
2479
2516
|
var no_unstable_default_props_default = createRule({
|
|
2480
2517
|
meta: {
|
|
2481
2518
|
type: "problem",
|
|
2482
2519
|
docs: {
|
|
2483
2520
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2484
|
-
[Symbol.for("rule_features")]:
|
|
2521
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2485
2522
|
},
|
|
2486
2523
|
messages: {
|
|
2487
2524
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2488
2525
|
},
|
|
2489
2526
|
schema: []
|
|
2490
2527
|
},
|
|
2491
|
-
name:
|
|
2492
|
-
create:
|
|
2528
|
+
name: RULE_NAME44,
|
|
2529
|
+
create: create44,
|
|
2493
2530
|
defaultOptions: []
|
|
2494
2531
|
});
|
|
2495
|
-
function
|
|
2532
|
+
function create44(context) {
|
|
2496
2533
|
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
2497
2534
|
const declarators = /* @__PURE__ */ new Map();
|
|
2498
2535
|
return {
|
|
@@ -2548,8 +2585,8 @@ function create43(context) {
|
|
|
2548
2585
|
}
|
|
2549
2586
|
};
|
|
2550
2587
|
}
|
|
2551
|
-
var
|
|
2552
|
-
var
|
|
2588
|
+
var RULE_NAME45 = "no-unused-class-component-members";
|
|
2589
|
+
var RULE_FEATURES45 = [];
|
|
2553
2590
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2554
2591
|
"componentDidCatch",
|
|
2555
2592
|
"componentDidMount",
|
|
@@ -2575,18 +2612,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2575
2612
|
type: "problem",
|
|
2576
2613
|
docs: {
|
|
2577
2614
|
description: "Warns unused class component methods and properties.",
|
|
2578
|
-
[Symbol.for("rule_features")]:
|
|
2615
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2579
2616
|
},
|
|
2580
2617
|
messages: {
|
|
2581
2618
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2582
2619
|
},
|
|
2583
2620
|
schema: []
|
|
2584
2621
|
},
|
|
2585
|
-
name:
|
|
2586
|
-
create:
|
|
2622
|
+
name: RULE_NAME45,
|
|
2623
|
+
create: create45,
|
|
2587
2624
|
defaultOptions: []
|
|
2588
2625
|
});
|
|
2589
|
-
function
|
|
2626
|
+
function create45(context) {
|
|
2590
2627
|
const classEntries = [];
|
|
2591
2628
|
const methodEntries = [];
|
|
2592
2629
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2696,8 +2733,8 @@ function create44(context) {
|
|
|
2696
2733
|
}
|
|
2697
2734
|
};
|
|
2698
2735
|
}
|
|
2699
|
-
var
|
|
2700
|
-
var
|
|
2736
|
+
var RULE_NAME46 = "no-unused-state";
|
|
2737
|
+
var RULE_FEATURES46 = [];
|
|
2701
2738
|
function isKeyLiteral3(node, key) {
|
|
2702
2739
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
2703
2740
|
}
|
|
@@ -2706,18 +2743,18 @@ var no_unused_state_default = createRule({
|
|
|
2706
2743
|
type: "problem",
|
|
2707
2744
|
docs: {
|
|
2708
2745
|
description: "Warns unused class component state.",
|
|
2709
|
-
[Symbol.for("rule_features")]:
|
|
2746
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2710
2747
|
},
|
|
2711
2748
|
messages: {
|
|
2712
2749
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2713
2750
|
},
|
|
2714
2751
|
schema: []
|
|
2715
2752
|
},
|
|
2716
|
-
name:
|
|
2717
|
-
create:
|
|
2753
|
+
name: RULE_NAME46,
|
|
2754
|
+
create: create46,
|
|
2718
2755
|
defaultOptions: []
|
|
2719
2756
|
});
|
|
2720
|
-
function
|
|
2757
|
+
function create46(context) {
|
|
2721
2758
|
const classEntries = [];
|
|
2722
2759
|
const methodEntries = [];
|
|
2723
2760
|
const constructorEntries = [];
|
|
@@ -2851,8 +2888,8 @@ function create45(context) {
|
|
|
2851
2888
|
}
|
|
2852
2889
|
};
|
|
2853
2890
|
}
|
|
2854
|
-
var
|
|
2855
|
-
var
|
|
2891
|
+
var RULE_NAME47 = "no-use-context";
|
|
2892
|
+
var RULE_FEATURES47 = [
|
|
2856
2893
|
"MOD"
|
|
2857
2894
|
];
|
|
2858
2895
|
var no_use_context_default = createRule({
|
|
@@ -2860,7 +2897,7 @@ var no_use_context_default = createRule({
|
|
|
2860
2897
|
type: "problem",
|
|
2861
2898
|
docs: {
|
|
2862
2899
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2863
|
-
[Symbol.for("rule_features")]:
|
|
2900
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2864
2901
|
},
|
|
2865
2902
|
fixable: "code",
|
|
2866
2903
|
messages: {
|
|
@@ -2868,11 +2905,11 @@ var no_use_context_default = createRule({
|
|
|
2868
2905
|
},
|
|
2869
2906
|
schema: []
|
|
2870
2907
|
},
|
|
2871
|
-
name:
|
|
2872
|
-
create:
|
|
2908
|
+
name: RULE_NAME47,
|
|
2909
|
+
create: create47,
|
|
2873
2910
|
defaultOptions: []
|
|
2874
2911
|
});
|
|
2875
|
-
function
|
|
2912
|
+
function create47(context) {
|
|
2876
2913
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2877
2914
|
const settings4 = getSettingsFromContext(context);
|
|
2878
2915
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2950,25 +2987,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2950
2987
|
return tokens;
|
|
2951
2988
|
}
|
|
2952
2989
|
}
|
|
2953
|
-
var
|
|
2954
|
-
var
|
|
2990
|
+
var RULE_NAME48 = "no-useless-forward-ref";
|
|
2991
|
+
var RULE_FEATURES48 = [];
|
|
2955
2992
|
var no_useless_forward_ref_default = createRule({
|
|
2956
2993
|
meta: {
|
|
2957
2994
|
type: "problem",
|
|
2958
2995
|
docs: {
|
|
2959
2996
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2960
|
-
[Symbol.for("rule_features")]:
|
|
2997
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
2961
2998
|
},
|
|
2962
2999
|
messages: {
|
|
2963
3000
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2964
3001
|
},
|
|
2965
3002
|
schema: []
|
|
2966
3003
|
},
|
|
2967
|
-
name:
|
|
2968
|
-
create:
|
|
3004
|
+
name: RULE_NAME48,
|
|
3005
|
+
create: create48,
|
|
2969
3006
|
defaultOptions: []
|
|
2970
3007
|
});
|
|
2971
|
-
function
|
|
3008
|
+
function create48(context) {
|
|
2972
3009
|
return {
|
|
2973
3010
|
CallExpression(node) {
|
|
2974
3011
|
if (!ER21.isForwardRefCall(context, node)) {
|
|
@@ -2989,7 +3026,7 @@ function create47(context) {
|
|
|
2989
3026
|
}
|
|
2990
3027
|
};
|
|
2991
3028
|
}
|
|
2992
|
-
var
|
|
3029
|
+
var RULE_NAME49 = "no-useless-fragment";
|
|
2993
3030
|
var defaultOptions = [{
|
|
2994
3031
|
allowExpressions: true
|
|
2995
3032
|
}];
|
|
@@ -3015,11 +3052,11 @@ var no_useless_fragment_default = createRule({
|
|
|
3015
3052
|
}
|
|
3016
3053
|
}]
|
|
3017
3054
|
},
|
|
3018
|
-
name:
|
|
3019
|
-
create:
|
|
3055
|
+
name: RULE_NAME49,
|
|
3056
|
+
create: create49,
|
|
3020
3057
|
defaultOptions
|
|
3021
3058
|
});
|
|
3022
|
-
function
|
|
3059
|
+
function create49(context, [option]) {
|
|
3023
3060
|
const { allowExpressions = true } = option;
|
|
3024
3061
|
return {
|
|
3025
3062
|
JSXElement(node) {
|
|
@@ -3131,8 +3168,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3131
3168
|
}
|
|
3132
3169
|
return;
|
|
3133
3170
|
}
|
|
3134
|
-
var
|
|
3135
|
-
var
|
|
3171
|
+
var RULE_NAME50 = "prefer-destructuring-assignment";
|
|
3172
|
+
var RULE_FEATURES49 = [];
|
|
3136
3173
|
function isMemberExpressionWithObjectName(node) {
|
|
3137
3174
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3138
3175
|
}
|
|
@@ -3141,18 +3178,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3141
3178
|
type: "problem",
|
|
3142
3179
|
docs: {
|
|
3143
3180
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3144
|
-
[Symbol.for("rule_features")]:
|
|
3181
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3145
3182
|
},
|
|
3146
3183
|
messages: {
|
|
3147
3184
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3148
3185
|
},
|
|
3149
3186
|
schema: []
|
|
3150
3187
|
},
|
|
3151
|
-
name:
|
|
3152
|
-
create:
|
|
3188
|
+
name: RULE_NAME50,
|
|
3189
|
+
create: create50,
|
|
3153
3190
|
defaultOptions: []
|
|
3154
3191
|
});
|
|
3155
|
-
function
|
|
3192
|
+
function create50(context) {
|
|
3156
3193
|
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
3157
3194
|
const memberExpressionWithNames = [];
|
|
3158
3195
|
return {
|
|
@@ -3212,8 +3249,8 @@ function create49(context) {
|
|
|
3212
3249
|
}
|
|
3213
3250
|
};
|
|
3214
3251
|
}
|
|
3215
|
-
var
|
|
3216
|
-
var
|
|
3252
|
+
var RULE_NAME51 = "prefer-react-namespace-import";
|
|
3253
|
+
var RULE_FEATURES50 = [
|
|
3217
3254
|
"FIX"
|
|
3218
3255
|
];
|
|
3219
3256
|
var prefer_react_namespace_import_default = createRule({
|
|
@@ -3221,7 +3258,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3221
3258
|
type: "problem",
|
|
3222
3259
|
docs: {
|
|
3223
3260
|
description: "Enforces React is imported via a namespace import.",
|
|
3224
|
-
[Symbol.for("rule_features")]:
|
|
3261
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3225
3262
|
},
|
|
3226
3263
|
fixable: "code",
|
|
3227
3264
|
messages: {
|
|
@@ -3229,11 +3266,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3229
3266
|
},
|
|
3230
3267
|
schema: []
|
|
3231
3268
|
},
|
|
3232
|
-
name:
|
|
3233
|
-
create:
|
|
3269
|
+
name: RULE_NAME51,
|
|
3270
|
+
create: create51,
|
|
3234
3271
|
defaultOptions: []
|
|
3235
3272
|
});
|
|
3236
|
-
function
|
|
3273
|
+
function create51(context) {
|
|
3237
3274
|
const { importSource } = getSettingsFromContext(context);
|
|
3238
3275
|
return {
|
|
3239
3276
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3266,8 +3303,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3266
3303
|
}
|
|
3267
3304
|
};
|
|
3268
3305
|
}
|
|
3269
|
-
var
|
|
3270
|
-
var
|
|
3306
|
+
var RULE_NAME52 = "prefer-read-only-props";
|
|
3307
|
+
var RULE_FEATURES51 = [
|
|
3271
3308
|
"TSC",
|
|
3272
3309
|
"EXP"
|
|
3273
3310
|
];
|
|
@@ -3276,18 +3313,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3276
3313
|
type: "problem",
|
|
3277
3314
|
docs: {
|
|
3278
3315
|
description: "Enforces read-only props in components.",
|
|
3279
|
-
[Symbol.for("rule_features")]:
|
|
3316
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3280
3317
|
},
|
|
3281
3318
|
messages: {
|
|
3282
3319
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3283
3320
|
},
|
|
3284
3321
|
schema: []
|
|
3285
3322
|
},
|
|
3286
|
-
name:
|
|
3287
|
-
create:
|
|
3323
|
+
name: RULE_NAME52,
|
|
3324
|
+
create: create52,
|
|
3288
3325
|
defaultOptions: []
|
|
3289
3326
|
});
|
|
3290
|
-
function
|
|
3327
|
+
function create52(context) {
|
|
3291
3328
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3292
3329
|
const { ctx, listeners } = ER21.useComponentCollector(context);
|
|
3293
3330
|
return {
|
|
@@ -3317,8 +3354,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3317
3354
|
return true;
|
|
3318
3355
|
}
|
|
3319
3356
|
}
|
|
3320
|
-
var
|
|
3321
|
-
var
|
|
3357
|
+
var RULE_NAME53 = "prefer-shorthand-boolean";
|
|
3358
|
+
var RULE_FEATURES52 = [
|
|
3322
3359
|
"FIX"
|
|
3323
3360
|
];
|
|
3324
3361
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3326,7 +3363,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3326
3363
|
type: "problem",
|
|
3327
3364
|
docs: {
|
|
3328
3365
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3329
|
-
[Symbol.for("rule_features")]:
|
|
3366
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3330
3367
|
},
|
|
3331
3368
|
fixable: "code",
|
|
3332
3369
|
messages: {
|
|
@@ -3334,11 +3371,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3334
3371
|
},
|
|
3335
3372
|
schema: []
|
|
3336
3373
|
},
|
|
3337
|
-
name:
|
|
3338
|
-
create:
|
|
3374
|
+
name: RULE_NAME53,
|
|
3375
|
+
create: create53,
|
|
3339
3376
|
defaultOptions: []
|
|
3340
3377
|
});
|
|
3341
|
-
function
|
|
3378
|
+
function create53(context) {
|
|
3342
3379
|
return {
|
|
3343
3380
|
JSXAttribute(node) {
|
|
3344
3381
|
const { value } = node;
|
|
@@ -3358,8 +3395,8 @@ function create52(context) {
|
|
|
3358
3395
|
}
|
|
3359
3396
|
};
|
|
3360
3397
|
}
|
|
3361
|
-
var
|
|
3362
|
-
var
|
|
3398
|
+
var RULE_NAME54 = "prefer-shorthand-fragment";
|
|
3399
|
+
var RULE_FEATURES53 = [
|
|
3363
3400
|
"FIX"
|
|
3364
3401
|
];
|
|
3365
3402
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3367,7 +3404,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3367
3404
|
type: "problem",
|
|
3368
3405
|
docs: {
|
|
3369
3406
|
description: "Enforces shorthand syntax for fragments.",
|
|
3370
|
-
[Symbol.for("rule_features")]:
|
|
3407
|
+
[Symbol.for("rule_features")]: RULE_FEATURES53
|
|
3371
3408
|
},
|
|
3372
3409
|
fixable: "code",
|
|
3373
3410
|
messages: {
|
|
@@ -3375,11 +3412,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3375
3412
|
},
|
|
3376
3413
|
schema: []
|
|
3377
3414
|
},
|
|
3378
|
-
name:
|
|
3379
|
-
create:
|
|
3415
|
+
name: RULE_NAME54,
|
|
3416
|
+
create: create54,
|
|
3380
3417
|
defaultOptions: []
|
|
3381
3418
|
});
|
|
3382
|
-
function
|
|
3419
|
+
function create54(context) {
|
|
3383
3420
|
return {
|
|
3384
3421
|
JSXElement(node) {
|
|
3385
3422
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3465,6 +3502,7 @@ var plugin = {
|
|
|
3465
3502
|
// Part: JSX only rules
|
|
3466
3503
|
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3467
3504
|
"jsx-no-undef": jsx_no_undef_default,
|
|
3505
|
+
"jsx-uses-react": jsx_uses_react_default,
|
|
3468
3506
|
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3469
3507
|
// Part: deprecated rules
|
|
3470
3508
|
/** @deprecated Use `no-useless-forward-ref` instead */
|