eslint-plugin-react-x 1.21.1-next.0 → 1.22.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +264 -261
- package/dist/index.mjs +264 -261
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
|
41
41
|
|
|
42
42
|
// package.json
|
|
43
43
|
var name = "eslint-plugin-react-x";
|
|
44
|
-
var version = "1.
|
|
44
|
+
var version = "1.22.0-beta.0";
|
|
45
45
|
var createRule = shared.createRuleForPlugin("x");
|
|
46
46
|
|
|
47
47
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -145,88 +145,10 @@ var ensure_forward_ref_using_ref_default = createRule({
|
|
|
145
145
|
},
|
|
146
146
|
defaultOptions: []
|
|
147
147
|
});
|
|
148
|
-
var RULE_NAME4 = "
|
|
148
|
+
var RULE_NAME4 = "no-access-state-in-setstate";
|
|
149
149
|
var RULE_FEATURES4 = [
|
|
150
150
|
"CHK"
|
|
151
151
|
];
|
|
152
|
-
var jsx_no_duplicate_props_default = createRule({
|
|
153
|
-
meta: {
|
|
154
|
-
type: "problem",
|
|
155
|
-
docs: {
|
|
156
|
-
description: "disallow duplicate props",
|
|
157
|
-
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
158
|
-
},
|
|
159
|
-
messages: {
|
|
160
|
-
jsxNoDuplicateProps: "Duplicate prop '{{name}}'"
|
|
161
|
-
},
|
|
162
|
-
schema: []
|
|
163
|
-
},
|
|
164
|
-
name: RULE_NAME4,
|
|
165
|
-
create(context) {
|
|
166
|
-
return {
|
|
167
|
-
JSXOpeningElement(node) {
|
|
168
|
-
const props = [];
|
|
169
|
-
for (const attr of node.attributes) {
|
|
170
|
-
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
171
|
-
const name2 = attr.name.name;
|
|
172
|
-
if (!eff.isString(name2)) continue;
|
|
173
|
-
if (!props.includes(name2)) {
|
|
174
|
-
props.push(name2);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
context.report({
|
|
178
|
-
messageId: "jsxNoDuplicateProps",
|
|
179
|
-
node: attr,
|
|
180
|
-
data: { name: name2 }
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
defaultOptions: []
|
|
187
|
-
});
|
|
188
|
-
var RULE_NAME5 = "jsx-uses-vars";
|
|
189
|
-
var RULE_FEATURES5 = [];
|
|
190
|
-
var jsx_uses_vars_default = createRule({
|
|
191
|
-
meta: {
|
|
192
|
-
type: "problem",
|
|
193
|
-
docs: {
|
|
194
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
195
|
-
description: "a helper rule to mark variables as used",
|
|
196
|
-
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
197
|
-
},
|
|
198
|
-
messages: {
|
|
199
|
-
jsxUsesVars: ""
|
|
200
|
-
},
|
|
201
|
-
schema: []
|
|
202
|
-
},
|
|
203
|
-
name: RULE_NAME5,
|
|
204
|
-
create(context) {
|
|
205
|
-
function getName5(node) {
|
|
206
|
-
switch (node.type) {
|
|
207
|
-
case types.AST_NODE_TYPES.JSXIdentifier:
|
|
208
|
-
return eff.O.some(node.name);
|
|
209
|
-
case types.AST_NODE_TYPES.JSXMemberExpression:
|
|
210
|
-
return getName5(node.object);
|
|
211
|
-
default:
|
|
212
|
-
return eff.O.none();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
JSXOpeningElement(node) {
|
|
217
|
-
if (node.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) return;
|
|
218
|
-
eff.O.map(getName5(node.name), (name2) => {
|
|
219
|
-
context.sourceCode.markVariableAsUsed(name2, node);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
defaultOptions: []
|
|
225
|
-
});
|
|
226
|
-
var RULE_NAME6 = "no-access-state-in-setstate";
|
|
227
|
-
var RULE_FEATURES6 = [
|
|
228
|
-
"CHK"
|
|
229
|
-
];
|
|
230
152
|
function getName(node) {
|
|
231
153
|
if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
|
|
232
154
|
return getName(node.expression);
|
|
@@ -247,14 +169,14 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
247
169
|
type: "problem",
|
|
248
170
|
docs: {
|
|
249
171
|
description: "disallow accessing 'this.state' within 'setState'",
|
|
250
|
-
[Symbol.for("rule_features")]:
|
|
172
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
251
173
|
},
|
|
252
174
|
messages: {
|
|
253
175
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
254
176
|
},
|
|
255
177
|
schema: []
|
|
256
178
|
},
|
|
257
|
-
name:
|
|
179
|
+
name: RULE_NAME4,
|
|
258
180
|
create(context) {
|
|
259
181
|
if (!context.sourceCode.text.includes("setState")) return {};
|
|
260
182
|
const classStack = [];
|
|
@@ -325,8 +247,8 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
325
247
|
},
|
|
326
248
|
defaultOptions: []
|
|
327
249
|
});
|
|
328
|
-
var
|
|
329
|
-
var
|
|
250
|
+
var RULE_NAME5 = "no-array-index-key";
|
|
251
|
+
var RULE_FEATURES5 = [
|
|
330
252
|
"CHK"
|
|
331
253
|
];
|
|
332
254
|
var reactChildrenMethod = ["forEach", "map"];
|
|
@@ -394,14 +316,14 @@ var no_array_index_key_default = createRule({
|
|
|
394
316
|
type: "problem",
|
|
395
317
|
docs: {
|
|
396
318
|
description: "disallow using Array index as 'key'",
|
|
397
|
-
[Symbol.for("rule_features")]:
|
|
319
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
398
320
|
},
|
|
399
321
|
messages: {
|
|
400
322
|
noArrayIndexKey: "Do not use Array index as 'key'."
|
|
401
323
|
},
|
|
402
324
|
schema: []
|
|
403
325
|
},
|
|
404
|
-
name:
|
|
326
|
+
name: RULE_NAME5,
|
|
405
327
|
create(context) {
|
|
406
328
|
const indexParamNames = [];
|
|
407
329
|
function isArrayIndex(node) {
|
|
@@ -469,8 +391,8 @@ var no_array_index_key_default = createRule({
|
|
|
469
391
|
},
|
|
470
392
|
defaultOptions: []
|
|
471
393
|
});
|
|
472
|
-
var
|
|
473
|
-
var
|
|
394
|
+
var RULE_NAME6 = "no-children-count";
|
|
395
|
+
var RULE_FEATURES6 = [
|
|
474
396
|
"CHK"
|
|
475
397
|
];
|
|
476
398
|
var no_children_count_default = createRule({
|
|
@@ -478,14 +400,14 @@ var no_children_count_default = createRule({
|
|
|
478
400
|
type: "problem",
|
|
479
401
|
docs: {
|
|
480
402
|
description: "disallow using 'Children.count'",
|
|
481
|
-
[Symbol.for("rule_features")]:
|
|
403
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
482
404
|
},
|
|
483
405
|
messages: {
|
|
484
406
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
485
407
|
},
|
|
486
408
|
schema: []
|
|
487
409
|
},
|
|
488
|
-
name:
|
|
410
|
+
name: RULE_NAME6,
|
|
489
411
|
create(context) {
|
|
490
412
|
return {
|
|
491
413
|
MemberExpression(node) {
|
|
@@ -500,8 +422,8 @@ var no_children_count_default = createRule({
|
|
|
500
422
|
},
|
|
501
423
|
defaultOptions: []
|
|
502
424
|
});
|
|
503
|
-
var
|
|
504
|
-
var
|
|
425
|
+
var RULE_NAME7 = "no-children-for-each";
|
|
426
|
+
var RULE_FEATURES7 = [
|
|
505
427
|
"CHK"
|
|
506
428
|
];
|
|
507
429
|
var no_children_for_each_default = createRule({
|
|
@@ -509,14 +431,14 @@ var no_children_for_each_default = createRule({
|
|
|
509
431
|
type: "problem",
|
|
510
432
|
docs: {
|
|
511
433
|
description: "disallow using 'Children.forEach'",
|
|
512
|
-
[Symbol.for("rule_features")]:
|
|
434
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
513
435
|
},
|
|
514
436
|
messages: {
|
|
515
437
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
516
438
|
},
|
|
517
439
|
schema: []
|
|
518
440
|
},
|
|
519
|
-
name:
|
|
441
|
+
name: RULE_NAME7,
|
|
520
442
|
create(context) {
|
|
521
443
|
return {
|
|
522
444
|
MemberExpression(node) {
|
|
@@ -531,8 +453,8 @@ var no_children_for_each_default = createRule({
|
|
|
531
453
|
},
|
|
532
454
|
defaultOptions: []
|
|
533
455
|
});
|
|
534
|
-
var
|
|
535
|
-
var
|
|
456
|
+
var RULE_NAME8 = "no-children-map";
|
|
457
|
+
var RULE_FEATURES8 = [
|
|
536
458
|
"CHK"
|
|
537
459
|
];
|
|
538
460
|
var no_children_map_default = createRule({
|
|
@@ -540,14 +462,14 @@ var no_children_map_default = createRule({
|
|
|
540
462
|
type: "problem",
|
|
541
463
|
docs: {
|
|
542
464
|
description: "disallow using 'Children.map'",
|
|
543
|
-
[Symbol.for("rule_features")]:
|
|
465
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
544
466
|
},
|
|
545
467
|
messages: {
|
|
546
468
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
547
469
|
},
|
|
548
470
|
schema: []
|
|
549
471
|
},
|
|
550
|
-
name:
|
|
472
|
+
name: RULE_NAME8,
|
|
551
473
|
create(context) {
|
|
552
474
|
return {
|
|
553
475
|
MemberExpression(node) {
|
|
@@ -562,8 +484,8 @@ var no_children_map_default = createRule({
|
|
|
562
484
|
},
|
|
563
485
|
defaultOptions: []
|
|
564
486
|
});
|
|
565
|
-
var
|
|
566
|
-
var
|
|
487
|
+
var RULE_NAME9 = "no-children-only";
|
|
488
|
+
var RULE_FEATURES9 = [
|
|
567
489
|
"CHK"
|
|
568
490
|
];
|
|
569
491
|
var no_children_only_default = createRule({
|
|
@@ -571,14 +493,14 @@ var no_children_only_default = createRule({
|
|
|
571
493
|
type: "problem",
|
|
572
494
|
docs: {
|
|
573
495
|
description: "disallow using 'Children.only'",
|
|
574
|
-
[Symbol.for("rule_features")]:
|
|
496
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
575
497
|
},
|
|
576
498
|
messages: {
|
|
577
499
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
578
500
|
},
|
|
579
501
|
schema: []
|
|
580
502
|
},
|
|
581
|
-
name:
|
|
503
|
+
name: RULE_NAME9,
|
|
582
504
|
create(context) {
|
|
583
505
|
return {
|
|
584
506
|
MemberExpression(node) {
|
|
@@ -593,8 +515,8 @@ var no_children_only_default = createRule({
|
|
|
593
515
|
},
|
|
594
516
|
defaultOptions: []
|
|
595
517
|
});
|
|
596
|
-
var
|
|
597
|
-
var
|
|
518
|
+
var RULE_NAME10 = "no-children-prop";
|
|
519
|
+
var RULE_FEATURES10 = [
|
|
598
520
|
"CHK"
|
|
599
521
|
];
|
|
600
522
|
var no_children_prop_default = createRule({
|
|
@@ -602,14 +524,14 @@ var no_children_prop_default = createRule({
|
|
|
602
524
|
type: "problem",
|
|
603
525
|
docs: {
|
|
604
526
|
description: "disallow passing 'children' as props",
|
|
605
|
-
[Symbol.for("rule_features")]:
|
|
527
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
606
528
|
},
|
|
607
529
|
messages: {
|
|
608
530
|
noChildrenProp: "Do not pass 'children' as props."
|
|
609
531
|
},
|
|
610
532
|
schema: []
|
|
611
533
|
},
|
|
612
|
-
name:
|
|
534
|
+
name: RULE_NAME10,
|
|
613
535
|
create(context) {
|
|
614
536
|
return {
|
|
615
537
|
JSXElement(node) {
|
|
@@ -622,8 +544,8 @@ var no_children_prop_default = createRule({
|
|
|
622
544
|
},
|
|
623
545
|
defaultOptions: []
|
|
624
546
|
});
|
|
625
|
-
var
|
|
626
|
-
var
|
|
547
|
+
var RULE_NAME11 = "no-children-to-array";
|
|
548
|
+
var RULE_FEATURES11 = [
|
|
627
549
|
"CHK"
|
|
628
550
|
];
|
|
629
551
|
var no_children_to_array_default = createRule({
|
|
@@ -631,14 +553,14 @@ var no_children_to_array_default = createRule({
|
|
|
631
553
|
type: "problem",
|
|
632
554
|
docs: {
|
|
633
555
|
description: "disallow using 'Children.toArray'",
|
|
634
|
-
[Symbol.for("rule_features")]:
|
|
556
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
635
557
|
},
|
|
636
558
|
messages: {
|
|
637
559
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
638
560
|
},
|
|
639
561
|
schema: []
|
|
640
562
|
},
|
|
641
|
-
name:
|
|
563
|
+
name: RULE_NAME11,
|
|
642
564
|
create(context) {
|
|
643
565
|
return {
|
|
644
566
|
MemberExpression(node) {
|
|
@@ -653,8 +575,8 @@ var no_children_to_array_default = createRule({
|
|
|
653
575
|
},
|
|
654
576
|
defaultOptions: []
|
|
655
577
|
});
|
|
656
|
-
var
|
|
657
|
-
var
|
|
578
|
+
var RULE_NAME12 = "no-class-component";
|
|
579
|
+
var RULE_FEATURES12 = [
|
|
658
580
|
"CHK"
|
|
659
581
|
];
|
|
660
582
|
var isComponentDidCatch = tsPattern.isMatching({
|
|
@@ -678,14 +600,14 @@ var no_class_component_default = createRule({
|
|
|
678
600
|
type: "problem",
|
|
679
601
|
docs: {
|
|
680
602
|
description: "disallow using class components",
|
|
681
|
-
[Symbol.for("rule_features")]:
|
|
603
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
682
604
|
},
|
|
683
605
|
messages: {
|
|
684
606
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
685
607
|
},
|
|
686
608
|
schema: []
|
|
687
609
|
},
|
|
688
|
-
name:
|
|
610
|
+
name: RULE_NAME12,
|
|
689
611
|
create(context) {
|
|
690
612
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
691
613
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -709,8 +631,8 @@ var no_class_component_default = createRule({
|
|
|
709
631
|
},
|
|
710
632
|
defaultOptions: []
|
|
711
633
|
});
|
|
712
|
-
var
|
|
713
|
-
var
|
|
634
|
+
var RULE_NAME13 = "no-clone-element";
|
|
635
|
+
var RULE_FEATURES13 = [
|
|
714
636
|
"CHK"
|
|
715
637
|
];
|
|
716
638
|
var no_clone_element_default = createRule({
|
|
@@ -718,14 +640,14 @@ var no_clone_element_default = createRule({
|
|
|
718
640
|
type: "problem",
|
|
719
641
|
docs: {
|
|
720
642
|
description: "disallow using 'cloneElement'",
|
|
721
|
-
[Symbol.for("rule_features")]:
|
|
643
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
722
644
|
},
|
|
723
645
|
messages: {
|
|
724
646
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
725
647
|
},
|
|
726
648
|
schema: []
|
|
727
649
|
},
|
|
728
|
-
name:
|
|
650
|
+
name: RULE_NAME13,
|
|
729
651
|
create(context) {
|
|
730
652
|
return {
|
|
731
653
|
CallExpression(node) {
|
|
@@ -739,8 +661,8 @@ var no_clone_element_default = createRule({
|
|
|
739
661
|
},
|
|
740
662
|
defaultOptions: []
|
|
741
663
|
});
|
|
742
|
-
var
|
|
743
|
-
var
|
|
664
|
+
var RULE_NAME14 = "no-comment-textnodes";
|
|
665
|
+
var RULE_FEATURES14 = [
|
|
744
666
|
"CHK"
|
|
745
667
|
];
|
|
746
668
|
var no_comment_textnodes_default = createRule({
|
|
@@ -748,14 +670,14 @@ var no_comment_textnodes_default = createRule({
|
|
|
748
670
|
type: "problem",
|
|
749
671
|
docs: {
|
|
750
672
|
description: "disallow comments from being inserted as text nodes",
|
|
751
|
-
[Symbol.for("rule_features")]:
|
|
673
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
752
674
|
},
|
|
753
675
|
messages: {
|
|
754
676
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
755
677
|
},
|
|
756
678
|
schema: []
|
|
757
679
|
},
|
|
758
|
-
name:
|
|
680
|
+
name: RULE_NAME14,
|
|
759
681
|
create(context) {
|
|
760
682
|
function hasCommentLike(node) {
|
|
761
683
|
if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
|
|
@@ -779,8 +701,8 @@ var no_comment_textnodes_default = createRule({
|
|
|
779
701
|
},
|
|
780
702
|
defaultOptions: []
|
|
781
703
|
});
|
|
782
|
-
var
|
|
783
|
-
var
|
|
704
|
+
var RULE_NAME15 = "no-complex-conditional-rendering";
|
|
705
|
+
var RULE_FEATURES15 = [
|
|
784
706
|
"CHK"
|
|
785
707
|
];
|
|
786
708
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -788,14 +710,14 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
788
710
|
type: "problem",
|
|
789
711
|
docs: {
|
|
790
712
|
description: "disallow complex conditional rendering",
|
|
791
|
-
[Symbol.for("rule_features")]:
|
|
713
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
792
714
|
},
|
|
793
715
|
messages: {
|
|
794
716
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
795
717
|
},
|
|
796
718
|
schema: []
|
|
797
719
|
},
|
|
798
|
-
name:
|
|
720
|
+
name: RULE_NAME15,
|
|
799
721
|
create(context) {
|
|
800
722
|
function getReportDescriptor(node) {
|
|
801
723
|
const jsxExpContainer = node.parent?.parent;
|
|
@@ -817,8 +739,8 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
817
739
|
},
|
|
818
740
|
defaultOptions: []
|
|
819
741
|
});
|
|
820
|
-
var
|
|
821
|
-
var
|
|
742
|
+
var RULE_NAME16 = "no-component-will-mount";
|
|
743
|
+
var RULE_FEATURES16 = [
|
|
822
744
|
"CHK",
|
|
823
745
|
"MOD"
|
|
824
746
|
];
|
|
@@ -830,7 +752,7 @@ var no_component_will_mount_default = createRule({
|
|
|
830
752
|
type: "problem",
|
|
831
753
|
docs: {
|
|
832
754
|
description: "disallow using 'componentWillMount'",
|
|
833
|
-
[Symbol.for("rule_features")]:
|
|
755
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
834
756
|
},
|
|
835
757
|
fixable: "code",
|
|
836
758
|
messages: {
|
|
@@ -838,7 +760,7 @@ var no_component_will_mount_default = createRule({
|
|
|
838
760
|
},
|
|
839
761
|
schema: []
|
|
840
762
|
},
|
|
841
|
-
name:
|
|
763
|
+
name: RULE_NAME16,
|
|
842
764
|
create(context) {
|
|
843
765
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
844
766
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -866,8 +788,8 @@ var no_component_will_mount_default = createRule({
|
|
|
866
788
|
},
|
|
867
789
|
defaultOptions: []
|
|
868
790
|
});
|
|
869
|
-
var
|
|
870
|
-
var
|
|
791
|
+
var RULE_NAME17 = "no-component-will-receive-props";
|
|
792
|
+
var RULE_FEATURES17 = [
|
|
871
793
|
"CHK",
|
|
872
794
|
"MOD"
|
|
873
795
|
];
|
|
@@ -879,7 +801,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
879
801
|
type: "problem",
|
|
880
802
|
docs: {
|
|
881
803
|
description: "disallow using 'componentWillReceiveProps'",
|
|
882
|
-
[Symbol.for("rule_features")]:
|
|
804
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
883
805
|
},
|
|
884
806
|
fixable: "code",
|
|
885
807
|
messages: {
|
|
@@ -887,7 +809,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
887
809
|
},
|
|
888
810
|
schema: []
|
|
889
811
|
},
|
|
890
|
-
name:
|
|
812
|
+
name: RULE_NAME17,
|
|
891
813
|
create(context) {
|
|
892
814
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
893
815
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -915,8 +837,8 @@ var no_component_will_receive_props_default = createRule({
|
|
|
915
837
|
},
|
|
916
838
|
defaultOptions: []
|
|
917
839
|
});
|
|
918
|
-
var
|
|
919
|
-
var
|
|
840
|
+
var RULE_NAME18 = "no-component-will-update";
|
|
841
|
+
var RULE_FEATURES18 = [
|
|
920
842
|
"CHK",
|
|
921
843
|
"MOD"
|
|
922
844
|
];
|
|
@@ -928,7 +850,7 @@ var no_component_will_update_default = createRule({
|
|
|
928
850
|
type: "problem",
|
|
929
851
|
docs: {
|
|
930
852
|
description: "disallow using 'componentWillReceiveProps'",
|
|
931
|
-
[Symbol.for("rule_features")]:
|
|
853
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
932
854
|
},
|
|
933
855
|
fixable: "code",
|
|
934
856
|
messages: {
|
|
@@ -936,7 +858,7 @@ var no_component_will_update_default = createRule({
|
|
|
936
858
|
},
|
|
937
859
|
schema: []
|
|
938
860
|
},
|
|
939
|
-
name:
|
|
861
|
+
name: RULE_NAME18,
|
|
940
862
|
create(context) {
|
|
941
863
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
942
864
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -964,8 +886,8 @@ var no_component_will_update_default = createRule({
|
|
|
964
886
|
},
|
|
965
887
|
defaultOptions: []
|
|
966
888
|
});
|
|
967
|
-
var
|
|
968
|
-
var
|
|
889
|
+
var RULE_NAME19 = "no-context-provider";
|
|
890
|
+
var RULE_FEATURES19 = [
|
|
969
891
|
"CHK",
|
|
970
892
|
"MOD"
|
|
971
893
|
];
|
|
@@ -974,7 +896,7 @@ var no_context_provider_default = createRule({
|
|
|
974
896
|
type: "problem",
|
|
975
897
|
docs: {
|
|
976
898
|
description: "disallow the use of '<Context.Provider>'",
|
|
977
|
-
[Symbol.for("rule_features")]:
|
|
899
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
978
900
|
},
|
|
979
901
|
fixable: "code",
|
|
980
902
|
messages: {
|
|
@@ -982,7 +904,7 @@ var no_context_provider_default = createRule({
|
|
|
982
904
|
},
|
|
983
905
|
schema: []
|
|
984
906
|
},
|
|
985
|
-
name:
|
|
907
|
+
name: RULE_NAME19,
|
|
986
908
|
create(context) {
|
|
987
909
|
if (!context.sourceCode.text.includes(".Provider")) return {};
|
|
988
910
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1010,8 +932,8 @@ var no_context_provider_default = createRule({
|
|
|
1010
932
|
},
|
|
1011
933
|
defaultOptions: []
|
|
1012
934
|
});
|
|
1013
|
-
var
|
|
1014
|
-
var
|
|
935
|
+
var RULE_NAME20 = "no-create-ref";
|
|
936
|
+
var RULE_FEATURES20 = [
|
|
1015
937
|
"CHK"
|
|
1016
938
|
];
|
|
1017
939
|
var no_create_ref_default = createRule({
|
|
@@ -1019,14 +941,14 @@ var no_create_ref_default = createRule({
|
|
|
1019
941
|
type: "problem",
|
|
1020
942
|
docs: {
|
|
1021
943
|
description: "disallow using 'createRef' in function components",
|
|
1022
|
-
[Symbol.for("rule_features")]:
|
|
944
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1023
945
|
},
|
|
1024
946
|
messages: {
|
|
1025
947
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1026
948
|
},
|
|
1027
949
|
schema: []
|
|
1028
950
|
},
|
|
1029
|
-
name:
|
|
951
|
+
name: RULE_NAME20,
|
|
1030
952
|
create(context) {
|
|
1031
953
|
return {
|
|
1032
954
|
CallExpression(node) {
|
|
@@ -1038,8 +960,8 @@ var no_create_ref_default = createRule({
|
|
|
1038
960
|
},
|
|
1039
961
|
defaultOptions: []
|
|
1040
962
|
});
|
|
1041
|
-
var
|
|
1042
|
-
var
|
|
963
|
+
var RULE_NAME21 = "no-default-props";
|
|
964
|
+
var RULE_FEATURES21 = [
|
|
1043
965
|
"CHK"
|
|
1044
966
|
];
|
|
1045
967
|
var no_default_props_default = createRule({
|
|
@@ -1047,14 +969,14 @@ var no_default_props_default = createRule({
|
|
|
1047
969
|
type: "problem",
|
|
1048
970
|
docs: {
|
|
1049
971
|
description: "disallow using 'defaultProps' property in components",
|
|
1050
|
-
[Symbol.for("rule_features")]:
|
|
972
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1051
973
|
},
|
|
1052
974
|
messages: {
|
|
1053
975
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1054
976
|
},
|
|
1055
977
|
schema: []
|
|
1056
978
|
},
|
|
1057
|
-
name:
|
|
979
|
+
name: RULE_NAME21,
|
|
1058
980
|
create(context) {
|
|
1059
981
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1060
982
|
return {
|
|
@@ -1081,8 +1003,8 @@ var no_default_props_default = createRule({
|
|
|
1081
1003
|
},
|
|
1082
1004
|
defaultOptions: []
|
|
1083
1005
|
});
|
|
1084
|
-
var
|
|
1085
|
-
var
|
|
1006
|
+
var RULE_NAME22 = "no-direct-mutation-state";
|
|
1007
|
+
var RULE_FEATURES22 = [
|
|
1086
1008
|
"CHK"
|
|
1087
1009
|
];
|
|
1088
1010
|
function getName2(node) {
|
|
@@ -1112,14 +1034,14 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1112
1034
|
type: "problem",
|
|
1113
1035
|
docs: {
|
|
1114
1036
|
description: "disallow direct mutation of state",
|
|
1115
|
-
[Symbol.for("rule_features")]:
|
|
1037
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1116
1038
|
},
|
|
1117
1039
|
messages: {
|
|
1118
1040
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1119
1041
|
},
|
|
1120
1042
|
schema: []
|
|
1121
1043
|
},
|
|
1122
|
-
name:
|
|
1044
|
+
name: RULE_NAME22,
|
|
1123
1045
|
create(context) {
|
|
1124
1046
|
function getReportDescriptor(node) {
|
|
1125
1047
|
if (!isAssignmentToThisState(node)) return eff.O.none();
|
|
@@ -1143,8 +1065,47 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1143
1065
|
},
|
|
1144
1066
|
defaultOptions: []
|
|
1145
1067
|
});
|
|
1146
|
-
var
|
|
1147
|
-
var
|
|
1068
|
+
var RULE_NAME23 = "no-duplicate-jsx-props";
|
|
1069
|
+
var RULE_FEATURES23 = [
|
|
1070
|
+
"CHK"
|
|
1071
|
+
];
|
|
1072
|
+
var no_duplicate_jsx_props_default = createRule({
|
|
1073
|
+
meta: {
|
|
1074
|
+
type: "problem",
|
|
1075
|
+
docs: {
|
|
1076
|
+
description: "disallow duplicate props",
|
|
1077
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1078
|
+
},
|
|
1079
|
+
messages: {
|
|
1080
|
+
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1081
|
+
},
|
|
1082
|
+
schema: []
|
|
1083
|
+
},
|
|
1084
|
+
name: RULE_NAME23,
|
|
1085
|
+
create(context) {
|
|
1086
|
+
return {
|
|
1087
|
+
JSXOpeningElement(node) {
|
|
1088
|
+
const props = [];
|
|
1089
|
+
for (const attr of node.attributes) {
|
|
1090
|
+
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
1091
|
+
const name2 = attr.name.name;
|
|
1092
|
+
if (!eff.isString(name2)) continue;
|
|
1093
|
+
if (!props.includes(name2)) {
|
|
1094
|
+
props.push(name2);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
context.report({
|
|
1098
|
+
messageId: "noDuplicateJsxProps",
|
|
1099
|
+
node: attr
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
},
|
|
1105
|
+
defaultOptions: []
|
|
1106
|
+
});
|
|
1107
|
+
var RULE_NAME24 = "no-duplicate-key";
|
|
1108
|
+
var RULE_FEATURES24 = [
|
|
1148
1109
|
"CHK"
|
|
1149
1110
|
];
|
|
1150
1111
|
var no_duplicate_key_default = createRule({
|
|
@@ -1152,14 +1113,14 @@ var no_duplicate_key_default = createRule({
|
|
|
1152
1113
|
type: "problem",
|
|
1153
1114
|
docs: {
|
|
1154
1115
|
description: "disallow duplicate keys when rendering list",
|
|
1155
|
-
[Symbol.for("rule_features")]:
|
|
1116
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1156
1117
|
},
|
|
1157
1118
|
messages: {
|
|
1158
1119
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1159
1120
|
},
|
|
1160
1121
|
schema: []
|
|
1161
1122
|
},
|
|
1162
|
-
name:
|
|
1123
|
+
name: RULE_NAME24,
|
|
1163
1124
|
create(context) {
|
|
1164
1125
|
const isWithinChildrenToArrayRef = eff.MutRef.make(false);
|
|
1165
1126
|
function isKeyEqual(a, b) {
|
|
@@ -1276,8 +1237,8 @@ var no_duplicate_key_default = createRule({
|
|
|
1276
1237
|
},
|
|
1277
1238
|
defaultOptions: []
|
|
1278
1239
|
});
|
|
1279
|
-
var
|
|
1280
|
-
var
|
|
1240
|
+
var RULE_NAME25 = "no-forward-ref";
|
|
1241
|
+
var RULE_FEATURES25 = [
|
|
1281
1242
|
"CHK",
|
|
1282
1243
|
"MOD"
|
|
1283
1244
|
];
|
|
@@ -1286,7 +1247,7 @@ var no_forward_ref_default = createRule({
|
|
|
1286
1247
|
type: "problem",
|
|
1287
1248
|
docs: {
|
|
1288
1249
|
description: "disallow the use of 'forwardRef'",
|
|
1289
|
-
[Symbol.for("rule_features")]:
|
|
1250
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1290
1251
|
},
|
|
1291
1252
|
fixable: "code",
|
|
1292
1253
|
messages: {
|
|
@@ -1294,7 +1255,7 @@ var no_forward_ref_default = createRule({
|
|
|
1294
1255
|
},
|
|
1295
1256
|
schema: []
|
|
1296
1257
|
},
|
|
1297
|
-
name:
|
|
1258
|
+
name: RULE_NAME25,
|
|
1298
1259
|
create(context) {
|
|
1299
1260
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
1300
1261
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1373,8 +1334,8 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
|
|
|
1373
1334
|
...arg1 ? [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])] : []
|
|
1374
1335
|
];
|
|
1375
1336
|
}
|
|
1376
|
-
var
|
|
1377
|
-
var
|
|
1337
|
+
var RULE_NAME26 = "no-implicit-key";
|
|
1338
|
+
var RULE_FEATURES26 = [
|
|
1378
1339
|
"CHK"
|
|
1379
1340
|
];
|
|
1380
1341
|
var no_implicit_key_default = createRule({
|
|
@@ -1382,14 +1343,14 @@ var no_implicit_key_default = createRule({
|
|
|
1382
1343
|
type: "problem",
|
|
1383
1344
|
docs: {
|
|
1384
1345
|
description: "disallow implicit 'key' props",
|
|
1385
|
-
[Symbol.for("rule_features")]:
|
|
1346
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1386
1347
|
},
|
|
1387
1348
|
messages: {
|
|
1388
1349
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1389
1350
|
},
|
|
1390
1351
|
schema: []
|
|
1391
1352
|
},
|
|
1392
|
-
name:
|
|
1353
|
+
name: RULE_NAME26,
|
|
1393
1354
|
create(context) {
|
|
1394
1355
|
function getReportDescriptor(node) {
|
|
1395
1356
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1432,8 +1393,8 @@ function isTrueLiteralType(type) {
|
|
|
1432
1393
|
function unionTypeParts(type) {
|
|
1433
1394
|
return isUnionType(type) ? type.types : [type];
|
|
1434
1395
|
}
|
|
1435
|
-
var
|
|
1436
|
-
var
|
|
1396
|
+
var RULE_NAME27 = "no-leaked-conditional-rendering";
|
|
1397
|
+
var RULE_FEATURES27 = [
|
|
1437
1398
|
"CHK",
|
|
1438
1399
|
"TSC"
|
|
1439
1400
|
];
|
|
@@ -1534,14 +1495,14 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1534
1495
|
type: "problem",
|
|
1535
1496
|
docs: {
|
|
1536
1497
|
description: "disallow problematic leaked values from being rendered",
|
|
1537
|
-
[Symbol.for("rule_features")]:
|
|
1498
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1538
1499
|
},
|
|
1539
1500
|
messages: {
|
|
1540
1501
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1541
1502
|
},
|
|
1542
1503
|
schema: []
|
|
1543
1504
|
},
|
|
1544
|
-
name:
|
|
1505
|
+
name: RULE_NAME27,
|
|
1545
1506
|
create(context) {
|
|
1546
1507
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1547
1508
|
const { version: version2 } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
@@ -1598,8 +1559,8 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1598
1559
|
},
|
|
1599
1560
|
defaultOptions: []
|
|
1600
1561
|
});
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1562
|
+
var RULE_NAME28 = "no-missing-component-display-name";
|
|
1563
|
+
var RULE_FEATURES28 = [
|
|
1603
1564
|
"CHK"
|
|
1604
1565
|
];
|
|
1605
1566
|
var no_missing_component_display_name_default = createRule({
|
|
@@ -1607,14 +1568,14 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1607
1568
|
type: "problem",
|
|
1608
1569
|
docs: {
|
|
1609
1570
|
description: "require 'displayName' for 'memo' and 'forwardRef' components",
|
|
1610
|
-
[Symbol.for("rule_features")]:
|
|
1571
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1611
1572
|
},
|
|
1612
1573
|
messages: {
|
|
1613
1574
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1614
1575
|
},
|
|
1615
1576
|
schema: []
|
|
1616
1577
|
},
|
|
1617
|
-
name:
|
|
1578
|
+
name: RULE_NAME28,
|
|
1618
1579
|
create(context) {
|
|
1619
1580
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1620
1581
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -1638,8 +1599,8 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1638
1599
|
},
|
|
1639
1600
|
defaultOptions: []
|
|
1640
1601
|
});
|
|
1641
|
-
var
|
|
1642
|
-
var
|
|
1602
|
+
var RULE_NAME29 = "no-missing-key";
|
|
1603
|
+
var RULE_FEATURES29 = [
|
|
1643
1604
|
"CHK"
|
|
1644
1605
|
];
|
|
1645
1606
|
var no_missing_key_default = createRule({
|
|
@@ -1647,7 +1608,7 @@ var no_missing_key_default = createRule({
|
|
|
1647
1608
|
type: "problem",
|
|
1648
1609
|
docs: {
|
|
1649
1610
|
description: "require 'key' when rendering list",
|
|
1650
|
-
[Symbol.for("rule_features")]:
|
|
1611
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1651
1612
|
},
|
|
1652
1613
|
messages: {
|
|
1653
1614
|
noMissingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1655,7 +1616,7 @@ var no_missing_key_default = createRule({
|
|
|
1655
1616
|
},
|
|
1656
1617
|
schema: []
|
|
1657
1618
|
},
|
|
1658
|
-
name:
|
|
1619
|
+
name: RULE_NAME29,
|
|
1659
1620
|
create(context) {
|
|
1660
1621
|
const isWithinChildrenToArrayRef = eff.MutRef.make(false);
|
|
1661
1622
|
function checkIteratorElement(node) {
|
|
@@ -1759,8 +1720,8 @@ var no_missing_key_default = createRule({
|
|
|
1759
1720
|
},
|
|
1760
1721
|
defaultOptions: []
|
|
1761
1722
|
});
|
|
1762
|
-
var
|
|
1763
|
-
var
|
|
1723
|
+
var RULE_NAME30 = "no-nested-components";
|
|
1724
|
+
var RULE_FEATURES30 = [
|
|
1764
1725
|
"CHK"
|
|
1765
1726
|
];
|
|
1766
1727
|
var no_nested_components_default = createRule({
|
|
@@ -1768,7 +1729,7 @@ var no_nested_components_default = createRule({
|
|
|
1768
1729
|
type: "problem",
|
|
1769
1730
|
docs: {
|
|
1770
1731
|
description: "disallow using unstable nested components",
|
|
1771
|
-
[Symbol.for("rule_features")]:
|
|
1732
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1772
1733
|
},
|
|
1773
1734
|
messages: {
|
|
1774
1735
|
nestedComponent: "Do not nest components inside other components. Move it to the top level.",
|
|
@@ -1776,7 +1737,7 @@ var no_nested_components_default = createRule({
|
|
|
1776
1737
|
},
|
|
1777
1738
|
schema: []
|
|
1778
1739
|
},
|
|
1779
|
-
name:
|
|
1740
|
+
name: RULE_NAME30,
|
|
1780
1741
|
create(context) {
|
|
1781
1742
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefinedLiteral | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1782
1743
|
const collector = core.useComponentCollector(context, hint);
|
|
@@ -1860,8 +1821,8 @@ var no_nested_components_default = createRule({
|
|
|
1860
1821
|
},
|
|
1861
1822
|
defaultOptions: []
|
|
1862
1823
|
});
|
|
1863
|
-
var
|
|
1864
|
-
var
|
|
1824
|
+
var RULE_NAME31 = "no-prop-types";
|
|
1825
|
+
var RULE_FEATURES31 = [
|
|
1865
1826
|
"CHK"
|
|
1866
1827
|
];
|
|
1867
1828
|
var no_prop_types_default = createRule({
|
|
@@ -1869,14 +1830,14 @@ var no_prop_types_default = createRule({
|
|
|
1869
1830
|
type: "problem",
|
|
1870
1831
|
docs: {
|
|
1871
1832
|
description: "disallow using 'propTypes' property in components",
|
|
1872
|
-
[Symbol.for("rule_features")]:
|
|
1833
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1873
1834
|
},
|
|
1874
1835
|
messages: {
|
|
1875
1836
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1876
1837
|
},
|
|
1877
1838
|
schema: []
|
|
1878
1839
|
},
|
|
1879
|
-
name:
|
|
1840
|
+
name: RULE_NAME31,
|
|
1880
1841
|
create(context) {
|
|
1881
1842
|
if (!context.sourceCode.text.includes("propTypes")) return {};
|
|
1882
1843
|
return {
|
|
@@ -1903,8 +1864,8 @@ var no_prop_types_default = createRule({
|
|
|
1903
1864
|
},
|
|
1904
1865
|
defaultOptions: []
|
|
1905
1866
|
});
|
|
1906
|
-
var
|
|
1907
|
-
var
|
|
1867
|
+
var RULE_NAME32 = "no-redundant-should-component-update";
|
|
1868
|
+
var RULE_FEATURES32 = [
|
|
1908
1869
|
"CHK"
|
|
1909
1870
|
];
|
|
1910
1871
|
function isShouldComponentUpdate(node) {
|
|
@@ -1915,14 +1876,14 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1915
1876
|
type: "problem",
|
|
1916
1877
|
docs: {
|
|
1917
1878
|
description: "disallow using 'shouldComponentUpdate' in class component extends 'React.PureComponent'",
|
|
1918
|
-
[Symbol.for("rule_features")]:
|
|
1879
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1919
1880
|
},
|
|
1920
1881
|
messages: {
|
|
1921
1882
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
1922
1883
|
},
|
|
1923
1884
|
schema: []
|
|
1924
1885
|
},
|
|
1925
|
-
name:
|
|
1886
|
+
name: RULE_NAME32,
|
|
1926
1887
|
create(context) {
|
|
1927
1888
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
1928
1889
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -1950,8 +1911,8 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1950
1911
|
},
|
|
1951
1912
|
defaultOptions: []
|
|
1952
1913
|
});
|
|
1953
|
-
var
|
|
1954
|
-
var
|
|
1914
|
+
var RULE_NAME33 = "no-set-state-in-component-did-mount";
|
|
1915
|
+
var RULE_FEATURES33 = [
|
|
1955
1916
|
"CHK"
|
|
1956
1917
|
];
|
|
1957
1918
|
function isComponentDidMount(node) {
|
|
@@ -1962,14 +1923,14 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1962
1923
|
type: "problem",
|
|
1963
1924
|
docs: {
|
|
1964
1925
|
description: "disallow using 'setState' in 'componentDidMount'",
|
|
1965
|
-
[Symbol.for("rule_features")]:
|
|
1926
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1966
1927
|
},
|
|
1967
1928
|
messages: {
|
|
1968
1929
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
1969
1930
|
},
|
|
1970
1931
|
schema: []
|
|
1971
1932
|
},
|
|
1972
|
-
name:
|
|
1933
|
+
name: RULE_NAME33,
|
|
1973
1934
|
create(context) {
|
|
1974
1935
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
1975
1936
|
function getReportDescriptor(node) {
|
|
@@ -1997,8 +1958,8 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1997
1958
|
},
|
|
1998
1959
|
defaultOptions: []
|
|
1999
1960
|
});
|
|
2000
|
-
var
|
|
2001
|
-
var
|
|
1961
|
+
var RULE_NAME34 = "no-set-state-in-component-did-update";
|
|
1962
|
+
var RULE_FEATURES34 = [
|
|
2002
1963
|
"CHK"
|
|
2003
1964
|
];
|
|
2004
1965
|
function isComponentDidUpdate(node) {
|
|
@@ -2009,14 +1970,14 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2009
1970
|
type: "problem",
|
|
2010
1971
|
docs: {
|
|
2011
1972
|
description: "disallow using 'setState' in 'componentDidUpdate'",
|
|
2012
|
-
[Symbol.for("rule_features")]:
|
|
1973
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2013
1974
|
},
|
|
2014
1975
|
messages: {
|
|
2015
1976
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2016
1977
|
},
|
|
2017
1978
|
schema: []
|
|
2018
1979
|
},
|
|
2019
|
-
name:
|
|
1980
|
+
name: RULE_NAME34,
|
|
2020
1981
|
create(context) {
|
|
2021
1982
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2022
1983
|
function getReportDescriptor(node) {
|
|
@@ -2044,8 +2005,8 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2044
2005
|
},
|
|
2045
2006
|
defaultOptions: []
|
|
2046
2007
|
});
|
|
2047
|
-
var
|
|
2048
|
-
var
|
|
2008
|
+
var RULE_NAME35 = "no-set-state-in-component-will-update";
|
|
2009
|
+
var RULE_FEATURES35 = [
|
|
2049
2010
|
"CHK"
|
|
2050
2011
|
];
|
|
2051
2012
|
function isComponentWillUpdate3(node) {
|
|
@@ -2056,14 +2017,14 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2056
2017
|
type: "problem",
|
|
2057
2018
|
docs: {
|
|
2058
2019
|
description: "disallow using 'setState' in 'componentWillUpdate'",
|
|
2059
|
-
[Symbol.for("rule_features")]:
|
|
2020
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2060
2021
|
},
|
|
2061
2022
|
messages: {
|
|
2062
2023
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2063
2024
|
},
|
|
2064
2025
|
schema: []
|
|
2065
2026
|
},
|
|
2066
|
-
name:
|
|
2027
|
+
name: RULE_NAME35,
|
|
2067
2028
|
create(context) {
|
|
2068
2029
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2069
2030
|
function getReportDescriptor(node) {
|
|
@@ -2091,8 +2052,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2091
2052
|
},
|
|
2092
2053
|
defaultOptions: []
|
|
2093
2054
|
});
|
|
2094
|
-
var
|
|
2095
|
-
var
|
|
2055
|
+
var RULE_NAME36 = "no-string-refs";
|
|
2056
|
+
var RULE_FEATURES36 = [
|
|
2096
2057
|
"CHK"
|
|
2097
2058
|
];
|
|
2098
2059
|
function containsStringLiteral({ value }) {
|
|
@@ -2108,14 +2069,14 @@ var no_string_refs_default = createRule({
|
|
|
2108
2069
|
type: "problem",
|
|
2109
2070
|
docs: {
|
|
2110
2071
|
description: "disallow using deprecated string refs",
|
|
2111
|
-
[Symbol.for("rule_features")]:
|
|
2072
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2112
2073
|
},
|
|
2113
2074
|
messages: {
|
|
2114
2075
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2115
2076
|
},
|
|
2116
2077
|
schema: []
|
|
2117
2078
|
},
|
|
2118
|
-
name:
|
|
2079
|
+
name: RULE_NAME36,
|
|
2119
2080
|
create(context) {
|
|
2120
2081
|
return {
|
|
2121
2082
|
JSXAttribute(node) {
|
|
@@ -2131,8 +2092,8 @@ var no_string_refs_default = createRule({
|
|
|
2131
2092
|
},
|
|
2132
2093
|
defaultOptions: []
|
|
2133
2094
|
});
|
|
2134
|
-
var
|
|
2135
|
-
var
|
|
2095
|
+
var RULE_NAME37 = "no-unsafe-component-will-mount";
|
|
2096
|
+
var RULE_FEATURES37 = [
|
|
2136
2097
|
"CHK"
|
|
2137
2098
|
];
|
|
2138
2099
|
function isUnsafeComponentWillMount(node) {
|
|
@@ -2143,14 +2104,14 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2143
2104
|
type: "problem",
|
|
2144
2105
|
docs: {
|
|
2145
2106
|
description: "disallow using 'UNSAFE_componentWillMount'",
|
|
2146
|
-
[Symbol.for("rule_features")]:
|
|
2107
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2147
2108
|
},
|
|
2148
2109
|
messages: {
|
|
2149
2110
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2150
2111
|
},
|
|
2151
2112
|
schema: []
|
|
2152
2113
|
},
|
|
2153
|
-
name:
|
|
2114
|
+
name: RULE_NAME37,
|
|
2154
2115
|
create(context) {
|
|
2155
2116
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2156
2117
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -2174,8 +2135,8 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2174
2135
|
},
|
|
2175
2136
|
defaultOptions: []
|
|
2176
2137
|
});
|
|
2177
|
-
var
|
|
2178
|
-
var
|
|
2138
|
+
var RULE_NAME38 = "no-unsafe-component-will-receive-props";
|
|
2139
|
+
var RULE_FEATURES38 = [
|
|
2179
2140
|
"CHK"
|
|
2180
2141
|
];
|
|
2181
2142
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
@@ -2186,14 +2147,14 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2186
2147
|
type: "problem",
|
|
2187
2148
|
docs: {
|
|
2188
2149
|
description: "disallow using 'UNSAFE_componentWillReceiveProps'",
|
|
2189
|
-
[Symbol.for("rule_features")]:
|
|
2150
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2190
2151
|
},
|
|
2191
2152
|
messages: {
|
|
2192
2153
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2193
2154
|
},
|
|
2194
2155
|
schema: []
|
|
2195
2156
|
},
|
|
2196
|
-
name:
|
|
2157
|
+
name: RULE_NAME38,
|
|
2197
2158
|
create(context) {
|
|
2198
2159
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
2199
2160
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -2217,8 +2178,8 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2217
2178
|
},
|
|
2218
2179
|
defaultOptions: []
|
|
2219
2180
|
});
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2181
|
+
var RULE_NAME39 = "no-unsafe-component-will-update";
|
|
2182
|
+
var RULE_FEATURES39 = [
|
|
2222
2183
|
"CHK"
|
|
2223
2184
|
];
|
|
2224
2185
|
function isUnsafeComponentWillUpdate(node) {
|
|
@@ -2229,14 +2190,14 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2229
2190
|
type: "problem",
|
|
2230
2191
|
docs: {
|
|
2231
2192
|
description: "disallow using 'UNSAFE_componentWillUpdate'",
|
|
2232
|
-
[Symbol.for("rule_features")]:
|
|
2193
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2233
2194
|
},
|
|
2234
2195
|
messages: {
|
|
2235
2196
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2236
2197
|
},
|
|
2237
2198
|
schema: []
|
|
2238
2199
|
},
|
|
2239
|
-
name:
|
|
2200
|
+
name: RULE_NAME39,
|
|
2240
2201
|
create(context) {
|
|
2241
2202
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2242
2203
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
@@ -2260,8 +2221,8 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2260
2221
|
},
|
|
2261
2222
|
defaultOptions: []
|
|
2262
2223
|
});
|
|
2263
|
-
var
|
|
2264
|
-
var
|
|
2224
|
+
var RULE_NAME40 = "no-unstable-context-value";
|
|
2225
|
+
var RULE_FEATURES40 = [
|
|
2265
2226
|
"CHK"
|
|
2266
2227
|
];
|
|
2267
2228
|
var no_unstable_context_value_default = createRule({
|
|
@@ -2269,7 +2230,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2269
2230
|
type: "problem",
|
|
2270
2231
|
docs: {
|
|
2271
2232
|
description: "disallow passing constructed values to context providers",
|
|
2272
|
-
[Symbol.for("rule_features")]:
|
|
2233
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2273
2234
|
},
|
|
2274
2235
|
messages: {
|
|
2275
2236
|
noUnstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render.",
|
|
@@ -2278,7 +2239,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2278
2239
|
},
|
|
2279
2240
|
schema: []
|
|
2280
2241
|
},
|
|
2281
|
-
name:
|
|
2242
|
+
name: RULE_NAME40,
|
|
2282
2243
|
create(context) {
|
|
2283
2244
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2284
2245
|
const possibleValueConstructions = /* @__PURE__ */ new Map();
|
|
@@ -2331,8 +2292,8 @@ var no_unstable_context_value_default = createRule({
|
|
|
2331
2292
|
},
|
|
2332
2293
|
defaultOptions: []
|
|
2333
2294
|
});
|
|
2334
|
-
var
|
|
2335
|
-
var
|
|
2295
|
+
var RULE_NAME41 = "no-unstable-default-props";
|
|
2296
|
+
var RULE_FEATURES41 = [
|
|
2336
2297
|
"CHK"
|
|
2337
2298
|
];
|
|
2338
2299
|
var no_unstable_default_props_default = createRule({
|
|
@@ -2340,14 +2301,14 @@ var no_unstable_default_props_default = createRule({
|
|
|
2340
2301
|
type: "problem",
|
|
2341
2302
|
docs: {
|
|
2342
2303
|
description: "disallow using unstable value as default param in function component",
|
|
2343
|
-
[Symbol.for("rule_features")]:
|
|
2304
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2344
2305
|
},
|
|
2345
2306
|
messages: {
|
|
2346
2307
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2347
2308
|
},
|
|
2348
2309
|
schema: []
|
|
2349
2310
|
},
|
|
2350
|
-
name:
|
|
2311
|
+
name: RULE_NAME41,
|
|
2351
2312
|
create(context) {
|
|
2352
2313
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2353
2314
|
const possibleDestructuringDeclarators = /* @__PURE__ */ new WeakMap();
|
|
@@ -2400,8 +2361,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2400
2361
|
},
|
|
2401
2362
|
defaultOptions: []
|
|
2402
2363
|
});
|
|
2403
|
-
var
|
|
2404
|
-
var
|
|
2364
|
+
var RULE_NAME42 = "no-unused-class-component-members";
|
|
2365
|
+
var RULE_FEATURES42 = [
|
|
2405
2366
|
"CHK"
|
|
2406
2367
|
];
|
|
2407
2368
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -2441,14 +2402,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2441
2402
|
type: "problem",
|
|
2442
2403
|
docs: {
|
|
2443
2404
|
description: "disallow unused class component members",
|
|
2444
|
-
[Symbol.for("rule_features")]:
|
|
2405
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2445
2406
|
},
|
|
2446
2407
|
messages: {
|
|
2447
2408
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2448
2409
|
},
|
|
2449
2410
|
schema: []
|
|
2450
2411
|
},
|
|
2451
|
-
name:
|
|
2412
|
+
name: RULE_NAME42,
|
|
2452
2413
|
create(context) {
|
|
2453
2414
|
const classStack = [];
|
|
2454
2415
|
const methodStack = [];
|
|
@@ -2531,8 +2492,8 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2531
2492
|
},
|
|
2532
2493
|
defaultOptions: []
|
|
2533
2494
|
});
|
|
2534
|
-
var
|
|
2535
|
-
var
|
|
2495
|
+
var RULE_NAME43 = "no-unused-state";
|
|
2496
|
+
var RULE_FEATURES43 = [
|
|
2536
2497
|
"CHK"
|
|
2537
2498
|
];
|
|
2538
2499
|
function getName4(node) {
|
|
@@ -2568,14 +2529,14 @@ var no_unused_state_default = createRule({
|
|
|
2568
2529
|
type: "problem",
|
|
2569
2530
|
docs: {
|
|
2570
2531
|
description: "disallow unused state of class component",
|
|
2571
|
-
[Symbol.for("rule_features")]:
|
|
2532
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2572
2533
|
},
|
|
2573
2534
|
messages: {
|
|
2574
2535
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2575
2536
|
},
|
|
2576
2537
|
schema: []
|
|
2577
2538
|
},
|
|
2578
|
-
name:
|
|
2539
|
+
name: RULE_NAME43,
|
|
2579
2540
|
create(context) {
|
|
2580
2541
|
const classStack = [];
|
|
2581
2542
|
const methodStack = [];
|
|
@@ -2676,7 +2637,7 @@ var no_unused_state_default = createRule({
|
|
|
2676
2637
|
},
|
|
2677
2638
|
defaultOptions: []
|
|
2678
2639
|
});
|
|
2679
|
-
var
|
|
2640
|
+
var RULE_NAME44 = "no-useless-fragment";
|
|
2680
2641
|
function check(node, context, allowExpressions) {
|
|
2681
2642
|
const initialScope = context.sourceCode.getScope(node);
|
|
2682
2643
|
if (JSX8__namespace.isKeyedElement(node, initialScope)) return;
|
|
@@ -2722,7 +2683,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2722
2683
|
}
|
|
2723
2684
|
}]
|
|
2724
2685
|
},
|
|
2725
|
-
name:
|
|
2686
|
+
name: RULE_NAME44,
|
|
2726
2687
|
create(context, [option]) {
|
|
2727
2688
|
const { allowExpressions = true } = option;
|
|
2728
2689
|
return {
|
|
@@ -2737,8 +2698,8 @@ var no_useless_fragment_default = createRule({
|
|
|
2737
2698
|
},
|
|
2738
2699
|
defaultOptions
|
|
2739
2700
|
});
|
|
2740
|
-
var
|
|
2741
|
-
var
|
|
2701
|
+
var RULE_NAME45 = "prefer-destructuring-assignment";
|
|
2702
|
+
var RULE_FEATURES44 = [
|
|
2742
2703
|
"CHK"
|
|
2743
2704
|
];
|
|
2744
2705
|
function isMemberExpressionWithObjectName(node) {
|
|
@@ -2749,14 +2710,14 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2749
2710
|
type: "problem",
|
|
2750
2711
|
docs: {
|
|
2751
2712
|
description: "enforce using destructuring assignment in component props and context",
|
|
2752
|
-
[Symbol.for("rule_features")]:
|
|
2713
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2753
2714
|
},
|
|
2754
2715
|
messages: {
|
|
2755
2716
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
2756
2717
|
},
|
|
2757
2718
|
schema: []
|
|
2758
2719
|
},
|
|
2759
|
-
name:
|
|
2720
|
+
name: RULE_NAME45,
|
|
2760
2721
|
create(context) {
|
|
2761
2722
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2762
2723
|
const memberExpressionWithNames = [];
|
|
@@ -2811,8 +2772,8 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
2811
2772
|
},
|
|
2812
2773
|
defaultOptions: []
|
|
2813
2774
|
});
|
|
2814
|
-
var
|
|
2815
|
-
var
|
|
2775
|
+
var RULE_NAME46 = "prefer-react-namespace-import";
|
|
2776
|
+
var RULE_FEATURES45 = [
|
|
2816
2777
|
"CHK",
|
|
2817
2778
|
"FIX"
|
|
2818
2779
|
];
|
|
@@ -2821,7 +2782,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2821
2782
|
type: "problem",
|
|
2822
2783
|
docs: {
|
|
2823
2784
|
description: "enforce React is imported via a namespace import",
|
|
2824
|
-
[Symbol.for("rule_features")]:
|
|
2785
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2825
2786
|
},
|
|
2826
2787
|
fixable: "code",
|
|
2827
2788
|
messages: {
|
|
@@ -2829,7 +2790,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2829
2790
|
},
|
|
2830
2791
|
schema: []
|
|
2831
2792
|
},
|
|
2832
|
-
name:
|
|
2793
|
+
name: RULE_NAME46,
|
|
2833
2794
|
create(context) {
|
|
2834
2795
|
const importSource = shared.decodeSettings(context.settings).importSource ?? "react";
|
|
2835
2796
|
return {
|
|
@@ -2865,8 +2826,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
2865
2826
|
},
|
|
2866
2827
|
defaultOptions: []
|
|
2867
2828
|
});
|
|
2868
|
-
var
|
|
2869
|
-
var
|
|
2829
|
+
var RULE_NAME47 = "prefer-read-only-props";
|
|
2830
|
+
var RULE_FEATURES46 = [
|
|
2870
2831
|
"CHK",
|
|
2871
2832
|
"TSC"
|
|
2872
2833
|
];
|
|
@@ -2883,14 +2844,14 @@ var prefer_read_only_props_default = createRule({
|
|
|
2883
2844
|
type: "problem",
|
|
2884
2845
|
docs: {
|
|
2885
2846
|
description: "enforce read-only props in components",
|
|
2886
|
-
[Symbol.for("rule_features")]:
|
|
2847
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2887
2848
|
},
|
|
2888
2849
|
messages: {
|
|
2889
2850
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
2890
2851
|
},
|
|
2891
2852
|
schema: []
|
|
2892
2853
|
},
|
|
2893
|
-
name:
|
|
2854
|
+
name: RULE_NAME47,
|
|
2894
2855
|
create(context) {
|
|
2895
2856
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
2896
2857
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2910,8 +2871,8 @@ var prefer_read_only_props_default = createRule({
|
|
|
2910
2871
|
},
|
|
2911
2872
|
defaultOptions: []
|
|
2912
2873
|
});
|
|
2913
|
-
var
|
|
2914
|
-
var
|
|
2874
|
+
var RULE_NAME48 = "prefer-shorthand-boolean";
|
|
2875
|
+
var RULE_FEATURES47 = [
|
|
2915
2876
|
"CHK",
|
|
2916
2877
|
"FIX"
|
|
2917
2878
|
];
|
|
@@ -2920,7 +2881,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2920
2881
|
type: "problem",
|
|
2921
2882
|
docs: {
|
|
2922
2883
|
description: "enforce using shorthand boolean attributes",
|
|
2923
|
-
[Symbol.for("rule_features")]:
|
|
2884
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2924
2885
|
},
|
|
2925
2886
|
fixable: "code",
|
|
2926
2887
|
messages: {
|
|
@@ -2928,7 +2889,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2928
2889
|
},
|
|
2929
2890
|
schema: []
|
|
2930
2891
|
},
|
|
2931
|
-
name:
|
|
2892
|
+
name: RULE_NAME48,
|
|
2932
2893
|
create(context) {
|
|
2933
2894
|
function getReportDescriptor(node) {
|
|
2934
2895
|
const { value } = node;
|
|
@@ -2950,8 +2911,8 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
2950
2911
|
},
|
|
2951
2912
|
defaultOptions: []
|
|
2952
2913
|
});
|
|
2953
|
-
var
|
|
2954
|
-
var
|
|
2914
|
+
var RULE_NAME49 = "prefer-shorthand-fragment";
|
|
2915
|
+
var RULE_FEATURES48 = [
|
|
2955
2916
|
"CHK"
|
|
2956
2917
|
];
|
|
2957
2918
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -2959,14 +2920,14 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
2959
2920
|
type: "problem",
|
|
2960
2921
|
docs: {
|
|
2961
2922
|
description: "enforce using fragment syntax instead of 'Fragment' component",
|
|
2962
|
-
[Symbol.for("rule_features")]:
|
|
2923
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
2963
2924
|
},
|
|
2964
2925
|
messages: {
|
|
2965
2926
|
preferShorthandFragment: "Use fragment shorthand syntax instead of 'Fragment' component."
|
|
2966
2927
|
},
|
|
2967
2928
|
schema: []
|
|
2968
2929
|
},
|
|
2969
|
-
name:
|
|
2930
|
+
name: RULE_NAME49,
|
|
2970
2931
|
create(context) {
|
|
2971
2932
|
function getReportDescriptor(node) {
|
|
2972
2933
|
if (!core.isFragmentElement(node, context)) return eff.O.none();
|
|
@@ -2983,9 +2944,47 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
2983
2944
|
},
|
|
2984
2945
|
defaultOptions: []
|
|
2985
2946
|
});
|
|
2947
|
+
var RULE_NAME50 = "use-jsx-vars";
|
|
2948
|
+
var RULE_FEATURES49 = [];
|
|
2949
|
+
var use_jsx_vars_default = createRule({
|
|
2950
|
+
meta: {
|
|
2951
|
+
type: "problem",
|
|
2952
|
+
docs: {
|
|
2953
|
+
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
2954
|
+
description: "a helper rule to mark variables as used",
|
|
2955
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
2956
|
+
},
|
|
2957
|
+
messages: {
|
|
2958
|
+
useJsxVars: ""
|
|
2959
|
+
},
|
|
2960
|
+
schema: []
|
|
2961
|
+
},
|
|
2962
|
+
name: RULE_NAME50,
|
|
2963
|
+
create(context) {
|
|
2964
|
+
function getName5(node) {
|
|
2965
|
+
switch (node.type) {
|
|
2966
|
+
case types.AST_NODE_TYPES.JSXIdentifier:
|
|
2967
|
+
return eff.O.some(node.name);
|
|
2968
|
+
case types.AST_NODE_TYPES.JSXMemberExpression:
|
|
2969
|
+
return getName5(node.object);
|
|
2970
|
+
default:
|
|
2971
|
+
return eff.O.none();
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
return {
|
|
2975
|
+
JSXOpeningElement(node) {
|
|
2976
|
+
if (node.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) return;
|
|
2977
|
+
eff.O.map(getName5(node.name), (name2) => {
|
|
2978
|
+
context.sourceCode.markVariableAsUsed(name2, node);
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
},
|
|
2983
|
+
defaultOptions: []
|
|
2984
|
+
});
|
|
2986
2985
|
|
|
2987
2986
|
// src/index.ts
|
|
2988
|
-
var
|
|
2987
|
+
var index_default = {
|
|
2989
2988
|
meta: {
|
|
2990
2989
|
name,
|
|
2991
2990
|
version
|
|
@@ -2994,8 +2993,6 @@ var src_default = {
|
|
|
2994
2993
|
"avoid-shorthand-boolean": avoid_shorthand_boolean_default,
|
|
2995
2994
|
"avoid-shorthand-fragment": avoid_shorthand_fragment_default,
|
|
2996
2995
|
"ensure-forward-ref-using-ref": ensure_forward_ref_using_ref_default,
|
|
2997
|
-
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
2998
|
-
"jsx-uses-vars": jsx_uses_vars_default,
|
|
2999
2996
|
"no-access-state-in-setstate": no_access_state_in_setstate_default,
|
|
3000
2997
|
"no-array-index-key": no_array_index_key_default,
|
|
3001
2998
|
"no-children-count": no_children_count_default,
|
|
@@ -3015,6 +3012,7 @@ var src_default = {
|
|
|
3015
3012
|
"no-create-ref": no_create_ref_default,
|
|
3016
3013
|
"no-default-props": no_default_props_default,
|
|
3017
3014
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3015
|
+
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3018
3016
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3019
3017
|
"no-forward-ref": no_forward_ref_default,
|
|
3020
3018
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3041,10 +3039,15 @@ var src_default = {
|
|
|
3041
3039
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3042
3040
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3043
3041
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3044
|
-
|
|
3042
|
+
"use-jsx-vars": use_jsx_vars_default,
|
|
3043
|
+
// Part: deprecated rules
|
|
3044
|
+
/** @deprecated Use `no-duplicate-jsx-props` instead. */
|
|
3045
|
+
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3046
|
+
/** @deprecated Use `use-jsx-vars` instead. */
|
|
3047
|
+
"jsx-uses-vars": use_jsx_vars_default,
|
|
3045
3048
|
/** @deprecated Use `no-complex-conditional-rendering` instead. */
|
|
3046
3049
|
"no-complicated-conditional-rendering": no_complex_conditional_rendering_default
|
|
3047
3050
|
}
|
|
3048
3051
|
};
|
|
3049
3052
|
|
|
3050
|
-
module.exports =
|
|
3053
|
+
module.exports = index_default;
|