eslint-plugin-react-x 1.38.0-beta.7 → 1.38.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +349 -305
- package/dist/index.mjs +348 -304
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,13 @@ import { getDocsUrl, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLIN
|
|
|
2
2
|
import * as JSX8 from '@eslint-react/jsx';
|
|
3
3
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
|
+
import * as VAR2 from '@eslint-react/var';
|
|
5
6
|
import * as AST11 from '@eslint-react/ast';
|
|
6
7
|
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';
|
|
7
8
|
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
8
9
|
import { isMatching, match, P } from 'ts-pattern';
|
|
9
10
|
import { createReport } from '@eslint-react/kit';
|
|
10
11
|
import { compare } from 'compare-versions';
|
|
11
|
-
import * as VAR from '@eslint-react/var';
|
|
12
12
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
13
13
|
import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
14
14
|
import ts from 'typescript';
|
|
@@ -29,6 +29,9 @@ __export(recommended_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
var name = "react-x/recommended";
|
|
31
31
|
var rules = {
|
|
32
|
+
"react-x/jsx-no-duplicate-props": "warn",
|
|
33
|
+
"react-x/jsx-no-undef": "error",
|
|
34
|
+
"react-x/jsx-uses-vars": "warn",
|
|
32
35
|
"react-x/no-access-state-in-setstate": "error",
|
|
33
36
|
"react-x/no-array-index-key": "warn",
|
|
34
37
|
"react-x/no-children-count": "warn",
|
|
@@ -45,7 +48,6 @@ var rules = {
|
|
|
45
48
|
"react-x/no-create-ref": "error",
|
|
46
49
|
"react-x/no-default-props": "error",
|
|
47
50
|
"react-x/no-direct-mutation-state": "error",
|
|
48
|
-
"react-x/jsx-no-duplicate-props": "warn",
|
|
49
51
|
"react-x/no-duplicate-key": "warn",
|
|
50
52
|
"react-x/no-forward-ref": "warn",
|
|
51
53
|
"react-x/no-implicit-key": "warn",
|
|
@@ -65,8 +67,7 @@ var rules = {
|
|
|
65
67
|
"react-x/no-unused-class-component-members": "warn",
|
|
66
68
|
"react-x/no-unused-state": "warn",
|
|
67
69
|
"react-x/no-use-context": "warn",
|
|
68
|
-
"react-x/no-useless-forward-ref": "warn"
|
|
69
|
-
"react-x/jsx-uses-vars": "warn"
|
|
70
|
+
"react-x/no-useless-forward-ref": "warn"
|
|
70
71
|
};
|
|
71
72
|
var settings = {
|
|
72
73
|
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
@@ -91,6 +92,7 @@ var name2 = "react-x/recommended-typescript";
|
|
|
91
92
|
var rules2 = {
|
|
92
93
|
...rules,
|
|
93
94
|
"react-x/jsx-no-duplicate-props": "off",
|
|
95
|
+
"react-x/jsx-no-undef": "off",
|
|
94
96
|
"react-x/jsx-uses-vars": "off"
|
|
95
97
|
};
|
|
96
98
|
var settings2 = {
|
|
@@ -110,7 +112,7 @@ var settings3 = {
|
|
|
110
112
|
|
|
111
113
|
// package.json
|
|
112
114
|
var name4 = "eslint-plugin-react-x";
|
|
113
|
-
var version = "1.38.0-beta.
|
|
115
|
+
var version = "1.38.0-beta.8";
|
|
114
116
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
115
117
|
|
|
116
118
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -221,17 +223,17 @@ function create3(context) {
|
|
|
221
223
|
}
|
|
222
224
|
};
|
|
223
225
|
}
|
|
224
|
-
var RULE_NAME4 = "jsx-
|
|
226
|
+
var RULE_NAME4 = "jsx-no-undef";
|
|
225
227
|
var RULE_FEATURES4 = [];
|
|
226
|
-
var
|
|
228
|
+
var jsx_no_undef_default = createRule({
|
|
227
229
|
meta: {
|
|
228
230
|
type: "problem",
|
|
229
231
|
docs: {
|
|
230
|
-
description: "
|
|
232
|
+
description: "Disallow undefined variables in JSX.",
|
|
231
233
|
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
232
234
|
},
|
|
233
235
|
messages: {
|
|
234
|
-
|
|
236
|
+
jsxNoUndef: "JSX variable {{name}} is not defined."
|
|
235
237
|
},
|
|
236
238
|
schema: []
|
|
237
239
|
},
|
|
@@ -240,6 +242,47 @@ var jsx_uses_vars_default = createRule({
|
|
|
240
242
|
defaultOptions: []
|
|
241
243
|
});
|
|
242
244
|
function create4(context) {
|
|
245
|
+
return {
|
|
246
|
+
JSXIdentifier(node) {
|
|
247
|
+
if (node.name === "this") {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (/^[a-z]/u.test(node.name)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
257
|
+
if (VAR2.findVariable(node.name, initialScope) == null) {
|
|
258
|
+
context.report({
|
|
259
|
+
messageId: "jsxNoUndef",
|
|
260
|
+
node,
|
|
261
|
+
data: { name: node.name }
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
var RULE_NAME5 = "jsx-uses-vars";
|
|
268
|
+
var RULE_FEATURES5 = [];
|
|
269
|
+
var jsx_uses_vars_default = createRule({
|
|
270
|
+
meta: {
|
|
271
|
+
type: "problem",
|
|
272
|
+
docs: {
|
|
273
|
+
description: "Marks variables used in JSX as used.",
|
|
274
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
275
|
+
},
|
|
276
|
+
messages: {
|
|
277
|
+
jsxUsesVars: "JSX variables should be marked as used."
|
|
278
|
+
},
|
|
279
|
+
schema: []
|
|
280
|
+
},
|
|
281
|
+
name: RULE_NAME5,
|
|
282
|
+
create: create5,
|
|
283
|
+
defaultOptions: []
|
|
284
|
+
});
|
|
285
|
+
function create5(context) {
|
|
243
286
|
return {
|
|
244
287
|
JSXOpeningElement(node) {
|
|
245
288
|
switch (node.name.type) {
|
|
@@ -261,8 +304,8 @@ function create4(context) {
|
|
|
261
304
|
}
|
|
262
305
|
};
|
|
263
306
|
}
|
|
264
|
-
var
|
|
265
|
-
var
|
|
307
|
+
var RULE_NAME6 = "no-access-state-in-setstate";
|
|
308
|
+
var RULE_FEATURES6 = [];
|
|
266
309
|
function isKeyLiteral(node, key) {
|
|
267
310
|
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);
|
|
268
311
|
}
|
|
@@ -271,18 +314,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
271
314
|
type: "problem",
|
|
272
315
|
docs: {
|
|
273
316
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
274
|
-
[Symbol.for("rule_features")]:
|
|
317
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
275
318
|
},
|
|
276
319
|
messages: {
|
|
277
320
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
278
321
|
},
|
|
279
322
|
schema: []
|
|
280
323
|
},
|
|
281
|
-
name:
|
|
282
|
-
create:
|
|
324
|
+
name: RULE_NAME6,
|
|
325
|
+
create: create6,
|
|
283
326
|
defaultOptions: []
|
|
284
327
|
});
|
|
285
|
-
function
|
|
328
|
+
function create6(context) {
|
|
286
329
|
if (!context.sourceCode.text.includes("setState")) {
|
|
287
330
|
return {};
|
|
288
331
|
}
|
|
@@ -373,8 +416,8 @@ function create5(context) {
|
|
|
373
416
|
}
|
|
374
417
|
};
|
|
375
418
|
}
|
|
376
|
-
var
|
|
377
|
-
var
|
|
419
|
+
var RULE_NAME7 = "no-array-index-key";
|
|
420
|
+
var RULE_FEATURES7 = [];
|
|
378
421
|
var reactChildrenMethod = ["forEach", "map"];
|
|
379
422
|
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
380
423
|
["every", 1],
|
|
@@ -458,18 +501,18 @@ var no_array_index_key_default = createRule({
|
|
|
458
501
|
type: "problem",
|
|
459
502
|
docs: {
|
|
460
503
|
description: "Disallow an item's index in the array as its key.",
|
|
461
|
-
[Symbol.for("rule_features")]:
|
|
504
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
462
505
|
},
|
|
463
506
|
messages: {
|
|
464
507
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
465
508
|
},
|
|
466
509
|
schema: []
|
|
467
510
|
},
|
|
468
|
-
name:
|
|
469
|
-
create:
|
|
511
|
+
name: RULE_NAME7,
|
|
512
|
+
create: create7,
|
|
470
513
|
defaultOptions: []
|
|
471
514
|
});
|
|
472
|
-
function
|
|
515
|
+
function create7(context) {
|
|
473
516
|
const report = createReport(context);
|
|
474
517
|
const indexParamNames = [];
|
|
475
518
|
function isArrayIndex(node) {
|
|
@@ -567,25 +610,25 @@ function create6(context) {
|
|
|
567
610
|
}
|
|
568
611
|
};
|
|
569
612
|
}
|
|
570
|
-
var
|
|
571
|
-
var
|
|
613
|
+
var RULE_NAME8 = "no-children-count";
|
|
614
|
+
var RULE_FEATURES8 = [];
|
|
572
615
|
var no_children_count_default = createRule({
|
|
573
616
|
meta: {
|
|
574
617
|
type: "problem",
|
|
575
618
|
docs: {
|
|
576
619
|
description: "Disallow `Children.count`.",
|
|
577
|
-
[Symbol.for("rule_features")]:
|
|
620
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
578
621
|
},
|
|
579
622
|
messages: {
|
|
580
623
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
581
624
|
},
|
|
582
625
|
schema: []
|
|
583
626
|
},
|
|
584
|
-
name:
|
|
585
|
-
create:
|
|
627
|
+
name: RULE_NAME8,
|
|
628
|
+
create: create8,
|
|
586
629
|
defaultOptions: []
|
|
587
630
|
});
|
|
588
|
-
function
|
|
631
|
+
function create8(context) {
|
|
589
632
|
return {
|
|
590
633
|
MemberExpression(node) {
|
|
591
634
|
if (isChildrenCount(context, node)) {
|
|
@@ -597,25 +640,25 @@ function create7(context) {
|
|
|
597
640
|
}
|
|
598
641
|
};
|
|
599
642
|
}
|
|
600
|
-
var
|
|
601
|
-
var
|
|
643
|
+
var RULE_NAME9 = "no-children-for-each";
|
|
644
|
+
var RULE_FEATURES9 = [];
|
|
602
645
|
var no_children_for_each_default = createRule({
|
|
603
646
|
meta: {
|
|
604
647
|
type: "problem",
|
|
605
648
|
docs: {
|
|
606
649
|
description: "Disallow 'Children.forEach'.",
|
|
607
|
-
[Symbol.for("rule_features")]:
|
|
650
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
608
651
|
},
|
|
609
652
|
messages: {
|
|
610
653
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
611
654
|
},
|
|
612
655
|
schema: []
|
|
613
656
|
},
|
|
614
|
-
name:
|
|
615
|
-
create:
|
|
657
|
+
name: RULE_NAME9,
|
|
658
|
+
create: create9,
|
|
616
659
|
defaultOptions: []
|
|
617
660
|
});
|
|
618
|
-
function
|
|
661
|
+
function create9(context) {
|
|
619
662
|
return {
|
|
620
663
|
MemberExpression(node) {
|
|
621
664
|
if (isChildrenForEach(context, node)) {
|
|
@@ -627,25 +670,25 @@ function create8(context) {
|
|
|
627
670
|
}
|
|
628
671
|
};
|
|
629
672
|
}
|
|
630
|
-
var
|
|
631
|
-
var
|
|
673
|
+
var RULE_NAME10 = "no-children-map";
|
|
674
|
+
var RULE_FEATURES10 = [];
|
|
632
675
|
var no_children_map_default = createRule({
|
|
633
676
|
meta: {
|
|
634
677
|
type: "problem",
|
|
635
678
|
docs: {
|
|
636
679
|
description: "Disallow `Children.map`.",
|
|
637
|
-
[Symbol.for("rule_features")]:
|
|
680
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
638
681
|
},
|
|
639
682
|
messages: {
|
|
640
683
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
641
684
|
},
|
|
642
685
|
schema: []
|
|
643
686
|
},
|
|
644
|
-
name:
|
|
645
|
-
create:
|
|
687
|
+
name: RULE_NAME10,
|
|
688
|
+
create: create10,
|
|
646
689
|
defaultOptions: []
|
|
647
690
|
});
|
|
648
|
-
function
|
|
691
|
+
function create10(context) {
|
|
649
692
|
return {
|
|
650
693
|
MemberExpression(node) {
|
|
651
694
|
if (isChildrenMap(context, node)) {
|
|
@@ -657,25 +700,25 @@ function create9(context) {
|
|
|
657
700
|
}
|
|
658
701
|
};
|
|
659
702
|
}
|
|
660
|
-
var
|
|
661
|
-
var
|
|
703
|
+
var RULE_NAME11 = "no-children-only";
|
|
704
|
+
var RULE_FEATURES11 = [];
|
|
662
705
|
var no_children_only_default = createRule({
|
|
663
706
|
meta: {
|
|
664
707
|
type: "problem",
|
|
665
708
|
docs: {
|
|
666
709
|
description: "Disallow `Children.only`.",
|
|
667
|
-
[Symbol.for("rule_features")]:
|
|
710
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
668
711
|
},
|
|
669
712
|
messages: {
|
|
670
713
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
671
714
|
},
|
|
672
715
|
schema: []
|
|
673
716
|
},
|
|
674
|
-
name:
|
|
675
|
-
create:
|
|
717
|
+
name: RULE_NAME11,
|
|
718
|
+
create: create11,
|
|
676
719
|
defaultOptions: []
|
|
677
720
|
});
|
|
678
|
-
function
|
|
721
|
+
function create11(context) {
|
|
679
722
|
return {
|
|
680
723
|
MemberExpression(node) {
|
|
681
724
|
if (isChildrenOnly(context, node)) {
|
|
@@ -687,25 +730,25 @@ function create10(context) {
|
|
|
687
730
|
}
|
|
688
731
|
};
|
|
689
732
|
}
|
|
690
|
-
var
|
|
691
|
-
var
|
|
733
|
+
var RULE_NAME12 = "no-children-prop";
|
|
734
|
+
var RULE_FEATURES12 = [];
|
|
692
735
|
var no_children_prop_default = createRule({
|
|
693
736
|
meta: {
|
|
694
737
|
type: "problem",
|
|
695
738
|
docs: {
|
|
696
739
|
description: "Disallow passing `children` as a prop.",
|
|
697
|
-
[Symbol.for("rule_features")]:
|
|
740
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
698
741
|
},
|
|
699
742
|
messages: {
|
|
700
743
|
noChildrenProp: "Do not pass 'children' as props."
|
|
701
744
|
},
|
|
702
745
|
schema: []
|
|
703
746
|
},
|
|
704
|
-
name:
|
|
705
|
-
create:
|
|
747
|
+
name: RULE_NAME12,
|
|
748
|
+
create: create12,
|
|
706
749
|
defaultOptions: []
|
|
707
750
|
});
|
|
708
|
-
function
|
|
751
|
+
function create12(context) {
|
|
709
752
|
return {
|
|
710
753
|
JSXElement(node) {
|
|
711
754
|
const attribute = JSX8.getAttribute(
|
|
@@ -722,25 +765,25 @@ function create11(context) {
|
|
|
722
765
|
}
|
|
723
766
|
};
|
|
724
767
|
}
|
|
725
|
-
var
|
|
726
|
-
var
|
|
768
|
+
var RULE_NAME13 = "no-children-to-array";
|
|
769
|
+
var RULE_FEATURES13 = [];
|
|
727
770
|
var no_children_to_array_default = createRule({
|
|
728
771
|
meta: {
|
|
729
772
|
type: "problem",
|
|
730
773
|
docs: {
|
|
731
774
|
description: "Disallow `Children.toArray`.",
|
|
732
|
-
[Symbol.for("rule_features")]:
|
|
775
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
733
776
|
},
|
|
734
777
|
messages: {
|
|
735
778
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
736
779
|
},
|
|
737
780
|
schema: []
|
|
738
781
|
},
|
|
739
|
-
name:
|
|
740
|
-
create:
|
|
782
|
+
name: RULE_NAME13,
|
|
783
|
+
create: create13,
|
|
741
784
|
defaultOptions: []
|
|
742
785
|
});
|
|
743
|
-
function
|
|
786
|
+
function create13(context) {
|
|
744
787
|
return {
|
|
745
788
|
MemberExpression(node) {
|
|
746
789
|
if (isChildrenToArray(context, node)) {
|
|
@@ -752,25 +795,25 @@ function create12(context) {
|
|
|
752
795
|
}
|
|
753
796
|
};
|
|
754
797
|
}
|
|
755
|
-
var
|
|
756
|
-
var
|
|
798
|
+
var RULE_NAME14 = "no-class-component";
|
|
799
|
+
var RULE_FEATURES14 = [];
|
|
757
800
|
var no_class_component_default = createRule({
|
|
758
801
|
meta: {
|
|
759
802
|
type: "problem",
|
|
760
803
|
docs: {
|
|
761
804
|
description: "Disallow class components.",
|
|
762
|
-
[Symbol.for("rule_features")]:
|
|
805
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
763
806
|
},
|
|
764
807
|
messages: {
|
|
765
808
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
766
809
|
},
|
|
767
810
|
schema: []
|
|
768
811
|
},
|
|
769
|
-
name:
|
|
770
|
-
create:
|
|
812
|
+
name: RULE_NAME14,
|
|
813
|
+
create: create14,
|
|
771
814
|
defaultOptions: []
|
|
772
815
|
});
|
|
773
|
-
function
|
|
816
|
+
function create14(context) {
|
|
774
817
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
775
818
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
776
819
|
return {
|
|
@@ -792,25 +835,25 @@ function create13(context) {
|
|
|
792
835
|
}
|
|
793
836
|
};
|
|
794
837
|
}
|
|
795
|
-
var
|
|
796
|
-
var
|
|
838
|
+
var RULE_NAME15 = "no-clone-element";
|
|
839
|
+
var RULE_FEATURES15 = [];
|
|
797
840
|
var no_clone_element_default = createRule({
|
|
798
841
|
meta: {
|
|
799
842
|
type: "problem",
|
|
800
843
|
docs: {
|
|
801
844
|
description: "Disallow `cloneElement`.",
|
|
802
|
-
[Symbol.for("rule_features")]:
|
|
845
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
803
846
|
},
|
|
804
847
|
messages: {
|
|
805
848
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
806
849
|
},
|
|
807
850
|
schema: []
|
|
808
851
|
},
|
|
809
|
-
name:
|
|
810
|
-
create:
|
|
852
|
+
name: RULE_NAME15,
|
|
853
|
+
create: create15,
|
|
811
854
|
defaultOptions: []
|
|
812
855
|
});
|
|
813
|
-
function
|
|
856
|
+
function create15(context) {
|
|
814
857
|
return {
|
|
815
858
|
CallExpression(node) {
|
|
816
859
|
if (!isCloneElementCall(context, node)) {
|
|
@@ -823,25 +866,25 @@ function create14(context) {
|
|
|
823
866
|
}
|
|
824
867
|
};
|
|
825
868
|
}
|
|
826
|
-
var
|
|
827
|
-
var
|
|
869
|
+
var RULE_NAME16 = "no-comment-textnodes";
|
|
870
|
+
var RULE_FEATURES16 = [];
|
|
828
871
|
var no_comment_textnodes_default = createRule({
|
|
829
872
|
meta: {
|
|
830
873
|
type: "problem",
|
|
831
874
|
docs: {
|
|
832
875
|
description: "Prevents comments from being inserted as text nodes.",
|
|
833
|
-
[Symbol.for("rule_features")]:
|
|
876
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
834
877
|
},
|
|
835
878
|
messages: {
|
|
836
879
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
837
880
|
},
|
|
838
881
|
schema: []
|
|
839
882
|
},
|
|
840
|
-
name:
|
|
841
|
-
create:
|
|
883
|
+
name: RULE_NAME16,
|
|
884
|
+
create: create16,
|
|
842
885
|
defaultOptions: []
|
|
843
886
|
});
|
|
844
|
-
function
|
|
887
|
+
function create16(context) {
|
|
845
888
|
function hasCommentLike(node) {
|
|
846
889
|
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
847
890
|
return false;
|
|
@@ -869,8 +912,8 @@ function create15(context) {
|
|
|
869
912
|
Literal: visitorFunction
|
|
870
913
|
};
|
|
871
914
|
}
|
|
872
|
-
var
|
|
873
|
-
var
|
|
915
|
+
var RULE_NAME17 = "no-complex-conditional-rendering";
|
|
916
|
+
var RULE_FEATURES17 = [
|
|
874
917
|
"EXP"
|
|
875
918
|
];
|
|
876
919
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -878,18 +921,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
878
921
|
type: "problem",
|
|
879
922
|
docs: {
|
|
880
923
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
881
|
-
[Symbol.for("rule_features")]:
|
|
924
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
882
925
|
},
|
|
883
926
|
messages: {
|
|
884
927
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
885
928
|
},
|
|
886
929
|
schema: []
|
|
887
930
|
},
|
|
888
|
-
name:
|
|
889
|
-
create:
|
|
931
|
+
name: RULE_NAME17,
|
|
932
|
+
create: create17,
|
|
890
933
|
defaultOptions: []
|
|
891
934
|
});
|
|
892
|
-
function
|
|
935
|
+
function create17(context) {
|
|
893
936
|
const visitorFunction = (node) => {
|
|
894
937
|
const jsxExpContainer = node.parent?.parent;
|
|
895
938
|
if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -914,8 +957,8 @@ function create16(context) {
|
|
|
914
957
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
915
958
|
};
|
|
916
959
|
}
|
|
917
|
-
var
|
|
918
|
-
var
|
|
960
|
+
var RULE_NAME18 = "no-component-will-mount";
|
|
961
|
+
var RULE_FEATURES18 = [
|
|
919
962
|
"MOD"
|
|
920
963
|
];
|
|
921
964
|
function isComponentWillMount(node) {
|
|
@@ -926,7 +969,7 @@ var no_component_will_mount_default = createRule({
|
|
|
926
969
|
type: "problem",
|
|
927
970
|
docs: {
|
|
928
971
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
929
|
-
[Symbol.for("rule_features")]:
|
|
972
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
930
973
|
},
|
|
931
974
|
fixable: "code",
|
|
932
975
|
messages: {
|
|
@@ -934,11 +977,11 @@ var no_component_will_mount_default = createRule({
|
|
|
934
977
|
},
|
|
935
978
|
schema: []
|
|
936
979
|
},
|
|
937
|
-
name:
|
|
938
|
-
create:
|
|
980
|
+
name: RULE_NAME18,
|
|
981
|
+
create: create18,
|
|
939
982
|
defaultOptions: []
|
|
940
983
|
});
|
|
941
|
-
function
|
|
984
|
+
function create18(context) {
|
|
942
985
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
943
986
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
944
987
|
return {
|
|
@@ -965,8 +1008,8 @@ function create17(context) {
|
|
|
965
1008
|
}
|
|
966
1009
|
};
|
|
967
1010
|
}
|
|
968
|
-
var
|
|
969
|
-
var
|
|
1011
|
+
var RULE_NAME19 = "no-component-will-receive-props";
|
|
1012
|
+
var RULE_FEATURES19 = [
|
|
970
1013
|
"MOD"
|
|
971
1014
|
];
|
|
972
1015
|
function isComponentWillUpdate(node) {
|
|
@@ -977,7 +1020,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
977
1020
|
type: "problem",
|
|
978
1021
|
docs: {
|
|
979
1022
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
980
|
-
[Symbol.for("rule_features")]:
|
|
1023
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
981
1024
|
},
|
|
982
1025
|
fixable: "code",
|
|
983
1026
|
messages: {
|
|
@@ -985,11 +1028,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
985
1028
|
},
|
|
986
1029
|
schema: []
|
|
987
1030
|
},
|
|
988
|
-
name:
|
|
989
|
-
create:
|
|
1031
|
+
name: RULE_NAME19,
|
|
1032
|
+
create: create19,
|
|
990
1033
|
defaultOptions: []
|
|
991
1034
|
});
|
|
992
|
-
function
|
|
1035
|
+
function create19(context) {
|
|
993
1036
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
994
1037
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
995
1038
|
return {
|
|
@@ -1016,8 +1059,8 @@ function create18(context) {
|
|
|
1016
1059
|
}
|
|
1017
1060
|
};
|
|
1018
1061
|
}
|
|
1019
|
-
var
|
|
1020
|
-
var
|
|
1062
|
+
var RULE_NAME20 = "no-component-will-update";
|
|
1063
|
+
var RULE_FEATURES20 = [
|
|
1021
1064
|
"MOD"
|
|
1022
1065
|
];
|
|
1023
1066
|
function isComponentWillUpdate2(node) {
|
|
@@ -1028,7 +1071,7 @@ var no_component_will_update_default = createRule({
|
|
|
1028
1071
|
type: "problem",
|
|
1029
1072
|
docs: {
|
|
1030
1073
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
1031
|
-
[Symbol.for("rule_features")]:
|
|
1074
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
1032
1075
|
},
|
|
1033
1076
|
fixable: "code",
|
|
1034
1077
|
messages: {
|
|
@@ -1036,11 +1079,11 @@ var no_component_will_update_default = createRule({
|
|
|
1036
1079
|
},
|
|
1037
1080
|
schema: []
|
|
1038
1081
|
},
|
|
1039
|
-
name:
|
|
1040
|
-
create:
|
|
1082
|
+
name: RULE_NAME20,
|
|
1083
|
+
create: create20,
|
|
1041
1084
|
defaultOptions: []
|
|
1042
1085
|
});
|
|
1043
|
-
function
|
|
1086
|
+
function create20(context) {
|
|
1044
1087
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1045
1088
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
1046
1089
|
return {
|
|
@@ -1067,8 +1110,8 @@ function create19(context) {
|
|
|
1067
1110
|
}
|
|
1068
1111
|
};
|
|
1069
1112
|
}
|
|
1070
|
-
var
|
|
1071
|
-
var
|
|
1113
|
+
var RULE_NAME21 = "no-context-provider";
|
|
1114
|
+
var RULE_FEATURES21 = [
|
|
1072
1115
|
"MOD"
|
|
1073
1116
|
];
|
|
1074
1117
|
var no_context_provider_default = createRule({
|
|
@@ -1076,7 +1119,7 @@ var no_context_provider_default = createRule({
|
|
|
1076
1119
|
type: "problem",
|
|
1077
1120
|
docs: {
|
|
1078
1121
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1079
|
-
[Symbol.for("rule_features")]:
|
|
1122
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1080
1123
|
},
|
|
1081
1124
|
fixable: "code",
|
|
1082
1125
|
messages: {
|
|
@@ -1084,11 +1127,11 @@ var no_context_provider_default = createRule({
|
|
|
1084
1127
|
},
|
|
1085
1128
|
schema: []
|
|
1086
1129
|
},
|
|
1087
|
-
name:
|
|
1088
|
-
create:
|
|
1130
|
+
name: RULE_NAME21,
|
|
1131
|
+
create: create21,
|
|
1089
1132
|
defaultOptions: []
|
|
1090
1133
|
});
|
|
1091
|
-
function
|
|
1134
|
+
function create21(context) {
|
|
1092
1135
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1093
1136
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1094
1137
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1120,25 +1163,25 @@ function create20(context) {
|
|
|
1120
1163
|
}
|
|
1121
1164
|
};
|
|
1122
1165
|
}
|
|
1123
|
-
var
|
|
1124
|
-
var
|
|
1166
|
+
var RULE_NAME22 = "no-create-ref";
|
|
1167
|
+
var RULE_FEATURES22 = [];
|
|
1125
1168
|
var no_create_ref_default = createRule({
|
|
1126
1169
|
meta: {
|
|
1127
1170
|
type: "problem",
|
|
1128
1171
|
docs: {
|
|
1129
1172
|
description: "Disallow `createRef` in function components.",
|
|
1130
|
-
[Symbol.for("rule_features")]:
|
|
1173
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1131
1174
|
},
|
|
1132
1175
|
messages: {
|
|
1133
1176
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1134
1177
|
},
|
|
1135
1178
|
schema: []
|
|
1136
1179
|
},
|
|
1137
|
-
name:
|
|
1138
|
-
create:
|
|
1180
|
+
name: RULE_NAME22,
|
|
1181
|
+
create: create22,
|
|
1139
1182
|
defaultOptions: []
|
|
1140
1183
|
});
|
|
1141
|
-
function
|
|
1184
|
+
function create22(context) {
|
|
1142
1185
|
return {
|
|
1143
1186
|
CallExpression(node) {
|
|
1144
1187
|
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
@@ -1147,25 +1190,25 @@ function create21(context) {
|
|
|
1147
1190
|
}
|
|
1148
1191
|
};
|
|
1149
1192
|
}
|
|
1150
|
-
var
|
|
1151
|
-
var
|
|
1193
|
+
var RULE_NAME23 = "no-default-props";
|
|
1194
|
+
var RULE_FEATURES23 = [];
|
|
1152
1195
|
var no_default_props_default = createRule({
|
|
1153
1196
|
meta: {
|
|
1154
1197
|
type: "problem",
|
|
1155
1198
|
docs: {
|
|
1156
1199
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1157
|
-
[Symbol.for("rule_features")]:
|
|
1200
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1158
1201
|
},
|
|
1159
1202
|
messages: {
|
|
1160
1203
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1161
1204
|
},
|
|
1162
1205
|
schema: []
|
|
1163
1206
|
},
|
|
1164
|
-
name:
|
|
1165
|
-
create:
|
|
1207
|
+
name: RULE_NAME23,
|
|
1208
|
+
create: create23,
|
|
1166
1209
|
defaultOptions: []
|
|
1167
1210
|
});
|
|
1168
|
-
function
|
|
1211
|
+
function create23(context) {
|
|
1169
1212
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1170
1213
|
return {
|
|
1171
1214
|
AssignmentExpression(node) {
|
|
@@ -1182,8 +1225,8 @@ function create22(context) {
|
|
|
1182
1225
|
if (!isComponentNameLoose(object.name)) {
|
|
1183
1226
|
return;
|
|
1184
1227
|
}
|
|
1185
|
-
const variable =
|
|
1186
|
-
const variableNode =
|
|
1228
|
+
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1229
|
+
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
1187
1230
|
if (variableNode == null) return;
|
|
1188
1231
|
if (!AST11.isFunction(variableNode) && !isClassComponent(variableNode)) return;
|
|
1189
1232
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
@@ -1199,8 +1242,8 @@ function create22(context) {
|
|
|
1199
1242
|
}
|
|
1200
1243
|
};
|
|
1201
1244
|
}
|
|
1202
|
-
var
|
|
1203
|
-
var
|
|
1245
|
+
var RULE_NAME24 = "no-direct-mutation-state";
|
|
1246
|
+
var RULE_FEATURES24 = [];
|
|
1204
1247
|
function isConstructorFunction(node) {
|
|
1205
1248
|
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";
|
|
1206
1249
|
}
|
|
@@ -1209,18 +1252,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1209
1252
|
type: "problem",
|
|
1210
1253
|
docs: {
|
|
1211
1254
|
description: "Disallow direct mutation of `this.state`.",
|
|
1212
|
-
[Symbol.for("rule_features")]:
|
|
1255
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1213
1256
|
},
|
|
1214
1257
|
messages: {
|
|
1215
1258
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1216
1259
|
},
|
|
1217
1260
|
schema: []
|
|
1218
1261
|
},
|
|
1219
|
-
name:
|
|
1220
|
-
create:
|
|
1262
|
+
name: RULE_NAME24,
|
|
1263
|
+
create: create24,
|
|
1221
1264
|
defaultOptions: []
|
|
1222
1265
|
});
|
|
1223
|
-
function
|
|
1266
|
+
function create24(context) {
|
|
1224
1267
|
return {
|
|
1225
1268
|
AssignmentExpression(node) {
|
|
1226
1269
|
if (!isAssignmentToThisState(node)) return;
|
|
@@ -1241,25 +1284,25 @@ function create23(context) {
|
|
|
1241
1284
|
}
|
|
1242
1285
|
};
|
|
1243
1286
|
}
|
|
1244
|
-
var
|
|
1245
|
-
var
|
|
1287
|
+
var RULE_NAME25 = "no-duplicate-key";
|
|
1288
|
+
var RULE_FEATURES25 = [];
|
|
1246
1289
|
var no_duplicate_key_default = createRule({
|
|
1247
1290
|
meta: {
|
|
1248
1291
|
type: "problem",
|
|
1249
1292
|
docs: {
|
|
1250
1293
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1251
|
-
[Symbol.for("rule_features")]:
|
|
1294
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1252
1295
|
},
|
|
1253
1296
|
messages: {
|
|
1254
1297
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1255
1298
|
},
|
|
1256
1299
|
schema: []
|
|
1257
1300
|
},
|
|
1258
|
-
name:
|
|
1259
|
-
create:
|
|
1301
|
+
name: RULE_NAME25,
|
|
1302
|
+
create: create25,
|
|
1260
1303
|
defaultOptions: []
|
|
1261
1304
|
});
|
|
1262
|
-
function
|
|
1305
|
+
function create25(context) {
|
|
1263
1306
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1264
1307
|
return {};
|
|
1265
1308
|
}
|
|
@@ -1323,8 +1366,8 @@ function create24(context) {
|
|
|
1323
1366
|
}
|
|
1324
1367
|
};
|
|
1325
1368
|
}
|
|
1326
|
-
var
|
|
1327
|
-
var
|
|
1369
|
+
var RULE_NAME26 = "no-forward-ref";
|
|
1370
|
+
var RULE_FEATURES26 = [
|
|
1328
1371
|
"MOD"
|
|
1329
1372
|
];
|
|
1330
1373
|
var no_forward_ref_default = createRule({
|
|
@@ -1332,7 +1375,7 @@ var no_forward_ref_default = createRule({
|
|
|
1332
1375
|
type: "problem",
|
|
1333
1376
|
docs: {
|
|
1334
1377
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1335
|
-
[Symbol.for("rule_features")]:
|
|
1378
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1336
1379
|
},
|
|
1337
1380
|
fixable: "code",
|
|
1338
1381
|
messages: {
|
|
@@ -1340,11 +1383,11 @@ var no_forward_ref_default = createRule({
|
|
|
1340
1383
|
},
|
|
1341
1384
|
schema: []
|
|
1342
1385
|
},
|
|
1343
|
-
name:
|
|
1344
|
-
create:
|
|
1386
|
+
name: RULE_NAME26,
|
|
1387
|
+
create: create26,
|
|
1345
1388
|
defaultOptions: []
|
|
1346
1389
|
});
|
|
1347
|
-
function
|
|
1390
|
+
function create26(context) {
|
|
1348
1391
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1349
1392
|
return {};
|
|
1350
1393
|
}
|
|
@@ -1432,8 +1475,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1432
1475
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1433
1476
|
];
|
|
1434
1477
|
}
|
|
1435
|
-
var
|
|
1436
|
-
var
|
|
1478
|
+
var RULE_NAME27 = "no-implicit-key";
|
|
1479
|
+
var RULE_FEATURES27 = [
|
|
1437
1480
|
"EXP"
|
|
1438
1481
|
];
|
|
1439
1482
|
var no_implicit_key_default = createRule({
|
|
@@ -1441,18 +1484,18 @@ var no_implicit_key_default = createRule({
|
|
|
1441
1484
|
type: "problem",
|
|
1442
1485
|
docs: {
|
|
1443
1486
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1444
|
-
[Symbol.for("rule_features")]:
|
|
1487
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1445
1488
|
},
|
|
1446
1489
|
messages: {
|
|
1447
1490
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1448
1491
|
},
|
|
1449
1492
|
schema: []
|
|
1450
1493
|
},
|
|
1451
|
-
name:
|
|
1452
|
-
create:
|
|
1494
|
+
name: RULE_NAME27,
|
|
1495
|
+
create: create27,
|
|
1453
1496
|
defaultOptions: []
|
|
1454
1497
|
});
|
|
1455
|
-
function
|
|
1498
|
+
function create27(context) {
|
|
1456
1499
|
return {
|
|
1457
1500
|
JSXOpeningElement(node) {
|
|
1458
1501
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1466,8 +1509,8 @@ function create26(context) {
|
|
|
1466
1509
|
}
|
|
1467
1510
|
};
|
|
1468
1511
|
}
|
|
1469
|
-
var
|
|
1470
|
-
var
|
|
1512
|
+
var RULE_NAME28 = "no-leaked-conditional-rendering";
|
|
1513
|
+
var RULE_FEATURES28 = [
|
|
1471
1514
|
"TSC"
|
|
1472
1515
|
];
|
|
1473
1516
|
var tsHelpers = {
|
|
@@ -1553,18 +1596,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1553
1596
|
type: "problem",
|
|
1554
1597
|
docs: {
|
|
1555
1598
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1556
|
-
[Symbol.for("rule_features")]:
|
|
1599
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1557
1600
|
},
|
|
1558
1601
|
messages: {
|
|
1559
1602
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1560
1603
|
},
|
|
1561
1604
|
schema: []
|
|
1562
1605
|
},
|
|
1563
|
-
name:
|
|
1564
|
-
create:
|
|
1606
|
+
name: RULE_NAME28,
|
|
1607
|
+
create: create28,
|
|
1565
1608
|
defaultOptions: []
|
|
1566
1609
|
});
|
|
1567
|
-
function
|
|
1610
|
+
function create28(context) {
|
|
1568
1611
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1569
1612
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1570
1613
|
const allowedVariants = [
|
|
@@ -1588,7 +1631,7 @@ function create27(context) {
|
|
|
1588
1631
|
return getReportDescriptor(right);
|
|
1589
1632
|
}
|
|
1590
1633
|
const initialScope = context.sourceCode.getScope(left);
|
|
1591
|
-
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" ||
|
|
1634
|
+
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR2.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1592
1635
|
if (isLeftNan) {
|
|
1593
1636
|
return {
|
|
1594
1637
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1610,7 +1653,7 @@ function create27(context) {
|
|
|
1610
1653
|
}).with({ type: AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
|
|
1611
1654
|
return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
|
|
1612
1655
|
}).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
1613
|
-
const variable =
|
|
1656
|
+
const variable = VAR2.findVariable(n.name, context.sourceCode.getScope(n));
|
|
1614
1657
|
const variableDefNode = variable?.defs.at(0)?.node;
|
|
1615
1658
|
return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => _);
|
|
1616
1659
|
}).otherwise(() => _);
|
|
@@ -1621,25 +1664,25 @@ function create27(context) {
|
|
|
1621
1664
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1622
1665
|
};
|
|
1623
1666
|
}
|
|
1624
|
-
var
|
|
1625
|
-
var
|
|
1667
|
+
var RULE_NAME29 = "no-missing-component-display-name";
|
|
1668
|
+
var RULE_FEATURES29 = [];
|
|
1626
1669
|
var no_missing_component_display_name_default = createRule({
|
|
1627
1670
|
meta: {
|
|
1628
1671
|
type: "problem",
|
|
1629
1672
|
docs: {
|
|
1630
1673
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1631
|
-
[Symbol.for("rule_features")]:
|
|
1674
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1632
1675
|
},
|
|
1633
1676
|
messages: {
|
|
1634
1677
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1635
1678
|
},
|
|
1636
1679
|
schema: []
|
|
1637
1680
|
},
|
|
1638
|
-
name:
|
|
1639
|
-
create:
|
|
1681
|
+
name: RULE_NAME29,
|
|
1682
|
+
create: create29,
|
|
1640
1683
|
defaultOptions: []
|
|
1641
1684
|
});
|
|
1642
|
-
function
|
|
1685
|
+
function create29(context) {
|
|
1643
1686
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1644
1687
|
const {
|
|
1645
1688
|
ctx,
|
|
@@ -1674,25 +1717,25 @@ function create28(context) {
|
|
|
1674
1717
|
}
|
|
1675
1718
|
};
|
|
1676
1719
|
}
|
|
1677
|
-
var
|
|
1678
|
-
var
|
|
1720
|
+
var RULE_NAME30 = "no-missing-context-display-name";
|
|
1721
|
+
var RULE_FEATURES30 = [];
|
|
1679
1722
|
var no_missing_context_display_name_default = createRule({
|
|
1680
1723
|
meta: {
|
|
1681
1724
|
type: "problem",
|
|
1682
1725
|
docs: {
|
|
1683
1726
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1684
|
-
[Symbol.for("rule_features")]:
|
|
1727
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1685
1728
|
},
|
|
1686
1729
|
messages: {
|
|
1687
1730
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1688
1731
|
},
|
|
1689
1732
|
schema: []
|
|
1690
1733
|
},
|
|
1691
|
-
name:
|
|
1692
|
-
create:
|
|
1734
|
+
name: RULE_NAME30,
|
|
1735
|
+
create: create30,
|
|
1693
1736
|
defaultOptions: []
|
|
1694
1737
|
});
|
|
1695
|
-
function
|
|
1738
|
+
function create30(context) {
|
|
1696
1739
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1697
1740
|
const createCalls = [];
|
|
1698
1741
|
const displayNameAssignments = [];
|
|
@@ -1730,14 +1773,14 @@ function create29(context) {
|
|
|
1730
1773
|
}
|
|
1731
1774
|
};
|
|
1732
1775
|
}
|
|
1733
|
-
var
|
|
1734
|
-
var
|
|
1776
|
+
var RULE_NAME31 = "no-missing-key";
|
|
1777
|
+
var RULE_FEATURES31 = [];
|
|
1735
1778
|
var no_missing_key_default = createRule({
|
|
1736
1779
|
meta: {
|
|
1737
1780
|
type: "problem",
|
|
1738
1781
|
docs: {
|
|
1739
1782
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1740
|
-
[Symbol.for("rule_features")]:
|
|
1783
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1741
1784
|
},
|
|
1742
1785
|
messages: {
|
|
1743
1786
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1745,11 +1788,11 @@ var no_missing_key_default = createRule({
|
|
|
1745
1788
|
},
|
|
1746
1789
|
schema: []
|
|
1747
1790
|
},
|
|
1748
|
-
name:
|
|
1749
|
-
create:
|
|
1791
|
+
name: RULE_NAME31,
|
|
1792
|
+
create: create31,
|
|
1750
1793
|
defaultOptions: []
|
|
1751
1794
|
});
|
|
1752
|
-
function
|
|
1795
|
+
function create31(context) {
|
|
1753
1796
|
const report = createReport(context);
|
|
1754
1797
|
const state = { isWithinChildrenToArray: false };
|
|
1755
1798
|
function checkIteratorElement(node) {
|
|
@@ -1862,25 +1905,25 @@ function create30(context) {
|
|
|
1862
1905
|
function isArrayFromCall(node) {
|
|
1863
1906
|
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";
|
|
1864
1907
|
}
|
|
1865
|
-
var
|
|
1866
|
-
var
|
|
1908
|
+
var RULE_NAME32 = "no-nested-component-definitions";
|
|
1909
|
+
var RULE_FEATURES32 = [];
|
|
1867
1910
|
var no_nested_component_definitions_default = createRule({
|
|
1868
1911
|
meta: {
|
|
1869
1912
|
type: "problem",
|
|
1870
1913
|
docs: {
|
|
1871
1914
|
description: "Disallow nesting component definitions inside other components.",
|
|
1872
|
-
[Symbol.for("rule_features")]:
|
|
1915
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1873
1916
|
},
|
|
1874
1917
|
messages: {
|
|
1875
1918
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1876
1919
|
},
|
|
1877
1920
|
schema: []
|
|
1878
1921
|
},
|
|
1879
|
-
name:
|
|
1880
|
-
create:
|
|
1922
|
+
name: RULE_NAME32,
|
|
1923
|
+
create: create32,
|
|
1881
1924
|
defaultOptions: []
|
|
1882
1925
|
});
|
|
1883
|
-
function
|
|
1926
|
+
function create32(context) {
|
|
1884
1927
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1885
1928
|
const collector = useComponentCollector(context, { hint });
|
|
1886
1929
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -1976,25 +2019,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1976
2019
|
if (prop == null) return false;
|
|
1977
2020
|
return prop === call.arguments[1];
|
|
1978
2021
|
}
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
2022
|
+
var RULE_NAME33 = "no-prop-types";
|
|
2023
|
+
var RULE_FEATURES33 = [];
|
|
1981
2024
|
var no_prop_types_default = createRule({
|
|
1982
2025
|
meta: {
|
|
1983
2026
|
type: "problem",
|
|
1984
2027
|
docs: {
|
|
1985
2028
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1986
|
-
[Symbol.for("rule_features")]:
|
|
2029
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1987
2030
|
},
|
|
1988
2031
|
messages: {
|
|
1989
2032
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1990
2033
|
},
|
|
1991
2034
|
schema: []
|
|
1992
2035
|
},
|
|
1993
|
-
name:
|
|
1994
|
-
create:
|
|
2036
|
+
name: RULE_NAME33,
|
|
2037
|
+
create: create33,
|
|
1995
2038
|
defaultOptions: []
|
|
1996
2039
|
});
|
|
1997
|
-
function
|
|
2040
|
+
function create33(context) {
|
|
1998
2041
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1999
2042
|
return {};
|
|
2000
2043
|
}
|
|
@@ -2013,8 +2056,8 @@ function create32(context) {
|
|
|
2013
2056
|
if (!isComponentNameLoose(object.name)) {
|
|
2014
2057
|
return;
|
|
2015
2058
|
}
|
|
2016
|
-
const variable =
|
|
2017
|
-
const variableNode =
|
|
2059
|
+
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2060
|
+
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
2018
2061
|
if (variableNode != null && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
|
|
2019
2062
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2020
2063
|
}
|
|
@@ -2030,8 +2073,8 @@ function create32(context) {
|
|
|
2030
2073
|
}
|
|
2031
2074
|
};
|
|
2032
2075
|
}
|
|
2033
|
-
var
|
|
2034
|
-
var
|
|
2076
|
+
var RULE_NAME34 = "no-redundant-should-component-update";
|
|
2077
|
+
var RULE_FEATURES34 = [];
|
|
2035
2078
|
function isShouldComponentUpdate(node) {
|
|
2036
2079
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2037
2080
|
}
|
|
@@ -2040,18 +2083,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2040
2083
|
type: "problem",
|
|
2041
2084
|
docs: {
|
|
2042
2085
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2043
|
-
[Symbol.for("rule_features")]:
|
|
2086
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2044
2087
|
},
|
|
2045
2088
|
messages: {
|
|
2046
2089
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2047
2090
|
},
|
|
2048
2091
|
schema: []
|
|
2049
2092
|
},
|
|
2050
|
-
name:
|
|
2051
|
-
create:
|
|
2093
|
+
name: RULE_NAME34,
|
|
2094
|
+
create: create34,
|
|
2052
2095
|
defaultOptions: []
|
|
2053
2096
|
});
|
|
2054
|
-
function
|
|
2097
|
+
function create34(context) {
|
|
2055
2098
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2056
2099
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2057
2100
|
return {
|
|
@@ -2078,8 +2121,8 @@ function create33(context) {
|
|
|
2078
2121
|
}
|
|
2079
2122
|
};
|
|
2080
2123
|
}
|
|
2081
|
-
var
|
|
2082
|
-
var
|
|
2124
|
+
var RULE_NAME35 = "no-set-state-in-component-did-mount";
|
|
2125
|
+
var RULE_FEATURES35 = [];
|
|
2083
2126
|
function isComponentDidMount(node) {
|
|
2084
2127
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2085
2128
|
}
|
|
@@ -2088,18 +2131,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2088
2131
|
type: "problem",
|
|
2089
2132
|
docs: {
|
|
2090
2133
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2091
|
-
[Symbol.for("rule_features")]:
|
|
2134
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2092
2135
|
},
|
|
2093
2136
|
messages: {
|
|
2094
2137
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2095
2138
|
},
|
|
2096
2139
|
schema: []
|
|
2097
2140
|
},
|
|
2098
|
-
name:
|
|
2099
|
-
create:
|
|
2141
|
+
name: RULE_NAME35,
|
|
2142
|
+
create: create35,
|
|
2100
2143
|
defaultOptions: []
|
|
2101
2144
|
});
|
|
2102
|
-
function
|
|
2145
|
+
function create35(context) {
|
|
2103
2146
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2104
2147
|
return {
|
|
2105
2148
|
CallExpression(node) {
|
|
@@ -2120,8 +2163,8 @@ function create34(context) {
|
|
|
2120
2163
|
}
|
|
2121
2164
|
};
|
|
2122
2165
|
}
|
|
2123
|
-
var
|
|
2124
|
-
var
|
|
2166
|
+
var RULE_NAME36 = "no-set-state-in-component-did-update";
|
|
2167
|
+
var RULE_FEATURES36 = [];
|
|
2125
2168
|
function isComponentDidUpdate(node) {
|
|
2126
2169
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2127
2170
|
}
|
|
@@ -2130,18 +2173,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2130
2173
|
type: "problem",
|
|
2131
2174
|
docs: {
|
|
2132
2175
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2133
|
-
[Symbol.for("rule_features")]:
|
|
2176
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2134
2177
|
},
|
|
2135
2178
|
messages: {
|
|
2136
2179
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2137
2180
|
},
|
|
2138
2181
|
schema: []
|
|
2139
2182
|
},
|
|
2140
|
-
name:
|
|
2141
|
-
create:
|
|
2183
|
+
name: RULE_NAME36,
|
|
2184
|
+
create: create36,
|
|
2142
2185
|
defaultOptions: []
|
|
2143
2186
|
});
|
|
2144
|
-
function
|
|
2187
|
+
function create36(context) {
|
|
2145
2188
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2146
2189
|
return {
|
|
2147
2190
|
CallExpression(node) {
|
|
@@ -2162,8 +2205,8 @@ function create35(context) {
|
|
|
2162
2205
|
}
|
|
2163
2206
|
};
|
|
2164
2207
|
}
|
|
2165
|
-
var
|
|
2166
|
-
var
|
|
2208
|
+
var RULE_NAME37 = "no-set-state-in-component-will-update";
|
|
2209
|
+
var RULE_FEATURES37 = [];
|
|
2167
2210
|
function isComponentWillUpdate3(node) {
|
|
2168
2211
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2169
2212
|
}
|
|
@@ -2172,18 +2215,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2172
2215
|
type: "problem",
|
|
2173
2216
|
docs: {
|
|
2174
2217
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2175
|
-
[Symbol.for("rule_features")]:
|
|
2218
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2176
2219
|
},
|
|
2177
2220
|
messages: {
|
|
2178
2221
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2179
2222
|
},
|
|
2180
2223
|
schema: []
|
|
2181
2224
|
},
|
|
2182
|
-
name:
|
|
2183
|
-
create:
|
|
2225
|
+
name: RULE_NAME37,
|
|
2226
|
+
create: create37,
|
|
2184
2227
|
defaultOptions: []
|
|
2185
2228
|
});
|
|
2186
|
-
function
|
|
2229
|
+
function create37(context) {
|
|
2187
2230
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2188
2231
|
return {
|
|
2189
2232
|
CallExpression(node) {
|
|
@@ -2204,8 +2247,8 @@ function create36(context) {
|
|
|
2204
2247
|
}
|
|
2205
2248
|
};
|
|
2206
2249
|
}
|
|
2207
|
-
var
|
|
2208
|
-
var
|
|
2250
|
+
var RULE_NAME38 = "no-string-refs";
|
|
2251
|
+
var RULE_FEATURES38 = [];
|
|
2209
2252
|
function containsStringLiteral({ value }) {
|
|
2210
2253
|
return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2211
2254
|
}
|
|
@@ -2223,18 +2266,18 @@ var no_string_refs_default = createRule({
|
|
|
2223
2266
|
type: "problem",
|
|
2224
2267
|
docs: {
|
|
2225
2268
|
description: "Disallow deprecated string `refs`.",
|
|
2226
|
-
[Symbol.for("rule_features")]:
|
|
2269
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2227
2270
|
},
|
|
2228
2271
|
messages: {
|
|
2229
2272
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2230
2273
|
},
|
|
2231
2274
|
schema: []
|
|
2232
2275
|
},
|
|
2233
|
-
name:
|
|
2234
|
-
create:
|
|
2276
|
+
name: RULE_NAME38,
|
|
2277
|
+
create: create38,
|
|
2235
2278
|
defaultOptions: []
|
|
2236
2279
|
});
|
|
2237
|
-
function
|
|
2280
|
+
function create38(context) {
|
|
2238
2281
|
return {
|
|
2239
2282
|
JSXAttribute(node) {
|
|
2240
2283
|
if (node.name.name !== "ref") {
|
|
@@ -2249,8 +2292,8 @@ function create37(context) {
|
|
|
2249
2292
|
}
|
|
2250
2293
|
};
|
|
2251
2294
|
}
|
|
2252
|
-
var
|
|
2253
|
-
var
|
|
2295
|
+
var RULE_NAME39 = "no-unsafe-component-will-mount";
|
|
2296
|
+
var RULE_FEATURES39 = [];
|
|
2254
2297
|
function isUnsafeComponentWillMount(node) {
|
|
2255
2298
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2256
2299
|
}
|
|
@@ -2259,18 +2302,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2259
2302
|
type: "problem",
|
|
2260
2303
|
docs: {
|
|
2261
2304
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2262
|
-
[Symbol.for("rule_features")]:
|
|
2305
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2263
2306
|
},
|
|
2264
2307
|
messages: {
|
|
2265
2308
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2266
2309
|
},
|
|
2267
2310
|
schema: []
|
|
2268
2311
|
},
|
|
2269
|
-
name:
|
|
2270
|
-
create:
|
|
2312
|
+
name: RULE_NAME39,
|
|
2313
|
+
create: create39,
|
|
2271
2314
|
defaultOptions: []
|
|
2272
2315
|
});
|
|
2273
|
-
function
|
|
2316
|
+
function create39(context) {
|
|
2274
2317
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2275
2318
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2276
2319
|
return {
|
|
@@ -2291,8 +2334,8 @@ function create38(context) {
|
|
|
2291
2334
|
}
|
|
2292
2335
|
};
|
|
2293
2336
|
}
|
|
2294
|
-
var
|
|
2295
|
-
var
|
|
2337
|
+
var RULE_NAME40 = "no-unsafe-component-will-receive-props";
|
|
2338
|
+
var RULE_FEATURES40 = [];
|
|
2296
2339
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2297
2340
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2298
2341
|
}
|
|
@@ -2301,18 +2344,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2301
2344
|
type: "problem",
|
|
2302
2345
|
docs: {
|
|
2303
2346
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2304
|
-
[Symbol.for("rule_features")]:
|
|
2347
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2305
2348
|
},
|
|
2306
2349
|
messages: {
|
|
2307
2350
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2308
2351
|
},
|
|
2309
2352
|
schema: []
|
|
2310
2353
|
},
|
|
2311
|
-
name:
|
|
2312
|
-
create:
|
|
2354
|
+
name: RULE_NAME40,
|
|
2355
|
+
create: create40,
|
|
2313
2356
|
defaultOptions: []
|
|
2314
2357
|
});
|
|
2315
|
-
function
|
|
2358
|
+
function create40(context) {
|
|
2316
2359
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2317
2360
|
return {};
|
|
2318
2361
|
}
|
|
@@ -2335,8 +2378,8 @@ function create39(context) {
|
|
|
2335
2378
|
}
|
|
2336
2379
|
};
|
|
2337
2380
|
}
|
|
2338
|
-
var
|
|
2339
|
-
var
|
|
2381
|
+
var RULE_NAME41 = "no-unsafe-component-will-update";
|
|
2382
|
+
var RULE_FEATURES41 = [];
|
|
2340
2383
|
function isUnsafeComponentWillUpdate(node) {
|
|
2341
2384
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2342
2385
|
}
|
|
@@ -2345,18 +2388,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2345
2388
|
type: "problem",
|
|
2346
2389
|
docs: {
|
|
2347
2390
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2348
|
-
[Symbol.for("rule_features")]:
|
|
2391
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2349
2392
|
},
|
|
2350
2393
|
messages: {
|
|
2351
2394
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2352
2395
|
},
|
|
2353
2396
|
schema: []
|
|
2354
2397
|
},
|
|
2355
|
-
name:
|
|
2356
|
-
create:
|
|
2398
|
+
name: RULE_NAME41,
|
|
2399
|
+
create: create41,
|
|
2357
2400
|
defaultOptions: []
|
|
2358
2401
|
});
|
|
2359
|
-
function
|
|
2402
|
+
function create41(context) {
|
|
2360
2403
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2361
2404
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2362
2405
|
return {
|
|
@@ -2377,25 +2420,25 @@ function create40(context) {
|
|
|
2377
2420
|
}
|
|
2378
2421
|
};
|
|
2379
2422
|
}
|
|
2380
|
-
var
|
|
2381
|
-
var
|
|
2423
|
+
var RULE_NAME42 = "no-unstable-context-value";
|
|
2424
|
+
var RULE_FEATURES42 = [];
|
|
2382
2425
|
var no_unstable_context_value_default = createRule({
|
|
2383
2426
|
meta: {
|
|
2384
2427
|
type: "problem",
|
|
2385
2428
|
docs: {
|
|
2386
2429
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2387
|
-
[Symbol.for("rule_features")]:
|
|
2430
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2388
2431
|
},
|
|
2389
2432
|
messages: {
|
|
2390
2433
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2391
2434
|
},
|
|
2392
2435
|
schema: []
|
|
2393
2436
|
},
|
|
2394
|
-
name:
|
|
2395
|
-
create:
|
|
2437
|
+
name: RULE_NAME42,
|
|
2438
|
+
create: create42,
|
|
2396
2439
|
defaultOptions: []
|
|
2397
2440
|
});
|
|
2398
|
-
function
|
|
2441
|
+
function create42(context) {
|
|
2399
2442
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2400
2443
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2401
2444
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2417,7 +2460,7 @@ function create41(context) {
|
|
|
2417
2460
|
if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2418
2461
|
const valueExpression = value.expression;
|
|
2419
2462
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2420
|
-
const construction =
|
|
2463
|
+
const construction = VAR2.getValueConstruction(valueExpression, initialScope);
|
|
2421
2464
|
if (construction == null) return;
|
|
2422
2465
|
if (isReactHookCall(construction.node)) {
|
|
2423
2466
|
return;
|
|
@@ -2450,25 +2493,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2450
2493
|
}
|
|
2451
2494
|
return false;
|
|
2452
2495
|
}
|
|
2453
|
-
var
|
|
2454
|
-
var
|
|
2496
|
+
var RULE_NAME43 = "no-unstable-default-props";
|
|
2497
|
+
var RULE_FEATURES43 = [];
|
|
2455
2498
|
var no_unstable_default_props_default = createRule({
|
|
2456
2499
|
meta: {
|
|
2457
2500
|
type: "problem",
|
|
2458
2501
|
docs: {
|
|
2459
2502
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2460
|
-
[Symbol.for("rule_features")]:
|
|
2503
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2461
2504
|
},
|
|
2462
2505
|
messages: {
|
|
2463
2506
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2464
2507
|
},
|
|
2465
2508
|
schema: []
|
|
2466
2509
|
},
|
|
2467
|
-
name:
|
|
2468
|
-
create:
|
|
2510
|
+
name: RULE_NAME43,
|
|
2511
|
+
create: create43,
|
|
2469
2512
|
defaultOptions: []
|
|
2470
2513
|
});
|
|
2471
|
-
function
|
|
2514
|
+
function create43(context) {
|
|
2472
2515
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2473
2516
|
const declarators = /* @__PURE__ */ new Map();
|
|
2474
2517
|
return {
|
|
@@ -2491,10 +2534,10 @@ function create42(context) {
|
|
|
2491
2534
|
const { value } = prop;
|
|
2492
2535
|
const { right } = value;
|
|
2493
2536
|
const initialScope = context.sourceCode.getScope(value);
|
|
2494
|
-
const construction =
|
|
2537
|
+
const construction = VAR2.getValueConstruction(
|
|
2495
2538
|
value,
|
|
2496
2539
|
initialScope,
|
|
2497
|
-
|
|
2540
|
+
VAR2.ValueConstructionHint.StrictCallExpression
|
|
2498
2541
|
);
|
|
2499
2542
|
if (construction == null) {
|
|
2500
2543
|
continue;
|
|
@@ -2524,8 +2567,8 @@ function create42(context) {
|
|
|
2524
2567
|
}
|
|
2525
2568
|
};
|
|
2526
2569
|
}
|
|
2527
|
-
var
|
|
2528
|
-
var
|
|
2570
|
+
var RULE_NAME44 = "no-unused-class-component-members";
|
|
2571
|
+
var RULE_FEATURES44 = [];
|
|
2529
2572
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2530
2573
|
"componentDidCatch",
|
|
2531
2574
|
"componentDidMount",
|
|
@@ -2551,18 +2594,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2551
2594
|
type: "problem",
|
|
2552
2595
|
docs: {
|
|
2553
2596
|
description: "Warns unused class component methods and properties.",
|
|
2554
|
-
[Symbol.for("rule_features")]:
|
|
2597
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2555
2598
|
},
|
|
2556
2599
|
messages: {
|
|
2557
2600
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2558
2601
|
},
|
|
2559
2602
|
schema: []
|
|
2560
2603
|
},
|
|
2561
|
-
name:
|
|
2562
|
-
create:
|
|
2604
|
+
name: RULE_NAME44,
|
|
2605
|
+
create: create44,
|
|
2563
2606
|
defaultOptions: []
|
|
2564
2607
|
});
|
|
2565
|
-
function
|
|
2608
|
+
function create44(context) {
|
|
2566
2609
|
const classEntries = [];
|
|
2567
2610
|
const methodEntries = [];
|
|
2568
2611
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2672,8 +2715,8 @@ function create43(context) {
|
|
|
2672
2715
|
}
|
|
2673
2716
|
};
|
|
2674
2717
|
}
|
|
2675
|
-
var
|
|
2676
|
-
var
|
|
2718
|
+
var RULE_NAME45 = "no-unused-state";
|
|
2719
|
+
var RULE_FEATURES45 = [];
|
|
2677
2720
|
function isKeyLiteral3(node, key) {
|
|
2678
2721
|
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);
|
|
2679
2722
|
}
|
|
@@ -2682,18 +2725,18 @@ var no_unused_state_default = createRule({
|
|
|
2682
2725
|
type: "problem",
|
|
2683
2726
|
docs: {
|
|
2684
2727
|
description: "Warns unused class component state.",
|
|
2685
|
-
[Symbol.for("rule_features")]:
|
|
2728
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2686
2729
|
},
|
|
2687
2730
|
messages: {
|
|
2688
2731
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2689
2732
|
},
|
|
2690
2733
|
schema: []
|
|
2691
2734
|
},
|
|
2692
|
-
name:
|
|
2693
|
-
create:
|
|
2735
|
+
name: RULE_NAME45,
|
|
2736
|
+
create: create45,
|
|
2694
2737
|
defaultOptions: []
|
|
2695
2738
|
});
|
|
2696
|
-
function
|
|
2739
|
+
function create45(context) {
|
|
2697
2740
|
const classEntries = [];
|
|
2698
2741
|
const methodEntries = [];
|
|
2699
2742
|
const constructorEntries = [];
|
|
@@ -2827,8 +2870,8 @@ function create44(context) {
|
|
|
2827
2870
|
}
|
|
2828
2871
|
};
|
|
2829
2872
|
}
|
|
2830
|
-
var
|
|
2831
|
-
var
|
|
2873
|
+
var RULE_NAME46 = "no-use-context";
|
|
2874
|
+
var RULE_FEATURES46 = [
|
|
2832
2875
|
"MOD"
|
|
2833
2876
|
];
|
|
2834
2877
|
var no_use_context_default = createRule({
|
|
@@ -2836,7 +2879,7 @@ var no_use_context_default = createRule({
|
|
|
2836
2879
|
type: "problem",
|
|
2837
2880
|
docs: {
|
|
2838
2881
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2839
|
-
[Symbol.for("rule_features")]:
|
|
2882
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2840
2883
|
},
|
|
2841
2884
|
fixable: "code",
|
|
2842
2885
|
messages: {
|
|
@@ -2844,11 +2887,11 @@ var no_use_context_default = createRule({
|
|
|
2844
2887
|
},
|
|
2845
2888
|
schema: []
|
|
2846
2889
|
},
|
|
2847
|
-
name:
|
|
2848
|
-
create:
|
|
2890
|
+
name: RULE_NAME46,
|
|
2891
|
+
create: create46,
|
|
2849
2892
|
defaultOptions: []
|
|
2850
2893
|
});
|
|
2851
|
-
function
|
|
2894
|
+
function create46(context) {
|
|
2852
2895
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2853
2896
|
const settings4 = getSettingsFromContext(context);
|
|
2854
2897
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2926,25 +2969,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2926
2969
|
return tokens;
|
|
2927
2970
|
}
|
|
2928
2971
|
}
|
|
2929
|
-
var
|
|
2930
|
-
var
|
|
2972
|
+
var RULE_NAME47 = "no-useless-forward-ref";
|
|
2973
|
+
var RULE_FEATURES47 = [];
|
|
2931
2974
|
var no_useless_forward_ref_default = createRule({
|
|
2932
2975
|
meta: {
|
|
2933
2976
|
type: "problem",
|
|
2934
2977
|
docs: {
|
|
2935
2978
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2936
|
-
[Symbol.for("rule_features")]:
|
|
2979
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2937
2980
|
},
|
|
2938
2981
|
messages: {
|
|
2939
2982
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2940
2983
|
},
|
|
2941
2984
|
schema: []
|
|
2942
2985
|
},
|
|
2943
|
-
name:
|
|
2944
|
-
create:
|
|
2986
|
+
name: RULE_NAME47,
|
|
2987
|
+
create: create47,
|
|
2945
2988
|
defaultOptions: []
|
|
2946
2989
|
});
|
|
2947
|
-
function
|
|
2990
|
+
function create47(context) {
|
|
2948
2991
|
return {
|
|
2949
2992
|
CallExpression(node) {
|
|
2950
2993
|
if (!isForwardRefCall(context, node)) {
|
|
@@ -2965,7 +3008,7 @@ function create46(context) {
|
|
|
2965
3008
|
}
|
|
2966
3009
|
};
|
|
2967
3010
|
}
|
|
2968
|
-
var
|
|
3011
|
+
var RULE_NAME48 = "no-useless-fragment";
|
|
2969
3012
|
var defaultOptions = [{
|
|
2970
3013
|
allowExpressions: true
|
|
2971
3014
|
}];
|
|
@@ -2991,11 +3034,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2991
3034
|
}
|
|
2992
3035
|
}]
|
|
2993
3036
|
},
|
|
2994
|
-
name:
|
|
2995
|
-
create:
|
|
3037
|
+
name: RULE_NAME48,
|
|
3038
|
+
create: create48,
|
|
2996
3039
|
defaultOptions
|
|
2997
3040
|
});
|
|
2998
|
-
function
|
|
3041
|
+
function create48(context, [option]) {
|
|
2999
3042
|
const { allowExpressions = true } = option;
|
|
3000
3043
|
return {
|
|
3001
3044
|
JSXElement(node) {
|
|
@@ -3107,8 +3150,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3107
3150
|
}
|
|
3108
3151
|
return;
|
|
3109
3152
|
}
|
|
3110
|
-
var
|
|
3111
|
-
var
|
|
3153
|
+
var RULE_NAME49 = "prefer-destructuring-assignment";
|
|
3154
|
+
var RULE_FEATURES48 = [];
|
|
3112
3155
|
function isMemberExpressionWithObjectName(node) {
|
|
3113
3156
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3114
3157
|
}
|
|
@@ -3117,18 +3160,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3117
3160
|
type: "problem",
|
|
3118
3161
|
docs: {
|
|
3119
3162
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3120
|
-
[Symbol.for("rule_features")]:
|
|
3163
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3121
3164
|
},
|
|
3122
3165
|
messages: {
|
|
3123
3166
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3124
3167
|
},
|
|
3125
3168
|
schema: []
|
|
3126
3169
|
},
|
|
3127
|
-
name:
|
|
3128
|
-
create:
|
|
3170
|
+
name: RULE_NAME49,
|
|
3171
|
+
create: create49,
|
|
3129
3172
|
defaultOptions: []
|
|
3130
3173
|
});
|
|
3131
|
-
function
|
|
3174
|
+
function create49(context) {
|
|
3132
3175
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3133
3176
|
const memberExpressionWithNames = [];
|
|
3134
3177
|
return {
|
|
@@ -3188,8 +3231,8 @@ function create48(context) {
|
|
|
3188
3231
|
}
|
|
3189
3232
|
};
|
|
3190
3233
|
}
|
|
3191
|
-
var
|
|
3192
|
-
var
|
|
3234
|
+
var RULE_NAME50 = "prefer-react-namespace-import";
|
|
3235
|
+
var RULE_FEATURES49 = [
|
|
3193
3236
|
"FIX",
|
|
3194
3237
|
"EXP"
|
|
3195
3238
|
];
|
|
@@ -3198,7 +3241,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3198
3241
|
type: "problem",
|
|
3199
3242
|
docs: {
|
|
3200
3243
|
description: "Enforces React is imported via a namespace import.",
|
|
3201
|
-
[Symbol.for("rule_features")]:
|
|
3244
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3202
3245
|
},
|
|
3203
3246
|
fixable: "code",
|
|
3204
3247
|
messages: {
|
|
@@ -3206,11 +3249,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3206
3249
|
},
|
|
3207
3250
|
schema: []
|
|
3208
3251
|
},
|
|
3209
|
-
name:
|
|
3210
|
-
create:
|
|
3252
|
+
name: RULE_NAME50,
|
|
3253
|
+
create: create50,
|
|
3211
3254
|
defaultOptions: []
|
|
3212
3255
|
});
|
|
3213
|
-
function
|
|
3256
|
+
function create50(context) {
|
|
3214
3257
|
const { importSource } = getSettingsFromContext(context);
|
|
3215
3258
|
return {
|
|
3216
3259
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3243,8 +3286,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3243
3286
|
}
|
|
3244
3287
|
};
|
|
3245
3288
|
}
|
|
3246
|
-
var
|
|
3247
|
-
var
|
|
3289
|
+
var RULE_NAME51 = "prefer-read-only-props";
|
|
3290
|
+
var RULE_FEATURES50 = [
|
|
3248
3291
|
"TSC",
|
|
3249
3292
|
"EXP"
|
|
3250
3293
|
];
|
|
@@ -3253,18 +3296,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3253
3296
|
type: "problem",
|
|
3254
3297
|
docs: {
|
|
3255
3298
|
description: "Enforces read-only props in components.",
|
|
3256
|
-
[Symbol.for("rule_features")]:
|
|
3299
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3257
3300
|
},
|
|
3258
3301
|
messages: {
|
|
3259
3302
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3260
3303
|
},
|
|
3261
3304
|
schema: []
|
|
3262
3305
|
},
|
|
3263
|
-
name:
|
|
3264
|
-
create:
|
|
3306
|
+
name: RULE_NAME51,
|
|
3307
|
+
create: create51,
|
|
3265
3308
|
defaultOptions: []
|
|
3266
3309
|
});
|
|
3267
|
-
function
|
|
3310
|
+
function create51(context) {
|
|
3268
3311
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3269
3312
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3270
3313
|
return {
|
|
@@ -3294,8 +3337,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3294
3337
|
return true;
|
|
3295
3338
|
}
|
|
3296
3339
|
}
|
|
3297
|
-
var
|
|
3298
|
-
var
|
|
3340
|
+
var RULE_NAME52 = "prefer-shorthand-boolean";
|
|
3341
|
+
var RULE_FEATURES51 = [
|
|
3299
3342
|
"FIX"
|
|
3300
3343
|
];
|
|
3301
3344
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3303,7 +3346,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3303
3346
|
type: "problem",
|
|
3304
3347
|
docs: {
|
|
3305
3348
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3306
|
-
[Symbol.for("rule_features")]:
|
|
3349
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3307
3350
|
},
|
|
3308
3351
|
fixable: "code",
|
|
3309
3352
|
messages: {
|
|
@@ -3311,11 +3354,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3311
3354
|
},
|
|
3312
3355
|
schema: []
|
|
3313
3356
|
},
|
|
3314
|
-
name:
|
|
3315
|
-
create:
|
|
3357
|
+
name: RULE_NAME52,
|
|
3358
|
+
create: create52,
|
|
3316
3359
|
defaultOptions: []
|
|
3317
3360
|
});
|
|
3318
|
-
function
|
|
3361
|
+
function create52(context) {
|
|
3319
3362
|
return {
|
|
3320
3363
|
JSXAttribute(node) {
|
|
3321
3364
|
const { value } = node;
|
|
@@ -3335,8 +3378,8 @@ function create51(context) {
|
|
|
3335
3378
|
}
|
|
3336
3379
|
};
|
|
3337
3380
|
}
|
|
3338
|
-
var
|
|
3339
|
-
var
|
|
3381
|
+
var RULE_NAME53 = "prefer-shorthand-fragment";
|
|
3382
|
+
var RULE_FEATURES52 = [
|
|
3340
3383
|
"FIX"
|
|
3341
3384
|
];
|
|
3342
3385
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3344,7 +3387,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3344
3387
|
type: "problem",
|
|
3345
3388
|
docs: {
|
|
3346
3389
|
description: "Enforces shorthand syntax for fragments.",
|
|
3347
|
-
[Symbol.for("rule_features")]:
|
|
3390
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3348
3391
|
},
|
|
3349
3392
|
fixable: "code",
|
|
3350
3393
|
messages: {
|
|
@@ -3352,11 +3395,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3352
3395
|
},
|
|
3353
3396
|
schema: []
|
|
3354
3397
|
},
|
|
3355
|
-
name:
|
|
3356
|
-
create:
|
|
3398
|
+
name: RULE_NAME53,
|
|
3399
|
+
create: create53,
|
|
3357
3400
|
defaultOptions: []
|
|
3358
3401
|
});
|
|
3359
|
-
function
|
|
3402
|
+
function create53(context) {
|
|
3360
3403
|
return {
|
|
3361
3404
|
JSXElement(node) {
|
|
3362
3405
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3441,6 +3484,7 @@ var plugin = {
|
|
|
3441
3484
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3442
3485
|
// Part: JSX only rules
|
|
3443
3486
|
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3487
|
+
"jsx-no-undef": jsx_no_undef_default,
|
|
3444
3488
|
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3445
3489
|
// Part: deprecated rules
|
|
3446
3490
|
/** @deprecated Use `no-useless-forward-ref` instead */
|