eslint-plugin-react-x 1.38.0-beta.5 → 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 +397 -392
- package/dist/index.mjs +397 -392
- 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,8 +896,8 @@ 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 = [
|
|
819
901
|
"EXP"
|
|
820
902
|
];
|
|
821
903
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -823,18 +905,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
823
905
|
type: "problem",
|
|
824
906
|
docs: {
|
|
825
907
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
826
|
-
[Symbol.for("rule_features")]:
|
|
908
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
827
909
|
},
|
|
828
910
|
messages: {
|
|
829
911
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
830
912
|
},
|
|
831
913
|
schema: []
|
|
832
914
|
},
|
|
833
|
-
name:
|
|
834
|
-
create:
|
|
915
|
+
name: RULE_NAME16,
|
|
916
|
+
create: create16,
|
|
835
917
|
defaultOptions: []
|
|
836
918
|
});
|
|
837
|
-
function
|
|
919
|
+
function create16(context) {
|
|
838
920
|
const visitorFunction = (node) => {
|
|
839
921
|
const jsxExpContainer = node.parent?.parent;
|
|
840
922
|
if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -859,8 +941,8 @@ function create14(context) {
|
|
|
859
941
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
860
942
|
};
|
|
861
943
|
}
|
|
862
|
-
var
|
|
863
|
-
var
|
|
944
|
+
var RULE_NAME17 = "no-component-will-mount";
|
|
945
|
+
var RULE_FEATURES17 = [
|
|
864
946
|
"MOD"
|
|
865
947
|
];
|
|
866
948
|
function isComponentWillMount(node) {
|
|
@@ -871,7 +953,7 @@ var no_component_will_mount_default = createRule({
|
|
|
871
953
|
type: "problem",
|
|
872
954
|
docs: {
|
|
873
955
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
874
|
-
[Symbol.for("rule_features")]:
|
|
956
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
875
957
|
},
|
|
876
958
|
fixable: "code",
|
|
877
959
|
messages: {
|
|
@@ -879,11 +961,11 @@ var no_component_will_mount_default = createRule({
|
|
|
879
961
|
},
|
|
880
962
|
schema: []
|
|
881
963
|
},
|
|
882
|
-
name:
|
|
883
|
-
create:
|
|
964
|
+
name: RULE_NAME17,
|
|
965
|
+
create: create17,
|
|
884
966
|
defaultOptions: []
|
|
885
967
|
});
|
|
886
|
-
function
|
|
968
|
+
function create17(context) {
|
|
887
969
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
888
970
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
889
971
|
return {
|
|
@@ -910,8 +992,8 @@ function create15(context) {
|
|
|
910
992
|
}
|
|
911
993
|
};
|
|
912
994
|
}
|
|
913
|
-
var
|
|
914
|
-
var
|
|
995
|
+
var RULE_NAME18 = "no-component-will-receive-props";
|
|
996
|
+
var RULE_FEATURES18 = [
|
|
915
997
|
"MOD"
|
|
916
998
|
];
|
|
917
999
|
function isComponentWillUpdate(node) {
|
|
@@ -922,7 +1004,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
922
1004
|
type: "problem",
|
|
923
1005
|
docs: {
|
|
924
1006
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
925
|
-
[Symbol.for("rule_features")]:
|
|
1007
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
926
1008
|
},
|
|
927
1009
|
fixable: "code",
|
|
928
1010
|
messages: {
|
|
@@ -930,11 +1012,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
930
1012
|
},
|
|
931
1013
|
schema: []
|
|
932
1014
|
},
|
|
933
|
-
name:
|
|
934
|
-
create:
|
|
1015
|
+
name: RULE_NAME18,
|
|
1016
|
+
create: create18,
|
|
935
1017
|
defaultOptions: []
|
|
936
1018
|
});
|
|
937
|
-
function
|
|
1019
|
+
function create18(context) {
|
|
938
1020
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
939
1021
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
940
1022
|
return {
|
|
@@ -961,8 +1043,8 @@ function create16(context) {
|
|
|
961
1043
|
}
|
|
962
1044
|
};
|
|
963
1045
|
}
|
|
964
|
-
var
|
|
965
|
-
var
|
|
1046
|
+
var RULE_NAME19 = "no-component-will-update";
|
|
1047
|
+
var RULE_FEATURES19 = [
|
|
966
1048
|
"MOD"
|
|
967
1049
|
];
|
|
968
1050
|
function isComponentWillUpdate2(node) {
|
|
@@ -973,7 +1055,7 @@ var no_component_will_update_default = createRule({
|
|
|
973
1055
|
type: "problem",
|
|
974
1056
|
docs: {
|
|
975
1057
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
976
|
-
[Symbol.for("rule_features")]:
|
|
1058
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
977
1059
|
},
|
|
978
1060
|
fixable: "code",
|
|
979
1061
|
messages: {
|
|
@@ -981,11 +1063,11 @@ var no_component_will_update_default = createRule({
|
|
|
981
1063
|
},
|
|
982
1064
|
schema: []
|
|
983
1065
|
},
|
|
984
|
-
name:
|
|
985
|
-
create:
|
|
1066
|
+
name: RULE_NAME19,
|
|
1067
|
+
create: create19,
|
|
986
1068
|
defaultOptions: []
|
|
987
1069
|
});
|
|
988
|
-
function
|
|
1070
|
+
function create19(context) {
|
|
989
1071
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
990
1072
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
991
1073
|
return {
|
|
@@ -1012,8 +1094,8 @@ function create17(context) {
|
|
|
1012
1094
|
}
|
|
1013
1095
|
};
|
|
1014
1096
|
}
|
|
1015
|
-
var
|
|
1016
|
-
var
|
|
1097
|
+
var RULE_NAME20 = "no-context-provider";
|
|
1098
|
+
var RULE_FEATURES20 = [
|
|
1017
1099
|
"MOD"
|
|
1018
1100
|
];
|
|
1019
1101
|
var no_context_provider_default = createRule({
|
|
@@ -1021,7 +1103,7 @@ var no_context_provider_default = createRule({
|
|
|
1021
1103
|
type: "problem",
|
|
1022
1104
|
docs: {
|
|
1023
1105
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1024
|
-
[Symbol.for("rule_features")]:
|
|
1106
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1025
1107
|
},
|
|
1026
1108
|
fixable: "code",
|
|
1027
1109
|
messages: {
|
|
@@ -1029,11 +1111,11 @@ var no_context_provider_default = createRule({
|
|
|
1029
1111
|
},
|
|
1030
1112
|
schema: []
|
|
1031
1113
|
},
|
|
1032
|
-
name:
|
|
1033
|
-
create:
|
|
1114
|
+
name: RULE_NAME20,
|
|
1115
|
+
create: create20,
|
|
1034
1116
|
defaultOptions: []
|
|
1035
1117
|
});
|
|
1036
|
-
function
|
|
1118
|
+
function create20(context) {
|
|
1037
1119
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1038
1120
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1039
1121
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1065,25 +1147,25 @@ function create18(context) {
|
|
|
1065
1147
|
}
|
|
1066
1148
|
};
|
|
1067
1149
|
}
|
|
1068
|
-
var
|
|
1069
|
-
var
|
|
1150
|
+
var RULE_NAME21 = "no-create-ref";
|
|
1151
|
+
var RULE_FEATURES21 = [];
|
|
1070
1152
|
var no_create_ref_default = createRule({
|
|
1071
1153
|
meta: {
|
|
1072
1154
|
type: "problem",
|
|
1073
1155
|
docs: {
|
|
1074
1156
|
description: "Disallow `createRef` in function components.",
|
|
1075
|
-
[Symbol.for("rule_features")]:
|
|
1157
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1076
1158
|
},
|
|
1077
1159
|
messages: {
|
|
1078
1160
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1079
1161
|
},
|
|
1080
1162
|
schema: []
|
|
1081
1163
|
},
|
|
1082
|
-
name:
|
|
1083
|
-
create:
|
|
1164
|
+
name: RULE_NAME21,
|
|
1165
|
+
create: create21,
|
|
1084
1166
|
defaultOptions: []
|
|
1085
1167
|
});
|
|
1086
|
-
function
|
|
1168
|
+
function create21(context) {
|
|
1087
1169
|
return {
|
|
1088
1170
|
CallExpression(node) {
|
|
1089
1171
|
if (core.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
|
|
@@ -1092,25 +1174,25 @@ function create19(context) {
|
|
|
1092
1174
|
}
|
|
1093
1175
|
};
|
|
1094
1176
|
}
|
|
1095
|
-
var
|
|
1096
|
-
var
|
|
1177
|
+
var RULE_NAME22 = "no-default-props";
|
|
1178
|
+
var RULE_FEATURES22 = [];
|
|
1097
1179
|
var no_default_props_default = createRule({
|
|
1098
1180
|
meta: {
|
|
1099
1181
|
type: "problem",
|
|
1100
1182
|
docs: {
|
|
1101
1183
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1102
|
-
[Symbol.for("rule_features")]:
|
|
1184
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1103
1185
|
},
|
|
1104
1186
|
messages: {
|
|
1105
1187
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1106
1188
|
},
|
|
1107
1189
|
schema: []
|
|
1108
1190
|
},
|
|
1109
|
-
name:
|
|
1110
|
-
create:
|
|
1191
|
+
name: RULE_NAME22,
|
|
1192
|
+
create: create22,
|
|
1111
1193
|
defaultOptions: []
|
|
1112
1194
|
});
|
|
1113
|
-
function
|
|
1195
|
+
function create22(context) {
|
|
1114
1196
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1115
1197
|
return {
|
|
1116
1198
|
AssignmentExpression(node) {
|
|
@@ -1144,8 +1226,8 @@ function create20(context) {
|
|
|
1144
1226
|
}
|
|
1145
1227
|
};
|
|
1146
1228
|
}
|
|
1147
|
-
var
|
|
1148
|
-
var
|
|
1229
|
+
var RULE_NAME23 = "no-direct-mutation-state";
|
|
1230
|
+
var RULE_FEATURES23 = [];
|
|
1149
1231
|
function isConstructorFunction(node) {
|
|
1150
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";
|
|
1151
1233
|
}
|
|
@@ -1154,18 +1236,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1154
1236
|
type: "problem",
|
|
1155
1237
|
docs: {
|
|
1156
1238
|
description: "Disallow direct mutation of `this.state`.",
|
|
1157
|
-
[Symbol.for("rule_features")]:
|
|
1239
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1158
1240
|
},
|
|
1159
1241
|
messages: {
|
|
1160
1242
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1161
1243
|
},
|
|
1162
1244
|
schema: []
|
|
1163
1245
|
},
|
|
1164
|
-
name:
|
|
1165
|
-
create:
|
|
1246
|
+
name: RULE_NAME23,
|
|
1247
|
+
create: create23,
|
|
1166
1248
|
defaultOptions: []
|
|
1167
1249
|
});
|
|
1168
|
-
function
|
|
1250
|
+
function create23(context) {
|
|
1169
1251
|
return {
|
|
1170
1252
|
AssignmentExpression(node) {
|
|
1171
1253
|
if (!core.isAssignmentToThisState(node)) return;
|
|
@@ -1186,67 +1268,25 @@ function create21(context) {
|
|
|
1186
1268
|
}
|
|
1187
1269
|
};
|
|
1188
1270
|
}
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1191
|
-
var no_duplicate_jsx_props_default = createRule({
|
|
1192
|
-
meta: {
|
|
1193
|
-
type: "problem",
|
|
1194
|
-
docs: {
|
|
1195
|
-
description: "Disallow duplicate props in JSX elements.",
|
|
1196
|
-
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1197
|
-
},
|
|
1198
|
-
messages: {
|
|
1199
|
-
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1200
|
-
},
|
|
1201
|
-
schema: []
|
|
1202
|
-
},
|
|
1203
|
-
name: RULE_NAME22,
|
|
1204
|
-
create: create22,
|
|
1205
|
-
defaultOptions: []
|
|
1206
|
-
});
|
|
1207
|
-
function create22(context) {
|
|
1208
|
-
return {
|
|
1209
|
-
JSXOpeningElement(node) {
|
|
1210
|
-
const props = [];
|
|
1211
|
-
for (const attr of node.attributes) {
|
|
1212
|
-
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
const name5 = attr.name.name;
|
|
1216
|
-
if (typeof name5 !== "string") {
|
|
1217
|
-
continue;
|
|
1218
|
-
}
|
|
1219
|
-
if (!props.includes(name5)) {
|
|
1220
|
-
props.push(name5);
|
|
1221
|
-
continue;
|
|
1222
|
-
}
|
|
1223
|
-
context.report({
|
|
1224
|
-
messageId: "noDuplicateJsxProps",
|
|
1225
|
-
node: attr
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
var RULE_NAME23 = "no-duplicate-key";
|
|
1232
|
-
var RULE_FEATURES23 = [];
|
|
1271
|
+
var RULE_NAME24 = "no-duplicate-key";
|
|
1272
|
+
var RULE_FEATURES24 = [];
|
|
1233
1273
|
var no_duplicate_key_default = createRule({
|
|
1234
1274
|
meta: {
|
|
1235
1275
|
type: "problem",
|
|
1236
1276
|
docs: {
|
|
1237
1277
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1238
|
-
[Symbol.for("rule_features")]:
|
|
1278
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1239
1279
|
},
|
|
1240
1280
|
messages: {
|
|
1241
1281
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1242
1282
|
},
|
|
1243
1283
|
schema: []
|
|
1244
1284
|
},
|
|
1245
|
-
name:
|
|
1246
|
-
create:
|
|
1285
|
+
name: RULE_NAME24,
|
|
1286
|
+
create: create24,
|
|
1247
1287
|
defaultOptions: []
|
|
1248
1288
|
});
|
|
1249
|
-
function
|
|
1289
|
+
function create24(context) {
|
|
1250
1290
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1251
1291
|
return {};
|
|
1252
1292
|
}
|
|
@@ -1310,8 +1350,8 @@ function create23(context) {
|
|
|
1310
1350
|
}
|
|
1311
1351
|
};
|
|
1312
1352
|
}
|
|
1313
|
-
var
|
|
1314
|
-
var
|
|
1353
|
+
var RULE_NAME25 = "no-forward-ref";
|
|
1354
|
+
var RULE_FEATURES25 = [
|
|
1315
1355
|
"MOD"
|
|
1316
1356
|
];
|
|
1317
1357
|
var no_forward_ref_default = createRule({
|
|
@@ -1319,7 +1359,7 @@ var no_forward_ref_default = createRule({
|
|
|
1319
1359
|
type: "problem",
|
|
1320
1360
|
docs: {
|
|
1321
1361
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1322
|
-
[Symbol.for("rule_features")]:
|
|
1362
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1323
1363
|
},
|
|
1324
1364
|
fixable: "code",
|
|
1325
1365
|
messages: {
|
|
@@ -1327,11 +1367,11 @@ var no_forward_ref_default = createRule({
|
|
|
1327
1367
|
},
|
|
1328
1368
|
schema: []
|
|
1329
1369
|
},
|
|
1330
|
-
name:
|
|
1331
|
-
create:
|
|
1370
|
+
name: RULE_NAME25,
|
|
1371
|
+
create: create25,
|
|
1332
1372
|
defaultOptions: []
|
|
1333
1373
|
});
|
|
1334
|
-
function
|
|
1374
|
+
function create25(context) {
|
|
1335
1375
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1336
1376
|
return {};
|
|
1337
1377
|
}
|
|
@@ -1419,8 +1459,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1419
1459
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1420
1460
|
];
|
|
1421
1461
|
}
|
|
1422
|
-
var
|
|
1423
|
-
var
|
|
1462
|
+
var RULE_NAME26 = "no-implicit-key";
|
|
1463
|
+
var RULE_FEATURES26 = [
|
|
1424
1464
|
"EXP"
|
|
1425
1465
|
];
|
|
1426
1466
|
var no_implicit_key_default = createRule({
|
|
@@ -1428,18 +1468,18 @@ var no_implicit_key_default = createRule({
|
|
|
1428
1468
|
type: "problem",
|
|
1429
1469
|
docs: {
|
|
1430
1470
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1431
|
-
[Symbol.for("rule_features")]:
|
|
1471
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1432
1472
|
},
|
|
1433
1473
|
messages: {
|
|
1434
1474
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1435
1475
|
},
|
|
1436
1476
|
schema: []
|
|
1437
1477
|
},
|
|
1438
|
-
name:
|
|
1439
|
-
create:
|
|
1478
|
+
name: RULE_NAME26,
|
|
1479
|
+
create: create26,
|
|
1440
1480
|
defaultOptions: []
|
|
1441
1481
|
});
|
|
1442
|
-
function
|
|
1482
|
+
function create26(context) {
|
|
1443
1483
|
return {
|
|
1444
1484
|
JSXOpeningElement(node) {
|
|
1445
1485
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1453,8 +1493,8 @@ function create25(context) {
|
|
|
1453
1493
|
}
|
|
1454
1494
|
};
|
|
1455
1495
|
}
|
|
1456
|
-
var
|
|
1457
|
-
var
|
|
1496
|
+
var RULE_NAME27 = "no-leaked-conditional-rendering";
|
|
1497
|
+
var RULE_FEATURES27 = [
|
|
1458
1498
|
"TSC"
|
|
1459
1499
|
];
|
|
1460
1500
|
var tsHelpers = {
|
|
@@ -1540,18 +1580,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1540
1580
|
type: "problem",
|
|
1541
1581
|
docs: {
|
|
1542
1582
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1543
|
-
[Symbol.for("rule_features")]:
|
|
1583
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1544
1584
|
},
|
|
1545
1585
|
messages: {
|
|
1546
1586
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1547
1587
|
},
|
|
1548
1588
|
schema: []
|
|
1549
1589
|
},
|
|
1550
|
-
name:
|
|
1551
|
-
create:
|
|
1590
|
+
name: RULE_NAME27,
|
|
1591
|
+
create: create27,
|
|
1552
1592
|
defaultOptions: []
|
|
1553
1593
|
});
|
|
1554
|
-
function
|
|
1594
|
+
function create27(context) {
|
|
1555
1595
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1556
1596
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1557
1597
|
const allowedVariants = [
|
|
@@ -1608,25 +1648,25 @@ function create26(context) {
|
|
|
1608
1648
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1609
1649
|
};
|
|
1610
1650
|
}
|
|
1611
|
-
var
|
|
1612
|
-
var
|
|
1651
|
+
var RULE_NAME28 = "no-missing-component-display-name";
|
|
1652
|
+
var RULE_FEATURES28 = [];
|
|
1613
1653
|
var no_missing_component_display_name_default = createRule({
|
|
1614
1654
|
meta: {
|
|
1615
1655
|
type: "problem",
|
|
1616
1656
|
docs: {
|
|
1617
1657
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1618
|
-
[Symbol.for("rule_features")]:
|
|
1658
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1619
1659
|
},
|
|
1620
1660
|
messages: {
|
|
1621
1661
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1622
1662
|
},
|
|
1623
1663
|
schema: []
|
|
1624
1664
|
},
|
|
1625
|
-
name:
|
|
1626
|
-
create:
|
|
1665
|
+
name: RULE_NAME28,
|
|
1666
|
+
create: create28,
|
|
1627
1667
|
defaultOptions: []
|
|
1628
1668
|
});
|
|
1629
|
-
function
|
|
1669
|
+
function create28(context) {
|
|
1630
1670
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1631
1671
|
const {
|
|
1632
1672
|
ctx,
|
|
@@ -1661,25 +1701,25 @@ function create27(context) {
|
|
|
1661
1701
|
}
|
|
1662
1702
|
};
|
|
1663
1703
|
}
|
|
1664
|
-
var
|
|
1665
|
-
var
|
|
1704
|
+
var RULE_NAME29 = "no-missing-context-display-name";
|
|
1705
|
+
var RULE_FEATURES29 = [];
|
|
1666
1706
|
var no_missing_context_display_name_default = createRule({
|
|
1667
1707
|
meta: {
|
|
1668
1708
|
type: "problem",
|
|
1669
1709
|
docs: {
|
|
1670
1710
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1671
|
-
[Symbol.for("rule_features")]:
|
|
1711
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1672
1712
|
},
|
|
1673
1713
|
messages: {
|
|
1674
1714
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1675
1715
|
},
|
|
1676
1716
|
schema: []
|
|
1677
1717
|
},
|
|
1678
|
-
name:
|
|
1679
|
-
create:
|
|
1718
|
+
name: RULE_NAME29,
|
|
1719
|
+
create: create29,
|
|
1680
1720
|
defaultOptions: []
|
|
1681
1721
|
});
|
|
1682
|
-
function
|
|
1722
|
+
function create29(context) {
|
|
1683
1723
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1684
1724
|
const createCalls = [];
|
|
1685
1725
|
const displayNameAssignments = [];
|
|
@@ -1717,14 +1757,14 @@ function create28(context) {
|
|
|
1717
1757
|
}
|
|
1718
1758
|
};
|
|
1719
1759
|
}
|
|
1720
|
-
var
|
|
1721
|
-
var
|
|
1760
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1761
|
+
var RULE_FEATURES30 = [];
|
|
1722
1762
|
var no_missing_key_default = createRule({
|
|
1723
1763
|
meta: {
|
|
1724
1764
|
type: "problem",
|
|
1725
1765
|
docs: {
|
|
1726
1766
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1727
|
-
[Symbol.for("rule_features")]:
|
|
1767
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1728
1768
|
},
|
|
1729
1769
|
messages: {
|
|
1730
1770
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1732,11 +1772,11 @@ var no_missing_key_default = createRule({
|
|
|
1732
1772
|
},
|
|
1733
1773
|
schema: []
|
|
1734
1774
|
},
|
|
1735
|
-
name:
|
|
1736
|
-
create:
|
|
1775
|
+
name: RULE_NAME30,
|
|
1776
|
+
create: create30,
|
|
1737
1777
|
defaultOptions: []
|
|
1738
1778
|
});
|
|
1739
|
-
function
|
|
1779
|
+
function create30(context) {
|
|
1740
1780
|
const report = kit.createReport(context);
|
|
1741
1781
|
const state = { isWithinChildrenToArray: false };
|
|
1742
1782
|
function checkIteratorElement(node) {
|
|
@@ -1849,26 +1889,25 @@ function create29(context) {
|
|
|
1849
1889
|
function isArrayFromCall(node) {
|
|
1850
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";
|
|
1851
1891
|
}
|
|
1852
|
-
var
|
|
1853
|
-
var
|
|
1892
|
+
var RULE_NAME31 = "no-nested-component-definitions";
|
|
1893
|
+
var RULE_FEATURES31 = [];
|
|
1854
1894
|
var no_nested_component_definitions_default = createRule({
|
|
1855
1895
|
meta: {
|
|
1856
1896
|
type: "problem",
|
|
1857
1897
|
docs: {
|
|
1858
1898
|
description: "Disallow nesting component definitions inside other components.",
|
|
1859
|
-
[Symbol.for("rule_features")]:
|
|
1899
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1860
1900
|
},
|
|
1861
1901
|
messages: {
|
|
1862
|
-
|
|
1863
|
-
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}}"
|
|
1864
1903
|
},
|
|
1865
1904
|
schema: []
|
|
1866
1905
|
},
|
|
1867
|
-
name:
|
|
1868
|
-
create:
|
|
1906
|
+
name: RULE_NAME31,
|
|
1907
|
+
create: create31,
|
|
1869
1908
|
defaultOptions: []
|
|
1870
1909
|
});
|
|
1871
|
-
function
|
|
1910
|
+
function create31(context) {
|
|
1872
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;
|
|
1873
1912
|
const collector = core.useComponentCollector(context, { hint });
|
|
1874
1913
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
@@ -1894,10 +1933,11 @@ function create30(context) {
|
|
|
1894
1933
|
if (isInsideJSXAttributeValue(component)) {
|
|
1895
1934
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1896
1935
|
context.report({
|
|
1897
|
-
messageId: "
|
|
1936
|
+
messageId: "noNestedComponentDefinitions",
|
|
1898
1937
|
node: component,
|
|
1899
1938
|
data: {
|
|
1900
|
-
name: name5
|
|
1939
|
+
name: name5,
|
|
1940
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1901
1941
|
}
|
|
1902
1942
|
});
|
|
1903
1943
|
}
|
|
@@ -1905,10 +1945,11 @@ function create30(context) {
|
|
|
1905
1945
|
}
|
|
1906
1946
|
if (isInsideCreateElementProps(context, component)) {
|
|
1907
1947
|
context.report({
|
|
1908
|
-
messageId: "
|
|
1948
|
+
messageId: "noNestedComponentDefinitions",
|
|
1909
1949
|
node: component,
|
|
1910
1950
|
data: {
|
|
1911
|
-
name: name5
|
|
1951
|
+
name: name5,
|
|
1952
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1912
1953
|
}
|
|
1913
1954
|
});
|
|
1914
1955
|
continue;
|
|
@@ -1916,20 +1957,22 @@ function create30(context) {
|
|
|
1916
1957
|
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
1917
1958
|
if (parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1918
1959
|
context.report({
|
|
1919
|
-
messageId:
|
|
1960
|
+
messageId: "noNestedComponentDefinitions",
|
|
1920
1961
|
node: component,
|
|
1921
1962
|
data: {
|
|
1922
|
-
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."
|
|
1923
1965
|
}
|
|
1924
1966
|
});
|
|
1925
1967
|
continue;
|
|
1926
1968
|
}
|
|
1927
1969
|
if (core.isInsideRenderMethod(component)) {
|
|
1928
1970
|
context.report({
|
|
1929
|
-
messageId: "
|
|
1971
|
+
messageId: "noNestedComponentDefinitions",
|
|
1930
1972
|
node: component,
|
|
1931
1973
|
data: {
|
|
1932
|
-
name: name5
|
|
1974
|
+
name: name5,
|
|
1975
|
+
suggestion: "Move it to the top level."
|
|
1933
1976
|
}
|
|
1934
1977
|
});
|
|
1935
1978
|
}
|
|
@@ -1939,10 +1982,11 @@ function create30(context) {
|
|
|
1939
1982
|
continue;
|
|
1940
1983
|
}
|
|
1941
1984
|
context.report({
|
|
1942
|
-
messageId: "
|
|
1985
|
+
messageId: "noNestedComponentDefinitions",
|
|
1943
1986
|
node: component,
|
|
1944
1987
|
data: {
|
|
1945
|
-
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."
|
|
1946
1990
|
}
|
|
1947
1991
|
});
|
|
1948
1992
|
}
|
|
@@ -1959,25 +2003,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1959
2003
|
if (prop == null) return false;
|
|
1960
2004
|
return prop === call.arguments[1];
|
|
1961
2005
|
}
|
|
1962
|
-
var
|
|
1963
|
-
var
|
|
2006
|
+
var RULE_NAME32 = "no-prop-types";
|
|
2007
|
+
var RULE_FEATURES32 = [];
|
|
1964
2008
|
var no_prop_types_default = createRule({
|
|
1965
2009
|
meta: {
|
|
1966
2010
|
type: "problem",
|
|
1967
2011
|
docs: {
|
|
1968
2012
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1969
|
-
[Symbol.for("rule_features")]:
|
|
2013
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1970
2014
|
},
|
|
1971
2015
|
messages: {
|
|
1972
2016
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1973
2017
|
},
|
|
1974
2018
|
schema: []
|
|
1975
2019
|
},
|
|
1976
|
-
name:
|
|
1977
|
-
create:
|
|
2020
|
+
name: RULE_NAME32,
|
|
2021
|
+
create: create32,
|
|
1978
2022
|
defaultOptions: []
|
|
1979
2023
|
});
|
|
1980
|
-
function
|
|
2024
|
+
function create32(context) {
|
|
1981
2025
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1982
2026
|
return {};
|
|
1983
2027
|
}
|
|
@@ -2013,8 +2057,8 @@ function create31(context) {
|
|
|
2013
2057
|
}
|
|
2014
2058
|
};
|
|
2015
2059
|
}
|
|
2016
|
-
var
|
|
2017
|
-
var
|
|
2060
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
2061
|
+
var RULE_FEATURES33 = [];
|
|
2018
2062
|
function isShouldComponentUpdate(node) {
|
|
2019
2063
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2020
2064
|
}
|
|
@@ -2023,18 +2067,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2023
2067
|
type: "problem",
|
|
2024
2068
|
docs: {
|
|
2025
2069
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2026
|
-
[Symbol.for("rule_features")]:
|
|
2070
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
2027
2071
|
},
|
|
2028
2072
|
messages: {
|
|
2029
2073
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2030
2074
|
},
|
|
2031
2075
|
schema: []
|
|
2032
2076
|
},
|
|
2033
|
-
name:
|
|
2034
|
-
create:
|
|
2077
|
+
name: RULE_NAME33,
|
|
2078
|
+
create: create33,
|
|
2035
2079
|
defaultOptions: []
|
|
2036
2080
|
});
|
|
2037
|
-
function
|
|
2081
|
+
function create33(context) {
|
|
2038
2082
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2039
2083
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2040
2084
|
return {
|
|
@@ -2061,8 +2105,8 @@ function create32(context) {
|
|
|
2061
2105
|
}
|
|
2062
2106
|
};
|
|
2063
2107
|
}
|
|
2064
|
-
var
|
|
2065
|
-
var
|
|
2108
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
2109
|
+
var RULE_FEATURES34 = [];
|
|
2066
2110
|
function isComponentDidMount(node) {
|
|
2067
2111
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2068
2112
|
}
|
|
@@ -2071,18 +2115,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2071
2115
|
type: "problem",
|
|
2072
2116
|
docs: {
|
|
2073
2117
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2074
|
-
[Symbol.for("rule_features")]:
|
|
2118
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2075
2119
|
},
|
|
2076
2120
|
messages: {
|
|
2077
2121
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2078
2122
|
},
|
|
2079
2123
|
schema: []
|
|
2080
2124
|
},
|
|
2081
|
-
name:
|
|
2082
|
-
create:
|
|
2125
|
+
name: RULE_NAME34,
|
|
2126
|
+
create: create34,
|
|
2083
2127
|
defaultOptions: []
|
|
2084
2128
|
});
|
|
2085
|
-
function
|
|
2129
|
+
function create34(context) {
|
|
2086
2130
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2087
2131
|
return {
|
|
2088
2132
|
CallExpression(node) {
|
|
@@ -2103,8 +2147,8 @@ function create33(context) {
|
|
|
2103
2147
|
}
|
|
2104
2148
|
};
|
|
2105
2149
|
}
|
|
2106
|
-
var
|
|
2107
|
-
var
|
|
2150
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
2151
|
+
var RULE_FEATURES35 = [];
|
|
2108
2152
|
function isComponentDidUpdate(node) {
|
|
2109
2153
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2110
2154
|
}
|
|
@@ -2113,18 +2157,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2113
2157
|
type: "problem",
|
|
2114
2158
|
docs: {
|
|
2115
2159
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2116
|
-
[Symbol.for("rule_features")]:
|
|
2160
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2117
2161
|
},
|
|
2118
2162
|
messages: {
|
|
2119
2163
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2120
2164
|
},
|
|
2121
2165
|
schema: []
|
|
2122
2166
|
},
|
|
2123
|
-
name:
|
|
2124
|
-
create:
|
|
2167
|
+
name: RULE_NAME35,
|
|
2168
|
+
create: create35,
|
|
2125
2169
|
defaultOptions: []
|
|
2126
2170
|
});
|
|
2127
|
-
function
|
|
2171
|
+
function create35(context) {
|
|
2128
2172
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2129
2173
|
return {
|
|
2130
2174
|
CallExpression(node) {
|
|
@@ -2145,8 +2189,8 @@ function create34(context) {
|
|
|
2145
2189
|
}
|
|
2146
2190
|
};
|
|
2147
2191
|
}
|
|
2148
|
-
var
|
|
2149
|
-
var
|
|
2192
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
2193
|
+
var RULE_FEATURES36 = [];
|
|
2150
2194
|
function isComponentWillUpdate3(node) {
|
|
2151
2195
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2152
2196
|
}
|
|
@@ -2155,18 +2199,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2155
2199
|
type: "problem",
|
|
2156
2200
|
docs: {
|
|
2157
2201
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2158
|
-
[Symbol.for("rule_features")]:
|
|
2202
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2159
2203
|
},
|
|
2160
2204
|
messages: {
|
|
2161
2205
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2162
2206
|
},
|
|
2163
2207
|
schema: []
|
|
2164
2208
|
},
|
|
2165
|
-
name:
|
|
2166
|
-
create:
|
|
2209
|
+
name: RULE_NAME36,
|
|
2210
|
+
create: create36,
|
|
2167
2211
|
defaultOptions: []
|
|
2168
2212
|
});
|
|
2169
|
-
function
|
|
2213
|
+
function create36(context) {
|
|
2170
2214
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2171
2215
|
return {
|
|
2172
2216
|
CallExpression(node) {
|
|
@@ -2187,8 +2231,8 @@ function create35(context) {
|
|
|
2187
2231
|
}
|
|
2188
2232
|
};
|
|
2189
2233
|
}
|
|
2190
|
-
var
|
|
2191
|
-
var
|
|
2234
|
+
var RULE_NAME37 = "no-string-refs";
|
|
2235
|
+
var RULE_FEATURES37 = [];
|
|
2192
2236
|
function containsStringLiteral({ value }) {
|
|
2193
2237
|
return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2194
2238
|
}
|
|
@@ -2206,18 +2250,18 @@ var no_string_refs_default = createRule({
|
|
|
2206
2250
|
type: "problem",
|
|
2207
2251
|
docs: {
|
|
2208
2252
|
description: "Disallow deprecated string `refs`.",
|
|
2209
|
-
[Symbol.for("rule_features")]:
|
|
2253
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2210
2254
|
},
|
|
2211
2255
|
messages: {
|
|
2212
2256
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2213
2257
|
},
|
|
2214
2258
|
schema: []
|
|
2215
2259
|
},
|
|
2216
|
-
name:
|
|
2217
|
-
create:
|
|
2260
|
+
name: RULE_NAME37,
|
|
2261
|
+
create: create37,
|
|
2218
2262
|
defaultOptions: []
|
|
2219
2263
|
});
|
|
2220
|
-
function
|
|
2264
|
+
function create37(context) {
|
|
2221
2265
|
return {
|
|
2222
2266
|
JSXAttribute(node) {
|
|
2223
2267
|
if (node.name.name !== "ref") {
|
|
@@ -2232,8 +2276,8 @@ function create36(context) {
|
|
|
2232
2276
|
}
|
|
2233
2277
|
};
|
|
2234
2278
|
}
|
|
2235
|
-
var
|
|
2236
|
-
var
|
|
2279
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
2280
|
+
var RULE_FEATURES38 = [];
|
|
2237
2281
|
function isUnsafeComponentWillMount(node) {
|
|
2238
2282
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2239
2283
|
}
|
|
@@ -2242,18 +2286,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2242
2286
|
type: "problem",
|
|
2243
2287
|
docs: {
|
|
2244
2288
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2245
|
-
[Symbol.for("rule_features")]:
|
|
2289
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2246
2290
|
},
|
|
2247
2291
|
messages: {
|
|
2248
2292
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2249
2293
|
},
|
|
2250
2294
|
schema: []
|
|
2251
2295
|
},
|
|
2252
|
-
name:
|
|
2253
|
-
create:
|
|
2296
|
+
name: RULE_NAME38,
|
|
2297
|
+
create: create38,
|
|
2254
2298
|
defaultOptions: []
|
|
2255
2299
|
});
|
|
2256
|
-
function
|
|
2300
|
+
function create38(context) {
|
|
2257
2301
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2258
2302
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2259
2303
|
return {
|
|
@@ -2274,8 +2318,8 @@ function create37(context) {
|
|
|
2274
2318
|
}
|
|
2275
2319
|
};
|
|
2276
2320
|
}
|
|
2277
|
-
var
|
|
2278
|
-
var
|
|
2321
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
2322
|
+
var RULE_FEATURES39 = [];
|
|
2279
2323
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2280
2324
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2281
2325
|
}
|
|
@@ -2284,18 +2328,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2284
2328
|
type: "problem",
|
|
2285
2329
|
docs: {
|
|
2286
2330
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2287
|
-
[Symbol.for("rule_features")]:
|
|
2331
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2288
2332
|
},
|
|
2289
2333
|
messages: {
|
|
2290
2334
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2291
2335
|
},
|
|
2292
2336
|
schema: []
|
|
2293
2337
|
},
|
|
2294
|
-
name:
|
|
2295
|
-
create:
|
|
2338
|
+
name: RULE_NAME39,
|
|
2339
|
+
create: create39,
|
|
2296
2340
|
defaultOptions: []
|
|
2297
2341
|
});
|
|
2298
|
-
function
|
|
2342
|
+
function create39(context) {
|
|
2299
2343
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2300
2344
|
return {};
|
|
2301
2345
|
}
|
|
@@ -2318,8 +2362,8 @@ function create38(context) {
|
|
|
2318
2362
|
}
|
|
2319
2363
|
};
|
|
2320
2364
|
}
|
|
2321
|
-
var
|
|
2322
|
-
var
|
|
2365
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
2366
|
+
var RULE_FEATURES40 = [];
|
|
2323
2367
|
function isUnsafeComponentWillUpdate(node) {
|
|
2324
2368
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2325
2369
|
}
|
|
@@ -2328,18 +2372,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2328
2372
|
type: "problem",
|
|
2329
2373
|
docs: {
|
|
2330
2374
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2331
|
-
[Symbol.for("rule_features")]:
|
|
2375
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2332
2376
|
},
|
|
2333
2377
|
messages: {
|
|
2334
2378
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2335
2379
|
},
|
|
2336
2380
|
schema: []
|
|
2337
2381
|
},
|
|
2338
|
-
name:
|
|
2339
|
-
create:
|
|
2382
|
+
name: RULE_NAME40,
|
|
2383
|
+
create: create40,
|
|
2340
2384
|
defaultOptions: []
|
|
2341
2385
|
});
|
|
2342
|
-
function
|
|
2386
|
+
function create40(context) {
|
|
2343
2387
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2344
2388
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2345
2389
|
return {
|
|
@@ -2360,25 +2404,25 @@ function create39(context) {
|
|
|
2360
2404
|
}
|
|
2361
2405
|
};
|
|
2362
2406
|
}
|
|
2363
|
-
var
|
|
2364
|
-
var
|
|
2407
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
2408
|
+
var RULE_FEATURES41 = [];
|
|
2365
2409
|
var no_unstable_context_value_default = createRule({
|
|
2366
2410
|
meta: {
|
|
2367
2411
|
type: "problem",
|
|
2368
2412
|
docs: {
|
|
2369
2413
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2370
|
-
[Symbol.for("rule_features")]:
|
|
2414
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2371
2415
|
},
|
|
2372
2416
|
messages: {
|
|
2373
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}}"
|
|
2374
2418
|
},
|
|
2375
2419
|
schema: []
|
|
2376
2420
|
},
|
|
2377
|
-
name:
|
|
2378
|
-
create:
|
|
2421
|
+
name: RULE_NAME41,
|
|
2422
|
+
create: create41,
|
|
2379
2423
|
defaultOptions: []
|
|
2380
2424
|
});
|
|
2381
|
-
function
|
|
2425
|
+
function create41(context) {
|
|
2382
2426
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2383
2427
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2384
2428
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2433,25 +2477,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2433
2477
|
}
|
|
2434
2478
|
return false;
|
|
2435
2479
|
}
|
|
2436
|
-
var
|
|
2437
|
-
var
|
|
2480
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2481
|
+
var RULE_FEATURES42 = [];
|
|
2438
2482
|
var no_unstable_default_props_default = createRule({
|
|
2439
2483
|
meta: {
|
|
2440
2484
|
type: "problem",
|
|
2441
2485
|
docs: {
|
|
2442
2486
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2443
|
-
[Symbol.for("rule_features")]:
|
|
2487
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2444
2488
|
},
|
|
2445
2489
|
messages: {
|
|
2446
2490
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2447
2491
|
},
|
|
2448
2492
|
schema: []
|
|
2449
2493
|
},
|
|
2450
|
-
name:
|
|
2451
|
-
create:
|
|
2494
|
+
name: RULE_NAME42,
|
|
2495
|
+
create: create42,
|
|
2452
2496
|
defaultOptions: []
|
|
2453
2497
|
});
|
|
2454
|
-
function
|
|
2498
|
+
function create42(context) {
|
|
2455
2499
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2456
2500
|
const declarators = /* @__PURE__ */ new Map();
|
|
2457
2501
|
return {
|
|
@@ -2507,8 +2551,8 @@ function create41(context) {
|
|
|
2507
2551
|
}
|
|
2508
2552
|
};
|
|
2509
2553
|
}
|
|
2510
|
-
var
|
|
2511
|
-
var
|
|
2554
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2555
|
+
var RULE_FEATURES43 = [];
|
|
2512
2556
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2513
2557
|
"componentDidCatch",
|
|
2514
2558
|
"componentDidMount",
|
|
@@ -2534,18 +2578,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2534
2578
|
type: "problem",
|
|
2535
2579
|
docs: {
|
|
2536
2580
|
description: "Warns unused class component methods and properties.",
|
|
2537
|
-
[Symbol.for("rule_features")]:
|
|
2581
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2538
2582
|
},
|
|
2539
2583
|
messages: {
|
|
2540
2584
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2541
2585
|
},
|
|
2542
2586
|
schema: []
|
|
2543
2587
|
},
|
|
2544
|
-
name:
|
|
2545
|
-
create:
|
|
2588
|
+
name: RULE_NAME43,
|
|
2589
|
+
create: create43,
|
|
2546
2590
|
defaultOptions: []
|
|
2547
2591
|
});
|
|
2548
|
-
function
|
|
2592
|
+
function create43(context) {
|
|
2549
2593
|
const classEntries = [];
|
|
2550
2594
|
const methodEntries = [];
|
|
2551
2595
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2655,8 +2699,8 @@ function create42(context) {
|
|
|
2655
2699
|
}
|
|
2656
2700
|
};
|
|
2657
2701
|
}
|
|
2658
|
-
var
|
|
2659
|
-
var
|
|
2702
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2703
|
+
var RULE_FEATURES44 = [];
|
|
2660
2704
|
function isKeyLiteral3(node, key) {
|
|
2661
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);
|
|
2662
2706
|
}
|
|
@@ -2665,18 +2709,18 @@ var no_unused_state_default = createRule({
|
|
|
2665
2709
|
type: "problem",
|
|
2666
2710
|
docs: {
|
|
2667
2711
|
description: "Warns unused class component state.",
|
|
2668
|
-
[Symbol.for("rule_features")]:
|
|
2712
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2669
2713
|
},
|
|
2670
2714
|
messages: {
|
|
2671
2715
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2672
2716
|
},
|
|
2673
2717
|
schema: []
|
|
2674
2718
|
},
|
|
2675
|
-
name:
|
|
2676
|
-
create:
|
|
2719
|
+
name: RULE_NAME44,
|
|
2720
|
+
create: create44,
|
|
2677
2721
|
defaultOptions: []
|
|
2678
2722
|
});
|
|
2679
|
-
function
|
|
2723
|
+
function create44(context) {
|
|
2680
2724
|
const classEntries = [];
|
|
2681
2725
|
const methodEntries = [];
|
|
2682
2726
|
const constructorEntries = [];
|
|
@@ -2810,8 +2854,8 @@ function create43(context) {
|
|
|
2810
2854
|
}
|
|
2811
2855
|
};
|
|
2812
2856
|
}
|
|
2813
|
-
var
|
|
2814
|
-
var
|
|
2857
|
+
var RULE_NAME45 = "no-use-context";
|
|
2858
|
+
var RULE_FEATURES45 = [
|
|
2815
2859
|
"MOD"
|
|
2816
2860
|
];
|
|
2817
2861
|
var no_use_context_default = createRule({
|
|
@@ -2819,7 +2863,7 @@ var no_use_context_default = createRule({
|
|
|
2819
2863
|
type: "problem",
|
|
2820
2864
|
docs: {
|
|
2821
2865
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2822
|
-
[Symbol.for("rule_features")]:
|
|
2866
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2823
2867
|
},
|
|
2824
2868
|
fixable: "code",
|
|
2825
2869
|
messages: {
|
|
@@ -2827,11 +2871,11 @@ var no_use_context_default = createRule({
|
|
|
2827
2871
|
},
|
|
2828
2872
|
schema: []
|
|
2829
2873
|
},
|
|
2830
|
-
name:
|
|
2831
|
-
create:
|
|
2874
|
+
name: RULE_NAME45,
|
|
2875
|
+
create: create45,
|
|
2832
2876
|
defaultOptions: []
|
|
2833
2877
|
});
|
|
2834
|
-
function
|
|
2878
|
+
function create45(context) {
|
|
2835
2879
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2836
2880
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2837
2881
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2909,25 +2953,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2909
2953
|
return tokens;
|
|
2910
2954
|
}
|
|
2911
2955
|
}
|
|
2912
|
-
var
|
|
2913
|
-
var
|
|
2956
|
+
var RULE_NAME46 = "no-useless-forward-ref";
|
|
2957
|
+
var RULE_FEATURES46 = [];
|
|
2914
2958
|
var no_useless_forward_ref_default = createRule({
|
|
2915
2959
|
meta: {
|
|
2916
2960
|
type: "problem",
|
|
2917
2961
|
docs: {
|
|
2918
2962
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2919
|
-
[Symbol.for("rule_features")]:
|
|
2963
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2920
2964
|
},
|
|
2921
2965
|
messages: {
|
|
2922
2966
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2923
2967
|
},
|
|
2924
2968
|
schema: []
|
|
2925
2969
|
},
|
|
2926
|
-
name:
|
|
2927
|
-
create:
|
|
2970
|
+
name: RULE_NAME46,
|
|
2971
|
+
create: create46,
|
|
2928
2972
|
defaultOptions: []
|
|
2929
2973
|
});
|
|
2930
|
-
function
|
|
2974
|
+
function create46(context) {
|
|
2931
2975
|
return {
|
|
2932
2976
|
CallExpression(node) {
|
|
2933
2977
|
if (!core.isForwardRefCall(context, node)) {
|
|
@@ -2948,7 +2992,7 @@ function create45(context) {
|
|
|
2948
2992
|
}
|
|
2949
2993
|
};
|
|
2950
2994
|
}
|
|
2951
|
-
var
|
|
2995
|
+
var RULE_NAME47 = "no-useless-fragment";
|
|
2952
2996
|
var defaultOptions = [{
|
|
2953
2997
|
allowExpressions: true
|
|
2954
2998
|
}];
|
|
@@ -2974,11 +3018,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2974
3018
|
}
|
|
2975
3019
|
}]
|
|
2976
3020
|
},
|
|
2977
|
-
name:
|
|
2978
|
-
create:
|
|
3021
|
+
name: RULE_NAME47,
|
|
3022
|
+
create: create47,
|
|
2979
3023
|
defaultOptions
|
|
2980
3024
|
});
|
|
2981
|
-
function
|
|
3025
|
+
function create47(context, [option]) {
|
|
2982
3026
|
const { allowExpressions = true } = option;
|
|
2983
3027
|
return {
|
|
2984
3028
|
JSXElement(node) {
|
|
@@ -3090,8 +3134,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3090
3134
|
}
|
|
3091
3135
|
return;
|
|
3092
3136
|
}
|
|
3093
|
-
var
|
|
3094
|
-
var
|
|
3137
|
+
var RULE_NAME48 = "prefer-destructuring-assignment";
|
|
3138
|
+
var RULE_FEATURES47 = [];
|
|
3095
3139
|
function isMemberExpressionWithObjectName(node) {
|
|
3096
3140
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3097
3141
|
}
|
|
@@ -3100,18 +3144,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3100
3144
|
type: "problem",
|
|
3101
3145
|
docs: {
|
|
3102
3146
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3103
|
-
[Symbol.for("rule_features")]:
|
|
3147
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
3104
3148
|
},
|
|
3105
3149
|
messages: {
|
|
3106
3150
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3107
3151
|
},
|
|
3108
3152
|
schema: []
|
|
3109
3153
|
},
|
|
3110
|
-
name:
|
|
3111
|
-
create:
|
|
3154
|
+
name: RULE_NAME48,
|
|
3155
|
+
create: create48,
|
|
3112
3156
|
defaultOptions: []
|
|
3113
3157
|
});
|
|
3114
|
-
function
|
|
3158
|
+
function create48(context) {
|
|
3115
3159
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3116
3160
|
const memberExpressionWithNames = [];
|
|
3117
3161
|
return {
|
|
@@ -3171,8 +3215,8 @@ function create47(context) {
|
|
|
3171
3215
|
}
|
|
3172
3216
|
};
|
|
3173
3217
|
}
|
|
3174
|
-
var
|
|
3175
|
-
var
|
|
3218
|
+
var RULE_NAME49 = "prefer-react-namespace-import";
|
|
3219
|
+
var RULE_FEATURES48 = [
|
|
3176
3220
|
"FIX",
|
|
3177
3221
|
"EXP"
|
|
3178
3222
|
];
|
|
@@ -3181,7 +3225,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3181
3225
|
type: "problem",
|
|
3182
3226
|
docs: {
|
|
3183
3227
|
description: "Enforces React is imported via a namespace import.",
|
|
3184
|
-
[Symbol.for("rule_features")]:
|
|
3228
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3185
3229
|
},
|
|
3186
3230
|
fixable: "code",
|
|
3187
3231
|
messages: {
|
|
@@ -3189,11 +3233,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3189
3233
|
},
|
|
3190
3234
|
schema: []
|
|
3191
3235
|
},
|
|
3192
|
-
name:
|
|
3193
|
-
create:
|
|
3236
|
+
name: RULE_NAME49,
|
|
3237
|
+
create: create49,
|
|
3194
3238
|
defaultOptions: []
|
|
3195
3239
|
});
|
|
3196
|
-
function
|
|
3240
|
+
function create49(context) {
|
|
3197
3241
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3198
3242
|
return {
|
|
3199
3243
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3226,8 +3270,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3226
3270
|
}
|
|
3227
3271
|
};
|
|
3228
3272
|
}
|
|
3229
|
-
var
|
|
3230
|
-
var
|
|
3273
|
+
var RULE_NAME50 = "prefer-read-only-props";
|
|
3274
|
+
var RULE_FEATURES49 = [
|
|
3231
3275
|
"TSC",
|
|
3232
3276
|
"EXP"
|
|
3233
3277
|
];
|
|
@@ -3236,18 +3280,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3236
3280
|
type: "problem",
|
|
3237
3281
|
docs: {
|
|
3238
3282
|
description: "Enforces read-only props in components.",
|
|
3239
|
-
[Symbol.for("rule_features")]:
|
|
3283
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3240
3284
|
},
|
|
3241
3285
|
messages: {
|
|
3242
3286
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3243
3287
|
},
|
|
3244
3288
|
schema: []
|
|
3245
3289
|
},
|
|
3246
|
-
name:
|
|
3247
|
-
create:
|
|
3290
|
+
name: RULE_NAME50,
|
|
3291
|
+
create: create50,
|
|
3248
3292
|
defaultOptions: []
|
|
3249
3293
|
});
|
|
3250
|
-
function
|
|
3294
|
+
function create50(context) {
|
|
3251
3295
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3252
3296
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3253
3297
|
return {
|
|
@@ -3277,8 +3321,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3277
3321
|
return true;
|
|
3278
3322
|
}
|
|
3279
3323
|
}
|
|
3280
|
-
var
|
|
3281
|
-
var
|
|
3324
|
+
var RULE_NAME51 = "prefer-shorthand-boolean";
|
|
3325
|
+
var RULE_FEATURES50 = [
|
|
3282
3326
|
"FIX"
|
|
3283
3327
|
];
|
|
3284
3328
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3286,7 +3330,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3286
3330
|
type: "problem",
|
|
3287
3331
|
docs: {
|
|
3288
3332
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3289
|
-
[Symbol.for("rule_features")]:
|
|
3333
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3290
3334
|
},
|
|
3291
3335
|
fixable: "code",
|
|
3292
3336
|
messages: {
|
|
@@ -3294,11 +3338,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3294
3338
|
},
|
|
3295
3339
|
schema: []
|
|
3296
3340
|
},
|
|
3297
|
-
name:
|
|
3298
|
-
create:
|
|
3341
|
+
name: RULE_NAME51,
|
|
3342
|
+
create: create51,
|
|
3299
3343
|
defaultOptions: []
|
|
3300
3344
|
});
|
|
3301
|
-
function
|
|
3345
|
+
function create51(context) {
|
|
3302
3346
|
return {
|
|
3303
3347
|
JSXAttribute(node) {
|
|
3304
3348
|
const { value } = node;
|
|
@@ -3318,8 +3362,8 @@ function create50(context) {
|
|
|
3318
3362
|
}
|
|
3319
3363
|
};
|
|
3320
3364
|
}
|
|
3321
|
-
var
|
|
3322
|
-
var
|
|
3365
|
+
var RULE_NAME52 = "prefer-shorthand-fragment";
|
|
3366
|
+
var RULE_FEATURES51 = [
|
|
3323
3367
|
"FIX"
|
|
3324
3368
|
];
|
|
3325
3369
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3327,7 +3371,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3327
3371
|
type: "problem",
|
|
3328
3372
|
docs: {
|
|
3329
3373
|
description: "Enforces shorthand syntax for fragments.",
|
|
3330
|
-
[Symbol.for("rule_features")]:
|
|
3374
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3331
3375
|
},
|
|
3332
3376
|
fixable: "code",
|
|
3333
3377
|
messages: {
|
|
@@ -3335,11 +3379,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3335
3379
|
},
|
|
3336
3380
|
schema: []
|
|
3337
3381
|
},
|
|
3338
|
-
name:
|
|
3339
|
-
create:
|
|
3382
|
+
name: RULE_NAME52,
|
|
3383
|
+
create: create52,
|
|
3340
3384
|
defaultOptions: []
|
|
3341
3385
|
});
|
|
3342
|
-
function
|
|
3386
|
+
function create52(context) {
|
|
3343
3387
|
return {
|
|
3344
3388
|
JSXElement(node) {
|
|
3345
3389
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
@@ -3364,46 +3408,6 @@ function create51(context) {
|
|
|
3364
3408
|
}
|
|
3365
3409
|
};
|
|
3366
3410
|
}
|
|
3367
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3368
|
-
var RULE_FEATURES51 = [];
|
|
3369
|
-
var use_jsx_vars_default = createRule({
|
|
3370
|
-
meta: {
|
|
3371
|
-
type: "problem",
|
|
3372
|
-
docs: {
|
|
3373
|
-
description: "Marks variables used in JSX as used.",
|
|
3374
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3375
|
-
},
|
|
3376
|
-
messages: {
|
|
3377
|
-
useJsxVars: ""
|
|
3378
|
-
},
|
|
3379
|
-
schema: []
|
|
3380
|
-
},
|
|
3381
|
-
name: RULE_NAME52,
|
|
3382
|
-
create: create52,
|
|
3383
|
-
defaultOptions: []
|
|
3384
|
-
});
|
|
3385
|
-
function create52(context) {
|
|
3386
|
-
return {
|
|
3387
|
-
JSXOpeningElement(node) {
|
|
3388
|
-
switch (node.name.type) {
|
|
3389
|
-
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
3390
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3391
|
-
return;
|
|
3392
|
-
}
|
|
3393
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3394
|
-
break;
|
|
3395
|
-
}
|
|
3396
|
-
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
3397
|
-
const { object } = node.name;
|
|
3398
|
-
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
3399
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3400
|
-
}
|
|
3401
|
-
break;
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
};
|
|
3406
|
-
}
|
|
3407
3411
|
|
|
3408
3412
|
// src/plugin.ts
|
|
3409
3413
|
var plugin = {
|
|
@@ -3433,7 +3437,6 @@ var plugin = {
|
|
|
3433
3437
|
"no-create-ref": no_create_ref_default,
|
|
3434
3438
|
"no-default-props": no_default_props_default,
|
|
3435
3439
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3436
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3437
3440
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3438
3441
|
"no-forward-ref": no_forward_ref_default,
|
|
3439
3442
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3463,18 +3466,20 @@ var plugin = {
|
|
|
3463
3466
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3464
3467
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3465
3468
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3466
|
-
|
|
3469
|
+
// Part: JSX only rules
|
|
3470
|
+
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3471
|
+
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3467
3472
|
// Part: deprecated rules
|
|
3468
3473
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3469
3474
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3470
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3471
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3472
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3473
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3474
3475
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3475
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,
|
|
3476
3479
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3477
|
-
"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
|
|
3478
3483
|
}
|
|
3479
3484
|
};
|
|
3480
3485
|
|