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.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getDocsUrl, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
2
|
import * as JSX8 from '@eslint-react/jsx';
|
|
3
3
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
4
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
4
5
|
import * as AST11 from '@eslint-react/ast';
|
|
5
6
|
import { isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isComponentNameLoose, isCreateRefCall, isAssignmentToThisState, isForwardRefCall, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, getInstanceId, isInstanceIdEqual, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideRenderMethod, isCreateElementCall, isReactHookCall, isReactHookCallWithNameAlias, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
6
7
|
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
7
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
8
8
|
import { isMatching, match, P } from 'ts-pattern';
|
|
9
9
|
import { createReport } from '@eslint-react/kit';
|
|
10
10
|
import { compare } from 'compare-versions';
|
|
@@ -45,7 +45,7 @@ var rules = {
|
|
|
45
45
|
"react-x/no-create-ref": "error",
|
|
46
46
|
"react-x/no-default-props": "error",
|
|
47
47
|
"react-x/no-direct-mutation-state": "error",
|
|
48
|
-
"react-x/no-duplicate-
|
|
48
|
+
"react-x/jsx-no-duplicate-props": "warn",
|
|
49
49
|
"react-x/no-duplicate-key": "warn",
|
|
50
50
|
"react-x/no-forward-ref": "warn",
|
|
51
51
|
"react-x/no-implicit-key": "warn",
|
|
@@ -66,7 +66,7 @@ var rules = {
|
|
|
66
66
|
"react-x/no-unused-state": "warn",
|
|
67
67
|
"react-x/no-use-context": "warn",
|
|
68
68
|
"react-x/no-useless-forward-ref": "warn",
|
|
69
|
-
"react-x/
|
|
69
|
+
"react-x/jsx-uses-vars": "warn"
|
|
70
70
|
};
|
|
71
71
|
var settings = {
|
|
72
72
|
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
@@ -90,8 +90,8 @@ __export(recommended_typescript_exports, {
|
|
|
90
90
|
var name2 = "react-x/recommended-typescript";
|
|
91
91
|
var rules2 = {
|
|
92
92
|
...rules,
|
|
93
|
-
"react-x/no-duplicate-
|
|
94
|
-
"react-x/
|
|
93
|
+
"react-x/jsx-no-duplicate-props": "off",
|
|
94
|
+
"react-x/jsx-uses-vars": "off"
|
|
95
95
|
};
|
|
96
96
|
var settings2 = {
|
|
97
97
|
...settings
|
|
@@ -110,7 +110,7 @@ var settings3 = {
|
|
|
110
110
|
|
|
111
111
|
// package.json
|
|
112
112
|
var name4 = "eslint-plugin-react-x";
|
|
113
|
-
var version = "1.38.0-beta.
|
|
113
|
+
var version = "1.38.0-beta.7";
|
|
114
114
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
115
115
|
|
|
116
116
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -179,8 +179,90 @@ function create2(context) {
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
var RULE_NAME3 = "no-
|
|
182
|
+
var RULE_NAME3 = "jsx-no-duplicate-props";
|
|
183
183
|
var RULE_FEATURES3 = [];
|
|
184
|
+
var jsx_no_duplicate_props_default = createRule({
|
|
185
|
+
meta: {
|
|
186
|
+
type: "problem",
|
|
187
|
+
docs: {
|
|
188
|
+
description: "Disallow duplicate props in JSX elements.",
|
|
189
|
+
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
190
|
+
},
|
|
191
|
+
messages: {
|
|
192
|
+
jsxNoDuplicateProps: "This JSX property is assigned multiple times."
|
|
193
|
+
},
|
|
194
|
+
schema: []
|
|
195
|
+
},
|
|
196
|
+
name: RULE_NAME3,
|
|
197
|
+
create: create3,
|
|
198
|
+
defaultOptions: []
|
|
199
|
+
});
|
|
200
|
+
function create3(context) {
|
|
201
|
+
return {
|
|
202
|
+
JSXOpeningElement(node) {
|
|
203
|
+
const props = [];
|
|
204
|
+
for (const attr of node.attributes) {
|
|
205
|
+
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const name5 = attr.name.name;
|
|
209
|
+
if (typeof name5 !== "string") {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (!props.includes(name5)) {
|
|
213
|
+
props.push(name5);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
context.report({
|
|
217
|
+
messageId: "jsxNoDuplicateProps",
|
|
218
|
+
node: attr
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
var RULE_NAME4 = "jsx-uses-vars";
|
|
225
|
+
var RULE_FEATURES4 = [];
|
|
226
|
+
var jsx_uses_vars_default = createRule({
|
|
227
|
+
meta: {
|
|
228
|
+
type: "problem",
|
|
229
|
+
docs: {
|
|
230
|
+
description: "Marks variables used in JSX as used.",
|
|
231
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
232
|
+
},
|
|
233
|
+
messages: {
|
|
234
|
+
jsxUsesVars: "JSX variables should be marked as used."
|
|
235
|
+
},
|
|
236
|
+
schema: []
|
|
237
|
+
},
|
|
238
|
+
name: RULE_NAME4,
|
|
239
|
+
create: create4,
|
|
240
|
+
defaultOptions: []
|
|
241
|
+
});
|
|
242
|
+
function create4(context) {
|
|
243
|
+
return {
|
|
244
|
+
JSXOpeningElement(node) {
|
|
245
|
+
switch (node.name.type) {
|
|
246
|
+
case AST_NODE_TYPES.JSXIdentifier: {
|
|
247
|
+
if (/^[a-z]/u.test(node.name.name)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case AST_NODE_TYPES.JSXMemberExpression: {
|
|
254
|
+
const { object } = node.name;
|
|
255
|
+
if (object.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
256
|
+
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
var RULE_NAME5 = "no-access-state-in-setstate";
|
|
265
|
+
var RULE_FEATURES5 = [];
|
|
184
266
|
function isKeyLiteral(node, key) {
|
|
185
267
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
186
268
|
}
|
|
@@ -189,18 +271,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
189
271
|
type: "problem",
|
|
190
272
|
docs: {
|
|
191
273
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
192
|
-
[Symbol.for("rule_features")]:
|
|
274
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
193
275
|
},
|
|
194
276
|
messages: {
|
|
195
277
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
196
278
|
},
|
|
197
279
|
schema: []
|
|
198
280
|
},
|
|
199
|
-
name:
|
|
200
|
-
create:
|
|
281
|
+
name: RULE_NAME5,
|
|
282
|
+
create: create5,
|
|
201
283
|
defaultOptions: []
|
|
202
284
|
});
|
|
203
|
-
function
|
|
285
|
+
function create5(context) {
|
|
204
286
|
if (!context.sourceCode.text.includes("setState")) {
|
|
205
287
|
return {};
|
|
206
288
|
}
|
|
@@ -291,8 +373,8 @@ function create3(context) {
|
|
|
291
373
|
}
|
|
292
374
|
};
|
|
293
375
|
}
|
|
294
|
-
var
|
|
295
|
-
var
|
|
376
|
+
var RULE_NAME6 = "no-array-index-key";
|
|
377
|
+
var RULE_FEATURES6 = [];
|
|
296
378
|
var reactChildrenMethod = ["forEach", "map"];
|
|
297
379
|
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
298
380
|
["every", 1],
|
|
@@ -376,18 +458,18 @@ var no_array_index_key_default = createRule({
|
|
|
376
458
|
type: "problem",
|
|
377
459
|
docs: {
|
|
378
460
|
description: "Disallow an item's index in the array as its key.",
|
|
379
|
-
[Symbol.for("rule_features")]:
|
|
461
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
380
462
|
},
|
|
381
463
|
messages: {
|
|
382
464
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
383
465
|
},
|
|
384
466
|
schema: []
|
|
385
467
|
},
|
|
386
|
-
name:
|
|
387
|
-
create:
|
|
468
|
+
name: RULE_NAME6,
|
|
469
|
+
create: create6,
|
|
388
470
|
defaultOptions: []
|
|
389
471
|
});
|
|
390
|
-
function
|
|
472
|
+
function create6(context) {
|
|
391
473
|
const report = createReport(context);
|
|
392
474
|
const indexParamNames = [];
|
|
393
475
|
function isArrayIndex(node) {
|
|
@@ -485,25 +567,25 @@ function create4(context) {
|
|
|
485
567
|
}
|
|
486
568
|
};
|
|
487
569
|
}
|
|
488
|
-
var
|
|
489
|
-
var
|
|
570
|
+
var RULE_NAME7 = "no-children-count";
|
|
571
|
+
var RULE_FEATURES7 = [];
|
|
490
572
|
var no_children_count_default = createRule({
|
|
491
573
|
meta: {
|
|
492
574
|
type: "problem",
|
|
493
575
|
docs: {
|
|
494
576
|
description: "Disallow `Children.count`.",
|
|
495
|
-
[Symbol.for("rule_features")]:
|
|
577
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
496
578
|
},
|
|
497
579
|
messages: {
|
|
498
580
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
499
581
|
},
|
|
500
582
|
schema: []
|
|
501
583
|
},
|
|
502
|
-
name:
|
|
503
|
-
create:
|
|
584
|
+
name: RULE_NAME7,
|
|
585
|
+
create: create7,
|
|
504
586
|
defaultOptions: []
|
|
505
587
|
});
|
|
506
|
-
function
|
|
588
|
+
function create7(context) {
|
|
507
589
|
return {
|
|
508
590
|
MemberExpression(node) {
|
|
509
591
|
if (isChildrenCount(context, node)) {
|
|
@@ -515,25 +597,25 @@ function create5(context) {
|
|
|
515
597
|
}
|
|
516
598
|
};
|
|
517
599
|
}
|
|
518
|
-
var
|
|
519
|
-
var
|
|
600
|
+
var RULE_NAME8 = "no-children-for-each";
|
|
601
|
+
var RULE_FEATURES8 = [];
|
|
520
602
|
var no_children_for_each_default = createRule({
|
|
521
603
|
meta: {
|
|
522
604
|
type: "problem",
|
|
523
605
|
docs: {
|
|
524
606
|
description: "Disallow 'Children.forEach'.",
|
|
525
|
-
[Symbol.for("rule_features")]:
|
|
607
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
526
608
|
},
|
|
527
609
|
messages: {
|
|
528
610
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
529
611
|
},
|
|
530
612
|
schema: []
|
|
531
613
|
},
|
|
532
|
-
name:
|
|
533
|
-
create:
|
|
614
|
+
name: RULE_NAME8,
|
|
615
|
+
create: create8,
|
|
534
616
|
defaultOptions: []
|
|
535
617
|
});
|
|
536
|
-
function
|
|
618
|
+
function create8(context) {
|
|
537
619
|
return {
|
|
538
620
|
MemberExpression(node) {
|
|
539
621
|
if (isChildrenForEach(context, node)) {
|
|
@@ -545,25 +627,25 @@ function create6(context) {
|
|
|
545
627
|
}
|
|
546
628
|
};
|
|
547
629
|
}
|
|
548
|
-
var
|
|
549
|
-
var
|
|
630
|
+
var RULE_NAME9 = "no-children-map";
|
|
631
|
+
var RULE_FEATURES9 = [];
|
|
550
632
|
var no_children_map_default = createRule({
|
|
551
633
|
meta: {
|
|
552
634
|
type: "problem",
|
|
553
635
|
docs: {
|
|
554
636
|
description: "Disallow `Children.map`.",
|
|
555
|
-
[Symbol.for("rule_features")]:
|
|
637
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
556
638
|
},
|
|
557
639
|
messages: {
|
|
558
640
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
559
641
|
},
|
|
560
642
|
schema: []
|
|
561
643
|
},
|
|
562
|
-
name:
|
|
563
|
-
create:
|
|
644
|
+
name: RULE_NAME9,
|
|
645
|
+
create: create9,
|
|
564
646
|
defaultOptions: []
|
|
565
647
|
});
|
|
566
|
-
function
|
|
648
|
+
function create9(context) {
|
|
567
649
|
return {
|
|
568
650
|
MemberExpression(node) {
|
|
569
651
|
if (isChildrenMap(context, node)) {
|
|
@@ -575,25 +657,25 @@ function create7(context) {
|
|
|
575
657
|
}
|
|
576
658
|
};
|
|
577
659
|
}
|
|
578
|
-
var
|
|
579
|
-
var
|
|
660
|
+
var RULE_NAME10 = "no-children-only";
|
|
661
|
+
var RULE_FEATURES10 = [];
|
|
580
662
|
var no_children_only_default = createRule({
|
|
581
663
|
meta: {
|
|
582
664
|
type: "problem",
|
|
583
665
|
docs: {
|
|
584
666
|
description: "Disallow `Children.only`.",
|
|
585
|
-
[Symbol.for("rule_features")]:
|
|
667
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
586
668
|
},
|
|
587
669
|
messages: {
|
|
588
670
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
589
671
|
},
|
|
590
672
|
schema: []
|
|
591
673
|
},
|
|
592
|
-
name:
|
|
593
|
-
create:
|
|
674
|
+
name: RULE_NAME10,
|
|
675
|
+
create: create10,
|
|
594
676
|
defaultOptions: []
|
|
595
677
|
});
|
|
596
|
-
function
|
|
678
|
+
function create10(context) {
|
|
597
679
|
return {
|
|
598
680
|
MemberExpression(node) {
|
|
599
681
|
if (isChildrenOnly(context, node)) {
|
|
@@ -605,25 +687,25 @@ function create8(context) {
|
|
|
605
687
|
}
|
|
606
688
|
};
|
|
607
689
|
}
|
|
608
|
-
var
|
|
609
|
-
var
|
|
690
|
+
var RULE_NAME11 = "no-children-prop";
|
|
691
|
+
var RULE_FEATURES11 = [];
|
|
610
692
|
var no_children_prop_default = createRule({
|
|
611
693
|
meta: {
|
|
612
694
|
type: "problem",
|
|
613
695
|
docs: {
|
|
614
696
|
description: "Disallow passing `children` as a prop.",
|
|
615
|
-
[Symbol.for("rule_features")]:
|
|
697
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
616
698
|
},
|
|
617
699
|
messages: {
|
|
618
700
|
noChildrenProp: "Do not pass 'children' as props."
|
|
619
701
|
},
|
|
620
702
|
schema: []
|
|
621
703
|
},
|
|
622
|
-
name:
|
|
623
|
-
create:
|
|
704
|
+
name: RULE_NAME11,
|
|
705
|
+
create: create11,
|
|
624
706
|
defaultOptions: []
|
|
625
707
|
});
|
|
626
|
-
function
|
|
708
|
+
function create11(context) {
|
|
627
709
|
return {
|
|
628
710
|
JSXElement(node) {
|
|
629
711
|
const attribute = JSX8.getAttribute(
|
|
@@ -640,25 +722,25 @@ function create9(context) {
|
|
|
640
722
|
}
|
|
641
723
|
};
|
|
642
724
|
}
|
|
643
|
-
var
|
|
644
|
-
var
|
|
725
|
+
var RULE_NAME12 = "no-children-to-array";
|
|
726
|
+
var RULE_FEATURES12 = [];
|
|
645
727
|
var no_children_to_array_default = createRule({
|
|
646
728
|
meta: {
|
|
647
729
|
type: "problem",
|
|
648
730
|
docs: {
|
|
649
731
|
description: "Disallow `Children.toArray`.",
|
|
650
|
-
[Symbol.for("rule_features")]:
|
|
732
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
651
733
|
},
|
|
652
734
|
messages: {
|
|
653
735
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
654
736
|
},
|
|
655
737
|
schema: []
|
|
656
738
|
},
|
|
657
|
-
name:
|
|
658
|
-
create:
|
|
739
|
+
name: RULE_NAME12,
|
|
740
|
+
create: create12,
|
|
659
741
|
defaultOptions: []
|
|
660
742
|
});
|
|
661
|
-
function
|
|
743
|
+
function create12(context) {
|
|
662
744
|
return {
|
|
663
745
|
MemberExpression(node) {
|
|
664
746
|
if (isChildrenToArray(context, node)) {
|
|
@@ -670,25 +752,25 @@ function create10(context) {
|
|
|
670
752
|
}
|
|
671
753
|
};
|
|
672
754
|
}
|
|
673
|
-
var
|
|
674
|
-
var
|
|
755
|
+
var RULE_NAME13 = "no-class-component";
|
|
756
|
+
var RULE_FEATURES13 = [];
|
|
675
757
|
var no_class_component_default = createRule({
|
|
676
758
|
meta: {
|
|
677
759
|
type: "problem",
|
|
678
760
|
docs: {
|
|
679
761
|
description: "Disallow class components.",
|
|
680
|
-
[Symbol.for("rule_features")]:
|
|
762
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
681
763
|
},
|
|
682
764
|
messages: {
|
|
683
765
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
684
766
|
},
|
|
685
767
|
schema: []
|
|
686
768
|
},
|
|
687
|
-
name:
|
|
688
|
-
create:
|
|
769
|
+
name: RULE_NAME13,
|
|
770
|
+
create: create13,
|
|
689
771
|
defaultOptions: []
|
|
690
772
|
});
|
|
691
|
-
function
|
|
773
|
+
function create13(context) {
|
|
692
774
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
693
775
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
694
776
|
return {
|
|
@@ -710,25 +792,25 @@ function create11(context) {
|
|
|
710
792
|
}
|
|
711
793
|
};
|
|
712
794
|
}
|
|
713
|
-
var
|
|
714
|
-
var
|
|
795
|
+
var RULE_NAME14 = "no-clone-element";
|
|
796
|
+
var RULE_FEATURES14 = [];
|
|
715
797
|
var no_clone_element_default = createRule({
|
|
716
798
|
meta: {
|
|
717
799
|
type: "problem",
|
|
718
800
|
docs: {
|
|
719
801
|
description: "Disallow `cloneElement`.",
|
|
720
|
-
[Symbol.for("rule_features")]:
|
|
802
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
721
803
|
},
|
|
722
804
|
messages: {
|
|
723
805
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
724
806
|
},
|
|
725
807
|
schema: []
|
|
726
808
|
},
|
|
727
|
-
name:
|
|
728
|
-
create:
|
|
809
|
+
name: RULE_NAME14,
|
|
810
|
+
create: create14,
|
|
729
811
|
defaultOptions: []
|
|
730
812
|
});
|
|
731
|
-
function
|
|
813
|
+
function create14(context) {
|
|
732
814
|
return {
|
|
733
815
|
CallExpression(node) {
|
|
734
816
|
if (!isCloneElementCall(context, node)) {
|
|
@@ -741,25 +823,25 @@ function create12(context) {
|
|
|
741
823
|
}
|
|
742
824
|
};
|
|
743
825
|
}
|
|
744
|
-
var
|
|
745
|
-
var
|
|
826
|
+
var RULE_NAME15 = "no-comment-textnodes";
|
|
827
|
+
var RULE_FEATURES15 = [];
|
|
746
828
|
var no_comment_textnodes_default = createRule({
|
|
747
829
|
meta: {
|
|
748
830
|
type: "problem",
|
|
749
831
|
docs: {
|
|
750
832
|
description: "Prevents comments from being inserted as text nodes.",
|
|
751
|
-
[Symbol.for("rule_features")]:
|
|
833
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
752
834
|
},
|
|
753
835
|
messages: {
|
|
754
836
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
755
837
|
},
|
|
756
838
|
schema: []
|
|
757
839
|
},
|
|
758
|
-
name:
|
|
759
|
-
create:
|
|
840
|
+
name: RULE_NAME15,
|
|
841
|
+
create: create15,
|
|
760
842
|
defaultOptions: []
|
|
761
843
|
});
|
|
762
|
-
function
|
|
844
|
+
function create15(context) {
|
|
763
845
|
function hasCommentLike(node) {
|
|
764
846
|
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
765
847
|
return false;
|
|
@@ -787,8 +869,8 @@ function create13(context) {
|
|
|
787
869
|
Literal: visitorFunction
|
|
788
870
|
};
|
|
789
871
|
}
|
|
790
|
-
var
|
|
791
|
-
var
|
|
872
|
+
var RULE_NAME16 = "no-complex-conditional-rendering";
|
|
873
|
+
var RULE_FEATURES16 = [
|
|
792
874
|
"EXP"
|
|
793
875
|
];
|
|
794
876
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -796,18 +878,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
796
878
|
type: "problem",
|
|
797
879
|
docs: {
|
|
798
880
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
799
|
-
[Symbol.for("rule_features")]:
|
|
881
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
800
882
|
},
|
|
801
883
|
messages: {
|
|
802
884
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
803
885
|
},
|
|
804
886
|
schema: []
|
|
805
887
|
},
|
|
806
|
-
name:
|
|
807
|
-
create:
|
|
888
|
+
name: RULE_NAME16,
|
|
889
|
+
create: create16,
|
|
808
890
|
defaultOptions: []
|
|
809
891
|
});
|
|
810
|
-
function
|
|
892
|
+
function create16(context) {
|
|
811
893
|
const visitorFunction = (node) => {
|
|
812
894
|
const jsxExpContainer = node.parent?.parent;
|
|
813
895
|
if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -832,8 +914,8 @@ function create14(context) {
|
|
|
832
914
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
833
915
|
};
|
|
834
916
|
}
|
|
835
|
-
var
|
|
836
|
-
var
|
|
917
|
+
var RULE_NAME17 = "no-component-will-mount";
|
|
918
|
+
var RULE_FEATURES17 = [
|
|
837
919
|
"MOD"
|
|
838
920
|
];
|
|
839
921
|
function isComponentWillMount(node) {
|
|
@@ -844,7 +926,7 @@ var no_component_will_mount_default = createRule({
|
|
|
844
926
|
type: "problem",
|
|
845
927
|
docs: {
|
|
846
928
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
847
|
-
[Symbol.for("rule_features")]:
|
|
929
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
848
930
|
},
|
|
849
931
|
fixable: "code",
|
|
850
932
|
messages: {
|
|
@@ -852,11 +934,11 @@ var no_component_will_mount_default = createRule({
|
|
|
852
934
|
},
|
|
853
935
|
schema: []
|
|
854
936
|
},
|
|
855
|
-
name:
|
|
856
|
-
create:
|
|
937
|
+
name: RULE_NAME17,
|
|
938
|
+
create: create17,
|
|
857
939
|
defaultOptions: []
|
|
858
940
|
});
|
|
859
|
-
function
|
|
941
|
+
function create17(context) {
|
|
860
942
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
861
943
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
862
944
|
return {
|
|
@@ -883,8 +965,8 @@ function create15(context) {
|
|
|
883
965
|
}
|
|
884
966
|
};
|
|
885
967
|
}
|
|
886
|
-
var
|
|
887
|
-
var
|
|
968
|
+
var RULE_NAME18 = "no-component-will-receive-props";
|
|
969
|
+
var RULE_FEATURES18 = [
|
|
888
970
|
"MOD"
|
|
889
971
|
];
|
|
890
972
|
function isComponentWillUpdate(node) {
|
|
@@ -895,7 +977,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
895
977
|
type: "problem",
|
|
896
978
|
docs: {
|
|
897
979
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
898
|
-
[Symbol.for("rule_features")]:
|
|
980
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
899
981
|
},
|
|
900
982
|
fixable: "code",
|
|
901
983
|
messages: {
|
|
@@ -903,11 +985,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
903
985
|
},
|
|
904
986
|
schema: []
|
|
905
987
|
},
|
|
906
|
-
name:
|
|
907
|
-
create:
|
|
988
|
+
name: RULE_NAME18,
|
|
989
|
+
create: create18,
|
|
908
990
|
defaultOptions: []
|
|
909
991
|
});
|
|
910
|
-
function
|
|
992
|
+
function create18(context) {
|
|
911
993
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
912
994
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
913
995
|
return {
|
|
@@ -934,8 +1016,8 @@ function create16(context) {
|
|
|
934
1016
|
}
|
|
935
1017
|
};
|
|
936
1018
|
}
|
|
937
|
-
var
|
|
938
|
-
var
|
|
1019
|
+
var RULE_NAME19 = "no-component-will-update";
|
|
1020
|
+
var RULE_FEATURES19 = [
|
|
939
1021
|
"MOD"
|
|
940
1022
|
];
|
|
941
1023
|
function isComponentWillUpdate2(node) {
|
|
@@ -946,7 +1028,7 @@ var no_component_will_update_default = createRule({
|
|
|
946
1028
|
type: "problem",
|
|
947
1029
|
docs: {
|
|
948
1030
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
949
|
-
[Symbol.for("rule_features")]:
|
|
1031
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
950
1032
|
},
|
|
951
1033
|
fixable: "code",
|
|
952
1034
|
messages: {
|
|
@@ -954,11 +1036,11 @@ var no_component_will_update_default = createRule({
|
|
|
954
1036
|
},
|
|
955
1037
|
schema: []
|
|
956
1038
|
},
|
|
957
|
-
name:
|
|
958
|
-
create:
|
|
1039
|
+
name: RULE_NAME19,
|
|
1040
|
+
create: create19,
|
|
959
1041
|
defaultOptions: []
|
|
960
1042
|
});
|
|
961
|
-
function
|
|
1043
|
+
function create19(context) {
|
|
962
1044
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
963
1045
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
964
1046
|
return {
|
|
@@ -985,8 +1067,8 @@ function create17(context) {
|
|
|
985
1067
|
}
|
|
986
1068
|
};
|
|
987
1069
|
}
|
|
988
|
-
var
|
|
989
|
-
var
|
|
1070
|
+
var RULE_NAME20 = "no-context-provider";
|
|
1071
|
+
var RULE_FEATURES20 = [
|
|
990
1072
|
"MOD"
|
|
991
1073
|
];
|
|
992
1074
|
var no_context_provider_default = createRule({
|
|
@@ -994,7 +1076,7 @@ var no_context_provider_default = createRule({
|
|
|
994
1076
|
type: "problem",
|
|
995
1077
|
docs: {
|
|
996
1078
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
997
|
-
[Symbol.for("rule_features")]:
|
|
1079
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
998
1080
|
},
|
|
999
1081
|
fixable: "code",
|
|
1000
1082
|
messages: {
|
|
@@ -1002,11 +1084,11 @@ var no_context_provider_default = createRule({
|
|
|
1002
1084
|
},
|
|
1003
1085
|
schema: []
|
|
1004
1086
|
},
|
|
1005
|
-
name:
|
|
1006
|
-
create:
|
|
1087
|
+
name: RULE_NAME20,
|
|
1088
|
+
create: create20,
|
|
1007
1089
|
defaultOptions: []
|
|
1008
1090
|
});
|
|
1009
|
-
function
|
|
1091
|
+
function create20(context) {
|
|
1010
1092
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1011
1093
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1012
1094
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1038,25 +1120,25 @@ function create18(context) {
|
|
|
1038
1120
|
}
|
|
1039
1121
|
};
|
|
1040
1122
|
}
|
|
1041
|
-
var
|
|
1042
|
-
var
|
|
1123
|
+
var RULE_NAME21 = "no-create-ref";
|
|
1124
|
+
var RULE_FEATURES21 = [];
|
|
1043
1125
|
var no_create_ref_default = createRule({
|
|
1044
1126
|
meta: {
|
|
1045
1127
|
type: "problem",
|
|
1046
1128
|
docs: {
|
|
1047
1129
|
description: "Disallow `createRef` in function components.",
|
|
1048
|
-
[Symbol.for("rule_features")]:
|
|
1130
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1049
1131
|
},
|
|
1050
1132
|
messages: {
|
|
1051
1133
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1052
1134
|
},
|
|
1053
1135
|
schema: []
|
|
1054
1136
|
},
|
|
1055
|
-
name:
|
|
1056
|
-
create:
|
|
1137
|
+
name: RULE_NAME21,
|
|
1138
|
+
create: create21,
|
|
1057
1139
|
defaultOptions: []
|
|
1058
1140
|
});
|
|
1059
|
-
function
|
|
1141
|
+
function create21(context) {
|
|
1060
1142
|
return {
|
|
1061
1143
|
CallExpression(node) {
|
|
1062
1144
|
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
@@ -1065,25 +1147,25 @@ function create19(context) {
|
|
|
1065
1147
|
}
|
|
1066
1148
|
};
|
|
1067
1149
|
}
|
|
1068
|
-
var
|
|
1069
|
-
var
|
|
1150
|
+
var RULE_NAME22 = "no-default-props";
|
|
1151
|
+
var RULE_FEATURES22 = [];
|
|
1070
1152
|
var no_default_props_default = createRule({
|
|
1071
1153
|
meta: {
|
|
1072
1154
|
type: "problem",
|
|
1073
1155
|
docs: {
|
|
1074
1156
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1075
|
-
[Symbol.for("rule_features")]:
|
|
1157
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1076
1158
|
},
|
|
1077
1159
|
messages: {
|
|
1078
1160
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1079
1161
|
},
|
|
1080
1162
|
schema: []
|
|
1081
1163
|
},
|
|
1082
|
-
name:
|
|
1083
|
-
create:
|
|
1164
|
+
name: RULE_NAME22,
|
|
1165
|
+
create: create22,
|
|
1084
1166
|
defaultOptions: []
|
|
1085
1167
|
});
|
|
1086
|
-
function
|
|
1168
|
+
function create22(context) {
|
|
1087
1169
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1088
1170
|
return {
|
|
1089
1171
|
AssignmentExpression(node) {
|
|
@@ -1117,8 +1199,8 @@ function create20(context) {
|
|
|
1117
1199
|
}
|
|
1118
1200
|
};
|
|
1119
1201
|
}
|
|
1120
|
-
var
|
|
1121
|
-
var
|
|
1202
|
+
var RULE_NAME23 = "no-direct-mutation-state";
|
|
1203
|
+
var RULE_FEATURES23 = [];
|
|
1122
1204
|
function isConstructorFunction(node) {
|
|
1123
1205
|
return AST11.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && AST11.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1124
1206
|
}
|
|
@@ -1127,18 +1209,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1127
1209
|
type: "problem",
|
|
1128
1210
|
docs: {
|
|
1129
1211
|
description: "Disallow direct mutation of `this.state`.",
|
|
1130
|
-
[Symbol.for("rule_features")]:
|
|
1212
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1131
1213
|
},
|
|
1132
1214
|
messages: {
|
|
1133
1215
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1134
1216
|
},
|
|
1135
1217
|
schema: []
|
|
1136
1218
|
},
|
|
1137
|
-
name:
|
|
1138
|
-
create:
|
|
1219
|
+
name: RULE_NAME23,
|
|
1220
|
+
create: create23,
|
|
1139
1221
|
defaultOptions: []
|
|
1140
1222
|
});
|
|
1141
|
-
function
|
|
1223
|
+
function create23(context) {
|
|
1142
1224
|
return {
|
|
1143
1225
|
AssignmentExpression(node) {
|
|
1144
1226
|
if (!isAssignmentToThisState(node)) return;
|
|
@@ -1159,67 +1241,25 @@ function create21(context) {
|
|
|
1159
1241
|
}
|
|
1160
1242
|
};
|
|
1161
1243
|
}
|
|
1162
|
-
var
|
|
1163
|
-
var
|
|
1164
|
-
var no_duplicate_jsx_props_default = createRule({
|
|
1165
|
-
meta: {
|
|
1166
|
-
type: "problem",
|
|
1167
|
-
docs: {
|
|
1168
|
-
description: "Disallow duplicate props in JSX elements.",
|
|
1169
|
-
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1170
|
-
},
|
|
1171
|
-
messages: {
|
|
1172
|
-
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1173
|
-
},
|
|
1174
|
-
schema: []
|
|
1175
|
-
},
|
|
1176
|
-
name: RULE_NAME22,
|
|
1177
|
-
create: create22,
|
|
1178
|
-
defaultOptions: []
|
|
1179
|
-
});
|
|
1180
|
-
function create22(context) {
|
|
1181
|
-
return {
|
|
1182
|
-
JSXOpeningElement(node) {
|
|
1183
|
-
const props = [];
|
|
1184
|
-
for (const attr of node.attributes) {
|
|
1185
|
-
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1186
|
-
continue;
|
|
1187
|
-
}
|
|
1188
|
-
const name5 = attr.name.name;
|
|
1189
|
-
if (typeof name5 !== "string") {
|
|
1190
|
-
continue;
|
|
1191
|
-
}
|
|
1192
|
-
if (!props.includes(name5)) {
|
|
1193
|
-
props.push(name5);
|
|
1194
|
-
continue;
|
|
1195
|
-
}
|
|
1196
|
-
context.report({
|
|
1197
|
-
messageId: "noDuplicateJsxProps",
|
|
1198
|
-
node: attr
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
var RULE_NAME23 = "no-duplicate-key";
|
|
1205
|
-
var RULE_FEATURES23 = [];
|
|
1244
|
+
var RULE_NAME24 = "no-duplicate-key";
|
|
1245
|
+
var RULE_FEATURES24 = [];
|
|
1206
1246
|
var no_duplicate_key_default = createRule({
|
|
1207
1247
|
meta: {
|
|
1208
1248
|
type: "problem",
|
|
1209
1249
|
docs: {
|
|
1210
1250
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1211
|
-
[Symbol.for("rule_features")]:
|
|
1251
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1212
1252
|
},
|
|
1213
1253
|
messages: {
|
|
1214
1254
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1215
1255
|
},
|
|
1216
1256
|
schema: []
|
|
1217
1257
|
},
|
|
1218
|
-
name:
|
|
1219
|
-
create:
|
|
1258
|
+
name: RULE_NAME24,
|
|
1259
|
+
create: create24,
|
|
1220
1260
|
defaultOptions: []
|
|
1221
1261
|
});
|
|
1222
|
-
function
|
|
1262
|
+
function create24(context) {
|
|
1223
1263
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1224
1264
|
return {};
|
|
1225
1265
|
}
|
|
@@ -1283,8 +1323,8 @@ function create23(context) {
|
|
|
1283
1323
|
}
|
|
1284
1324
|
};
|
|
1285
1325
|
}
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1326
|
+
var RULE_NAME25 = "no-forward-ref";
|
|
1327
|
+
var RULE_FEATURES25 = [
|
|
1288
1328
|
"MOD"
|
|
1289
1329
|
];
|
|
1290
1330
|
var no_forward_ref_default = createRule({
|
|
@@ -1292,7 +1332,7 @@ var no_forward_ref_default = createRule({
|
|
|
1292
1332
|
type: "problem",
|
|
1293
1333
|
docs: {
|
|
1294
1334
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1295
|
-
[Symbol.for("rule_features")]:
|
|
1335
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1296
1336
|
},
|
|
1297
1337
|
fixable: "code",
|
|
1298
1338
|
messages: {
|
|
@@ -1300,11 +1340,11 @@ var no_forward_ref_default = createRule({
|
|
|
1300
1340
|
},
|
|
1301
1341
|
schema: []
|
|
1302
1342
|
},
|
|
1303
|
-
name:
|
|
1304
|
-
create:
|
|
1343
|
+
name: RULE_NAME25,
|
|
1344
|
+
create: create25,
|
|
1305
1345
|
defaultOptions: []
|
|
1306
1346
|
});
|
|
1307
|
-
function
|
|
1347
|
+
function create25(context) {
|
|
1308
1348
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1309
1349
|
return {};
|
|
1310
1350
|
}
|
|
@@ -1392,8 +1432,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1392
1432
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1393
1433
|
];
|
|
1394
1434
|
}
|
|
1395
|
-
var
|
|
1396
|
-
var
|
|
1435
|
+
var RULE_NAME26 = "no-implicit-key";
|
|
1436
|
+
var RULE_FEATURES26 = [
|
|
1397
1437
|
"EXP"
|
|
1398
1438
|
];
|
|
1399
1439
|
var no_implicit_key_default = createRule({
|
|
@@ -1401,18 +1441,18 @@ var no_implicit_key_default = createRule({
|
|
|
1401
1441
|
type: "problem",
|
|
1402
1442
|
docs: {
|
|
1403
1443
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1404
|
-
[Symbol.for("rule_features")]:
|
|
1444
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1405
1445
|
},
|
|
1406
1446
|
messages: {
|
|
1407
1447
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1408
1448
|
},
|
|
1409
1449
|
schema: []
|
|
1410
1450
|
},
|
|
1411
|
-
name:
|
|
1412
|
-
create:
|
|
1451
|
+
name: RULE_NAME26,
|
|
1452
|
+
create: create26,
|
|
1413
1453
|
defaultOptions: []
|
|
1414
1454
|
});
|
|
1415
|
-
function
|
|
1455
|
+
function create26(context) {
|
|
1416
1456
|
return {
|
|
1417
1457
|
JSXOpeningElement(node) {
|
|
1418
1458
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1426,8 +1466,8 @@ function create25(context) {
|
|
|
1426
1466
|
}
|
|
1427
1467
|
};
|
|
1428
1468
|
}
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1469
|
+
var RULE_NAME27 = "no-leaked-conditional-rendering";
|
|
1470
|
+
var RULE_FEATURES27 = [
|
|
1431
1471
|
"TSC"
|
|
1432
1472
|
];
|
|
1433
1473
|
var tsHelpers = {
|
|
@@ -1513,18 +1553,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1513
1553
|
type: "problem",
|
|
1514
1554
|
docs: {
|
|
1515
1555
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1516
|
-
[Symbol.for("rule_features")]:
|
|
1556
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1517
1557
|
},
|
|
1518
1558
|
messages: {
|
|
1519
1559
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1520
1560
|
},
|
|
1521
1561
|
schema: []
|
|
1522
1562
|
},
|
|
1523
|
-
name:
|
|
1524
|
-
create:
|
|
1563
|
+
name: RULE_NAME27,
|
|
1564
|
+
create: create27,
|
|
1525
1565
|
defaultOptions: []
|
|
1526
1566
|
});
|
|
1527
|
-
function
|
|
1567
|
+
function create27(context) {
|
|
1528
1568
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1529
1569
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1530
1570
|
const allowedVariants = [
|
|
@@ -1581,25 +1621,25 @@ function create26(context) {
|
|
|
1581
1621
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1582
1622
|
};
|
|
1583
1623
|
}
|
|
1584
|
-
var
|
|
1585
|
-
var
|
|
1624
|
+
var RULE_NAME28 = "no-missing-component-display-name";
|
|
1625
|
+
var RULE_FEATURES28 = [];
|
|
1586
1626
|
var no_missing_component_display_name_default = createRule({
|
|
1587
1627
|
meta: {
|
|
1588
1628
|
type: "problem",
|
|
1589
1629
|
docs: {
|
|
1590
1630
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1591
|
-
[Symbol.for("rule_features")]:
|
|
1631
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1592
1632
|
},
|
|
1593
1633
|
messages: {
|
|
1594
1634
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1595
1635
|
},
|
|
1596
1636
|
schema: []
|
|
1597
1637
|
},
|
|
1598
|
-
name:
|
|
1599
|
-
create:
|
|
1638
|
+
name: RULE_NAME28,
|
|
1639
|
+
create: create28,
|
|
1600
1640
|
defaultOptions: []
|
|
1601
1641
|
});
|
|
1602
|
-
function
|
|
1642
|
+
function create28(context) {
|
|
1603
1643
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1604
1644
|
const {
|
|
1605
1645
|
ctx,
|
|
@@ -1634,25 +1674,25 @@ function create27(context) {
|
|
|
1634
1674
|
}
|
|
1635
1675
|
};
|
|
1636
1676
|
}
|
|
1637
|
-
var
|
|
1638
|
-
var
|
|
1677
|
+
var RULE_NAME29 = "no-missing-context-display-name";
|
|
1678
|
+
var RULE_FEATURES29 = [];
|
|
1639
1679
|
var no_missing_context_display_name_default = createRule({
|
|
1640
1680
|
meta: {
|
|
1641
1681
|
type: "problem",
|
|
1642
1682
|
docs: {
|
|
1643
1683
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1644
|
-
[Symbol.for("rule_features")]:
|
|
1684
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1645
1685
|
},
|
|
1646
1686
|
messages: {
|
|
1647
1687
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1648
1688
|
},
|
|
1649
1689
|
schema: []
|
|
1650
1690
|
},
|
|
1651
|
-
name:
|
|
1652
|
-
create:
|
|
1691
|
+
name: RULE_NAME29,
|
|
1692
|
+
create: create29,
|
|
1653
1693
|
defaultOptions: []
|
|
1654
1694
|
});
|
|
1655
|
-
function
|
|
1695
|
+
function create29(context) {
|
|
1656
1696
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1657
1697
|
const createCalls = [];
|
|
1658
1698
|
const displayNameAssignments = [];
|
|
@@ -1690,14 +1730,14 @@ function create28(context) {
|
|
|
1690
1730
|
}
|
|
1691
1731
|
};
|
|
1692
1732
|
}
|
|
1693
|
-
var
|
|
1694
|
-
var
|
|
1733
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1734
|
+
var RULE_FEATURES30 = [];
|
|
1695
1735
|
var no_missing_key_default = createRule({
|
|
1696
1736
|
meta: {
|
|
1697
1737
|
type: "problem",
|
|
1698
1738
|
docs: {
|
|
1699
1739
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1700
|
-
[Symbol.for("rule_features")]:
|
|
1740
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1701
1741
|
},
|
|
1702
1742
|
messages: {
|
|
1703
1743
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1705,11 +1745,11 @@ var no_missing_key_default = createRule({
|
|
|
1705
1745
|
},
|
|
1706
1746
|
schema: []
|
|
1707
1747
|
},
|
|
1708
|
-
name:
|
|
1709
|
-
create:
|
|
1748
|
+
name: RULE_NAME30,
|
|
1749
|
+
create: create30,
|
|
1710
1750
|
defaultOptions: []
|
|
1711
1751
|
});
|
|
1712
|
-
function
|
|
1752
|
+
function create30(context) {
|
|
1713
1753
|
const report = createReport(context);
|
|
1714
1754
|
const state = { isWithinChildrenToArray: false };
|
|
1715
1755
|
function checkIteratorElement(node) {
|
|
@@ -1822,26 +1862,25 @@ function create29(context) {
|
|
|
1822
1862
|
function isArrayFromCall(node) {
|
|
1823
1863
|
return node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1824
1864
|
}
|
|
1825
|
-
var
|
|
1826
|
-
var
|
|
1865
|
+
var RULE_NAME31 = "no-nested-component-definitions";
|
|
1866
|
+
var RULE_FEATURES31 = [];
|
|
1827
1867
|
var no_nested_component_definitions_default = createRule({
|
|
1828
1868
|
meta: {
|
|
1829
1869
|
type: "problem",
|
|
1830
1870
|
docs: {
|
|
1831
1871
|
description: "Disallow nesting component definitions inside other components.",
|
|
1832
|
-
[Symbol.for("rule_features")]:
|
|
1872
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1833
1873
|
},
|
|
1834
1874
|
messages: {
|
|
1835
|
-
|
|
1836
|
-
noNestedComponentDefinitionInProps: "Do not nest component definitions inside props. Move it to the top level or pass it as a prop."
|
|
1875
|
+
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1837
1876
|
},
|
|
1838
1877
|
schema: []
|
|
1839
1878
|
},
|
|
1840
|
-
name:
|
|
1841
|
-
create:
|
|
1879
|
+
name: RULE_NAME31,
|
|
1880
|
+
create: create31,
|
|
1842
1881
|
defaultOptions: []
|
|
1843
1882
|
});
|
|
1844
|
-
function
|
|
1883
|
+
function create31(context) {
|
|
1845
1884
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1846
1885
|
const collector = useComponentCollector(context, { hint });
|
|
1847
1886
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -1867,10 +1906,11 @@ function create30(context) {
|
|
|
1867
1906
|
if (isInsideJSXAttributeValue(component)) {
|
|
1868
1907
|
if (!isDeclaredInRenderPropLoose(component)) {
|
|
1869
1908
|
context.report({
|
|
1870
|
-
messageId: "
|
|
1909
|
+
messageId: "noNestedComponentDefinitions",
|
|
1871
1910
|
node: component,
|
|
1872
1911
|
data: {
|
|
1873
|
-
name: name5
|
|
1912
|
+
name: name5,
|
|
1913
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1874
1914
|
}
|
|
1875
1915
|
});
|
|
1876
1916
|
}
|
|
@@ -1878,10 +1918,11 @@ function create30(context) {
|
|
|
1878
1918
|
}
|
|
1879
1919
|
if (isInsideCreateElementProps(context, component)) {
|
|
1880
1920
|
context.report({
|
|
1881
|
-
messageId: "
|
|
1921
|
+
messageId: "noNestedComponentDefinitions",
|
|
1882
1922
|
node: component,
|
|
1883
1923
|
data: {
|
|
1884
|
-
name: name5
|
|
1924
|
+
name: name5,
|
|
1925
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1885
1926
|
}
|
|
1886
1927
|
});
|
|
1887
1928
|
continue;
|
|
@@ -1889,20 +1930,22 @@ function create30(context) {
|
|
|
1889
1930
|
const parentComponent = AST11.findParentNode(component, isFunctionComponent);
|
|
1890
1931
|
if (parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1891
1932
|
context.report({
|
|
1892
|
-
messageId:
|
|
1933
|
+
messageId: "noNestedComponentDefinitions",
|
|
1893
1934
|
node: component,
|
|
1894
1935
|
data: {
|
|
1895
|
-
name: name5
|
|
1936
|
+
name: name5,
|
|
1937
|
+
suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1896
1938
|
}
|
|
1897
1939
|
});
|
|
1898
1940
|
continue;
|
|
1899
1941
|
}
|
|
1900
1942
|
if (isInsideRenderMethod(component)) {
|
|
1901
1943
|
context.report({
|
|
1902
|
-
messageId: "
|
|
1944
|
+
messageId: "noNestedComponentDefinitions",
|
|
1903
1945
|
node: component,
|
|
1904
1946
|
data: {
|
|
1905
|
-
name: name5
|
|
1947
|
+
name: name5,
|
|
1948
|
+
suggestion: "Move it to the top level."
|
|
1906
1949
|
}
|
|
1907
1950
|
});
|
|
1908
1951
|
}
|
|
@@ -1912,10 +1955,11 @@ function create30(context) {
|
|
|
1912
1955
|
continue;
|
|
1913
1956
|
}
|
|
1914
1957
|
context.report({
|
|
1915
|
-
messageId: "
|
|
1958
|
+
messageId: "noNestedComponentDefinitions",
|
|
1916
1959
|
node: component,
|
|
1917
1960
|
data: {
|
|
1918
|
-
name: name5
|
|
1961
|
+
name: name5,
|
|
1962
|
+
suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1919
1963
|
}
|
|
1920
1964
|
});
|
|
1921
1965
|
}
|
|
@@ -1932,25 +1976,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1932
1976
|
if (prop == null) return false;
|
|
1933
1977
|
return prop === call.arguments[1];
|
|
1934
1978
|
}
|
|
1935
|
-
var
|
|
1936
|
-
var
|
|
1979
|
+
var RULE_NAME32 = "no-prop-types";
|
|
1980
|
+
var RULE_FEATURES32 = [];
|
|
1937
1981
|
var no_prop_types_default = createRule({
|
|
1938
1982
|
meta: {
|
|
1939
1983
|
type: "problem",
|
|
1940
1984
|
docs: {
|
|
1941
1985
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1942
|
-
[Symbol.for("rule_features")]:
|
|
1986
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1943
1987
|
},
|
|
1944
1988
|
messages: {
|
|
1945
1989
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1946
1990
|
},
|
|
1947
1991
|
schema: []
|
|
1948
1992
|
},
|
|
1949
|
-
name:
|
|
1950
|
-
create:
|
|
1993
|
+
name: RULE_NAME32,
|
|
1994
|
+
create: create32,
|
|
1951
1995
|
defaultOptions: []
|
|
1952
1996
|
});
|
|
1953
|
-
function
|
|
1997
|
+
function create32(context) {
|
|
1954
1998
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1955
1999
|
return {};
|
|
1956
2000
|
}
|
|
@@ -1986,8 +2030,8 @@ function create31(context) {
|
|
|
1986
2030
|
}
|
|
1987
2031
|
};
|
|
1988
2032
|
}
|
|
1989
|
-
var
|
|
1990
|
-
var
|
|
2033
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
2034
|
+
var RULE_FEATURES33 = [];
|
|
1991
2035
|
function isShouldComponentUpdate(node) {
|
|
1992
2036
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
1993
2037
|
}
|
|
@@ -1996,18 +2040,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1996
2040
|
type: "problem",
|
|
1997
2041
|
docs: {
|
|
1998
2042
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
1999
|
-
[Symbol.for("rule_features")]:
|
|
2043
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
2000
2044
|
},
|
|
2001
2045
|
messages: {
|
|
2002
2046
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2003
2047
|
},
|
|
2004
2048
|
schema: []
|
|
2005
2049
|
},
|
|
2006
|
-
name:
|
|
2007
|
-
create:
|
|
2050
|
+
name: RULE_NAME33,
|
|
2051
|
+
create: create33,
|
|
2008
2052
|
defaultOptions: []
|
|
2009
2053
|
});
|
|
2010
|
-
function
|
|
2054
|
+
function create33(context) {
|
|
2011
2055
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2012
2056
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2013
2057
|
return {
|
|
@@ -2034,8 +2078,8 @@ function create32(context) {
|
|
|
2034
2078
|
}
|
|
2035
2079
|
};
|
|
2036
2080
|
}
|
|
2037
|
-
var
|
|
2038
|
-
var
|
|
2081
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
2082
|
+
var RULE_FEATURES34 = [];
|
|
2039
2083
|
function isComponentDidMount(node) {
|
|
2040
2084
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2041
2085
|
}
|
|
@@ -2044,18 +2088,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2044
2088
|
type: "problem",
|
|
2045
2089
|
docs: {
|
|
2046
2090
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2047
|
-
[Symbol.for("rule_features")]:
|
|
2091
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2048
2092
|
},
|
|
2049
2093
|
messages: {
|
|
2050
2094
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2051
2095
|
},
|
|
2052
2096
|
schema: []
|
|
2053
2097
|
},
|
|
2054
|
-
name:
|
|
2055
|
-
create:
|
|
2098
|
+
name: RULE_NAME34,
|
|
2099
|
+
create: create34,
|
|
2056
2100
|
defaultOptions: []
|
|
2057
2101
|
});
|
|
2058
|
-
function
|
|
2102
|
+
function create34(context) {
|
|
2059
2103
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2060
2104
|
return {
|
|
2061
2105
|
CallExpression(node) {
|
|
@@ -2076,8 +2120,8 @@ function create33(context) {
|
|
|
2076
2120
|
}
|
|
2077
2121
|
};
|
|
2078
2122
|
}
|
|
2079
|
-
var
|
|
2080
|
-
var
|
|
2123
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
2124
|
+
var RULE_FEATURES35 = [];
|
|
2081
2125
|
function isComponentDidUpdate(node) {
|
|
2082
2126
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2083
2127
|
}
|
|
@@ -2086,18 +2130,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2086
2130
|
type: "problem",
|
|
2087
2131
|
docs: {
|
|
2088
2132
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2089
|
-
[Symbol.for("rule_features")]:
|
|
2133
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2090
2134
|
},
|
|
2091
2135
|
messages: {
|
|
2092
2136
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2093
2137
|
},
|
|
2094
2138
|
schema: []
|
|
2095
2139
|
},
|
|
2096
|
-
name:
|
|
2097
|
-
create:
|
|
2140
|
+
name: RULE_NAME35,
|
|
2141
|
+
create: create35,
|
|
2098
2142
|
defaultOptions: []
|
|
2099
2143
|
});
|
|
2100
|
-
function
|
|
2144
|
+
function create35(context) {
|
|
2101
2145
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2102
2146
|
return {
|
|
2103
2147
|
CallExpression(node) {
|
|
@@ -2118,8 +2162,8 @@ function create34(context) {
|
|
|
2118
2162
|
}
|
|
2119
2163
|
};
|
|
2120
2164
|
}
|
|
2121
|
-
var
|
|
2122
|
-
var
|
|
2165
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
2166
|
+
var RULE_FEATURES36 = [];
|
|
2123
2167
|
function isComponentWillUpdate3(node) {
|
|
2124
2168
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2125
2169
|
}
|
|
@@ -2128,18 +2172,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2128
2172
|
type: "problem",
|
|
2129
2173
|
docs: {
|
|
2130
2174
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2131
|
-
[Symbol.for("rule_features")]:
|
|
2175
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2132
2176
|
},
|
|
2133
2177
|
messages: {
|
|
2134
2178
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2135
2179
|
},
|
|
2136
2180
|
schema: []
|
|
2137
2181
|
},
|
|
2138
|
-
name:
|
|
2139
|
-
create:
|
|
2182
|
+
name: RULE_NAME36,
|
|
2183
|
+
create: create36,
|
|
2140
2184
|
defaultOptions: []
|
|
2141
2185
|
});
|
|
2142
|
-
function
|
|
2186
|
+
function create36(context) {
|
|
2143
2187
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2144
2188
|
return {
|
|
2145
2189
|
CallExpression(node) {
|
|
@@ -2160,8 +2204,8 @@ function create35(context) {
|
|
|
2160
2204
|
}
|
|
2161
2205
|
};
|
|
2162
2206
|
}
|
|
2163
|
-
var
|
|
2164
|
-
var
|
|
2207
|
+
var RULE_NAME37 = "no-string-refs";
|
|
2208
|
+
var RULE_FEATURES37 = [];
|
|
2165
2209
|
function containsStringLiteral({ value }) {
|
|
2166
2210
|
return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2167
2211
|
}
|
|
@@ -2179,18 +2223,18 @@ var no_string_refs_default = createRule({
|
|
|
2179
2223
|
type: "problem",
|
|
2180
2224
|
docs: {
|
|
2181
2225
|
description: "Disallow deprecated string `refs`.",
|
|
2182
|
-
[Symbol.for("rule_features")]:
|
|
2226
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2183
2227
|
},
|
|
2184
2228
|
messages: {
|
|
2185
2229
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2186
2230
|
},
|
|
2187
2231
|
schema: []
|
|
2188
2232
|
},
|
|
2189
|
-
name:
|
|
2190
|
-
create:
|
|
2233
|
+
name: RULE_NAME37,
|
|
2234
|
+
create: create37,
|
|
2191
2235
|
defaultOptions: []
|
|
2192
2236
|
});
|
|
2193
|
-
function
|
|
2237
|
+
function create37(context) {
|
|
2194
2238
|
return {
|
|
2195
2239
|
JSXAttribute(node) {
|
|
2196
2240
|
if (node.name.name !== "ref") {
|
|
@@ -2205,8 +2249,8 @@ function create36(context) {
|
|
|
2205
2249
|
}
|
|
2206
2250
|
};
|
|
2207
2251
|
}
|
|
2208
|
-
var
|
|
2209
|
-
var
|
|
2252
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
2253
|
+
var RULE_FEATURES38 = [];
|
|
2210
2254
|
function isUnsafeComponentWillMount(node) {
|
|
2211
2255
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2212
2256
|
}
|
|
@@ -2215,18 +2259,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2215
2259
|
type: "problem",
|
|
2216
2260
|
docs: {
|
|
2217
2261
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2218
|
-
[Symbol.for("rule_features")]:
|
|
2262
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2219
2263
|
},
|
|
2220
2264
|
messages: {
|
|
2221
2265
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2222
2266
|
},
|
|
2223
2267
|
schema: []
|
|
2224
2268
|
},
|
|
2225
|
-
name:
|
|
2226
|
-
create:
|
|
2269
|
+
name: RULE_NAME38,
|
|
2270
|
+
create: create38,
|
|
2227
2271
|
defaultOptions: []
|
|
2228
2272
|
});
|
|
2229
|
-
function
|
|
2273
|
+
function create38(context) {
|
|
2230
2274
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2231
2275
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2232
2276
|
return {
|
|
@@ -2247,8 +2291,8 @@ function create37(context) {
|
|
|
2247
2291
|
}
|
|
2248
2292
|
};
|
|
2249
2293
|
}
|
|
2250
|
-
var
|
|
2251
|
-
var
|
|
2294
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
2295
|
+
var RULE_FEATURES39 = [];
|
|
2252
2296
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2253
2297
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2254
2298
|
}
|
|
@@ -2257,18 +2301,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2257
2301
|
type: "problem",
|
|
2258
2302
|
docs: {
|
|
2259
2303
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2260
|
-
[Symbol.for("rule_features")]:
|
|
2304
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2261
2305
|
},
|
|
2262
2306
|
messages: {
|
|
2263
2307
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2264
2308
|
},
|
|
2265
2309
|
schema: []
|
|
2266
2310
|
},
|
|
2267
|
-
name:
|
|
2268
|
-
create:
|
|
2311
|
+
name: RULE_NAME39,
|
|
2312
|
+
create: create39,
|
|
2269
2313
|
defaultOptions: []
|
|
2270
2314
|
});
|
|
2271
|
-
function
|
|
2315
|
+
function create39(context) {
|
|
2272
2316
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2273
2317
|
return {};
|
|
2274
2318
|
}
|
|
@@ -2291,8 +2335,8 @@ function create38(context) {
|
|
|
2291
2335
|
}
|
|
2292
2336
|
};
|
|
2293
2337
|
}
|
|
2294
|
-
var
|
|
2295
|
-
var
|
|
2338
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
2339
|
+
var RULE_FEATURES40 = [];
|
|
2296
2340
|
function isUnsafeComponentWillUpdate(node) {
|
|
2297
2341
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2298
2342
|
}
|
|
@@ -2301,18 +2345,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2301
2345
|
type: "problem",
|
|
2302
2346
|
docs: {
|
|
2303
2347
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2304
|
-
[Symbol.for("rule_features")]:
|
|
2348
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2305
2349
|
},
|
|
2306
2350
|
messages: {
|
|
2307
2351
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2308
2352
|
},
|
|
2309
2353
|
schema: []
|
|
2310
2354
|
},
|
|
2311
|
-
name:
|
|
2312
|
-
create:
|
|
2355
|
+
name: RULE_NAME40,
|
|
2356
|
+
create: create40,
|
|
2313
2357
|
defaultOptions: []
|
|
2314
2358
|
});
|
|
2315
|
-
function
|
|
2359
|
+
function create40(context) {
|
|
2316
2360
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2317
2361
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2318
2362
|
return {
|
|
@@ -2333,25 +2377,25 @@ function create39(context) {
|
|
|
2333
2377
|
}
|
|
2334
2378
|
};
|
|
2335
2379
|
}
|
|
2336
|
-
var
|
|
2337
|
-
var
|
|
2380
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
2381
|
+
var RULE_FEATURES41 = [];
|
|
2338
2382
|
var no_unstable_context_value_default = createRule({
|
|
2339
2383
|
meta: {
|
|
2340
2384
|
type: "problem",
|
|
2341
2385
|
docs: {
|
|
2342
2386
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2343
|
-
[Symbol.for("rule_features")]:
|
|
2387
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2344
2388
|
},
|
|
2345
2389
|
messages: {
|
|
2346
2390
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2347
2391
|
},
|
|
2348
2392
|
schema: []
|
|
2349
2393
|
},
|
|
2350
|
-
name:
|
|
2351
|
-
create:
|
|
2394
|
+
name: RULE_NAME41,
|
|
2395
|
+
create: create41,
|
|
2352
2396
|
defaultOptions: []
|
|
2353
2397
|
});
|
|
2354
|
-
function
|
|
2398
|
+
function create41(context) {
|
|
2355
2399
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2356
2400
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2357
2401
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2406,25 +2450,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2406
2450
|
}
|
|
2407
2451
|
return false;
|
|
2408
2452
|
}
|
|
2409
|
-
var
|
|
2410
|
-
var
|
|
2453
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2454
|
+
var RULE_FEATURES42 = [];
|
|
2411
2455
|
var no_unstable_default_props_default = createRule({
|
|
2412
2456
|
meta: {
|
|
2413
2457
|
type: "problem",
|
|
2414
2458
|
docs: {
|
|
2415
2459
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2416
|
-
[Symbol.for("rule_features")]:
|
|
2460
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2417
2461
|
},
|
|
2418
2462
|
messages: {
|
|
2419
2463
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2420
2464
|
},
|
|
2421
2465
|
schema: []
|
|
2422
2466
|
},
|
|
2423
|
-
name:
|
|
2424
|
-
create:
|
|
2467
|
+
name: RULE_NAME42,
|
|
2468
|
+
create: create42,
|
|
2425
2469
|
defaultOptions: []
|
|
2426
2470
|
});
|
|
2427
|
-
function
|
|
2471
|
+
function create42(context) {
|
|
2428
2472
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2429
2473
|
const declarators = /* @__PURE__ */ new Map();
|
|
2430
2474
|
return {
|
|
@@ -2480,8 +2524,8 @@ function create41(context) {
|
|
|
2480
2524
|
}
|
|
2481
2525
|
};
|
|
2482
2526
|
}
|
|
2483
|
-
var
|
|
2484
|
-
var
|
|
2527
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2528
|
+
var RULE_FEATURES43 = [];
|
|
2485
2529
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2486
2530
|
"componentDidCatch",
|
|
2487
2531
|
"componentDidMount",
|
|
@@ -2507,18 +2551,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2507
2551
|
type: "problem",
|
|
2508
2552
|
docs: {
|
|
2509
2553
|
description: "Warns unused class component methods and properties.",
|
|
2510
|
-
[Symbol.for("rule_features")]:
|
|
2554
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2511
2555
|
},
|
|
2512
2556
|
messages: {
|
|
2513
2557
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2514
2558
|
},
|
|
2515
2559
|
schema: []
|
|
2516
2560
|
},
|
|
2517
|
-
name:
|
|
2518
|
-
create:
|
|
2561
|
+
name: RULE_NAME43,
|
|
2562
|
+
create: create43,
|
|
2519
2563
|
defaultOptions: []
|
|
2520
2564
|
});
|
|
2521
|
-
function
|
|
2565
|
+
function create43(context) {
|
|
2522
2566
|
const classEntries = [];
|
|
2523
2567
|
const methodEntries = [];
|
|
2524
2568
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2628,8 +2672,8 @@ function create42(context) {
|
|
|
2628
2672
|
}
|
|
2629
2673
|
};
|
|
2630
2674
|
}
|
|
2631
|
-
var
|
|
2632
|
-
var
|
|
2675
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2676
|
+
var RULE_FEATURES44 = [];
|
|
2633
2677
|
function isKeyLiteral3(node, key) {
|
|
2634
2678
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
2635
2679
|
}
|
|
@@ -2638,18 +2682,18 @@ var no_unused_state_default = createRule({
|
|
|
2638
2682
|
type: "problem",
|
|
2639
2683
|
docs: {
|
|
2640
2684
|
description: "Warns unused class component state.",
|
|
2641
|
-
[Symbol.for("rule_features")]:
|
|
2685
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2642
2686
|
},
|
|
2643
2687
|
messages: {
|
|
2644
2688
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2645
2689
|
},
|
|
2646
2690
|
schema: []
|
|
2647
2691
|
},
|
|
2648
|
-
name:
|
|
2649
|
-
create:
|
|
2692
|
+
name: RULE_NAME44,
|
|
2693
|
+
create: create44,
|
|
2650
2694
|
defaultOptions: []
|
|
2651
2695
|
});
|
|
2652
|
-
function
|
|
2696
|
+
function create44(context) {
|
|
2653
2697
|
const classEntries = [];
|
|
2654
2698
|
const methodEntries = [];
|
|
2655
2699
|
const constructorEntries = [];
|
|
@@ -2783,8 +2827,8 @@ function create43(context) {
|
|
|
2783
2827
|
}
|
|
2784
2828
|
};
|
|
2785
2829
|
}
|
|
2786
|
-
var
|
|
2787
|
-
var
|
|
2830
|
+
var RULE_NAME45 = "no-use-context";
|
|
2831
|
+
var RULE_FEATURES45 = [
|
|
2788
2832
|
"MOD"
|
|
2789
2833
|
];
|
|
2790
2834
|
var no_use_context_default = createRule({
|
|
@@ -2792,7 +2836,7 @@ var no_use_context_default = createRule({
|
|
|
2792
2836
|
type: "problem",
|
|
2793
2837
|
docs: {
|
|
2794
2838
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2795
|
-
[Symbol.for("rule_features")]:
|
|
2839
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2796
2840
|
},
|
|
2797
2841
|
fixable: "code",
|
|
2798
2842
|
messages: {
|
|
@@ -2800,11 +2844,11 @@ var no_use_context_default = createRule({
|
|
|
2800
2844
|
},
|
|
2801
2845
|
schema: []
|
|
2802
2846
|
},
|
|
2803
|
-
name:
|
|
2804
|
-
create:
|
|
2847
|
+
name: RULE_NAME45,
|
|
2848
|
+
create: create45,
|
|
2805
2849
|
defaultOptions: []
|
|
2806
2850
|
});
|
|
2807
|
-
function
|
|
2851
|
+
function create45(context) {
|
|
2808
2852
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2809
2853
|
const settings4 = getSettingsFromContext(context);
|
|
2810
2854
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2882,25 +2926,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2882
2926
|
return tokens;
|
|
2883
2927
|
}
|
|
2884
2928
|
}
|
|
2885
|
-
var
|
|
2886
|
-
var
|
|
2929
|
+
var RULE_NAME46 = "no-useless-forward-ref";
|
|
2930
|
+
var RULE_FEATURES46 = [];
|
|
2887
2931
|
var no_useless_forward_ref_default = createRule({
|
|
2888
2932
|
meta: {
|
|
2889
2933
|
type: "problem",
|
|
2890
2934
|
docs: {
|
|
2891
2935
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2892
|
-
[Symbol.for("rule_features")]:
|
|
2936
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2893
2937
|
},
|
|
2894
2938
|
messages: {
|
|
2895
2939
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2896
2940
|
},
|
|
2897
2941
|
schema: []
|
|
2898
2942
|
},
|
|
2899
|
-
name:
|
|
2900
|
-
create:
|
|
2943
|
+
name: RULE_NAME46,
|
|
2944
|
+
create: create46,
|
|
2901
2945
|
defaultOptions: []
|
|
2902
2946
|
});
|
|
2903
|
-
function
|
|
2947
|
+
function create46(context) {
|
|
2904
2948
|
return {
|
|
2905
2949
|
CallExpression(node) {
|
|
2906
2950
|
if (!isForwardRefCall(context, node)) {
|
|
@@ -2921,7 +2965,7 @@ function create45(context) {
|
|
|
2921
2965
|
}
|
|
2922
2966
|
};
|
|
2923
2967
|
}
|
|
2924
|
-
var
|
|
2968
|
+
var RULE_NAME47 = "no-useless-fragment";
|
|
2925
2969
|
var defaultOptions = [{
|
|
2926
2970
|
allowExpressions: true
|
|
2927
2971
|
}];
|
|
@@ -2947,11 +2991,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2947
2991
|
}
|
|
2948
2992
|
}]
|
|
2949
2993
|
},
|
|
2950
|
-
name:
|
|
2951
|
-
create:
|
|
2994
|
+
name: RULE_NAME47,
|
|
2995
|
+
create: create47,
|
|
2952
2996
|
defaultOptions
|
|
2953
2997
|
});
|
|
2954
|
-
function
|
|
2998
|
+
function create47(context, [option]) {
|
|
2955
2999
|
const { allowExpressions = true } = option;
|
|
2956
3000
|
return {
|
|
2957
3001
|
JSXElement(node) {
|
|
@@ -3063,8 +3107,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3063
3107
|
}
|
|
3064
3108
|
return;
|
|
3065
3109
|
}
|
|
3066
|
-
var
|
|
3067
|
-
var
|
|
3110
|
+
var RULE_NAME48 = "prefer-destructuring-assignment";
|
|
3111
|
+
var RULE_FEATURES47 = [];
|
|
3068
3112
|
function isMemberExpressionWithObjectName(node) {
|
|
3069
3113
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3070
3114
|
}
|
|
@@ -3073,18 +3117,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3073
3117
|
type: "problem",
|
|
3074
3118
|
docs: {
|
|
3075
3119
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3076
|
-
[Symbol.for("rule_features")]:
|
|
3120
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
3077
3121
|
},
|
|
3078
3122
|
messages: {
|
|
3079
3123
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3080
3124
|
},
|
|
3081
3125
|
schema: []
|
|
3082
3126
|
},
|
|
3083
|
-
name:
|
|
3084
|
-
create:
|
|
3127
|
+
name: RULE_NAME48,
|
|
3128
|
+
create: create48,
|
|
3085
3129
|
defaultOptions: []
|
|
3086
3130
|
});
|
|
3087
|
-
function
|
|
3131
|
+
function create48(context) {
|
|
3088
3132
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3089
3133
|
const memberExpressionWithNames = [];
|
|
3090
3134
|
return {
|
|
@@ -3144,8 +3188,8 @@ function create47(context) {
|
|
|
3144
3188
|
}
|
|
3145
3189
|
};
|
|
3146
3190
|
}
|
|
3147
|
-
var
|
|
3148
|
-
var
|
|
3191
|
+
var RULE_NAME49 = "prefer-react-namespace-import";
|
|
3192
|
+
var RULE_FEATURES48 = [
|
|
3149
3193
|
"FIX",
|
|
3150
3194
|
"EXP"
|
|
3151
3195
|
];
|
|
@@ -3154,7 +3198,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3154
3198
|
type: "problem",
|
|
3155
3199
|
docs: {
|
|
3156
3200
|
description: "Enforces React is imported via a namespace import.",
|
|
3157
|
-
[Symbol.for("rule_features")]:
|
|
3201
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3158
3202
|
},
|
|
3159
3203
|
fixable: "code",
|
|
3160
3204
|
messages: {
|
|
@@ -3162,11 +3206,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3162
3206
|
},
|
|
3163
3207
|
schema: []
|
|
3164
3208
|
},
|
|
3165
|
-
name:
|
|
3166
|
-
create:
|
|
3209
|
+
name: RULE_NAME49,
|
|
3210
|
+
create: create49,
|
|
3167
3211
|
defaultOptions: []
|
|
3168
3212
|
});
|
|
3169
|
-
function
|
|
3213
|
+
function create49(context) {
|
|
3170
3214
|
const { importSource } = getSettingsFromContext(context);
|
|
3171
3215
|
return {
|
|
3172
3216
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3199,8 +3243,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3199
3243
|
}
|
|
3200
3244
|
};
|
|
3201
3245
|
}
|
|
3202
|
-
var
|
|
3203
|
-
var
|
|
3246
|
+
var RULE_NAME50 = "prefer-read-only-props";
|
|
3247
|
+
var RULE_FEATURES49 = [
|
|
3204
3248
|
"TSC",
|
|
3205
3249
|
"EXP"
|
|
3206
3250
|
];
|
|
@@ -3209,18 +3253,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3209
3253
|
type: "problem",
|
|
3210
3254
|
docs: {
|
|
3211
3255
|
description: "Enforces read-only props in components.",
|
|
3212
|
-
[Symbol.for("rule_features")]:
|
|
3256
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3213
3257
|
},
|
|
3214
3258
|
messages: {
|
|
3215
3259
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3216
3260
|
},
|
|
3217
3261
|
schema: []
|
|
3218
3262
|
},
|
|
3219
|
-
name:
|
|
3220
|
-
create:
|
|
3263
|
+
name: RULE_NAME50,
|
|
3264
|
+
create: create50,
|
|
3221
3265
|
defaultOptions: []
|
|
3222
3266
|
});
|
|
3223
|
-
function
|
|
3267
|
+
function create50(context) {
|
|
3224
3268
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3225
3269
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3226
3270
|
return {
|
|
@@ -3250,8 +3294,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3250
3294
|
return true;
|
|
3251
3295
|
}
|
|
3252
3296
|
}
|
|
3253
|
-
var
|
|
3254
|
-
var
|
|
3297
|
+
var RULE_NAME51 = "prefer-shorthand-boolean";
|
|
3298
|
+
var RULE_FEATURES50 = [
|
|
3255
3299
|
"FIX"
|
|
3256
3300
|
];
|
|
3257
3301
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3259,7 +3303,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3259
3303
|
type: "problem",
|
|
3260
3304
|
docs: {
|
|
3261
3305
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3262
|
-
[Symbol.for("rule_features")]:
|
|
3306
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3263
3307
|
},
|
|
3264
3308
|
fixable: "code",
|
|
3265
3309
|
messages: {
|
|
@@ -3267,11 +3311,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3267
3311
|
},
|
|
3268
3312
|
schema: []
|
|
3269
3313
|
},
|
|
3270
|
-
name:
|
|
3271
|
-
create:
|
|
3314
|
+
name: RULE_NAME51,
|
|
3315
|
+
create: create51,
|
|
3272
3316
|
defaultOptions: []
|
|
3273
3317
|
});
|
|
3274
|
-
function
|
|
3318
|
+
function create51(context) {
|
|
3275
3319
|
return {
|
|
3276
3320
|
JSXAttribute(node) {
|
|
3277
3321
|
const { value } = node;
|
|
@@ -3291,8 +3335,8 @@ function create50(context) {
|
|
|
3291
3335
|
}
|
|
3292
3336
|
};
|
|
3293
3337
|
}
|
|
3294
|
-
var
|
|
3295
|
-
var
|
|
3338
|
+
var RULE_NAME52 = "prefer-shorthand-fragment";
|
|
3339
|
+
var RULE_FEATURES51 = [
|
|
3296
3340
|
"FIX"
|
|
3297
3341
|
];
|
|
3298
3342
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3300,7 +3344,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3300
3344
|
type: "problem",
|
|
3301
3345
|
docs: {
|
|
3302
3346
|
description: "Enforces shorthand syntax for fragments.",
|
|
3303
|
-
[Symbol.for("rule_features")]:
|
|
3347
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3304
3348
|
},
|
|
3305
3349
|
fixable: "code",
|
|
3306
3350
|
messages: {
|
|
@@ -3308,11 +3352,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3308
3352
|
},
|
|
3309
3353
|
schema: []
|
|
3310
3354
|
},
|
|
3311
|
-
name:
|
|
3312
|
-
create:
|
|
3355
|
+
name: RULE_NAME52,
|
|
3356
|
+
create: create52,
|
|
3313
3357
|
defaultOptions: []
|
|
3314
3358
|
});
|
|
3315
|
-
function
|
|
3359
|
+
function create52(context) {
|
|
3316
3360
|
return {
|
|
3317
3361
|
JSXElement(node) {
|
|
3318
3362
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3337,46 +3381,6 @@ function create51(context) {
|
|
|
3337
3381
|
}
|
|
3338
3382
|
};
|
|
3339
3383
|
}
|
|
3340
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3341
|
-
var RULE_FEATURES51 = [];
|
|
3342
|
-
var use_jsx_vars_default = createRule({
|
|
3343
|
-
meta: {
|
|
3344
|
-
type: "problem",
|
|
3345
|
-
docs: {
|
|
3346
|
-
description: "Marks variables used in JSX as used.",
|
|
3347
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3348
|
-
},
|
|
3349
|
-
messages: {
|
|
3350
|
-
useJsxVars: ""
|
|
3351
|
-
},
|
|
3352
|
-
schema: []
|
|
3353
|
-
},
|
|
3354
|
-
name: RULE_NAME52,
|
|
3355
|
-
create: create52,
|
|
3356
|
-
defaultOptions: []
|
|
3357
|
-
});
|
|
3358
|
-
function create52(context) {
|
|
3359
|
-
return {
|
|
3360
|
-
JSXOpeningElement(node) {
|
|
3361
|
-
switch (node.name.type) {
|
|
3362
|
-
case AST_NODE_TYPES.JSXIdentifier: {
|
|
3363
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3364
|
-
return;
|
|
3365
|
-
}
|
|
3366
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3367
|
-
break;
|
|
3368
|
-
}
|
|
3369
|
-
case AST_NODE_TYPES.JSXMemberExpression: {
|
|
3370
|
-
const { object } = node.name;
|
|
3371
|
-
if (object.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
3372
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3373
|
-
}
|
|
3374
|
-
break;
|
|
3375
|
-
}
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
};
|
|
3379
|
-
}
|
|
3380
3384
|
|
|
3381
3385
|
// src/plugin.ts
|
|
3382
3386
|
var plugin = {
|
|
@@ -3406,7 +3410,6 @@ var plugin = {
|
|
|
3406
3410
|
"no-create-ref": no_create_ref_default,
|
|
3407
3411
|
"no-default-props": no_default_props_default,
|
|
3408
3412
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3409
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3410
3413
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3411
3414
|
"no-forward-ref": no_forward_ref_default,
|
|
3412
3415
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3436,18 +3439,20 @@ var plugin = {
|
|
|
3436
3439
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3437
3440
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3438
3441
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3439
|
-
|
|
3442
|
+
// Part: JSX only rules
|
|
3443
|
+
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3444
|
+
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3440
3445
|
// Part: deprecated rules
|
|
3441
3446
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3442
3447
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3443
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3444
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3445
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3446
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3447
3448
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3448
3449
|
"no-complicated-conditional-rendering": no_complex_conditional_rendering_default,
|
|
3450
|
+
/** @deprecated Use `jsx-no-duplicate-props` instead */
|
|
3451
|
+
"no-duplicate-jsx-props": jsx_no_duplicate_props_default,
|
|
3449
3452
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3450
|
-
"no-nested-components": no_nested_component_definitions_default
|
|
3453
|
+
"no-nested-components": no_nested_component_definitions_default,
|
|
3454
|
+
/** @deprecated Use `jsx-uses-vars` instead */
|
|
3455
|
+
"use-jsx-vars": jsx_uses_vars_default
|
|
3451
3456
|
}
|
|
3452
3457
|
};
|
|
3453
3458
|
|