eslint-plugin-react-x 1.38.0-beta.4 → 1.38.0-beta.7
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 +24 -26
- package/dist/index.d.ts +24 -26
- package/dist/index.js +405 -394
- package/dist/index.mjs +405 -394
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var shared = require('@eslint-react/shared');
|
|
4
4
|
var JSX8 = require('@eslint-react/jsx');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
|
+
var types = require('@typescript-eslint/types');
|
|
6
7
|
var AST11 = require('@eslint-react/ast');
|
|
7
8
|
var core = require('@eslint-react/core');
|
|
8
9
|
var eff = require('@eslint-react/eff');
|
|
9
|
-
var types = require('@typescript-eslint/types');
|
|
10
10
|
var tsPattern = require('ts-pattern');
|
|
11
11
|
var kit = require('@eslint-react/kit');
|
|
12
12
|
var compareVersions = require('compare-versions');
|
|
@@ -72,7 +72,7 @@ var rules = {
|
|
|
72
72
|
"react-x/no-create-ref": "error",
|
|
73
73
|
"react-x/no-default-props": "error",
|
|
74
74
|
"react-x/no-direct-mutation-state": "error",
|
|
75
|
-
"react-x/no-duplicate-
|
|
75
|
+
"react-x/jsx-no-duplicate-props": "warn",
|
|
76
76
|
"react-x/no-duplicate-key": "warn",
|
|
77
77
|
"react-x/no-forward-ref": "warn",
|
|
78
78
|
"react-x/no-implicit-key": "warn",
|
|
@@ -93,7 +93,7 @@ var rules = {
|
|
|
93
93
|
"react-x/no-unused-state": "warn",
|
|
94
94
|
"react-x/no-use-context": "warn",
|
|
95
95
|
"react-x/no-useless-forward-ref": "warn",
|
|
96
|
-
"react-x/
|
|
96
|
+
"react-x/jsx-uses-vars": "warn"
|
|
97
97
|
};
|
|
98
98
|
var settings = {
|
|
99
99
|
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
|
|
@@ -117,8 +117,8 @@ __export(recommended_typescript_exports, {
|
|
|
117
117
|
var name2 = "react-x/recommended-typescript";
|
|
118
118
|
var rules2 = {
|
|
119
119
|
...rules,
|
|
120
|
-
"react-x/no-duplicate-
|
|
121
|
-
"react-x/
|
|
120
|
+
"react-x/jsx-no-duplicate-props": "off",
|
|
121
|
+
"react-x/jsx-uses-vars": "off"
|
|
122
122
|
};
|
|
123
123
|
var settings2 = {
|
|
124
124
|
...settings
|
|
@@ -137,7 +137,7 @@ var settings3 = {
|
|
|
137
137
|
|
|
138
138
|
// package.json
|
|
139
139
|
var name4 = "eslint-plugin-react-x";
|
|
140
|
-
var version = "1.38.0-beta.
|
|
140
|
+
var version = "1.38.0-beta.7";
|
|
141
141
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
142
142
|
|
|
143
143
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -206,8 +206,90 @@ function create2(context) {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
var RULE_NAME3 = "no-
|
|
209
|
+
var RULE_NAME3 = "jsx-no-duplicate-props";
|
|
210
210
|
var RULE_FEATURES3 = [];
|
|
211
|
+
var jsx_no_duplicate_props_default = createRule({
|
|
212
|
+
meta: {
|
|
213
|
+
type: "problem",
|
|
214
|
+
docs: {
|
|
215
|
+
description: "Disallow duplicate props in JSX elements.",
|
|
216
|
+
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
217
|
+
},
|
|
218
|
+
messages: {
|
|
219
|
+
jsxNoDuplicateProps: "This JSX property is assigned multiple times."
|
|
220
|
+
},
|
|
221
|
+
schema: []
|
|
222
|
+
},
|
|
223
|
+
name: RULE_NAME3,
|
|
224
|
+
create: create3,
|
|
225
|
+
defaultOptions: []
|
|
226
|
+
});
|
|
227
|
+
function create3(context) {
|
|
228
|
+
return {
|
|
229
|
+
JSXOpeningElement(node) {
|
|
230
|
+
const props = [];
|
|
231
|
+
for (const attr of node.attributes) {
|
|
232
|
+
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const name5 = attr.name.name;
|
|
236
|
+
if (typeof name5 !== "string") {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (!props.includes(name5)) {
|
|
240
|
+
props.push(name5);
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
context.report({
|
|
244
|
+
messageId: "jsxNoDuplicateProps",
|
|
245
|
+
node: attr
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
var RULE_NAME4 = "jsx-uses-vars";
|
|
252
|
+
var RULE_FEATURES4 = [];
|
|
253
|
+
var jsx_uses_vars_default = createRule({
|
|
254
|
+
meta: {
|
|
255
|
+
type: "problem",
|
|
256
|
+
docs: {
|
|
257
|
+
description: "Marks variables used in JSX as used.",
|
|
258
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
259
|
+
},
|
|
260
|
+
messages: {
|
|
261
|
+
jsxUsesVars: "JSX variables should be marked as used."
|
|
262
|
+
},
|
|
263
|
+
schema: []
|
|
264
|
+
},
|
|
265
|
+
name: RULE_NAME4,
|
|
266
|
+
create: create4,
|
|
267
|
+
defaultOptions: []
|
|
268
|
+
});
|
|
269
|
+
function create4(context) {
|
|
270
|
+
return {
|
|
271
|
+
JSXOpeningElement(node) {
|
|
272
|
+
switch (node.name.type) {
|
|
273
|
+
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
274
|
+
if (/^[a-z]/u.test(node.name.name)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
281
|
+
const { object } = node.name;
|
|
282
|
+
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
283
|
+
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
var RULE_NAME5 = "no-access-state-in-setstate";
|
|
292
|
+
var RULE_FEATURES5 = [];
|
|
211
293
|
function isKeyLiteral(node, key) {
|
|
212
294
|
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);
|
|
213
295
|
}
|
|
@@ -216,18 +298,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
216
298
|
type: "problem",
|
|
217
299
|
docs: {
|
|
218
300
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
219
|
-
[Symbol.for("rule_features")]:
|
|
301
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
220
302
|
},
|
|
221
303
|
messages: {
|
|
222
304
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
223
305
|
},
|
|
224
306
|
schema: []
|
|
225
307
|
},
|
|
226
|
-
name:
|
|
227
|
-
create:
|
|
308
|
+
name: RULE_NAME5,
|
|
309
|
+
create: create5,
|
|
228
310
|
defaultOptions: []
|
|
229
311
|
});
|
|
230
|
-
function
|
|
312
|
+
function create5(context) {
|
|
231
313
|
if (!context.sourceCode.text.includes("setState")) {
|
|
232
314
|
return {};
|
|
233
315
|
}
|
|
@@ -318,8 +400,8 @@ function create3(context) {
|
|
|
318
400
|
}
|
|
319
401
|
};
|
|
320
402
|
}
|
|
321
|
-
var
|
|
322
|
-
var
|
|
403
|
+
var RULE_NAME6 = "no-array-index-key";
|
|
404
|
+
var RULE_FEATURES6 = [];
|
|
323
405
|
var reactChildrenMethod = ["forEach", "map"];
|
|
324
406
|
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
325
407
|
["every", 1],
|
|
@@ -403,18 +485,18 @@ var no_array_index_key_default = createRule({
|
|
|
403
485
|
type: "problem",
|
|
404
486
|
docs: {
|
|
405
487
|
description: "Disallow an item's index in the array as its key.",
|
|
406
|
-
[Symbol.for("rule_features")]:
|
|
488
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
407
489
|
},
|
|
408
490
|
messages: {
|
|
409
491
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
410
492
|
},
|
|
411
493
|
schema: []
|
|
412
494
|
},
|
|
413
|
-
name:
|
|
414
|
-
create:
|
|
495
|
+
name: RULE_NAME6,
|
|
496
|
+
create: create6,
|
|
415
497
|
defaultOptions: []
|
|
416
498
|
});
|
|
417
|
-
function
|
|
499
|
+
function create6(context) {
|
|
418
500
|
const report = kit.createReport(context);
|
|
419
501
|
const indexParamNames = [];
|
|
420
502
|
function isArrayIndex(node) {
|
|
@@ -512,25 +594,25 @@ function create4(context) {
|
|
|
512
594
|
}
|
|
513
595
|
};
|
|
514
596
|
}
|
|
515
|
-
var
|
|
516
|
-
var
|
|
597
|
+
var RULE_NAME7 = "no-children-count";
|
|
598
|
+
var RULE_FEATURES7 = [];
|
|
517
599
|
var no_children_count_default = createRule({
|
|
518
600
|
meta: {
|
|
519
601
|
type: "problem",
|
|
520
602
|
docs: {
|
|
521
603
|
description: "Disallow `Children.count`.",
|
|
522
|
-
[Symbol.for("rule_features")]:
|
|
604
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
523
605
|
},
|
|
524
606
|
messages: {
|
|
525
607
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
526
608
|
},
|
|
527
609
|
schema: []
|
|
528
610
|
},
|
|
529
|
-
name:
|
|
530
|
-
create:
|
|
611
|
+
name: RULE_NAME7,
|
|
612
|
+
create: create7,
|
|
531
613
|
defaultOptions: []
|
|
532
614
|
});
|
|
533
|
-
function
|
|
615
|
+
function create7(context) {
|
|
534
616
|
return {
|
|
535
617
|
MemberExpression(node) {
|
|
536
618
|
if (core.isChildrenCount(context, node)) {
|
|
@@ -542,25 +624,25 @@ function create5(context) {
|
|
|
542
624
|
}
|
|
543
625
|
};
|
|
544
626
|
}
|
|
545
|
-
var
|
|
546
|
-
var
|
|
627
|
+
var RULE_NAME8 = "no-children-for-each";
|
|
628
|
+
var RULE_FEATURES8 = [];
|
|
547
629
|
var no_children_for_each_default = createRule({
|
|
548
630
|
meta: {
|
|
549
631
|
type: "problem",
|
|
550
632
|
docs: {
|
|
551
633
|
description: "Disallow 'Children.forEach'.",
|
|
552
|
-
[Symbol.for("rule_features")]:
|
|
634
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
553
635
|
},
|
|
554
636
|
messages: {
|
|
555
637
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
556
638
|
},
|
|
557
639
|
schema: []
|
|
558
640
|
},
|
|
559
|
-
name:
|
|
560
|
-
create:
|
|
641
|
+
name: RULE_NAME8,
|
|
642
|
+
create: create8,
|
|
561
643
|
defaultOptions: []
|
|
562
644
|
});
|
|
563
|
-
function
|
|
645
|
+
function create8(context) {
|
|
564
646
|
return {
|
|
565
647
|
MemberExpression(node) {
|
|
566
648
|
if (core.isChildrenForEach(context, node)) {
|
|
@@ -572,25 +654,25 @@ function create6(context) {
|
|
|
572
654
|
}
|
|
573
655
|
};
|
|
574
656
|
}
|
|
575
|
-
var
|
|
576
|
-
var
|
|
657
|
+
var RULE_NAME9 = "no-children-map";
|
|
658
|
+
var RULE_FEATURES9 = [];
|
|
577
659
|
var no_children_map_default = createRule({
|
|
578
660
|
meta: {
|
|
579
661
|
type: "problem",
|
|
580
662
|
docs: {
|
|
581
663
|
description: "Disallow `Children.map`.",
|
|
582
|
-
[Symbol.for("rule_features")]:
|
|
664
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
583
665
|
},
|
|
584
666
|
messages: {
|
|
585
667
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
586
668
|
},
|
|
587
669
|
schema: []
|
|
588
670
|
},
|
|
589
|
-
name:
|
|
590
|
-
create:
|
|
671
|
+
name: RULE_NAME9,
|
|
672
|
+
create: create9,
|
|
591
673
|
defaultOptions: []
|
|
592
674
|
});
|
|
593
|
-
function
|
|
675
|
+
function create9(context) {
|
|
594
676
|
return {
|
|
595
677
|
MemberExpression(node) {
|
|
596
678
|
if (core.isChildrenMap(context, node)) {
|
|
@@ -602,25 +684,25 @@ function create7(context) {
|
|
|
602
684
|
}
|
|
603
685
|
};
|
|
604
686
|
}
|
|
605
|
-
var
|
|
606
|
-
var
|
|
687
|
+
var RULE_NAME10 = "no-children-only";
|
|
688
|
+
var RULE_FEATURES10 = [];
|
|
607
689
|
var no_children_only_default = createRule({
|
|
608
690
|
meta: {
|
|
609
691
|
type: "problem",
|
|
610
692
|
docs: {
|
|
611
693
|
description: "Disallow `Children.only`.",
|
|
612
|
-
[Symbol.for("rule_features")]:
|
|
694
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
613
695
|
},
|
|
614
696
|
messages: {
|
|
615
697
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
616
698
|
},
|
|
617
699
|
schema: []
|
|
618
700
|
},
|
|
619
|
-
name:
|
|
620
|
-
create:
|
|
701
|
+
name: RULE_NAME10,
|
|
702
|
+
create: create10,
|
|
621
703
|
defaultOptions: []
|
|
622
704
|
});
|
|
623
|
-
function
|
|
705
|
+
function create10(context) {
|
|
624
706
|
return {
|
|
625
707
|
MemberExpression(node) {
|
|
626
708
|
if (core.isChildrenOnly(context, node)) {
|
|
@@ -632,25 +714,25 @@ function create8(context) {
|
|
|
632
714
|
}
|
|
633
715
|
};
|
|
634
716
|
}
|
|
635
|
-
var
|
|
636
|
-
var
|
|
717
|
+
var RULE_NAME11 = "no-children-prop";
|
|
718
|
+
var RULE_FEATURES11 = [];
|
|
637
719
|
var no_children_prop_default = createRule({
|
|
638
720
|
meta: {
|
|
639
721
|
type: "problem",
|
|
640
722
|
docs: {
|
|
641
723
|
description: "Disallow passing `children` as a prop.",
|
|
642
|
-
[Symbol.for("rule_features")]:
|
|
724
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
643
725
|
},
|
|
644
726
|
messages: {
|
|
645
727
|
noChildrenProp: "Do not pass 'children' as props."
|
|
646
728
|
},
|
|
647
729
|
schema: []
|
|
648
730
|
},
|
|
649
|
-
name:
|
|
650
|
-
create:
|
|
731
|
+
name: RULE_NAME11,
|
|
732
|
+
create: create11,
|
|
651
733
|
defaultOptions: []
|
|
652
734
|
});
|
|
653
|
-
function
|
|
735
|
+
function create11(context) {
|
|
654
736
|
return {
|
|
655
737
|
JSXElement(node) {
|
|
656
738
|
const attribute = JSX8__namespace.getAttribute(
|
|
@@ -667,25 +749,25 @@ function create9(context) {
|
|
|
667
749
|
}
|
|
668
750
|
};
|
|
669
751
|
}
|
|
670
|
-
var
|
|
671
|
-
var
|
|
752
|
+
var RULE_NAME12 = "no-children-to-array";
|
|
753
|
+
var RULE_FEATURES12 = [];
|
|
672
754
|
var no_children_to_array_default = createRule({
|
|
673
755
|
meta: {
|
|
674
756
|
type: "problem",
|
|
675
757
|
docs: {
|
|
676
758
|
description: "Disallow `Children.toArray`.",
|
|
677
|
-
[Symbol.for("rule_features")]:
|
|
759
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
678
760
|
},
|
|
679
761
|
messages: {
|
|
680
762
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
681
763
|
},
|
|
682
764
|
schema: []
|
|
683
765
|
},
|
|
684
|
-
name:
|
|
685
|
-
create:
|
|
766
|
+
name: RULE_NAME12,
|
|
767
|
+
create: create12,
|
|
686
768
|
defaultOptions: []
|
|
687
769
|
});
|
|
688
|
-
function
|
|
770
|
+
function create12(context) {
|
|
689
771
|
return {
|
|
690
772
|
MemberExpression(node) {
|
|
691
773
|
if (core.isChildrenToArray(context, node)) {
|
|
@@ -697,25 +779,25 @@ function create10(context) {
|
|
|
697
779
|
}
|
|
698
780
|
};
|
|
699
781
|
}
|
|
700
|
-
var
|
|
701
|
-
var
|
|
782
|
+
var RULE_NAME13 = "no-class-component";
|
|
783
|
+
var RULE_FEATURES13 = [];
|
|
702
784
|
var no_class_component_default = createRule({
|
|
703
785
|
meta: {
|
|
704
786
|
type: "problem",
|
|
705
787
|
docs: {
|
|
706
788
|
description: "Disallow class components.",
|
|
707
|
-
[Symbol.for("rule_features")]:
|
|
789
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
708
790
|
},
|
|
709
791
|
messages: {
|
|
710
792
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
711
793
|
},
|
|
712
794
|
schema: []
|
|
713
795
|
},
|
|
714
|
-
name:
|
|
715
|
-
create:
|
|
796
|
+
name: RULE_NAME13,
|
|
797
|
+
create: create13,
|
|
716
798
|
defaultOptions: []
|
|
717
799
|
});
|
|
718
|
-
function
|
|
800
|
+
function create13(context) {
|
|
719
801
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
720
802
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
721
803
|
return {
|
|
@@ -737,25 +819,25 @@ function create11(context) {
|
|
|
737
819
|
}
|
|
738
820
|
};
|
|
739
821
|
}
|
|
740
|
-
var
|
|
741
|
-
var
|
|
822
|
+
var RULE_NAME14 = "no-clone-element";
|
|
823
|
+
var RULE_FEATURES14 = [];
|
|
742
824
|
var no_clone_element_default = createRule({
|
|
743
825
|
meta: {
|
|
744
826
|
type: "problem",
|
|
745
827
|
docs: {
|
|
746
828
|
description: "Disallow `cloneElement`.",
|
|
747
|
-
[Symbol.for("rule_features")]:
|
|
829
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
748
830
|
},
|
|
749
831
|
messages: {
|
|
750
832
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
751
833
|
},
|
|
752
834
|
schema: []
|
|
753
835
|
},
|
|
754
|
-
name:
|
|
755
|
-
create:
|
|
836
|
+
name: RULE_NAME14,
|
|
837
|
+
create: create14,
|
|
756
838
|
defaultOptions: []
|
|
757
839
|
});
|
|
758
|
-
function
|
|
840
|
+
function create14(context) {
|
|
759
841
|
return {
|
|
760
842
|
CallExpression(node) {
|
|
761
843
|
if (!core.isCloneElementCall(context, node)) {
|
|
@@ -768,25 +850,25 @@ function create12(context) {
|
|
|
768
850
|
}
|
|
769
851
|
};
|
|
770
852
|
}
|
|
771
|
-
var
|
|
772
|
-
var
|
|
853
|
+
var RULE_NAME15 = "no-comment-textnodes";
|
|
854
|
+
var RULE_FEATURES15 = [];
|
|
773
855
|
var no_comment_textnodes_default = createRule({
|
|
774
856
|
meta: {
|
|
775
857
|
type: "problem",
|
|
776
858
|
docs: {
|
|
777
859
|
description: "Prevents comments from being inserted as text nodes.",
|
|
778
|
-
[Symbol.for("rule_features")]:
|
|
860
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
779
861
|
},
|
|
780
862
|
messages: {
|
|
781
863
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
782
864
|
},
|
|
783
865
|
schema: []
|
|
784
866
|
},
|
|
785
|
-
name:
|
|
786
|
-
create:
|
|
867
|
+
name: RULE_NAME15,
|
|
868
|
+
create: create15,
|
|
787
869
|
defaultOptions: []
|
|
788
870
|
});
|
|
789
|
-
function
|
|
871
|
+
function create15(context) {
|
|
790
872
|
function hasCommentLike(node) {
|
|
791
873
|
if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
792
874
|
return false;
|
|
@@ -814,25 +896,27 @@ function create13(context) {
|
|
|
814
896
|
Literal: visitorFunction
|
|
815
897
|
};
|
|
816
898
|
}
|
|
817
|
-
var
|
|
818
|
-
var
|
|
899
|
+
var RULE_NAME16 = "no-complex-conditional-rendering";
|
|
900
|
+
var RULE_FEATURES16 = [
|
|
901
|
+
"EXP"
|
|
902
|
+
];
|
|
819
903
|
var no_complex_conditional_rendering_default = createRule({
|
|
820
904
|
meta: {
|
|
821
905
|
type: "problem",
|
|
822
906
|
docs: {
|
|
823
907
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
824
|
-
[Symbol.for("rule_features")]:
|
|
908
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
825
909
|
},
|
|
826
910
|
messages: {
|
|
827
911
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
828
912
|
},
|
|
829
913
|
schema: []
|
|
830
914
|
},
|
|
831
|
-
name:
|
|
832
|
-
create:
|
|
915
|
+
name: RULE_NAME16,
|
|
916
|
+
create: create16,
|
|
833
917
|
defaultOptions: []
|
|
834
918
|
});
|
|
835
|
-
function
|
|
919
|
+
function create16(context) {
|
|
836
920
|
const visitorFunction = (node) => {
|
|
837
921
|
const jsxExpContainer = node.parent?.parent;
|
|
838
922
|
if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -857,8 +941,8 @@ function create14(context) {
|
|
|
857
941
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
858
942
|
};
|
|
859
943
|
}
|
|
860
|
-
var
|
|
861
|
-
var
|
|
944
|
+
var RULE_NAME17 = "no-component-will-mount";
|
|
945
|
+
var RULE_FEATURES17 = [
|
|
862
946
|
"MOD"
|
|
863
947
|
];
|
|
864
948
|
function isComponentWillMount(node) {
|
|
@@ -869,7 +953,7 @@ var no_component_will_mount_default = createRule({
|
|
|
869
953
|
type: "problem",
|
|
870
954
|
docs: {
|
|
871
955
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
872
|
-
[Symbol.for("rule_features")]:
|
|
956
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
873
957
|
},
|
|
874
958
|
fixable: "code",
|
|
875
959
|
messages: {
|
|
@@ -877,11 +961,11 @@ var no_component_will_mount_default = createRule({
|
|
|
877
961
|
},
|
|
878
962
|
schema: []
|
|
879
963
|
},
|
|
880
|
-
name:
|
|
881
|
-
create:
|
|
964
|
+
name: RULE_NAME17,
|
|
965
|
+
create: create17,
|
|
882
966
|
defaultOptions: []
|
|
883
967
|
});
|
|
884
|
-
function
|
|
968
|
+
function create17(context) {
|
|
885
969
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
886
970
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
887
971
|
return {
|
|
@@ -908,8 +992,8 @@ function create15(context) {
|
|
|
908
992
|
}
|
|
909
993
|
};
|
|
910
994
|
}
|
|
911
|
-
var
|
|
912
|
-
var
|
|
995
|
+
var RULE_NAME18 = "no-component-will-receive-props";
|
|
996
|
+
var RULE_FEATURES18 = [
|
|
913
997
|
"MOD"
|
|
914
998
|
];
|
|
915
999
|
function isComponentWillUpdate(node) {
|
|
@@ -920,7 +1004,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
920
1004
|
type: "problem",
|
|
921
1005
|
docs: {
|
|
922
1006
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
923
|
-
[Symbol.for("rule_features")]:
|
|
1007
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
924
1008
|
},
|
|
925
1009
|
fixable: "code",
|
|
926
1010
|
messages: {
|
|
@@ -928,11 +1012,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
928
1012
|
},
|
|
929
1013
|
schema: []
|
|
930
1014
|
},
|
|
931
|
-
name:
|
|
932
|
-
create:
|
|
1015
|
+
name: RULE_NAME18,
|
|
1016
|
+
create: create18,
|
|
933
1017
|
defaultOptions: []
|
|
934
1018
|
});
|
|
935
|
-
function
|
|
1019
|
+
function create18(context) {
|
|
936
1020
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
937
1021
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
938
1022
|
return {
|
|
@@ -959,8 +1043,8 @@ function create16(context) {
|
|
|
959
1043
|
}
|
|
960
1044
|
};
|
|
961
1045
|
}
|
|
962
|
-
var
|
|
963
|
-
var
|
|
1046
|
+
var RULE_NAME19 = "no-component-will-update";
|
|
1047
|
+
var RULE_FEATURES19 = [
|
|
964
1048
|
"MOD"
|
|
965
1049
|
];
|
|
966
1050
|
function isComponentWillUpdate2(node) {
|
|
@@ -971,7 +1055,7 @@ var no_component_will_update_default = createRule({
|
|
|
971
1055
|
type: "problem",
|
|
972
1056
|
docs: {
|
|
973
1057
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
974
|
-
[Symbol.for("rule_features")]:
|
|
1058
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
975
1059
|
},
|
|
976
1060
|
fixable: "code",
|
|
977
1061
|
messages: {
|
|
@@ -979,11 +1063,11 @@ var no_component_will_update_default = createRule({
|
|
|
979
1063
|
},
|
|
980
1064
|
schema: []
|
|
981
1065
|
},
|
|
982
|
-
name:
|
|
983
|
-
create:
|
|
1066
|
+
name: RULE_NAME19,
|
|
1067
|
+
create: create19,
|
|
984
1068
|
defaultOptions: []
|
|
985
1069
|
});
|
|
986
|
-
function
|
|
1070
|
+
function create19(context) {
|
|
987
1071
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
988
1072
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
989
1073
|
return {
|
|
@@ -1010,8 +1094,8 @@ function create17(context) {
|
|
|
1010
1094
|
}
|
|
1011
1095
|
};
|
|
1012
1096
|
}
|
|
1013
|
-
var
|
|
1014
|
-
var
|
|
1097
|
+
var RULE_NAME20 = "no-context-provider";
|
|
1098
|
+
var RULE_FEATURES20 = [
|
|
1015
1099
|
"MOD"
|
|
1016
1100
|
];
|
|
1017
1101
|
var no_context_provider_default = createRule({
|
|
@@ -1019,7 +1103,7 @@ var no_context_provider_default = createRule({
|
|
|
1019
1103
|
type: "problem",
|
|
1020
1104
|
docs: {
|
|
1021
1105
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1022
|
-
[Symbol.for("rule_features")]:
|
|
1106
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1023
1107
|
},
|
|
1024
1108
|
fixable: "code",
|
|
1025
1109
|
messages: {
|
|
@@ -1027,11 +1111,11 @@ var no_context_provider_default = createRule({
|
|
|
1027
1111
|
},
|
|
1028
1112
|
schema: []
|
|
1029
1113
|
},
|
|
1030
|
-
name:
|
|
1031
|
-
create:
|
|
1114
|
+
name: RULE_NAME20,
|
|
1115
|
+
create: create20,
|
|
1032
1116
|
defaultOptions: []
|
|
1033
1117
|
});
|
|
1034
|
-
function
|
|
1118
|
+
function create20(context) {
|
|
1035
1119
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1036
1120
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1037
1121
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1063,25 +1147,25 @@ function create18(context) {
|
|
|
1063
1147
|
}
|
|
1064
1148
|
};
|
|
1065
1149
|
}
|
|
1066
|
-
var
|
|
1067
|
-
var
|
|
1150
|
+
var RULE_NAME21 = "no-create-ref";
|
|
1151
|
+
var RULE_FEATURES21 = [];
|
|
1068
1152
|
var no_create_ref_default = createRule({
|
|
1069
1153
|
meta: {
|
|
1070
1154
|
type: "problem",
|
|
1071
1155
|
docs: {
|
|
1072
1156
|
description: "Disallow `createRef` in function components.",
|
|
1073
|
-
[Symbol.for("rule_features")]:
|
|
1157
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1074
1158
|
},
|
|
1075
1159
|
messages: {
|
|
1076
1160
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1077
1161
|
},
|
|
1078
1162
|
schema: []
|
|
1079
1163
|
},
|
|
1080
|
-
name:
|
|
1081
|
-
create:
|
|
1164
|
+
name: RULE_NAME21,
|
|
1165
|
+
create: create21,
|
|
1082
1166
|
defaultOptions: []
|
|
1083
1167
|
});
|
|
1084
|
-
function
|
|
1168
|
+
function create21(context) {
|
|
1085
1169
|
return {
|
|
1086
1170
|
CallExpression(node) {
|
|
1087
1171
|
if (core.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
|
|
@@ -1090,25 +1174,25 @@ function create19(context) {
|
|
|
1090
1174
|
}
|
|
1091
1175
|
};
|
|
1092
1176
|
}
|
|
1093
|
-
var
|
|
1094
|
-
var
|
|
1177
|
+
var RULE_NAME22 = "no-default-props";
|
|
1178
|
+
var RULE_FEATURES22 = [];
|
|
1095
1179
|
var no_default_props_default = createRule({
|
|
1096
1180
|
meta: {
|
|
1097
1181
|
type: "problem",
|
|
1098
1182
|
docs: {
|
|
1099
1183
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1100
|
-
[Symbol.for("rule_features")]:
|
|
1184
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1101
1185
|
},
|
|
1102
1186
|
messages: {
|
|
1103
1187
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1104
1188
|
},
|
|
1105
1189
|
schema: []
|
|
1106
1190
|
},
|
|
1107
|
-
name:
|
|
1108
|
-
create:
|
|
1191
|
+
name: RULE_NAME22,
|
|
1192
|
+
create: create22,
|
|
1109
1193
|
defaultOptions: []
|
|
1110
1194
|
});
|
|
1111
|
-
function
|
|
1195
|
+
function create22(context) {
|
|
1112
1196
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1113
1197
|
return {
|
|
1114
1198
|
AssignmentExpression(node) {
|
|
@@ -1142,8 +1226,8 @@ function create20(context) {
|
|
|
1142
1226
|
}
|
|
1143
1227
|
};
|
|
1144
1228
|
}
|
|
1145
|
-
var
|
|
1146
|
-
var
|
|
1229
|
+
var RULE_NAME23 = "no-direct-mutation-state";
|
|
1230
|
+
var RULE_FEATURES23 = [];
|
|
1147
1231
|
function isConstructorFunction(node) {
|
|
1148
1232
|
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";
|
|
1149
1233
|
}
|
|
@@ -1152,18 +1236,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1152
1236
|
type: "problem",
|
|
1153
1237
|
docs: {
|
|
1154
1238
|
description: "Disallow direct mutation of `this.state`.",
|
|
1155
|
-
[Symbol.for("rule_features")]:
|
|
1239
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1156
1240
|
},
|
|
1157
1241
|
messages: {
|
|
1158
1242
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1159
1243
|
},
|
|
1160
1244
|
schema: []
|
|
1161
1245
|
},
|
|
1162
|
-
name:
|
|
1163
|
-
create:
|
|
1246
|
+
name: RULE_NAME23,
|
|
1247
|
+
create: create23,
|
|
1164
1248
|
defaultOptions: []
|
|
1165
1249
|
});
|
|
1166
|
-
function
|
|
1250
|
+
function create23(context) {
|
|
1167
1251
|
return {
|
|
1168
1252
|
AssignmentExpression(node) {
|
|
1169
1253
|
if (!core.isAssignmentToThisState(node)) return;
|
|
@@ -1184,67 +1268,25 @@ function create21(context) {
|
|
|
1184
1268
|
}
|
|
1185
1269
|
};
|
|
1186
1270
|
}
|
|
1187
|
-
var
|
|
1188
|
-
var
|
|
1189
|
-
var no_duplicate_jsx_props_default = createRule({
|
|
1190
|
-
meta: {
|
|
1191
|
-
type: "problem",
|
|
1192
|
-
docs: {
|
|
1193
|
-
description: "Disallow duplicate props in JSX elements.",
|
|
1194
|
-
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1195
|
-
},
|
|
1196
|
-
messages: {
|
|
1197
|
-
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1198
|
-
},
|
|
1199
|
-
schema: []
|
|
1200
|
-
},
|
|
1201
|
-
name: RULE_NAME22,
|
|
1202
|
-
create: create22,
|
|
1203
|
-
defaultOptions: []
|
|
1204
|
-
});
|
|
1205
|
-
function create22(context) {
|
|
1206
|
-
return {
|
|
1207
|
-
JSXOpeningElement(node) {
|
|
1208
|
-
const props = [];
|
|
1209
|
-
for (const attr of node.attributes) {
|
|
1210
|
-
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1211
|
-
continue;
|
|
1212
|
-
}
|
|
1213
|
-
const name5 = attr.name.name;
|
|
1214
|
-
if (typeof name5 !== "string") {
|
|
1215
|
-
continue;
|
|
1216
|
-
}
|
|
1217
|
-
if (!props.includes(name5)) {
|
|
1218
|
-
props.push(name5);
|
|
1219
|
-
continue;
|
|
1220
|
-
}
|
|
1221
|
-
context.report({
|
|
1222
|
-
messageId: "noDuplicateJsxProps",
|
|
1223
|
-
node: attr
|
|
1224
|
-
});
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
var RULE_NAME23 = "no-duplicate-key";
|
|
1230
|
-
var RULE_FEATURES23 = [];
|
|
1271
|
+
var RULE_NAME24 = "no-duplicate-key";
|
|
1272
|
+
var RULE_FEATURES24 = [];
|
|
1231
1273
|
var no_duplicate_key_default = createRule({
|
|
1232
1274
|
meta: {
|
|
1233
1275
|
type: "problem",
|
|
1234
1276
|
docs: {
|
|
1235
1277
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1236
|
-
[Symbol.for("rule_features")]:
|
|
1278
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1237
1279
|
},
|
|
1238
1280
|
messages: {
|
|
1239
1281
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1240
1282
|
},
|
|
1241
1283
|
schema: []
|
|
1242
1284
|
},
|
|
1243
|
-
name:
|
|
1244
|
-
create:
|
|
1285
|
+
name: RULE_NAME24,
|
|
1286
|
+
create: create24,
|
|
1245
1287
|
defaultOptions: []
|
|
1246
1288
|
});
|
|
1247
|
-
function
|
|
1289
|
+
function create24(context) {
|
|
1248
1290
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1249
1291
|
return {};
|
|
1250
1292
|
}
|
|
@@ -1308,8 +1350,8 @@ function create23(context) {
|
|
|
1308
1350
|
}
|
|
1309
1351
|
};
|
|
1310
1352
|
}
|
|
1311
|
-
var
|
|
1312
|
-
var
|
|
1353
|
+
var RULE_NAME25 = "no-forward-ref";
|
|
1354
|
+
var RULE_FEATURES25 = [
|
|
1313
1355
|
"MOD"
|
|
1314
1356
|
];
|
|
1315
1357
|
var no_forward_ref_default = createRule({
|
|
@@ -1317,7 +1359,7 @@ var no_forward_ref_default = createRule({
|
|
|
1317
1359
|
type: "problem",
|
|
1318
1360
|
docs: {
|
|
1319
1361
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1320
|
-
[Symbol.for("rule_features")]:
|
|
1362
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1321
1363
|
},
|
|
1322
1364
|
fixable: "code",
|
|
1323
1365
|
messages: {
|
|
@@ -1325,11 +1367,11 @@ var no_forward_ref_default = createRule({
|
|
|
1325
1367
|
},
|
|
1326
1368
|
schema: []
|
|
1327
1369
|
},
|
|
1328
|
-
name:
|
|
1329
|
-
create:
|
|
1370
|
+
name: RULE_NAME25,
|
|
1371
|
+
create: create25,
|
|
1330
1372
|
defaultOptions: []
|
|
1331
1373
|
});
|
|
1332
|
-
function
|
|
1374
|
+
function create25(context) {
|
|
1333
1375
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1334
1376
|
return {};
|
|
1335
1377
|
}
|
|
@@ -1417,25 +1459,27 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1417
1459
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1418
1460
|
];
|
|
1419
1461
|
}
|
|
1420
|
-
var
|
|
1421
|
-
var
|
|
1462
|
+
var RULE_NAME26 = "no-implicit-key";
|
|
1463
|
+
var RULE_FEATURES26 = [
|
|
1464
|
+
"EXP"
|
|
1465
|
+
];
|
|
1422
1466
|
var no_implicit_key_default = createRule({
|
|
1423
1467
|
meta: {
|
|
1424
1468
|
type: "problem",
|
|
1425
1469
|
docs: {
|
|
1426
1470
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1427
|
-
[Symbol.for("rule_features")]:
|
|
1471
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1428
1472
|
},
|
|
1429
1473
|
messages: {
|
|
1430
1474
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1431
1475
|
},
|
|
1432
1476
|
schema: []
|
|
1433
1477
|
},
|
|
1434
|
-
name:
|
|
1435
|
-
create:
|
|
1478
|
+
name: RULE_NAME26,
|
|
1479
|
+
create: create26,
|
|
1436
1480
|
defaultOptions: []
|
|
1437
1481
|
});
|
|
1438
|
-
function
|
|
1482
|
+
function create26(context) {
|
|
1439
1483
|
return {
|
|
1440
1484
|
JSXOpeningElement(node) {
|
|
1441
1485
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1449,8 +1493,8 @@ function create25(context) {
|
|
|
1449
1493
|
}
|
|
1450
1494
|
};
|
|
1451
1495
|
}
|
|
1452
|
-
var
|
|
1453
|
-
var
|
|
1496
|
+
var RULE_NAME27 = "no-leaked-conditional-rendering";
|
|
1497
|
+
var RULE_FEATURES27 = [
|
|
1454
1498
|
"TSC"
|
|
1455
1499
|
];
|
|
1456
1500
|
var tsHelpers = {
|
|
@@ -1536,18 +1580,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1536
1580
|
type: "problem",
|
|
1537
1581
|
docs: {
|
|
1538
1582
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1539
|
-
[Symbol.for("rule_features")]:
|
|
1583
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1540
1584
|
},
|
|
1541
1585
|
messages: {
|
|
1542
1586
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1543
1587
|
},
|
|
1544
1588
|
schema: []
|
|
1545
1589
|
},
|
|
1546
|
-
name:
|
|
1547
|
-
create:
|
|
1590
|
+
name: RULE_NAME27,
|
|
1591
|
+
create: create27,
|
|
1548
1592
|
defaultOptions: []
|
|
1549
1593
|
});
|
|
1550
|
-
function
|
|
1594
|
+
function create27(context) {
|
|
1551
1595
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1552
1596
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1553
1597
|
const allowedVariants = [
|
|
@@ -1604,25 +1648,25 @@ function create26(context) {
|
|
|
1604
1648
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1605
1649
|
};
|
|
1606
1650
|
}
|
|
1607
|
-
var
|
|
1608
|
-
var
|
|
1651
|
+
var RULE_NAME28 = "no-missing-component-display-name";
|
|
1652
|
+
var RULE_FEATURES28 = [];
|
|
1609
1653
|
var no_missing_component_display_name_default = createRule({
|
|
1610
1654
|
meta: {
|
|
1611
1655
|
type: "problem",
|
|
1612
1656
|
docs: {
|
|
1613
1657
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1614
|
-
[Symbol.for("rule_features")]:
|
|
1658
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1615
1659
|
},
|
|
1616
1660
|
messages: {
|
|
1617
1661
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1618
1662
|
},
|
|
1619
1663
|
schema: []
|
|
1620
1664
|
},
|
|
1621
|
-
name:
|
|
1622
|
-
create:
|
|
1665
|
+
name: RULE_NAME28,
|
|
1666
|
+
create: create28,
|
|
1623
1667
|
defaultOptions: []
|
|
1624
1668
|
});
|
|
1625
|
-
function
|
|
1669
|
+
function create28(context) {
|
|
1626
1670
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1627
1671
|
const {
|
|
1628
1672
|
ctx,
|
|
@@ -1657,25 +1701,25 @@ function create27(context) {
|
|
|
1657
1701
|
}
|
|
1658
1702
|
};
|
|
1659
1703
|
}
|
|
1660
|
-
var
|
|
1661
|
-
var
|
|
1704
|
+
var RULE_NAME29 = "no-missing-context-display-name";
|
|
1705
|
+
var RULE_FEATURES29 = [];
|
|
1662
1706
|
var no_missing_context_display_name_default = createRule({
|
|
1663
1707
|
meta: {
|
|
1664
1708
|
type: "problem",
|
|
1665
1709
|
docs: {
|
|
1666
1710
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1667
|
-
[Symbol.for("rule_features")]:
|
|
1711
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1668
1712
|
},
|
|
1669
1713
|
messages: {
|
|
1670
1714
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1671
1715
|
},
|
|
1672
1716
|
schema: []
|
|
1673
1717
|
},
|
|
1674
|
-
name:
|
|
1675
|
-
create:
|
|
1718
|
+
name: RULE_NAME29,
|
|
1719
|
+
create: create29,
|
|
1676
1720
|
defaultOptions: []
|
|
1677
1721
|
});
|
|
1678
|
-
function
|
|
1722
|
+
function create29(context) {
|
|
1679
1723
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1680
1724
|
const createCalls = [];
|
|
1681
1725
|
const displayNameAssignments = [];
|
|
@@ -1713,14 +1757,14 @@ function create28(context) {
|
|
|
1713
1757
|
}
|
|
1714
1758
|
};
|
|
1715
1759
|
}
|
|
1716
|
-
var
|
|
1717
|
-
var
|
|
1760
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1761
|
+
var RULE_FEATURES30 = [];
|
|
1718
1762
|
var no_missing_key_default = createRule({
|
|
1719
1763
|
meta: {
|
|
1720
1764
|
type: "problem",
|
|
1721
1765
|
docs: {
|
|
1722
1766
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1723
|
-
[Symbol.for("rule_features")]:
|
|
1767
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1724
1768
|
},
|
|
1725
1769
|
messages: {
|
|
1726
1770
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1728,11 +1772,11 @@ var no_missing_key_default = createRule({
|
|
|
1728
1772
|
},
|
|
1729
1773
|
schema: []
|
|
1730
1774
|
},
|
|
1731
|
-
name:
|
|
1732
|
-
create:
|
|
1775
|
+
name: RULE_NAME30,
|
|
1776
|
+
create: create30,
|
|
1733
1777
|
defaultOptions: []
|
|
1734
1778
|
});
|
|
1735
|
-
function
|
|
1779
|
+
function create30(context) {
|
|
1736
1780
|
const report = kit.createReport(context);
|
|
1737
1781
|
const state = { isWithinChildrenToArray: false };
|
|
1738
1782
|
function checkIteratorElement(node) {
|
|
@@ -1845,26 +1889,25 @@ function create29(context) {
|
|
|
1845
1889
|
function isArrayFromCall(node) {
|
|
1846
1890
|
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";
|
|
1847
1891
|
}
|
|
1848
|
-
var
|
|
1849
|
-
var
|
|
1892
|
+
var RULE_NAME31 = "no-nested-component-definitions";
|
|
1893
|
+
var RULE_FEATURES31 = [];
|
|
1850
1894
|
var no_nested_component_definitions_default = createRule({
|
|
1851
1895
|
meta: {
|
|
1852
1896
|
type: "problem",
|
|
1853
1897
|
docs: {
|
|
1854
1898
|
description: "Disallow nesting component definitions inside other components.",
|
|
1855
|
-
[Symbol.for("rule_features")]:
|
|
1899
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1856
1900
|
},
|
|
1857
1901
|
messages: {
|
|
1858
|
-
|
|
1859
|
-
noNestedComponentDefinitionInProps: "Do not nest component definitions inside props. Move it to the top level or pass it as a prop."
|
|
1902
|
+
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1860
1903
|
},
|
|
1861
1904
|
schema: []
|
|
1862
1905
|
},
|
|
1863
|
-
name:
|
|
1864
|
-
create:
|
|
1906
|
+
name: RULE_NAME31,
|
|
1907
|
+
create: create31,
|
|
1865
1908
|
defaultOptions: []
|
|
1866
1909
|
});
|
|
1867
|
-
function
|
|
1910
|
+
function create31(context) {
|
|
1868
1911
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1869
1912
|
const collector = core.useComponentCollector(context, { hint });
|
|
1870
1913
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
@@ -1890,10 +1933,11 @@ function create30(context) {
|
|
|
1890
1933
|
if (isInsideJSXAttributeValue(component)) {
|
|
1891
1934
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1892
1935
|
context.report({
|
|
1893
|
-
messageId: "
|
|
1936
|
+
messageId: "noNestedComponentDefinitions",
|
|
1894
1937
|
node: component,
|
|
1895
1938
|
data: {
|
|
1896
|
-
name: name5
|
|
1939
|
+
name: name5,
|
|
1940
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1897
1941
|
}
|
|
1898
1942
|
});
|
|
1899
1943
|
}
|
|
@@ -1901,10 +1945,11 @@ function create30(context) {
|
|
|
1901
1945
|
}
|
|
1902
1946
|
if (isInsideCreateElementProps(context, component)) {
|
|
1903
1947
|
context.report({
|
|
1904
|
-
messageId: "
|
|
1948
|
+
messageId: "noNestedComponentDefinitions",
|
|
1905
1949
|
node: component,
|
|
1906
1950
|
data: {
|
|
1907
|
-
name: name5
|
|
1951
|
+
name: name5,
|
|
1952
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1908
1953
|
}
|
|
1909
1954
|
});
|
|
1910
1955
|
continue;
|
|
@@ -1912,20 +1957,22 @@ function create30(context) {
|
|
|
1912
1957
|
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
1913
1958
|
if (parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1914
1959
|
context.report({
|
|
1915
|
-
messageId:
|
|
1960
|
+
messageId: "noNestedComponentDefinitions",
|
|
1916
1961
|
node: component,
|
|
1917
1962
|
data: {
|
|
1918
|
-
name: name5
|
|
1963
|
+
name: name5,
|
|
1964
|
+
suggestion: component.parent.type === types.AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1919
1965
|
}
|
|
1920
1966
|
});
|
|
1921
1967
|
continue;
|
|
1922
1968
|
}
|
|
1923
1969
|
if (core.isInsideRenderMethod(component)) {
|
|
1924
1970
|
context.report({
|
|
1925
|
-
messageId: "
|
|
1971
|
+
messageId: "noNestedComponentDefinitions",
|
|
1926
1972
|
node: component,
|
|
1927
1973
|
data: {
|
|
1928
|
-
name: name5
|
|
1974
|
+
name: name5,
|
|
1975
|
+
suggestion: "Move it to the top level."
|
|
1929
1976
|
}
|
|
1930
1977
|
});
|
|
1931
1978
|
}
|
|
@@ -1935,10 +1982,11 @@ function create30(context) {
|
|
|
1935
1982
|
continue;
|
|
1936
1983
|
}
|
|
1937
1984
|
context.report({
|
|
1938
|
-
messageId: "
|
|
1985
|
+
messageId: "noNestedComponentDefinitions",
|
|
1939
1986
|
node: component,
|
|
1940
1987
|
data: {
|
|
1941
|
-
name: name5
|
|
1988
|
+
name: name5,
|
|
1989
|
+
suggestion: component.parent.type === types.AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1942
1990
|
}
|
|
1943
1991
|
});
|
|
1944
1992
|
}
|
|
@@ -1955,25 +2003,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1955
2003
|
if (prop == null) return false;
|
|
1956
2004
|
return prop === call.arguments[1];
|
|
1957
2005
|
}
|
|
1958
|
-
var
|
|
1959
|
-
var
|
|
2006
|
+
var RULE_NAME32 = "no-prop-types";
|
|
2007
|
+
var RULE_FEATURES32 = [];
|
|
1960
2008
|
var no_prop_types_default = createRule({
|
|
1961
2009
|
meta: {
|
|
1962
2010
|
type: "problem",
|
|
1963
2011
|
docs: {
|
|
1964
2012
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1965
|
-
[Symbol.for("rule_features")]:
|
|
2013
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1966
2014
|
},
|
|
1967
2015
|
messages: {
|
|
1968
2016
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1969
2017
|
},
|
|
1970
2018
|
schema: []
|
|
1971
2019
|
},
|
|
1972
|
-
name:
|
|
1973
|
-
create:
|
|
2020
|
+
name: RULE_NAME32,
|
|
2021
|
+
create: create32,
|
|
1974
2022
|
defaultOptions: []
|
|
1975
2023
|
});
|
|
1976
|
-
function
|
|
2024
|
+
function create32(context) {
|
|
1977
2025
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1978
2026
|
return {};
|
|
1979
2027
|
}
|
|
@@ -2009,8 +2057,8 @@ function create31(context) {
|
|
|
2009
2057
|
}
|
|
2010
2058
|
};
|
|
2011
2059
|
}
|
|
2012
|
-
var
|
|
2013
|
-
var
|
|
2060
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
2061
|
+
var RULE_FEATURES33 = [];
|
|
2014
2062
|
function isShouldComponentUpdate(node) {
|
|
2015
2063
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2016
2064
|
}
|
|
@@ -2019,18 +2067,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2019
2067
|
type: "problem",
|
|
2020
2068
|
docs: {
|
|
2021
2069
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2022
|
-
[Symbol.for("rule_features")]:
|
|
2070
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
2023
2071
|
},
|
|
2024
2072
|
messages: {
|
|
2025
2073
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2026
2074
|
},
|
|
2027
2075
|
schema: []
|
|
2028
2076
|
},
|
|
2029
|
-
name:
|
|
2030
|
-
create:
|
|
2077
|
+
name: RULE_NAME33,
|
|
2078
|
+
create: create33,
|
|
2031
2079
|
defaultOptions: []
|
|
2032
2080
|
});
|
|
2033
|
-
function
|
|
2081
|
+
function create33(context) {
|
|
2034
2082
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2035
2083
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2036
2084
|
return {
|
|
@@ -2057,8 +2105,8 @@ function create32(context) {
|
|
|
2057
2105
|
}
|
|
2058
2106
|
};
|
|
2059
2107
|
}
|
|
2060
|
-
var
|
|
2061
|
-
var
|
|
2108
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
2109
|
+
var RULE_FEATURES34 = [];
|
|
2062
2110
|
function isComponentDidMount(node) {
|
|
2063
2111
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2064
2112
|
}
|
|
@@ -2067,18 +2115,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2067
2115
|
type: "problem",
|
|
2068
2116
|
docs: {
|
|
2069
2117
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2070
|
-
[Symbol.for("rule_features")]:
|
|
2118
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2071
2119
|
},
|
|
2072
2120
|
messages: {
|
|
2073
2121
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2074
2122
|
},
|
|
2075
2123
|
schema: []
|
|
2076
2124
|
},
|
|
2077
|
-
name:
|
|
2078
|
-
create:
|
|
2125
|
+
name: RULE_NAME34,
|
|
2126
|
+
create: create34,
|
|
2079
2127
|
defaultOptions: []
|
|
2080
2128
|
});
|
|
2081
|
-
function
|
|
2129
|
+
function create34(context) {
|
|
2082
2130
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2083
2131
|
return {
|
|
2084
2132
|
CallExpression(node) {
|
|
@@ -2099,8 +2147,8 @@ function create33(context) {
|
|
|
2099
2147
|
}
|
|
2100
2148
|
};
|
|
2101
2149
|
}
|
|
2102
|
-
var
|
|
2103
|
-
var
|
|
2150
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
2151
|
+
var RULE_FEATURES35 = [];
|
|
2104
2152
|
function isComponentDidUpdate(node) {
|
|
2105
2153
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2106
2154
|
}
|
|
@@ -2109,18 +2157,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2109
2157
|
type: "problem",
|
|
2110
2158
|
docs: {
|
|
2111
2159
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2112
|
-
[Symbol.for("rule_features")]:
|
|
2160
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2113
2161
|
},
|
|
2114
2162
|
messages: {
|
|
2115
2163
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2116
2164
|
},
|
|
2117
2165
|
schema: []
|
|
2118
2166
|
},
|
|
2119
|
-
name:
|
|
2120
|
-
create:
|
|
2167
|
+
name: RULE_NAME35,
|
|
2168
|
+
create: create35,
|
|
2121
2169
|
defaultOptions: []
|
|
2122
2170
|
});
|
|
2123
|
-
function
|
|
2171
|
+
function create35(context) {
|
|
2124
2172
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2125
2173
|
return {
|
|
2126
2174
|
CallExpression(node) {
|
|
@@ -2141,8 +2189,8 @@ function create34(context) {
|
|
|
2141
2189
|
}
|
|
2142
2190
|
};
|
|
2143
2191
|
}
|
|
2144
|
-
var
|
|
2145
|
-
var
|
|
2192
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
2193
|
+
var RULE_FEATURES36 = [];
|
|
2146
2194
|
function isComponentWillUpdate3(node) {
|
|
2147
2195
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2148
2196
|
}
|
|
@@ -2151,18 +2199,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2151
2199
|
type: "problem",
|
|
2152
2200
|
docs: {
|
|
2153
2201
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2154
|
-
[Symbol.for("rule_features")]:
|
|
2202
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2155
2203
|
},
|
|
2156
2204
|
messages: {
|
|
2157
2205
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2158
2206
|
},
|
|
2159
2207
|
schema: []
|
|
2160
2208
|
},
|
|
2161
|
-
name:
|
|
2162
|
-
create:
|
|
2209
|
+
name: RULE_NAME36,
|
|
2210
|
+
create: create36,
|
|
2163
2211
|
defaultOptions: []
|
|
2164
2212
|
});
|
|
2165
|
-
function
|
|
2213
|
+
function create36(context) {
|
|
2166
2214
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2167
2215
|
return {
|
|
2168
2216
|
CallExpression(node) {
|
|
@@ -2183,8 +2231,8 @@ function create35(context) {
|
|
|
2183
2231
|
}
|
|
2184
2232
|
};
|
|
2185
2233
|
}
|
|
2186
|
-
var
|
|
2187
|
-
var
|
|
2234
|
+
var RULE_NAME37 = "no-string-refs";
|
|
2235
|
+
var RULE_FEATURES37 = [];
|
|
2188
2236
|
function containsStringLiteral({ value }) {
|
|
2189
2237
|
return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2190
2238
|
}
|
|
@@ -2202,18 +2250,18 @@ var no_string_refs_default = createRule({
|
|
|
2202
2250
|
type: "problem",
|
|
2203
2251
|
docs: {
|
|
2204
2252
|
description: "Disallow deprecated string `refs`.",
|
|
2205
|
-
[Symbol.for("rule_features")]:
|
|
2253
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2206
2254
|
},
|
|
2207
2255
|
messages: {
|
|
2208
2256
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2209
2257
|
},
|
|
2210
2258
|
schema: []
|
|
2211
2259
|
},
|
|
2212
|
-
name:
|
|
2213
|
-
create:
|
|
2260
|
+
name: RULE_NAME37,
|
|
2261
|
+
create: create37,
|
|
2214
2262
|
defaultOptions: []
|
|
2215
2263
|
});
|
|
2216
|
-
function
|
|
2264
|
+
function create37(context) {
|
|
2217
2265
|
return {
|
|
2218
2266
|
JSXAttribute(node) {
|
|
2219
2267
|
if (node.name.name !== "ref") {
|
|
@@ -2228,8 +2276,8 @@ function create36(context) {
|
|
|
2228
2276
|
}
|
|
2229
2277
|
};
|
|
2230
2278
|
}
|
|
2231
|
-
var
|
|
2232
|
-
var
|
|
2279
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
2280
|
+
var RULE_FEATURES38 = [];
|
|
2233
2281
|
function isUnsafeComponentWillMount(node) {
|
|
2234
2282
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2235
2283
|
}
|
|
@@ -2238,18 +2286,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2238
2286
|
type: "problem",
|
|
2239
2287
|
docs: {
|
|
2240
2288
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2241
|
-
[Symbol.for("rule_features")]:
|
|
2289
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2242
2290
|
},
|
|
2243
2291
|
messages: {
|
|
2244
2292
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2245
2293
|
},
|
|
2246
2294
|
schema: []
|
|
2247
2295
|
},
|
|
2248
|
-
name:
|
|
2249
|
-
create:
|
|
2296
|
+
name: RULE_NAME38,
|
|
2297
|
+
create: create38,
|
|
2250
2298
|
defaultOptions: []
|
|
2251
2299
|
});
|
|
2252
|
-
function
|
|
2300
|
+
function create38(context) {
|
|
2253
2301
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2254
2302
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2255
2303
|
return {
|
|
@@ -2270,8 +2318,8 @@ function create37(context) {
|
|
|
2270
2318
|
}
|
|
2271
2319
|
};
|
|
2272
2320
|
}
|
|
2273
|
-
var
|
|
2274
|
-
var
|
|
2321
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
2322
|
+
var RULE_FEATURES39 = [];
|
|
2275
2323
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2276
2324
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2277
2325
|
}
|
|
@@ -2280,18 +2328,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2280
2328
|
type: "problem",
|
|
2281
2329
|
docs: {
|
|
2282
2330
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2283
|
-
[Symbol.for("rule_features")]:
|
|
2331
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2284
2332
|
},
|
|
2285
2333
|
messages: {
|
|
2286
2334
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2287
2335
|
},
|
|
2288
2336
|
schema: []
|
|
2289
2337
|
},
|
|
2290
|
-
name:
|
|
2291
|
-
create:
|
|
2338
|
+
name: RULE_NAME39,
|
|
2339
|
+
create: create39,
|
|
2292
2340
|
defaultOptions: []
|
|
2293
2341
|
});
|
|
2294
|
-
function
|
|
2342
|
+
function create39(context) {
|
|
2295
2343
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2296
2344
|
return {};
|
|
2297
2345
|
}
|
|
@@ -2314,8 +2362,8 @@ function create38(context) {
|
|
|
2314
2362
|
}
|
|
2315
2363
|
};
|
|
2316
2364
|
}
|
|
2317
|
-
var
|
|
2318
|
-
var
|
|
2365
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
2366
|
+
var RULE_FEATURES40 = [];
|
|
2319
2367
|
function isUnsafeComponentWillUpdate(node) {
|
|
2320
2368
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2321
2369
|
}
|
|
@@ -2324,18 +2372,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2324
2372
|
type: "problem",
|
|
2325
2373
|
docs: {
|
|
2326
2374
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2327
|
-
[Symbol.for("rule_features")]:
|
|
2375
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2328
2376
|
},
|
|
2329
2377
|
messages: {
|
|
2330
2378
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2331
2379
|
},
|
|
2332
2380
|
schema: []
|
|
2333
2381
|
},
|
|
2334
|
-
name:
|
|
2335
|
-
create:
|
|
2382
|
+
name: RULE_NAME40,
|
|
2383
|
+
create: create40,
|
|
2336
2384
|
defaultOptions: []
|
|
2337
2385
|
});
|
|
2338
|
-
function
|
|
2386
|
+
function create40(context) {
|
|
2339
2387
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2340
2388
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2341
2389
|
return {
|
|
@@ -2356,25 +2404,25 @@ function create39(context) {
|
|
|
2356
2404
|
}
|
|
2357
2405
|
};
|
|
2358
2406
|
}
|
|
2359
|
-
var
|
|
2360
|
-
var
|
|
2407
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
2408
|
+
var RULE_FEATURES41 = [];
|
|
2361
2409
|
var no_unstable_context_value_default = createRule({
|
|
2362
2410
|
meta: {
|
|
2363
2411
|
type: "problem",
|
|
2364
2412
|
docs: {
|
|
2365
2413
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2366
|
-
[Symbol.for("rule_features")]:
|
|
2414
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2367
2415
|
},
|
|
2368
2416
|
messages: {
|
|
2369
2417
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2370
2418
|
},
|
|
2371
2419
|
schema: []
|
|
2372
2420
|
},
|
|
2373
|
-
name:
|
|
2374
|
-
create:
|
|
2421
|
+
name: RULE_NAME41,
|
|
2422
|
+
create: create41,
|
|
2375
2423
|
defaultOptions: []
|
|
2376
2424
|
});
|
|
2377
|
-
function
|
|
2425
|
+
function create41(context) {
|
|
2378
2426
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2379
2427
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2380
2428
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2429,25 +2477,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2429
2477
|
}
|
|
2430
2478
|
return false;
|
|
2431
2479
|
}
|
|
2432
|
-
var
|
|
2433
|
-
var
|
|
2480
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2481
|
+
var RULE_FEATURES42 = [];
|
|
2434
2482
|
var no_unstable_default_props_default = createRule({
|
|
2435
2483
|
meta: {
|
|
2436
2484
|
type: "problem",
|
|
2437
2485
|
docs: {
|
|
2438
2486
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2439
|
-
[Symbol.for("rule_features")]:
|
|
2487
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2440
2488
|
},
|
|
2441
2489
|
messages: {
|
|
2442
2490
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2443
2491
|
},
|
|
2444
2492
|
schema: []
|
|
2445
2493
|
},
|
|
2446
|
-
name:
|
|
2447
|
-
create:
|
|
2494
|
+
name: RULE_NAME42,
|
|
2495
|
+
create: create42,
|
|
2448
2496
|
defaultOptions: []
|
|
2449
2497
|
});
|
|
2450
|
-
function
|
|
2498
|
+
function create42(context) {
|
|
2451
2499
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2452
2500
|
const declarators = /* @__PURE__ */ new Map();
|
|
2453
2501
|
return {
|
|
@@ -2503,8 +2551,8 @@ function create41(context) {
|
|
|
2503
2551
|
}
|
|
2504
2552
|
};
|
|
2505
2553
|
}
|
|
2506
|
-
var
|
|
2507
|
-
var
|
|
2554
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2555
|
+
var RULE_FEATURES43 = [];
|
|
2508
2556
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2509
2557
|
"componentDidCatch",
|
|
2510
2558
|
"componentDidMount",
|
|
@@ -2530,18 +2578,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2530
2578
|
type: "problem",
|
|
2531
2579
|
docs: {
|
|
2532
2580
|
description: "Warns unused class component methods and properties.",
|
|
2533
|
-
[Symbol.for("rule_features")]:
|
|
2581
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2534
2582
|
},
|
|
2535
2583
|
messages: {
|
|
2536
2584
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2537
2585
|
},
|
|
2538
2586
|
schema: []
|
|
2539
2587
|
},
|
|
2540
|
-
name:
|
|
2541
|
-
create:
|
|
2588
|
+
name: RULE_NAME43,
|
|
2589
|
+
create: create43,
|
|
2542
2590
|
defaultOptions: []
|
|
2543
2591
|
});
|
|
2544
|
-
function
|
|
2592
|
+
function create43(context) {
|
|
2545
2593
|
const classEntries = [];
|
|
2546
2594
|
const methodEntries = [];
|
|
2547
2595
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2651,8 +2699,8 @@ function create42(context) {
|
|
|
2651
2699
|
}
|
|
2652
2700
|
};
|
|
2653
2701
|
}
|
|
2654
|
-
var
|
|
2655
|
-
var
|
|
2702
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2703
|
+
var RULE_FEATURES44 = [];
|
|
2656
2704
|
function isKeyLiteral3(node, key) {
|
|
2657
2705
|
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);
|
|
2658
2706
|
}
|
|
@@ -2661,18 +2709,18 @@ var no_unused_state_default = createRule({
|
|
|
2661
2709
|
type: "problem",
|
|
2662
2710
|
docs: {
|
|
2663
2711
|
description: "Warns unused class component state.",
|
|
2664
|
-
[Symbol.for("rule_features")]:
|
|
2712
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2665
2713
|
},
|
|
2666
2714
|
messages: {
|
|
2667
2715
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2668
2716
|
},
|
|
2669
2717
|
schema: []
|
|
2670
2718
|
},
|
|
2671
|
-
name:
|
|
2672
|
-
create:
|
|
2719
|
+
name: RULE_NAME44,
|
|
2720
|
+
create: create44,
|
|
2673
2721
|
defaultOptions: []
|
|
2674
2722
|
});
|
|
2675
|
-
function
|
|
2723
|
+
function create44(context) {
|
|
2676
2724
|
const classEntries = [];
|
|
2677
2725
|
const methodEntries = [];
|
|
2678
2726
|
const constructorEntries = [];
|
|
@@ -2806,8 +2854,8 @@ function create43(context) {
|
|
|
2806
2854
|
}
|
|
2807
2855
|
};
|
|
2808
2856
|
}
|
|
2809
|
-
var
|
|
2810
|
-
var
|
|
2857
|
+
var RULE_NAME45 = "no-use-context";
|
|
2858
|
+
var RULE_FEATURES45 = [
|
|
2811
2859
|
"MOD"
|
|
2812
2860
|
];
|
|
2813
2861
|
var no_use_context_default = createRule({
|
|
@@ -2815,7 +2863,7 @@ var no_use_context_default = createRule({
|
|
|
2815
2863
|
type: "problem",
|
|
2816
2864
|
docs: {
|
|
2817
2865
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2818
|
-
[Symbol.for("rule_features")]:
|
|
2866
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2819
2867
|
},
|
|
2820
2868
|
fixable: "code",
|
|
2821
2869
|
messages: {
|
|
@@ -2823,11 +2871,11 @@ var no_use_context_default = createRule({
|
|
|
2823
2871
|
},
|
|
2824
2872
|
schema: []
|
|
2825
2873
|
},
|
|
2826
|
-
name:
|
|
2827
|
-
create:
|
|
2874
|
+
name: RULE_NAME45,
|
|
2875
|
+
create: create45,
|
|
2828
2876
|
defaultOptions: []
|
|
2829
2877
|
});
|
|
2830
|
-
function
|
|
2878
|
+
function create45(context) {
|
|
2831
2879
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2832
2880
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2833
2881
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2905,25 +2953,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2905
2953
|
return tokens;
|
|
2906
2954
|
}
|
|
2907
2955
|
}
|
|
2908
|
-
var
|
|
2909
|
-
var
|
|
2956
|
+
var RULE_NAME46 = "no-useless-forward-ref";
|
|
2957
|
+
var RULE_FEATURES46 = [];
|
|
2910
2958
|
var no_useless_forward_ref_default = createRule({
|
|
2911
2959
|
meta: {
|
|
2912
2960
|
type: "problem",
|
|
2913
2961
|
docs: {
|
|
2914
2962
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2915
|
-
[Symbol.for("rule_features")]:
|
|
2963
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2916
2964
|
},
|
|
2917
2965
|
messages: {
|
|
2918
2966
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2919
2967
|
},
|
|
2920
2968
|
schema: []
|
|
2921
2969
|
},
|
|
2922
|
-
name:
|
|
2923
|
-
create:
|
|
2970
|
+
name: RULE_NAME46,
|
|
2971
|
+
create: create46,
|
|
2924
2972
|
defaultOptions: []
|
|
2925
2973
|
});
|
|
2926
|
-
function
|
|
2974
|
+
function create46(context) {
|
|
2927
2975
|
return {
|
|
2928
2976
|
CallExpression(node) {
|
|
2929
2977
|
if (!core.isForwardRefCall(context, node)) {
|
|
@@ -2944,7 +2992,7 @@ function create45(context) {
|
|
|
2944
2992
|
}
|
|
2945
2993
|
};
|
|
2946
2994
|
}
|
|
2947
|
-
var
|
|
2995
|
+
var RULE_NAME47 = "no-useless-fragment";
|
|
2948
2996
|
var defaultOptions = [{
|
|
2949
2997
|
allowExpressions: true
|
|
2950
2998
|
}];
|
|
@@ -2970,11 +3018,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2970
3018
|
}
|
|
2971
3019
|
}]
|
|
2972
3020
|
},
|
|
2973
|
-
name:
|
|
2974
|
-
create:
|
|
3021
|
+
name: RULE_NAME47,
|
|
3022
|
+
create: create47,
|
|
2975
3023
|
defaultOptions
|
|
2976
3024
|
});
|
|
2977
|
-
function
|
|
3025
|
+
function create47(context, [option]) {
|
|
2978
3026
|
const { allowExpressions = true } = option;
|
|
2979
3027
|
return {
|
|
2980
3028
|
JSXElement(node) {
|
|
@@ -3086,8 +3134,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3086
3134
|
}
|
|
3087
3135
|
return;
|
|
3088
3136
|
}
|
|
3089
|
-
var
|
|
3090
|
-
var
|
|
3137
|
+
var RULE_NAME48 = "prefer-destructuring-assignment";
|
|
3138
|
+
var RULE_FEATURES47 = [];
|
|
3091
3139
|
function isMemberExpressionWithObjectName(node) {
|
|
3092
3140
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3093
3141
|
}
|
|
@@ -3096,18 +3144,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3096
3144
|
type: "problem",
|
|
3097
3145
|
docs: {
|
|
3098
3146
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3099
|
-
[Symbol.for("rule_features")]:
|
|
3147
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
3100
3148
|
},
|
|
3101
3149
|
messages: {
|
|
3102
3150
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3103
3151
|
},
|
|
3104
3152
|
schema: []
|
|
3105
3153
|
},
|
|
3106
|
-
name:
|
|
3107
|
-
create:
|
|
3154
|
+
name: RULE_NAME48,
|
|
3155
|
+
create: create48,
|
|
3108
3156
|
defaultOptions: []
|
|
3109
3157
|
});
|
|
3110
|
-
function
|
|
3158
|
+
function create48(context) {
|
|
3111
3159
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3112
3160
|
const memberExpressionWithNames = [];
|
|
3113
3161
|
return {
|
|
@@ -3167,16 +3215,17 @@ function create47(context) {
|
|
|
3167
3215
|
}
|
|
3168
3216
|
};
|
|
3169
3217
|
}
|
|
3170
|
-
var
|
|
3171
|
-
var
|
|
3172
|
-
"FIX"
|
|
3218
|
+
var RULE_NAME49 = "prefer-react-namespace-import";
|
|
3219
|
+
var RULE_FEATURES48 = [
|
|
3220
|
+
"FIX",
|
|
3221
|
+
"EXP"
|
|
3173
3222
|
];
|
|
3174
3223
|
var prefer_react_namespace_import_default = createRule({
|
|
3175
3224
|
meta: {
|
|
3176
3225
|
type: "problem",
|
|
3177
3226
|
docs: {
|
|
3178
3227
|
description: "Enforces React is imported via a namespace import.",
|
|
3179
|
-
[Symbol.for("rule_features")]:
|
|
3228
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3180
3229
|
},
|
|
3181
3230
|
fixable: "code",
|
|
3182
3231
|
messages: {
|
|
@@ -3184,11 +3233,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3184
3233
|
},
|
|
3185
3234
|
schema: []
|
|
3186
3235
|
},
|
|
3187
|
-
name:
|
|
3188
|
-
create:
|
|
3236
|
+
name: RULE_NAME49,
|
|
3237
|
+
create: create49,
|
|
3189
3238
|
defaultOptions: []
|
|
3190
3239
|
});
|
|
3191
|
-
function
|
|
3240
|
+
function create49(context) {
|
|
3192
3241
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3193
3242
|
return {
|
|
3194
3243
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3221,27 +3270,28 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3221
3270
|
}
|
|
3222
3271
|
};
|
|
3223
3272
|
}
|
|
3224
|
-
var
|
|
3225
|
-
var
|
|
3226
|
-
"TSC"
|
|
3273
|
+
var RULE_NAME50 = "prefer-read-only-props";
|
|
3274
|
+
var RULE_FEATURES49 = [
|
|
3275
|
+
"TSC",
|
|
3276
|
+
"EXP"
|
|
3227
3277
|
];
|
|
3228
3278
|
var prefer_read_only_props_default = createRule({
|
|
3229
3279
|
meta: {
|
|
3230
3280
|
type: "problem",
|
|
3231
3281
|
docs: {
|
|
3232
3282
|
description: "Enforces read-only props in components.",
|
|
3233
|
-
[Symbol.for("rule_features")]:
|
|
3283
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3234
3284
|
},
|
|
3235
3285
|
messages: {
|
|
3236
3286
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3237
3287
|
},
|
|
3238
3288
|
schema: []
|
|
3239
3289
|
},
|
|
3240
|
-
name:
|
|
3241
|
-
create:
|
|
3290
|
+
name: RULE_NAME50,
|
|
3291
|
+
create: create50,
|
|
3242
3292
|
defaultOptions: []
|
|
3243
3293
|
});
|
|
3244
|
-
function
|
|
3294
|
+
function create50(context) {
|
|
3245
3295
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3246
3296
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3247
3297
|
return {
|
|
@@ -3271,8 +3321,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3271
3321
|
return true;
|
|
3272
3322
|
}
|
|
3273
3323
|
}
|
|
3274
|
-
var
|
|
3275
|
-
var
|
|
3324
|
+
var RULE_NAME51 = "prefer-shorthand-boolean";
|
|
3325
|
+
var RULE_FEATURES50 = [
|
|
3276
3326
|
"FIX"
|
|
3277
3327
|
];
|
|
3278
3328
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3280,7 +3330,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3280
3330
|
type: "problem",
|
|
3281
3331
|
docs: {
|
|
3282
3332
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3283
|
-
[Symbol.for("rule_features")]:
|
|
3333
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3284
3334
|
},
|
|
3285
3335
|
fixable: "code",
|
|
3286
3336
|
messages: {
|
|
@@ -3288,11 +3338,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3288
3338
|
},
|
|
3289
3339
|
schema: []
|
|
3290
3340
|
},
|
|
3291
|
-
name:
|
|
3292
|
-
create:
|
|
3341
|
+
name: RULE_NAME51,
|
|
3342
|
+
create: create51,
|
|
3293
3343
|
defaultOptions: []
|
|
3294
3344
|
});
|
|
3295
|
-
function
|
|
3345
|
+
function create51(context) {
|
|
3296
3346
|
return {
|
|
3297
3347
|
JSXAttribute(node) {
|
|
3298
3348
|
const { value } = node;
|
|
@@ -3312,8 +3362,8 @@ function create50(context) {
|
|
|
3312
3362
|
}
|
|
3313
3363
|
};
|
|
3314
3364
|
}
|
|
3315
|
-
var
|
|
3316
|
-
var
|
|
3365
|
+
var RULE_NAME52 = "prefer-shorthand-fragment";
|
|
3366
|
+
var RULE_FEATURES51 = [
|
|
3317
3367
|
"FIX"
|
|
3318
3368
|
];
|
|
3319
3369
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3321,7 +3371,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3321
3371
|
type: "problem",
|
|
3322
3372
|
docs: {
|
|
3323
3373
|
description: "Enforces shorthand syntax for fragments.",
|
|
3324
|
-
[Symbol.for("rule_features")]:
|
|
3374
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3325
3375
|
},
|
|
3326
3376
|
fixable: "code",
|
|
3327
3377
|
messages: {
|
|
@@ -3329,11 +3379,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3329
3379
|
},
|
|
3330
3380
|
schema: []
|
|
3331
3381
|
},
|
|
3332
|
-
name:
|
|
3333
|
-
create:
|
|
3382
|
+
name: RULE_NAME52,
|
|
3383
|
+
create: create52,
|
|
3334
3384
|
defaultOptions: []
|
|
3335
3385
|
});
|
|
3336
|
-
function
|
|
3386
|
+
function create52(context) {
|
|
3337
3387
|
return {
|
|
3338
3388
|
JSXElement(node) {
|
|
3339
3389
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
@@ -3358,46 +3408,6 @@ function create51(context) {
|
|
|
3358
3408
|
}
|
|
3359
3409
|
};
|
|
3360
3410
|
}
|
|
3361
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3362
|
-
var RULE_FEATURES51 = [];
|
|
3363
|
-
var use_jsx_vars_default = createRule({
|
|
3364
|
-
meta: {
|
|
3365
|
-
type: "problem",
|
|
3366
|
-
docs: {
|
|
3367
|
-
description: "Marks variables used in JSX as used.",
|
|
3368
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3369
|
-
},
|
|
3370
|
-
messages: {
|
|
3371
|
-
useJsxVars: ""
|
|
3372
|
-
},
|
|
3373
|
-
schema: []
|
|
3374
|
-
},
|
|
3375
|
-
name: RULE_NAME52,
|
|
3376
|
-
create: create52,
|
|
3377
|
-
defaultOptions: []
|
|
3378
|
-
});
|
|
3379
|
-
function create52(context) {
|
|
3380
|
-
return {
|
|
3381
|
-
JSXOpeningElement(node) {
|
|
3382
|
-
switch (node.name.type) {
|
|
3383
|
-
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
3384
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3385
|
-
return;
|
|
3386
|
-
}
|
|
3387
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3388
|
-
break;
|
|
3389
|
-
}
|
|
3390
|
-
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
3391
|
-
const { object } = node.name;
|
|
3392
|
-
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
3393
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3394
|
-
}
|
|
3395
|
-
break;
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
3411
|
|
|
3402
3412
|
// src/plugin.ts
|
|
3403
3413
|
var plugin = {
|
|
@@ -3427,7 +3437,6 @@ var plugin = {
|
|
|
3427
3437
|
"no-create-ref": no_create_ref_default,
|
|
3428
3438
|
"no-default-props": no_default_props_default,
|
|
3429
3439
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3430
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3431
3440
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3432
3441
|
"no-forward-ref": no_forward_ref_default,
|
|
3433
3442
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3457,18 +3466,20 @@ var plugin = {
|
|
|
3457
3466
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3458
3467
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3459
3468
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3460
|
-
|
|
3469
|
+
// Part: JSX only rules
|
|
3470
|
+
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3471
|
+
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3461
3472
|
// Part: deprecated rules
|
|
3462
3473
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3463
3474
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3464
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3465
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3466
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3467
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3468
3475
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3469
3476
|
"no-complicated-conditional-rendering": no_complex_conditional_rendering_default,
|
|
3477
|
+
/** @deprecated Use `jsx-no-duplicate-props` instead */
|
|
3478
|
+
"no-duplicate-jsx-props": jsx_no_duplicate_props_default,
|
|
3470
3479
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3471
|
-
"no-nested-components": no_nested_component_definitions_default
|
|
3480
|
+
"no-nested-components": no_nested_component_definitions_default,
|
|
3481
|
+
/** @deprecated Use `jsx-uses-vars` instead */
|
|
3482
|
+
"use-jsx-vars": jsx_uses_vars_default
|
|
3472
3483
|
}
|
|
3473
3484
|
};
|
|
3474
3485
|
|