eslint-plugin-react-x 1.38.0-beta.5 → 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 +28 -26
- package/dist/index.d.ts +28 -26
- package/dist/index.js +453 -404
- package/dist/index.mjs +452 -403
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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';
|
|
5
|
+
import * as VAR2 from '@eslint-react/var';
|
|
4
6
|
import * as AST11 from '@eslint-react/ast';
|
|
5
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';
|
|
6
8
|
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
7
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
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/no-duplicate-jsx-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/use-jsx-vars": "warn"
|
|
70
|
+
"react-x/no-useless-forward-ref": "warn"
|
|
70
71
|
};
|
|
71
72
|
var settings = {
|
|
72
73
|
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
@@ -90,8 +91,9 @@ __export(recommended_typescript_exports, {
|
|
|
90
91
|
var name2 = "react-x/recommended-typescript";
|
|
91
92
|
var rules2 = {
|
|
92
93
|
...rules,
|
|
93
|
-
"react-x/no-duplicate-
|
|
94
|
-
"react-x/
|
|
94
|
+
"react-x/jsx-no-duplicate-props": "off",
|
|
95
|
+
"react-x/jsx-no-undef": "off",
|
|
96
|
+
"react-x/jsx-uses-vars": "off"
|
|
95
97
|
};
|
|
96
98
|
var settings2 = {
|
|
97
99
|
...settings
|
|
@@ -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
|
|
@@ -179,8 +181,131 @@ function create2(context) {
|
|
|
179
181
|
}
|
|
180
182
|
};
|
|
181
183
|
}
|
|
182
|
-
var RULE_NAME3 = "no-
|
|
184
|
+
var RULE_NAME3 = "jsx-no-duplicate-props";
|
|
183
185
|
var RULE_FEATURES3 = [];
|
|
186
|
+
var jsx_no_duplicate_props_default = createRule({
|
|
187
|
+
meta: {
|
|
188
|
+
type: "problem",
|
|
189
|
+
docs: {
|
|
190
|
+
description: "Disallow duplicate props in JSX elements.",
|
|
191
|
+
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
192
|
+
},
|
|
193
|
+
messages: {
|
|
194
|
+
jsxNoDuplicateProps: "This JSX property is assigned multiple times."
|
|
195
|
+
},
|
|
196
|
+
schema: []
|
|
197
|
+
},
|
|
198
|
+
name: RULE_NAME3,
|
|
199
|
+
create: create3,
|
|
200
|
+
defaultOptions: []
|
|
201
|
+
});
|
|
202
|
+
function create3(context) {
|
|
203
|
+
return {
|
|
204
|
+
JSXOpeningElement(node) {
|
|
205
|
+
const props = [];
|
|
206
|
+
for (const attr of node.attributes) {
|
|
207
|
+
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const name5 = attr.name.name;
|
|
211
|
+
if (typeof name5 !== "string") {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (!props.includes(name5)) {
|
|
215
|
+
props.push(name5);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
context.report({
|
|
219
|
+
messageId: "jsxNoDuplicateProps",
|
|
220
|
+
node: attr
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
var RULE_NAME4 = "jsx-no-undef";
|
|
227
|
+
var RULE_FEATURES4 = [];
|
|
228
|
+
var jsx_no_undef_default = createRule({
|
|
229
|
+
meta: {
|
|
230
|
+
type: "problem",
|
|
231
|
+
docs: {
|
|
232
|
+
description: "Disallow undefined variables in JSX.",
|
|
233
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
234
|
+
},
|
|
235
|
+
messages: {
|
|
236
|
+
jsxNoUndef: "JSX variable {{name}} is not defined."
|
|
237
|
+
},
|
|
238
|
+
schema: []
|
|
239
|
+
},
|
|
240
|
+
name: RULE_NAME4,
|
|
241
|
+
create: create4,
|
|
242
|
+
defaultOptions: []
|
|
243
|
+
});
|
|
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) {
|
|
286
|
+
return {
|
|
287
|
+
JSXOpeningElement(node) {
|
|
288
|
+
switch (node.name.type) {
|
|
289
|
+
case AST_NODE_TYPES.JSXIdentifier: {
|
|
290
|
+
if (/^[a-z]/u.test(node.name.name)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case AST_NODE_TYPES.JSXMemberExpression: {
|
|
297
|
+
const { object } = node.name;
|
|
298
|
+
if (object.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
299
|
+
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
var RULE_NAME6 = "no-access-state-in-setstate";
|
|
308
|
+
var RULE_FEATURES6 = [];
|
|
184
309
|
function isKeyLiteral(node, key) {
|
|
185
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);
|
|
186
311
|
}
|
|
@@ -189,18 +314,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
189
314
|
type: "problem",
|
|
190
315
|
docs: {
|
|
191
316
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
192
|
-
[Symbol.for("rule_features")]:
|
|
317
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
193
318
|
},
|
|
194
319
|
messages: {
|
|
195
320
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
196
321
|
},
|
|
197
322
|
schema: []
|
|
198
323
|
},
|
|
199
|
-
name:
|
|
200
|
-
create:
|
|
324
|
+
name: RULE_NAME6,
|
|
325
|
+
create: create6,
|
|
201
326
|
defaultOptions: []
|
|
202
327
|
});
|
|
203
|
-
function
|
|
328
|
+
function create6(context) {
|
|
204
329
|
if (!context.sourceCode.text.includes("setState")) {
|
|
205
330
|
return {};
|
|
206
331
|
}
|
|
@@ -291,8 +416,8 @@ function create3(context) {
|
|
|
291
416
|
}
|
|
292
417
|
};
|
|
293
418
|
}
|
|
294
|
-
var
|
|
295
|
-
var
|
|
419
|
+
var RULE_NAME7 = "no-array-index-key";
|
|
420
|
+
var RULE_FEATURES7 = [];
|
|
296
421
|
var reactChildrenMethod = ["forEach", "map"];
|
|
297
422
|
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
298
423
|
["every", 1],
|
|
@@ -376,18 +501,18 @@ var no_array_index_key_default = createRule({
|
|
|
376
501
|
type: "problem",
|
|
377
502
|
docs: {
|
|
378
503
|
description: "Disallow an item's index in the array as its key.",
|
|
379
|
-
[Symbol.for("rule_features")]:
|
|
504
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
380
505
|
},
|
|
381
506
|
messages: {
|
|
382
507
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
383
508
|
},
|
|
384
509
|
schema: []
|
|
385
510
|
},
|
|
386
|
-
name:
|
|
387
|
-
create:
|
|
511
|
+
name: RULE_NAME7,
|
|
512
|
+
create: create7,
|
|
388
513
|
defaultOptions: []
|
|
389
514
|
});
|
|
390
|
-
function
|
|
515
|
+
function create7(context) {
|
|
391
516
|
const report = createReport(context);
|
|
392
517
|
const indexParamNames = [];
|
|
393
518
|
function isArrayIndex(node) {
|
|
@@ -485,25 +610,25 @@ function create4(context) {
|
|
|
485
610
|
}
|
|
486
611
|
};
|
|
487
612
|
}
|
|
488
|
-
var
|
|
489
|
-
var
|
|
613
|
+
var RULE_NAME8 = "no-children-count";
|
|
614
|
+
var RULE_FEATURES8 = [];
|
|
490
615
|
var no_children_count_default = createRule({
|
|
491
616
|
meta: {
|
|
492
617
|
type: "problem",
|
|
493
618
|
docs: {
|
|
494
619
|
description: "Disallow `Children.count`.",
|
|
495
|
-
[Symbol.for("rule_features")]:
|
|
620
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
496
621
|
},
|
|
497
622
|
messages: {
|
|
498
623
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
499
624
|
},
|
|
500
625
|
schema: []
|
|
501
626
|
},
|
|
502
|
-
name:
|
|
503
|
-
create:
|
|
627
|
+
name: RULE_NAME8,
|
|
628
|
+
create: create8,
|
|
504
629
|
defaultOptions: []
|
|
505
630
|
});
|
|
506
|
-
function
|
|
631
|
+
function create8(context) {
|
|
507
632
|
return {
|
|
508
633
|
MemberExpression(node) {
|
|
509
634
|
if (isChildrenCount(context, node)) {
|
|
@@ -515,25 +640,25 @@ function create5(context) {
|
|
|
515
640
|
}
|
|
516
641
|
};
|
|
517
642
|
}
|
|
518
|
-
var
|
|
519
|
-
var
|
|
643
|
+
var RULE_NAME9 = "no-children-for-each";
|
|
644
|
+
var RULE_FEATURES9 = [];
|
|
520
645
|
var no_children_for_each_default = createRule({
|
|
521
646
|
meta: {
|
|
522
647
|
type: "problem",
|
|
523
648
|
docs: {
|
|
524
649
|
description: "Disallow 'Children.forEach'.",
|
|
525
|
-
[Symbol.for("rule_features")]:
|
|
650
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
526
651
|
},
|
|
527
652
|
messages: {
|
|
528
653
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
529
654
|
},
|
|
530
655
|
schema: []
|
|
531
656
|
},
|
|
532
|
-
name:
|
|
533
|
-
create:
|
|
657
|
+
name: RULE_NAME9,
|
|
658
|
+
create: create9,
|
|
534
659
|
defaultOptions: []
|
|
535
660
|
});
|
|
536
|
-
function
|
|
661
|
+
function create9(context) {
|
|
537
662
|
return {
|
|
538
663
|
MemberExpression(node) {
|
|
539
664
|
if (isChildrenForEach(context, node)) {
|
|
@@ -545,25 +670,25 @@ function create6(context) {
|
|
|
545
670
|
}
|
|
546
671
|
};
|
|
547
672
|
}
|
|
548
|
-
var
|
|
549
|
-
var
|
|
673
|
+
var RULE_NAME10 = "no-children-map";
|
|
674
|
+
var RULE_FEATURES10 = [];
|
|
550
675
|
var no_children_map_default = createRule({
|
|
551
676
|
meta: {
|
|
552
677
|
type: "problem",
|
|
553
678
|
docs: {
|
|
554
679
|
description: "Disallow `Children.map`.",
|
|
555
|
-
[Symbol.for("rule_features")]:
|
|
680
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
556
681
|
},
|
|
557
682
|
messages: {
|
|
558
683
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
559
684
|
},
|
|
560
685
|
schema: []
|
|
561
686
|
},
|
|
562
|
-
name:
|
|
563
|
-
create:
|
|
687
|
+
name: RULE_NAME10,
|
|
688
|
+
create: create10,
|
|
564
689
|
defaultOptions: []
|
|
565
690
|
});
|
|
566
|
-
function
|
|
691
|
+
function create10(context) {
|
|
567
692
|
return {
|
|
568
693
|
MemberExpression(node) {
|
|
569
694
|
if (isChildrenMap(context, node)) {
|
|
@@ -575,25 +700,25 @@ function create7(context) {
|
|
|
575
700
|
}
|
|
576
701
|
};
|
|
577
702
|
}
|
|
578
|
-
var
|
|
579
|
-
var
|
|
703
|
+
var RULE_NAME11 = "no-children-only";
|
|
704
|
+
var RULE_FEATURES11 = [];
|
|
580
705
|
var no_children_only_default = createRule({
|
|
581
706
|
meta: {
|
|
582
707
|
type: "problem",
|
|
583
708
|
docs: {
|
|
584
709
|
description: "Disallow `Children.only`.",
|
|
585
|
-
[Symbol.for("rule_features")]:
|
|
710
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
586
711
|
},
|
|
587
712
|
messages: {
|
|
588
713
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
589
714
|
},
|
|
590
715
|
schema: []
|
|
591
716
|
},
|
|
592
|
-
name:
|
|
593
|
-
create:
|
|
717
|
+
name: RULE_NAME11,
|
|
718
|
+
create: create11,
|
|
594
719
|
defaultOptions: []
|
|
595
720
|
});
|
|
596
|
-
function
|
|
721
|
+
function create11(context) {
|
|
597
722
|
return {
|
|
598
723
|
MemberExpression(node) {
|
|
599
724
|
if (isChildrenOnly(context, node)) {
|
|
@@ -605,25 +730,25 @@ function create8(context) {
|
|
|
605
730
|
}
|
|
606
731
|
};
|
|
607
732
|
}
|
|
608
|
-
var
|
|
609
|
-
var
|
|
733
|
+
var RULE_NAME12 = "no-children-prop";
|
|
734
|
+
var RULE_FEATURES12 = [];
|
|
610
735
|
var no_children_prop_default = createRule({
|
|
611
736
|
meta: {
|
|
612
737
|
type: "problem",
|
|
613
738
|
docs: {
|
|
614
739
|
description: "Disallow passing `children` as a prop.",
|
|
615
|
-
[Symbol.for("rule_features")]:
|
|
740
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
616
741
|
},
|
|
617
742
|
messages: {
|
|
618
743
|
noChildrenProp: "Do not pass 'children' as props."
|
|
619
744
|
},
|
|
620
745
|
schema: []
|
|
621
746
|
},
|
|
622
|
-
name:
|
|
623
|
-
create:
|
|
747
|
+
name: RULE_NAME12,
|
|
748
|
+
create: create12,
|
|
624
749
|
defaultOptions: []
|
|
625
750
|
});
|
|
626
|
-
function
|
|
751
|
+
function create12(context) {
|
|
627
752
|
return {
|
|
628
753
|
JSXElement(node) {
|
|
629
754
|
const attribute = JSX8.getAttribute(
|
|
@@ -640,25 +765,25 @@ function create9(context) {
|
|
|
640
765
|
}
|
|
641
766
|
};
|
|
642
767
|
}
|
|
643
|
-
var
|
|
644
|
-
var
|
|
768
|
+
var RULE_NAME13 = "no-children-to-array";
|
|
769
|
+
var RULE_FEATURES13 = [];
|
|
645
770
|
var no_children_to_array_default = createRule({
|
|
646
771
|
meta: {
|
|
647
772
|
type: "problem",
|
|
648
773
|
docs: {
|
|
649
774
|
description: "Disallow `Children.toArray`.",
|
|
650
|
-
[Symbol.for("rule_features")]:
|
|
775
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
651
776
|
},
|
|
652
777
|
messages: {
|
|
653
778
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
654
779
|
},
|
|
655
780
|
schema: []
|
|
656
781
|
},
|
|
657
|
-
name:
|
|
658
|
-
create:
|
|
782
|
+
name: RULE_NAME13,
|
|
783
|
+
create: create13,
|
|
659
784
|
defaultOptions: []
|
|
660
785
|
});
|
|
661
|
-
function
|
|
786
|
+
function create13(context) {
|
|
662
787
|
return {
|
|
663
788
|
MemberExpression(node) {
|
|
664
789
|
if (isChildrenToArray(context, node)) {
|
|
@@ -670,25 +795,25 @@ function create10(context) {
|
|
|
670
795
|
}
|
|
671
796
|
};
|
|
672
797
|
}
|
|
673
|
-
var
|
|
674
|
-
var
|
|
798
|
+
var RULE_NAME14 = "no-class-component";
|
|
799
|
+
var RULE_FEATURES14 = [];
|
|
675
800
|
var no_class_component_default = createRule({
|
|
676
801
|
meta: {
|
|
677
802
|
type: "problem",
|
|
678
803
|
docs: {
|
|
679
804
|
description: "Disallow class components.",
|
|
680
|
-
[Symbol.for("rule_features")]:
|
|
805
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
681
806
|
},
|
|
682
807
|
messages: {
|
|
683
808
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
684
809
|
},
|
|
685
810
|
schema: []
|
|
686
811
|
},
|
|
687
|
-
name:
|
|
688
|
-
create:
|
|
812
|
+
name: RULE_NAME14,
|
|
813
|
+
create: create14,
|
|
689
814
|
defaultOptions: []
|
|
690
815
|
});
|
|
691
|
-
function
|
|
816
|
+
function create14(context) {
|
|
692
817
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
693
818
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
694
819
|
return {
|
|
@@ -710,25 +835,25 @@ function create11(context) {
|
|
|
710
835
|
}
|
|
711
836
|
};
|
|
712
837
|
}
|
|
713
|
-
var
|
|
714
|
-
var
|
|
838
|
+
var RULE_NAME15 = "no-clone-element";
|
|
839
|
+
var RULE_FEATURES15 = [];
|
|
715
840
|
var no_clone_element_default = createRule({
|
|
716
841
|
meta: {
|
|
717
842
|
type: "problem",
|
|
718
843
|
docs: {
|
|
719
844
|
description: "Disallow `cloneElement`.",
|
|
720
|
-
[Symbol.for("rule_features")]:
|
|
845
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
721
846
|
},
|
|
722
847
|
messages: {
|
|
723
848
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
724
849
|
},
|
|
725
850
|
schema: []
|
|
726
851
|
},
|
|
727
|
-
name:
|
|
728
|
-
create:
|
|
852
|
+
name: RULE_NAME15,
|
|
853
|
+
create: create15,
|
|
729
854
|
defaultOptions: []
|
|
730
855
|
});
|
|
731
|
-
function
|
|
856
|
+
function create15(context) {
|
|
732
857
|
return {
|
|
733
858
|
CallExpression(node) {
|
|
734
859
|
if (!isCloneElementCall(context, node)) {
|
|
@@ -741,25 +866,25 @@ function create12(context) {
|
|
|
741
866
|
}
|
|
742
867
|
};
|
|
743
868
|
}
|
|
744
|
-
var
|
|
745
|
-
var
|
|
869
|
+
var RULE_NAME16 = "no-comment-textnodes";
|
|
870
|
+
var RULE_FEATURES16 = [];
|
|
746
871
|
var no_comment_textnodes_default = createRule({
|
|
747
872
|
meta: {
|
|
748
873
|
type: "problem",
|
|
749
874
|
docs: {
|
|
750
875
|
description: "Prevents comments from being inserted as text nodes.",
|
|
751
|
-
[Symbol.for("rule_features")]:
|
|
876
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
752
877
|
},
|
|
753
878
|
messages: {
|
|
754
879
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
755
880
|
},
|
|
756
881
|
schema: []
|
|
757
882
|
},
|
|
758
|
-
name:
|
|
759
|
-
create:
|
|
883
|
+
name: RULE_NAME16,
|
|
884
|
+
create: create16,
|
|
760
885
|
defaultOptions: []
|
|
761
886
|
});
|
|
762
|
-
function
|
|
887
|
+
function create16(context) {
|
|
763
888
|
function hasCommentLike(node) {
|
|
764
889
|
if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
765
890
|
return false;
|
|
@@ -787,8 +912,8 @@ function create13(context) {
|
|
|
787
912
|
Literal: visitorFunction
|
|
788
913
|
};
|
|
789
914
|
}
|
|
790
|
-
var
|
|
791
|
-
var
|
|
915
|
+
var RULE_NAME17 = "no-complex-conditional-rendering";
|
|
916
|
+
var RULE_FEATURES17 = [
|
|
792
917
|
"EXP"
|
|
793
918
|
];
|
|
794
919
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -796,18 +921,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
796
921
|
type: "problem",
|
|
797
922
|
docs: {
|
|
798
923
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
799
|
-
[Symbol.for("rule_features")]:
|
|
924
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
800
925
|
},
|
|
801
926
|
messages: {
|
|
802
927
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
803
928
|
},
|
|
804
929
|
schema: []
|
|
805
930
|
},
|
|
806
|
-
name:
|
|
807
|
-
create:
|
|
931
|
+
name: RULE_NAME17,
|
|
932
|
+
create: create17,
|
|
808
933
|
defaultOptions: []
|
|
809
934
|
});
|
|
810
|
-
function
|
|
935
|
+
function create17(context) {
|
|
811
936
|
const visitorFunction = (node) => {
|
|
812
937
|
const jsxExpContainer = node.parent?.parent;
|
|
813
938
|
if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -832,8 +957,8 @@ function create14(context) {
|
|
|
832
957
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
833
958
|
};
|
|
834
959
|
}
|
|
835
|
-
var
|
|
836
|
-
var
|
|
960
|
+
var RULE_NAME18 = "no-component-will-mount";
|
|
961
|
+
var RULE_FEATURES18 = [
|
|
837
962
|
"MOD"
|
|
838
963
|
];
|
|
839
964
|
function isComponentWillMount(node) {
|
|
@@ -844,7 +969,7 @@ var no_component_will_mount_default = createRule({
|
|
|
844
969
|
type: "problem",
|
|
845
970
|
docs: {
|
|
846
971
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
847
|
-
[Symbol.for("rule_features")]:
|
|
972
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
848
973
|
},
|
|
849
974
|
fixable: "code",
|
|
850
975
|
messages: {
|
|
@@ -852,11 +977,11 @@ var no_component_will_mount_default = createRule({
|
|
|
852
977
|
},
|
|
853
978
|
schema: []
|
|
854
979
|
},
|
|
855
|
-
name:
|
|
856
|
-
create:
|
|
980
|
+
name: RULE_NAME18,
|
|
981
|
+
create: create18,
|
|
857
982
|
defaultOptions: []
|
|
858
983
|
});
|
|
859
|
-
function
|
|
984
|
+
function create18(context) {
|
|
860
985
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
861
986
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
862
987
|
return {
|
|
@@ -883,8 +1008,8 @@ function create15(context) {
|
|
|
883
1008
|
}
|
|
884
1009
|
};
|
|
885
1010
|
}
|
|
886
|
-
var
|
|
887
|
-
var
|
|
1011
|
+
var RULE_NAME19 = "no-component-will-receive-props";
|
|
1012
|
+
var RULE_FEATURES19 = [
|
|
888
1013
|
"MOD"
|
|
889
1014
|
];
|
|
890
1015
|
function isComponentWillUpdate(node) {
|
|
@@ -895,7 +1020,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
895
1020
|
type: "problem",
|
|
896
1021
|
docs: {
|
|
897
1022
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
898
|
-
[Symbol.for("rule_features")]:
|
|
1023
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
899
1024
|
},
|
|
900
1025
|
fixable: "code",
|
|
901
1026
|
messages: {
|
|
@@ -903,11 +1028,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
903
1028
|
},
|
|
904
1029
|
schema: []
|
|
905
1030
|
},
|
|
906
|
-
name:
|
|
907
|
-
create:
|
|
1031
|
+
name: RULE_NAME19,
|
|
1032
|
+
create: create19,
|
|
908
1033
|
defaultOptions: []
|
|
909
1034
|
});
|
|
910
|
-
function
|
|
1035
|
+
function create19(context) {
|
|
911
1036
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
912
1037
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
913
1038
|
return {
|
|
@@ -934,8 +1059,8 @@ function create16(context) {
|
|
|
934
1059
|
}
|
|
935
1060
|
};
|
|
936
1061
|
}
|
|
937
|
-
var
|
|
938
|
-
var
|
|
1062
|
+
var RULE_NAME20 = "no-component-will-update";
|
|
1063
|
+
var RULE_FEATURES20 = [
|
|
939
1064
|
"MOD"
|
|
940
1065
|
];
|
|
941
1066
|
function isComponentWillUpdate2(node) {
|
|
@@ -946,7 +1071,7 @@ var no_component_will_update_default = createRule({
|
|
|
946
1071
|
type: "problem",
|
|
947
1072
|
docs: {
|
|
948
1073
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
949
|
-
[Symbol.for("rule_features")]:
|
|
1074
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
950
1075
|
},
|
|
951
1076
|
fixable: "code",
|
|
952
1077
|
messages: {
|
|
@@ -954,11 +1079,11 @@ var no_component_will_update_default = createRule({
|
|
|
954
1079
|
},
|
|
955
1080
|
schema: []
|
|
956
1081
|
},
|
|
957
|
-
name:
|
|
958
|
-
create:
|
|
1082
|
+
name: RULE_NAME20,
|
|
1083
|
+
create: create20,
|
|
959
1084
|
defaultOptions: []
|
|
960
1085
|
});
|
|
961
|
-
function
|
|
1086
|
+
function create20(context) {
|
|
962
1087
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
963
1088
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
964
1089
|
return {
|
|
@@ -985,8 +1110,8 @@ function create17(context) {
|
|
|
985
1110
|
}
|
|
986
1111
|
};
|
|
987
1112
|
}
|
|
988
|
-
var
|
|
989
|
-
var
|
|
1113
|
+
var RULE_NAME21 = "no-context-provider";
|
|
1114
|
+
var RULE_FEATURES21 = [
|
|
990
1115
|
"MOD"
|
|
991
1116
|
];
|
|
992
1117
|
var no_context_provider_default = createRule({
|
|
@@ -994,7 +1119,7 @@ var no_context_provider_default = createRule({
|
|
|
994
1119
|
type: "problem",
|
|
995
1120
|
docs: {
|
|
996
1121
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
997
|
-
[Symbol.for("rule_features")]:
|
|
1122
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
998
1123
|
},
|
|
999
1124
|
fixable: "code",
|
|
1000
1125
|
messages: {
|
|
@@ -1002,11 +1127,11 @@ var no_context_provider_default = createRule({
|
|
|
1002
1127
|
},
|
|
1003
1128
|
schema: []
|
|
1004
1129
|
},
|
|
1005
|
-
name:
|
|
1006
|
-
create:
|
|
1130
|
+
name: RULE_NAME21,
|
|
1131
|
+
create: create21,
|
|
1007
1132
|
defaultOptions: []
|
|
1008
1133
|
});
|
|
1009
|
-
function
|
|
1134
|
+
function create21(context) {
|
|
1010
1135
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1011
1136
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1012
1137
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1038,25 +1163,25 @@ function create18(context) {
|
|
|
1038
1163
|
}
|
|
1039
1164
|
};
|
|
1040
1165
|
}
|
|
1041
|
-
var
|
|
1042
|
-
var
|
|
1166
|
+
var RULE_NAME22 = "no-create-ref";
|
|
1167
|
+
var RULE_FEATURES22 = [];
|
|
1043
1168
|
var no_create_ref_default = createRule({
|
|
1044
1169
|
meta: {
|
|
1045
1170
|
type: "problem",
|
|
1046
1171
|
docs: {
|
|
1047
1172
|
description: "Disallow `createRef` in function components.",
|
|
1048
|
-
[Symbol.for("rule_features")]:
|
|
1173
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1049
1174
|
},
|
|
1050
1175
|
messages: {
|
|
1051
1176
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1052
1177
|
},
|
|
1053
1178
|
schema: []
|
|
1054
1179
|
},
|
|
1055
|
-
name:
|
|
1056
|
-
create:
|
|
1180
|
+
name: RULE_NAME22,
|
|
1181
|
+
create: create22,
|
|
1057
1182
|
defaultOptions: []
|
|
1058
1183
|
});
|
|
1059
|
-
function
|
|
1184
|
+
function create22(context) {
|
|
1060
1185
|
return {
|
|
1061
1186
|
CallExpression(node) {
|
|
1062
1187
|
if (isCreateRefCall(context, node) && AST11.findParentNode(node, isClassComponent) == null) {
|
|
@@ -1065,25 +1190,25 @@ function create19(context) {
|
|
|
1065
1190
|
}
|
|
1066
1191
|
};
|
|
1067
1192
|
}
|
|
1068
|
-
var
|
|
1069
|
-
var
|
|
1193
|
+
var RULE_NAME23 = "no-default-props";
|
|
1194
|
+
var RULE_FEATURES23 = [];
|
|
1070
1195
|
var no_default_props_default = createRule({
|
|
1071
1196
|
meta: {
|
|
1072
1197
|
type: "problem",
|
|
1073
1198
|
docs: {
|
|
1074
1199
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1075
|
-
[Symbol.for("rule_features")]:
|
|
1200
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1076
1201
|
},
|
|
1077
1202
|
messages: {
|
|
1078
1203
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1079
1204
|
},
|
|
1080
1205
|
schema: []
|
|
1081
1206
|
},
|
|
1082
|
-
name:
|
|
1083
|
-
create:
|
|
1207
|
+
name: RULE_NAME23,
|
|
1208
|
+
create: create23,
|
|
1084
1209
|
defaultOptions: []
|
|
1085
1210
|
});
|
|
1086
|
-
function
|
|
1211
|
+
function create23(context) {
|
|
1087
1212
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1088
1213
|
return {
|
|
1089
1214
|
AssignmentExpression(node) {
|
|
@@ -1100,8 +1225,8 @@ function create20(context) {
|
|
|
1100
1225
|
if (!isComponentNameLoose(object.name)) {
|
|
1101
1226
|
return;
|
|
1102
1227
|
}
|
|
1103
|
-
const variable =
|
|
1104
|
-
const variableNode =
|
|
1228
|
+
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1229
|
+
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
1105
1230
|
if (variableNode == null) return;
|
|
1106
1231
|
if (!AST11.isFunction(variableNode) && !isClassComponent(variableNode)) return;
|
|
1107
1232
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
@@ -1117,8 +1242,8 @@ function create20(context) {
|
|
|
1117
1242
|
}
|
|
1118
1243
|
};
|
|
1119
1244
|
}
|
|
1120
|
-
var
|
|
1121
|
-
var
|
|
1245
|
+
var RULE_NAME24 = "no-direct-mutation-state";
|
|
1246
|
+
var RULE_FEATURES24 = [];
|
|
1122
1247
|
function isConstructorFunction(node) {
|
|
1123
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";
|
|
1124
1249
|
}
|
|
@@ -1127,18 +1252,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1127
1252
|
type: "problem",
|
|
1128
1253
|
docs: {
|
|
1129
1254
|
description: "Disallow direct mutation of `this.state`.",
|
|
1130
|
-
[Symbol.for("rule_features")]:
|
|
1255
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1131
1256
|
},
|
|
1132
1257
|
messages: {
|
|
1133
1258
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1134
1259
|
},
|
|
1135
1260
|
schema: []
|
|
1136
1261
|
},
|
|
1137
|
-
name:
|
|
1138
|
-
create:
|
|
1262
|
+
name: RULE_NAME24,
|
|
1263
|
+
create: create24,
|
|
1139
1264
|
defaultOptions: []
|
|
1140
1265
|
});
|
|
1141
|
-
function
|
|
1266
|
+
function create24(context) {
|
|
1142
1267
|
return {
|
|
1143
1268
|
AssignmentExpression(node) {
|
|
1144
1269
|
if (!isAssignmentToThisState(node)) return;
|
|
@@ -1159,67 +1284,25 @@ function create21(context) {
|
|
|
1159
1284
|
}
|
|
1160
1285
|
};
|
|
1161
1286
|
}
|
|
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 = [];
|
|
1287
|
+
var RULE_NAME25 = "no-duplicate-key";
|
|
1288
|
+
var RULE_FEATURES25 = [];
|
|
1206
1289
|
var no_duplicate_key_default = createRule({
|
|
1207
1290
|
meta: {
|
|
1208
1291
|
type: "problem",
|
|
1209
1292
|
docs: {
|
|
1210
1293
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1211
|
-
[Symbol.for("rule_features")]:
|
|
1294
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1212
1295
|
},
|
|
1213
1296
|
messages: {
|
|
1214
1297
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1215
1298
|
},
|
|
1216
1299
|
schema: []
|
|
1217
1300
|
},
|
|
1218
|
-
name:
|
|
1219
|
-
create:
|
|
1301
|
+
name: RULE_NAME25,
|
|
1302
|
+
create: create25,
|
|
1220
1303
|
defaultOptions: []
|
|
1221
1304
|
});
|
|
1222
|
-
function
|
|
1305
|
+
function create25(context) {
|
|
1223
1306
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1224
1307
|
return {};
|
|
1225
1308
|
}
|
|
@@ -1283,8 +1366,8 @@ function create23(context) {
|
|
|
1283
1366
|
}
|
|
1284
1367
|
};
|
|
1285
1368
|
}
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1369
|
+
var RULE_NAME26 = "no-forward-ref";
|
|
1370
|
+
var RULE_FEATURES26 = [
|
|
1288
1371
|
"MOD"
|
|
1289
1372
|
];
|
|
1290
1373
|
var no_forward_ref_default = createRule({
|
|
@@ -1292,7 +1375,7 @@ var no_forward_ref_default = createRule({
|
|
|
1292
1375
|
type: "problem",
|
|
1293
1376
|
docs: {
|
|
1294
1377
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1295
|
-
[Symbol.for("rule_features")]:
|
|
1378
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1296
1379
|
},
|
|
1297
1380
|
fixable: "code",
|
|
1298
1381
|
messages: {
|
|
@@ -1300,11 +1383,11 @@ var no_forward_ref_default = createRule({
|
|
|
1300
1383
|
},
|
|
1301
1384
|
schema: []
|
|
1302
1385
|
},
|
|
1303
|
-
name:
|
|
1304
|
-
create:
|
|
1386
|
+
name: RULE_NAME26,
|
|
1387
|
+
create: create26,
|
|
1305
1388
|
defaultOptions: []
|
|
1306
1389
|
});
|
|
1307
|
-
function
|
|
1390
|
+
function create26(context) {
|
|
1308
1391
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1309
1392
|
return {};
|
|
1310
1393
|
}
|
|
@@ -1392,8 +1475,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1392
1475
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1393
1476
|
];
|
|
1394
1477
|
}
|
|
1395
|
-
var
|
|
1396
|
-
var
|
|
1478
|
+
var RULE_NAME27 = "no-implicit-key";
|
|
1479
|
+
var RULE_FEATURES27 = [
|
|
1397
1480
|
"EXP"
|
|
1398
1481
|
];
|
|
1399
1482
|
var no_implicit_key_default = createRule({
|
|
@@ -1401,18 +1484,18 @@ var no_implicit_key_default = createRule({
|
|
|
1401
1484
|
type: "problem",
|
|
1402
1485
|
docs: {
|
|
1403
1486
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1404
|
-
[Symbol.for("rule_features")]:
|
|
1487
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1405
1488
|
},
|
|
1406
1489
|
messages: {
|
|
1407
1490
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1408
1491
|
},
|
|
1409
1492
|
schema: []
|
|
1410
1493
|
},
|
|
1411
|
-
name:
|
|
1412
|
-
create:
|
|
1494
|
+
name: RULE_NAME27,
|
|
1495
|
+
create: create27,
|
|
1413
1496
|
defaultOptions: []
|
|
1414
1497
|
});
|
|
1415
|
-
function
|
|
1498
|
+
function create27(context) {
|
|
1416
1499
|
return {
|
|
1417
1500
|
JSXOpeningElement(node) {
|
|
1418
1501
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1426,8 +1509,8 @@ function create25(context) {
|
|
|
1426
1509
|
}
|
|
1427
1510
|
};
|
|
1428
1511
|
}
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1512
|
+
var RULE_NAME28 = "no-leaked-conditional-rendering";
|
|
1513
|
+
var RULE_FEATURES28 = [
|
|
1431
1514
|
"TSC"
|
|
1432
1515
|
];
|
|
1433
1516
|
var tsHelpers = {
|
|
@@ -1513,18 +1596,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1513
1596
|
type: "problem",
|
|
1514
1597
|
docs: {
|
|
1515
1598
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1516
|
-
[Symbol.for("rule_features")]:
|
|
1599
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1517
1600
|
},
|
|
1518
1601
|
messages: {
|
|
1519
1602
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1520
1603
|
},
|
|
1521
1604
|
schema: []
|
|
1522
1605
|
},
|
|
1523
|
-
name:
|
|
1524
|
-
create:
|
|
1606
|
+
name: RULE_NAME28,
|
|
1607
|
+
create: create28,
|
|
1525
1608
|
defaultOptions: []
|
|
1526
1609
|
});
|
|
1527
|
-
function
|
|
1610
|
+
function create28(context) {
|
|
1528
1611
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1529
1612
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1530
1613
|
const allowedVariants = [
|
|
@@ -1548,7 +1631,7 @@ function create26(context) {
|
|
|
1548
1631
|
return getReportDescriptor(right);
|
|
1549
1632
|
}
|
|
1550
1633
|
const initialScope = context.sourceCode.getScope(left);
|
|
1551
|
-
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";
|
|
1552
1635
|
if (isLeftNan) {
|
|
1553
1636
|
return {
|
|
1554
1637
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1570,7 +1653,7 @@ function create26(context) {
|
|
|
1570
1653
|
}).with({ type: AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
|
|
1571
1654
|
return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
|
|
1572
1655
|
}).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
1573
|
-
const variable =
|
|
1656
|
+
const variable = VAR2.findVariable(n.name, context.sourceCode.getScope(n));
|
|
1574
1657
|
const variableDefNode = variable?.defs.at(0)?.node;
|
|
1575
1658
|
return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => _);
|
|
1576
1659
|
}).otherwise(() => _);
|
|
@@ -1581,25 +1664,25 @@ function create26(context) {
|
|
|
1581
1664
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1582
1665
|
};
|
|
1583
1666
|
}
|
|
1584
|
-
var
|
|
1585
|
-
var
|
|
1667
|
+
var RULE_NAME29 = "no-missing-component-display-name";
|
|
1668
|
+
var RULE_FEATURES29 = [];
|
|
1586
1669
|
var no_missing_component_display_name_default = createRule({
|
|
1587
1670
|
meta: {
|
|
1588
1671
|
type: "problem",
|
|
1589
1672
|
docs: {
|
|
1590
1673
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1591
|
-
[Symbol.for("rule_features")]:
|
|
1674
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1592
1675
|
},
|
|
1593
1676
|
messages: {
|
|
1594
1677
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1595
1678
|
},
|
|
1596
1679
|
schema: []
|
|
1597
1680
|
},
|
|
1598
|
-
name:
|
|
1599
|
-
create:
|
|
1681
|
+
name: RULE_NAME29,
|
|
1682
|
+
create: create29,
|
|
1600
1683
|
defaultOptions: []
|
|
1601
1684
|
});
|
|
1602
|
-
function
|
|
1685
|
+
function create29(context) {
|
|
1603
1686
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1604
1687
|
const {
|
|
1605
1688
|
ctx,
|
|
@@ -1634,25 +1717,25 @@ function create27(context) {
|
|
|
1634
1717
|
}
|
|
1635
1718
|
};
|
|
1636
1719
|
}
|
|
1637
|
-
var
|
|
1638
|
-
var
|
|
1720
|
+
var RULE_NAME30 = "no-missing-context-display-name";
|
|
1721
|
+
var RULE_FEATURES30 = [];
|
|
1639
1722
|
var no_missing_context_display_name_default = createRule({
|
|
1640
1723
|
meta: {
|
|
1641
1724
|
type: "problem",
|
|
1642
1725
|
docs: {
|
|
1643
1726
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1644
|
-
[Symbol.for("rule_features")]:
|
|
1727
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1645
1728
|
},
|
|
1646
1729
|
messages: {
|
|
1647
1730
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1648
1731
|
},
|
|
1649
1732
|
schema: []
|
|
1650
1733
|
},
|
|
1651
|
-
name:
|
|
1652
|
-
create:
|
|
1734
|
+
name: RULE_NAME30,
|
|
1735
|
+
create: create30,
|
|
1653
1736
|
defaultOptions: []
|
|
1654
1737
|
});
|
|
1655
|
-
function
|
|
1738
|
+
function create30(context) {
|
|
1656
1739
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1657
1740
|
const createCalls = [];
|
|
1658
1741
|
const displayNameAssignments = [];
|
|
@@ -1690,14 +1773,14 @@ function create28(context) {
|
|
|
1690
1773
|
}
|
|
1691
1774
|
};
|
|
1692
1775
|
}
|
|
1693
|
-
var
|
|
1694
|
-
var
|
|
1776
|
+
var RULE_NAME31 = "no-missing-key";
|
|
1777
|
+
var RULE_FEATURES31 = [];
|
|
1695
1778
|
var no_missing_key_default = createRule({
|
|
1696
1779
|
meta: {
|
|
1697
1780
|
type: "problem",
|
|
1698
1781
|
docs: {
|
|
1699
1782
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1700
|
-
[Symbol.for("rule_features")]:
|
|
1783
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1701
1784
|
},
|
|
1702
1785
|
messages: {
|
|
1703
1786
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1705,11 +1788,11 @@ var no_missing_key_default = createRule({
|
|
|
1705
1788
|
},
|
|
1706
1789
|
schema: []
|
|
1707
1790
|
},
|
|
1708
|
-
name:
|
|
1709
|
-
create:
|
|
1791
|
+
name: RULE_NAME31,
|
|
1792
|
+
create: create31,
|
|
1710
1793
|
defaultOptions: []
|
|
1711
1794
|
});
|
|
1712
|
-
function
|
|
1795
|
+
function create31(context) {
|
|
1713
1796
|
const report = createReport(context);
|
|
1714
1797
|
const state = { isWithinChildrenToArray: false };
|
|
1715
1798
|
function checkIteratorElement(node) {
|
|
@@ -1822,26 +1905,25 @@ function create29(context) {
|
|
|
1822
1905
|
function isArrayFromCall(node) {
|
|
1823
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";
|
|
1824
1907
|
}
|
|
1825
|
-
var
|
|
1826
|
-
var
|
|
1908
|
+
var RULE_NAME32 = "no-nested-component-definitions";
|
|
1909
|
+
var RULE_FEATURES32 = [];
|
|
1827
1910
|
var no_nested_component_definitions_default = createRule({
|
|
1828
1911
|
meta: {
|
|
1829
1912
|
type: "problem",
|
|
1830
1913
|
docs: {
|
|
1831
1914
|
description: "Disallow nesting component definitions inside other components.",
|
|
1832
|
-
[Symbol.for("rule_features")]:
|
|
1915
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1833
1916
|
},
|
|
1834
1917
|
messages: {
|
|
1835
|
-
|
|
1836
|
-
noNestedComponentDefinitionInProps: "Do not nest component definitions inside props. Move it to the top level or pass it as a prop."
|
|
1918
|
+
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1837
1919
|
},
|
|
1838
1920
|
schema: []
|
|
1839
1921
|
},
|
|
1840
|
-
name:
|
|
1841
|
-
create:
|
|
1922
|
+
name: RULE_NAME32,
|
|
1923
|
+
create: create32,
|
|
1842
1924
|
defaultOptions: []
|
|
1843
1925
|
});
|
|
1844
|
-
function
|
|
1926
|
+
function create32(context) {
|
|
1845
1927
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1846
1928
|
const collector = useComponentCollector(context, { hint });
|
|
1847
1929
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -1867,10 +1949,11 @@ function create30(context) {
|
|
|
1867
1949
|
if (isInsideJSXAttributeValue(component)) {
|
|
1868
1950
|
if (!isDeclaredInRenderPropLoose(component)) {
|
|
1869
1951
|
context.report({
|
|
1870
|
-
messageId: "
|
|
1952
|
+
messageId: "noNestedComponentDefinitions",
|
|
1871
1953
|
node: component,
|
|
1872
1954
|
data: {
|
|
1873
|
-
name: name5
|
|
1955
|
+
name: name5,
|
|
1956
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1874
1957
|
}
|
|
1875
1958
|
});
|
|
1876
1959
|
}
|
|
@@ -1878,10 +1961,11 @@ function create30(context) {
|
|
|
1878
1961
|
}
|
|
1879
1962
|
if (isInsideCreateElementProps(context, component)) {
|
|
1880
1963
|
context.report({
|
|
1881
|
-
messageId: "
|
|
1964
|
+
messageId: "noNestedComponentDefinitions",
|
|
1882
1965
|
node: component,
|
|
1883
1966
|
data: {
|
|
1884
|
-
name: name5
|
|
1967
|
+
name: name5,
|
|
1968
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1885
1969
|
}
|
|
1886
1970
|
});
|
|
1887
1971
|
continue;
|
|
@@ -1889,20 +1973,22 @@ function create30(context) {
|
|
|
1889
1973
|
const parentComponent = AST11.findParentNode(component, isFunctionComponent);
|
|
1890
1974
|
if (parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1891
1975
|
context.report({
|
|
1892
|
-
messageId:
|
|
1976
|
+
messageId: "noNestedComponentDefinitions",
|
|
1893
1977
|
node: component,
|
|
1894
1978
|
data: {
|
|
1895
|
-
name: name5
|
|
1979
|
+
name: name5,
|
|
1980
|
+
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
1981
|
}
|
|
1897
1982
|
});
|
|
1898
1983
|
continue;
|
|
1899
1984
|
}
|
|
1900
1985
|
if (isInsideRenderMethod(component)) {
|
|
1901
1986
|
context.report({
|
|
1902
|
-
messageId: "
|
|
1987
|
+
messageId: "noNestedComponentDefinitions",
|
|
1903
1988
|
node: component,
|
|
1904
1989
|
data: {
|
|
1905
|
-
name: name5
|
|
1990
|
+
name: name5,
|
|
1991
|
+
suggestion: "Move it to the top level."
|
|
1906
1992
|
}
|
|
1907
1993
|
});
|
|
1908
1994
|
}
|
|
@@ -1912,10 +1998,11 @@ function create30(context) {
|
|
|
1912
1998
|
continue;
|
|
1913
1999
|
}
|
|
1914
2000
|
context.report({
|
|
1915
|
-
messageId: "
|
|
2001
|
+
messageId: "noNestedComponentDefinitions",
|
|
1916
2002
|
node: component,
|
|
1917
2003
|
data: {
|
|
1918
|
-
name: name5
|
|
2004
|
+
name: name5,
|
|
2005
|
+
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
2006
|
}
|
|
1920
2007
|
});
|
|
1921
2008
|
}
|
|
@@ -1932,25 +2019,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1932
2019
|
if (prop == null) return false;
|
|
1933
2020
|
return prop === call.arguments[1];
|
|
1934
2021
|
}
|
|
1935
|
-
var
|
|
1936
|
-
var
|
|
2022
|
+
var RULE_NAME33 = "no-prop-types";
|
|
2023
|
+
var RULE_FEATURES33 = [];
|
|
1937
2024
|
var no_prop_types_default = createRule({
|
|
1938
2025
|
meta: {
|
|
1939
2026
|
type: "problem",
|
|
1940
2027
|
docs: {
|
|
1941
2028
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1942
|
-
[Symbol.for("rule_features")]:
|
|
2029
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1943
2030
|
},
|
|
1944
2031
|
messages: {
|
|
1945
2032
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1946
2033
|
},
|
|
1947
2034
|
schema: []
|
|
1948
2035
|
},
|
|
1949
|
-
name:
|
|
1950
|
-
create:
|
|
2036
|
+
name: RULE_NAME33,
|
|
2037
|
+
create: create33,
|
|
1951
2038
|
defaultOptions: []
|
|
1952
2039
|
});
|
|
1953
|
-
function
|
|
2040
|
+
function create33(context) {
|
|
1954
2041
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1955
2042
|
return {};
|
|
1956
2043
|
}
|
|
@@ -1969,8 +2056,8 @@ function create31(context) {
|
|
|
1969
2056
|
if (!isComponentNameLoose(object.name)) {
|
|
1970
2057
|
return;
|
|
1971
2058
|
}
|
|
1972
|
-
const variable =
|
|
1973
|
-
const variableNode =
|
|
2059
|
+
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2060
|
+
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
1974
2061
|
if (variableNode != null && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
|
|
1975
2062
|
context.report({ messageId: "noPropTypes", node: property });
|
|
1976
2063
|
}
|
|
@@ -1986,8 +2073,8 @@ function create31(context) {
|
|
|
1986
2073
|
}
|
|
1987
2074
|
};
|
|
1988
2075
|
}
|
|
1989
|
-
var
|
|
1990
|
-
var
|
|
2076
|
+
var RULE_NAME34 = "no-redundant-should-component-update";
|
|
2077
|
+
var RULE_FEATURES34 = [];
|
|
1991
2078
|
function isShouldComponentUpdate(node) {
|
|
1992
2079
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
1993
2080
|
}
|
|
@@ -1996,18 +2083,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1996
2083
|
type: "problem",
|
|
1997
2084
|
docs: {
|
|
1998
2085
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
1999
|
-
[Symbol.for("rule_features")]:
|
|
2086
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2000
2087
|
},
|
|
2001
2088
|
messages: {
|
|
2002
2089
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2003
2090
|
},
|
|
2004
2091
|
schema: []
|
|
2005
2092
|
},
|
|
2006
|
-
name:
|
|
2007
|
-
create:
|
|
2093
|
+
name: RULE_NAME34,
|
|
2094
|
+
create: create34,
|
|
2008
2095
|
defaultOptions: []
|
|
2009
2096
|
});
|
|
2010
|
-
function
|
|
2097
|
+
function create34(context) {
|
|
2011
2098
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2012
2099
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2013
2100
|
return {
|
|
@@ -2034,8 +2121,8 @@ function create32(context) {
|
|
|
2034
2121
|
}
|
|
2035
2122
|
};
|
|
2036
2123
|
}
|
|
2037
|
-
var
|
|
2038
|
-
var
|
|
2124
|
+
var RULE_NAME35 = "no-set-state-in-component-did-mount";
|
|
2125
|
+
var RULE_FEATURES35 = [];
|
|
2039
2126
|
function isComponentDidMount(node) {
|
|
2040
2127
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2041
2128
|
}
|
|
@@ -2044,18 +2131,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2044
2131
|
type: "problem",
|
|
2045
2132
|
docs: {
|
|
2046
2133
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2047
|
-
[Symbol.for("rule_features")]:
|
|
2134
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2048
2135
|
},
|
|
2049
2136
|
messages: {
|
|
2050
2137
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2051
2138
|
},
|
|
2052
2139
|
schema: []
|
|
2053
2140
|
},
|
|
2054
|
-
name:
|
|
2055
|
-
create:
|
|
2141
|
+
name: RULE_NAME35,
|
|
2142
|
+
create: create35,
|
|
2056
2143
|
defaultOptions: []
|
|
2057
2144
|
});
|
|
2058
|
-
function
|
|
2145
|
+
function create35(context) {
|
|
2059
2146
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2060
2147
|
return {
|
|
2061
2148
|
CallExpression(node) {
|
|
@@ -2076,8 +2163,8 @@ function create33(context) {
|
|
|
2076
2163
|
}
|
|
2077
2164
|
};
|
|
2078
2165
|
}
|
|
2079
|
-
var
|
|
2080
|
-
var
|
|
2166
|
+
var RULE_NAME36 = "no-set-state-in-component-did-update";
|
|
2167
|
+
var RULE_FEATURES36 = [];
|
|
2081
2168
|
function isComponentDidUpdate(node) {
|
|
2082
2169
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2083
2170
|
}
|
|
@@ -2086,18 +2173,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2086
2173
|
type: "problem",
|
|
2087
2174
|
docs: {
|
|
2088
2175
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2089
|
-
[Symbol.for("rule_features")]:
|
|
2176
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2090
2177
|
},
|
|
2091
2178
|
messages: {
|
|
2092
2179
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2093
2180
|
},
|
|
2094
2181
|
schema: []
|
|
2095
2182
|
},
|
|
2096
|
-
name:
|
|
2097
|
-
create:
|
|
2183
|
+
name: RULE_NAME36,
|
|
2184
|
+
create: create36,
|
|
2098
2185
|
defaultOptions: []
|
|
2099
2186
|
});
|
|
2100
|
-
function
|
|
2187
|
+
function create36(context) {
|
|
2101
2188
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2102
2189
|
return {
|
|
2103
2190
|
CallExpression(node) {
|
|
@@ -2118,8 +2205,8 @@ function create34(context) {
|
|
|
2118
2205
|
}
|
|
2119
2206
|
};
|
|
2120
2207
|
}
|
|
2121
|
-
var
|
|
2122
|
-
var
|
|
2208
|
+
var RULE_NAME37 = "no-set-state-in-component-will-update";
|
|
2209
|
+
var RULE_FEATURES37 = [];
|
|
2123
2210
|
function isComponentWillUpdate3(node) {
|
|
2124
2211
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2125
2212
|
}
|
|
@@ -2128,18 +2215,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2128
2215
|
type: "problem",
|
|
2129
2216
|
docs: {
|
|
2130
2217
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2131
|
-
[Symbol.for("rule_features")]:
|
|
2218
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2132
2219
|
},
|
|
2133
2220
|
messages: {
|
|
2134
2221
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2135
2222
|
},
|
|
2136
2223
|
schema: []
|
|
2137
2224
|
},
|
|
2138
|
-
name:
|
|
2139
|
-
create:
|
|
2225
|
+
name: RULE_NAME37,
|
|
2226
|
+
create: create37,
|
|
2140
2227
|
defaultOptions: []
|
|
2141
2228
|
});
|
|
2142
|
-
function
|
|
2229
|
+
function create37(context) {
|
|
2143
2230
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2144
2231
|
return {
|
|
2145
2232
|
CallExpression(node) {
|
|
@@ -2160,8 +2247,8 @@ function create35(context) {
|
|
|
2160
2247
|
}
|
|
2161
2248
|
};
|
|
2162
2249
|
}
|
|
2163
|
-
var
|
|
2164
|
-
var
|
|
2250
|
+
var RULE_NAME38 = "no-string-refs";
|
|
2251
|
+
var RULE_FEATURES38 = [];
|
|
2165
2252
|
function containsStringLiteral({ value }) {
|
|
2166
2253
|
return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2167
2254
|
}
|
|
@@ -2179,18 +2266,18 @@ var no_string_refs_default = createRule({
|
|
|
2179
2266
|
type: "problem",
|
|
2180
2267
|
docs: {
|
|
2181
2268
|
description: "Disallow deprecated string `refs`.",
|
|
2182
|
-
[Symbol.for("rule_features")]:
|
|
2269
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2183
2270
|
},
|
|
2184
2271
|
messages: {
|
|
2185
2272
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2186
2273
|
},
|
|
2187
2274
|
schema: []
|
|
2188
2275
|
},
|
|
2189
|
-
name:
|
|
2190
|
-
create:
|
|
2276
|
+
name: RULE_NAME38,
|
|
2277
|
+
create: create38,
|
|
2191
2278
|
defaultOptions: []
|
|
2192
2279
|
});
|
|
2193
|
-
function
|
|
2280
|
+
function create38(context) {
|
|
2194
2281
|
return {
|
|
2195
2282
|
JSXAttribute(node) {
|
|
2196
2283
|
if (node.name.name !== "ref") {
|
|
@@ -2205,8 +2292,8 @@ function create36(context) {
|
|
|
2205
2292
|
}
|
|
2206
2293
|
};
|
|
2207
2294
|
}
|
|
2208
|
-
var
|
|
2209
|
-
var
|
|
2295
|
+
var RULE_NAME39 = "no-unsafe-component-will-mount";
|
|
2296
|
+
var RULE_FEATURES39 = [];
|
|
2210
2297
|
function isUnsafeComponentWillMount(node) {
|
|
2211
2298
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2212
2299
|
}
|
|
@@ -2215,18 +2302,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2215
2302
|
type: "problem",
|
|
2216
2303
|
docs: {
|
|
2217
2304
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2218
|
-
[Symbol.for("rule_features")]:
|
|
2305
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2219
2306
|
},
|
|
2220
2307
|
messages: {
|
|
2221
2308
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2222
2309
|
},
|
|
2223
2310
|
schema: []
|
|
2224
2311
|
},
|
|
2225
|
-
name:
|
|
2226
|
-
create:
|
|
2312
|
+
name: RULE_NAME39,
|
|
2313
|
+
create: create39,
|
|
2227
2314
|
defaultOptions: []
|
|
2228
2315
|
});
|
|
2229
|
-
function
|
|
2316
|
+
function create39(context) {
|
|
2230
2317
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2231
2318
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2232
2319
|
return {
|
|
@@ -2247,8 +2334,8 @@ function create37(context) {
|
|
|
2247
2334
|
}
|
|
2248
2335
|
};
|
|
2249
2336
|
}
|
|
2250
|
-
var
|
|
2251
|
-
var
|
|
2337
|
+
var RULE_NAME40 = "no-unsafe-component-will-receive-props";
|
|
2338
|
+
var RULE_FEATURES40 = [];
|
|
2252
2339
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2253
2340
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2254
2341
|
}
|
|
@@ -2257,18 +2344,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2257
2344
|
type: "problem",
|
|
2258
2345
|
docs: {
|
|
2259
2346
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2260
|
-
[Symbol.for("rule_features")]:
|
|
2347
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2261
2348
|
},
|
|
2262
2349
|
messages: {
|
|
2263
2350
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2264
2351
|
},
|
|
2265
2352
|
schema: []
|
|
2266
2353
|
},
|
|
2267
|
-
name:
|
|
2268
|
-
create:
|
|
2354
|
+
name: RULE_NAME40,
|
|
2355
|
+
create: create40,
|
|
2269
2356
|
defaultOptions: []
|
|
2270
2357
|
});
|
|
2271
|
-
function
|
|
2358
|
+
function create40(context) {
|
|
2272
2359
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2273
2360
|
return {};
|
|
2274
2361
|
}
|
|
@@ -2291,8 +2378,8 @@ function create38(context) {
|
|
|
2291
2378
|
}
|
|
2292
2379
|
};
|
|
2293
2380
|
}
|
|
2294
|
-
var
|
|
2295
|
-
var
|
|
2381
|
+
var RULE_NAME41 = "no-unsafe-component-will-update";
|
|
2382
|
+
var RULE_FEATURES41 = [];
|
|
2296
2383
|
function isUnsafeComponentWillUpdate(node) {
|
|
2297
2384
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2298
2385
|
}
|
|
@@ -2301,18 +2388,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2301
2388
|
type: "problem",
|
|
2302
2389
|
docs: {
|
|
2303
2390
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2304
|
-
[Symbol.for("rule_features")]:
|
|
2391
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2305
2392
|
},
|
|
2306
2393
|
messages: {
|
|
2307
2394
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2308
2395
|
},
|
|
2309
2396
|
schema: []
|
|
2310
2397
|
},
|
|
2311
|
-
name:
|
|
2312
|
-
create:
|
|
2398
|
+
name: RULE_NAME41,
|
|
2399
|
+
create: create41,
|
|
2313
2400
|
defaultOptions: []
|
|
2314
2401
|
});
|
|
2315
|
-
function
|
|
2402
|
+
function create41(context) {
|
|
2316
2403
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2317
2404
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2318
2405
|
return {
|
|
@@ -2333,25 +2420,25 @@ function create39(context) {
|
|
|
2333
2420
|
}
|
|
2334
2421
|
};
|
|
2335
2422
|
}
|
|
2336
|
-
var
|
|
2337
|
-
var
|
|
2423
|
+
var RULE_NAME42 = "no-unstable-context-value";
|
|
2424
|
+
var RULE_FEATURES42 = [];
|
|
2338
2425
|
var no_unstable_context_value_default = createRule({
|
|
2339
2426
|
meta: {
|
|
2340
2427
|
type: "problem",
|
|
2341
2428
|
docs: {
|
|
2342
2429
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2343
|
-
[Symbol.for("rule_features")]:
|
|
2430
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2344
2431
|
},
|
|
2345
2432
|
messages: {
|
|
2346
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}}"
|
|
2347
2434
|
},
|
|
2348
2435
|
schema: []
|
|
2349
2436
|
},
|
|
2350
|
-
name:
|
|
2351
|
-
create:
|
|
2437
|
+
name: RULE_NAME42,
|
|
2438
|
+
create: create42,
|
|
2352
2439
|
defaultOptions: []
|
|
2353
2440
|
});
|
|
2354
|
-
function
|
|
2441
|
+
function create42(context) {
|
|
2355
2442
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2356
2443
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2357
2444
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2373,7 +2460,7 @@ function create40(context) {
|
|
|
2373
2460
|
if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2374
2461
|
const valueExpression = value.expression;
|
|
2375
2462
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2376
|
-
const construction =
|
|
2463
|
+
const construction = VAR2.getValueConstruction(valueExpression, initialScope);
|
|
2377
2464
|
if (construction == null) return;
|
|
2378
2465
|
if (isReactHookCall(construction.node)) {
|
|
2379
2466
|
return;
|
|
@@ -2406,25 +2493,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2406
2493
|
}
|
|
2407
2494
|
return false;
|
|
2408
2495
|
}
|
|
2409
|
-
var
|
|
2410
|
-
var
|
|
2496
|
+
var RULE_NAME43 = "no-unstable-default-props";
|
|
2497
|
+
var RULE_FEATURES43 = [];
|
|
2411
2498
|
var no_unstable_default_props_default = createRule({
|
|
2412
2499
|
meta: {
|
|
2413
2500
|
type: "problem",
|
|
2414
2501
|
docs: {
|
|
2415
2502
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2416
|
-
[Symbol.for("rule_features")]:
|
|
2503
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2417
2504
|
},
|
|
2418
2505
|
messages: {
|
|
2419
2506
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2420
2507
|
},
|
|
2421
2508
|
schema: []
|
|
2422
2509
|
},
|
|
2423
|
-
name:
|
|
2424
|
-
create:
|
|
2510
|
+
name: RULE_NAME43,
|
|
2511
|
+
create: create43,
|
|
2425
2512
|
defaultOptions: []
|
|
2426
2513
|
});
|
|
2427
|
-
function
|
|
2514
|
+
function create43(context) {
|
|
2428
2515
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2429
2516
|
const declarators = /* @__PURE__ */ new Map();
|
|
2430
2517
|
return {
|
|
@@ -2447,10 +2534,10 @@ function create41(context) {
|
|
|
2447
2534
|
const { value } = prop;
|
|
2448
2535
|
const { right } = value;
|
|
2449
2536
|
const initialScope = context.sourceCode.getScope(value);
|
|
2450
|
-
const construction =
|
|
2537
|
+
const construction = VAR2.getValueConstruction(
|
|
2451
2538
|
value,
|
|
2452
2539
|
initialScope,
|
|
2453
|
-
|
|
2540
|
+
VAR2.ValueConstructionHint.StrictCallExpression
|
|
2454
2541
|
);
|
|
2455
2542
|
if (construction == null) {
|
|
2456
2543
|
continue;
|
|
@@ -2480,8 +2567,8 @@ function create41(context) {
|
|
|
2480
2567
|
}
|
|
2481
2568
|
};
|
|
2482
2569
|
}
|
|
2483
|
-
var
|
|
2484
|
-
var
|
|
2570
|
+
var RULE_NAME44 = "no-unused-class-component-members";
|
|
2571
|
+
var RULE_FEATURES44 = [];
|
|
2485
2572
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2486
2573
|
"componentDidCatch",
|
|
2487
2574
|
"componentDidMount",
|
|
@@ -2507,18 +2594,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2507
2594
|
type: "problem",
|
|
2508
2595
|
docs: {
|
|
2509
2596
|
description: "Warns unused class component methods and properties.",
|
|
2510
|
-
[Symbol.for("rule_features")]:
|
|
2597
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2511
2598
|
},
|
|
2512
2599
|
messages: {
|
|
2513
2600
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2514
2601
|
},
|
|
2515
2602
|
schema: []
|
|
2516
2603
|
},
|
|
2517
|
-
name:
|
|
2518
|
-
create:
|
|
2604
|
+
name: RULE_NAME44,
|
|
2605
|
+
create: create44,
|
|
2519
2606
|
defaultOptions: []
|
|
2520
2607
|
});
|
|
2521
|
-
function
|
|
2608
|
+
function create44(context) {
|
|
2522
2609
|
const classEntries = [];
|
|
2523
2610
|
const methodEntries = [];
|
|
2524
2611
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2628,8 +2715,8 @@ function create42(context) {
|
|
|
2628
2715
|
}
|
|
2629
2716
|
};
|
|
2630
2717
|
}
|
|
2631
|
-
var
|
|
2632
|
-
var
|
|
2718
|
+
var RULE_NAME45 = "no-unused-state";
|
|
2719
|
+
var RULE_FEATURES45 = [];
|
|
2633
2720
|
function isKeyLiteral3(node, key) {
|
|
2634
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);
|
|
2635
2722
|
}
|
|
@@ -2638,18 +2725,18 @@ var no_unused_state_default = createRule({
|
|
|
2638
2725
|
type: "problem",
|
|
2639
2726
|
docs: {
|
|
2640
2727
|
description: "Warns unused class component state.",
|
|
2641
|
-
[Symbol.for("rule_features")]:
|
|
2728
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2642
2729
|
},
|
|
2643
2730
|
messages: {
|
|
2644
2731
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2645
2732
|
},
|
|
2646
2733
|
schema: []
|
|
2647
2734
|
},
|
|
2648
|
-
name:
|
|
2649
|
-
create:
|
|
2735
|
+
name: RULE_NAME45,
|
|
2736
|
+
create: create45,
|
|
2650
2737
|
defaultOptions: []
|
|
2651
2738
|
});
|
|
2652
|
-
function
|
|
2739
|
+
function create45(context) {
|
|
2653
2740
|
const classEntries = [];
|
|
2654
2741
|
const methodEntries = [];
|
|
2655
2742
|
const constructorEntries = [];
|
|
@@ -2783,8 +2870,8 @@ function create43(context) {
|
|
|
2783
2870
|
}
|
|
2784
2871
|
};
|
|
2785
2872
|
}
|
|
2786
|
-
var
|
|
2787
|
-
var
|
|
2873
|
+
var RULE_NAME46 = "no-use-context";
|
|
2874
|
+
var RULE_FEATURES46 = [
|
|
2788
2875
|
"MOD"
|
|
2789
2876
|
];
|
|
2790
2877
|
var no_use_context_default = createRule({
|
|
@@ -2792,7 +2879,7 @@ var no_use_context_default = createRule({
|
|
|
2792
2879
|
type: "problem",
|
|
2793
2880
|
docs: {
|
|
2794
2881
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2795
|
-
[Symbol.for("rule_features")]:
|
|
2882
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2796
2883
|
},
|
|
2797
2884
|
fixable: "code",
|
|
2798
2885
|
messages: {
|
|
@@ -2800,11 +2887,11 @@ var no_use_context_default = createRule({
|
|
|
2800
2887
|
},
|
|
2801
2888
|
schema: []
|
|
2802
2889
|
},
|
|
2803
|
-
name:
|
|
2804
|
-
create:
|
|
2890
|
+
name: RULE_NAME46,
|
|
2891
|
+
create: create46,
|
|
2805
2892
|
defaultOptions: []
|
|
2806
2893
|
});
|
|
2807
|
-
function
|
|
2894
|
+
function create46(context) {
|
|
2808
2895
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2809
2896
|
const settings4 = getSettingsFromContext(context);
|
|
2810
2897
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2882,25 +2969,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2882
2969
|
return tokens;
|
|
2883
2970
|
}
|
|
2884
2971
|
}
|
|
2885
|
-
var
|
|
2886
|
-
var
|
|
2972
|
+
var RULE_NAME47 = "no-useless-forward-ref";
|
|
2973
|
+
var RULE_FEATURES47 = [];
|
|
2887
2974
|
var no_useless_forward_ref_default = createRule({
|
|
2888
2975
|
meta: {
|
|
2889
2976
|
type: "problem",
|
|
2890
2977
|
docs: {
|
|
2891
2978
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2892
|
-
[Symbol.for("rule_features")]:
|
|
2979
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2893
2980
|
},
|
|
2894
2981
|
messages: {
|
|
2895
2982
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2896
2983
|
},
|
|
2897
2984
|
schema: []
|
|
2898
2985
|
},
|
|
2899
|
-
name:
|
|
2900
|
-
create:
|
|
2986
|
+
name: RULE_NAME47,
|
|
2987
|
+
create: create47,
|
|
2901
2988
|
defaultOptions: []
|
|
2902
2989
|
});
|
|
2903
|
-
function
|
|
2990
|
+
function create47(context) {
|
|
2904
2991
|
return {
|
|
2905
2992
|
CallExpression(node) {
|
|
2906
2993
|
if (!isForwardRefCall(context, node)) {
|
|
@@ -2921,7 +3008,7 @@ function create45(context) {
|
|
|
2921
3008
|
}
|
|
2922
3009
|
};
|
|
2923
3010
|
}
|
|
2924
|
-
var
|
|
3011
|
+
var RULE_NAME48 = "no-useless-fragment";
|
|
2925
3012
|
var defaultOptions = [{
|
|
2926
3013
|
allowExpressions: true
|
|
2927
3014
|
}];
|
|
@@ -2947,11 +3034,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2947
3034
|
}
|
|
2948
3035
|
}]
|
|
2949
3036
|
},
|
|
2950
|
-
name:
|
|
2951
|
-
create:
|
|
3037
|
+
name: RULE_NAME48,
|
|
3038
|
+
create: create48,
|
|
2952
3039
|
defaultOptions
|
|
2953
3040
|
});
|
|
2954
|
-
function
|
|
3041
|
+
function create48(context, [option]) {
|
|
2955
3042
|
const { allowExpressions = true } = option;
|
|
2956
3043
|
return {
|
|
2957
3044
|
JSXElement(node) {
|
|
@@ -3063,8 +3150,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3063
3150
|
}
|
|
3064
3151
|
return;
|
|
3065
3152
|
}
|
|
3066
|
-
var
|
|
3067
|
-
var
|
|
3153
|
+
var RULE_NAME49 = "prefer-destructuring-assignment";
|
|
3154
|
+
var RULE_FEATURES48 = [];
|
|
3068
3155
|
function isMemberExpressionWithObjectName(node) {
|
|
3069
3156
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3070
3157
|
}
|
|
@@ -3073,18 +3160,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3073
3160
|
type: "problem",
|
|
3074
3161
|
docs: {
|
|
3075
3162
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3076
|
-
[Symbol.for("rule_features")]:
|
|
3163
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3077
3164
|
},
|
|
3078
3165
|
messages: {
|
|
3079
3166
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3080
3167
|
},
|
|
3081
3168
|
schema: []
|
|
3082
3169
|
},
|
|
3083
|
-
name:
|
|
3084
|
-
create:
|
|
3170
|
+
name: RULE_NAME49,
|
|
3171
|
+
create: create49,
|
|
3085
3172
|
defaultOptions: []
|
|
3086
3173
|
});
|
|
3087
|
-
function
|
|
3174
|
+
function create49(context) {
|
|
3088
3175
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3089
3176
|
const memberExpressionWithNames = [];
|
|
3090
3177
|
return {
|
|
@@ -3144,8 +3231,8 @@ function create47(context) {
|
|
|
3144
3231
|
}
|
|
3145
3232
|
};
|
|
3146
3233
|
}
|
|
3147
|
-
var
|
|
3148
|
-
var
|
|
3234
|
+
var RULE_NAME50 = "prefer-react-namespace-import";
|
|
3235
|
+
var RULE_FEATURES49 = [
|
|
3149
3236
|
"FIX",
|
|
3150
3237
|
"EXP"
|
|
3151
3238
|
];
|
|
@@ -3154,7 +3241,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3154
3241
|
type: "problem",
|
|
3155
3242
|
docs: {
|
|
3156
3243
|
description: "Enforces React is imported via a namespace import.",
|
|
3157
|
-
[Symbol.for("rule_features")]:
|
|
3244
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3158
3245
|
},
|
|
3159
3246
|
fixable: "code",
|
|
3160
3247
|
messages: {
|
|
@@ -3162,11 +3249,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3162
3249
|
},
|
|
3163
3250
|
schema: []
|
|
3164
3251
|
},
|
|
3165
|
-
name:
|
|
3166
|
-
create:
|
|
3252
|
+
name: RULE_NAME50,
|
|
3253
|
+
create: create50,
|
|
3167
3254
|
defaultOptions: []
|
|
3168
3255
|
});
|
|
3169
|
-
function
|
|
3256
|
+
function create50(context) {
|
|
3170
3257
|
const { importSource } = getSettingsFromContext(context);
|
|
3171
3258
|
return {
|
|
3172
3259
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3199,8 +3286,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3199
3286
|
}
|
|
3200
3287
|
};
|
|
3201
3288
|
}
|
|
3202
|
-
var
|
|
3203
|
-
var
|
|
3289
|
+
var RULE_NAME51 = "prefer-read-only-props";
|
|
3290
|
+
var RULE_FEATURES50 = [
|
|
3204
3291
|
"TSC",
|
|
3205
3292
|
"EXP"
|
|
3206
3293
|
];
|
|
@@ -3209,18 +3296,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3209
3296
|
type: "problem",
|
|
3210
3297
|
docs: {
|
|
3211
3298
|
description: "Enforces read-only props in components.",
|
|
3212
|
-
[Symbol.for("rule_features")]:
|
|
3299
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3213
3300
|
},
|
|
3214
3301
|
messages: {
|
|
3215
3302
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3216
3303
|
},
|
|
3217
3304
|
schema: []
|
|
3218
3305
|
},
|
|
3219
|
-
name:
|
|
3220
|
-
create:
|
|
3306
|
+
name: RULE_NAME51,
|
|
3307
|
+
create: create51,
|
|
3221
3308
|
defaultOptions: []
|
|
3222
3309
|
});
|
|
3223
|
-
function
|
|
3310
|
+
function create51(context) {
|
|
3224
3311
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3225
3312
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3226
3313
|
return {
|
|
@@ -3250,8 +3337,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3250
3337
|
return true;
|
|
3251
3338
|
}
|
|
3252
3339
|
}
|
|
3253
|
-
var
|
|
3254
|
-
var
|
|
3340
|
+
var RULE_NAME52 = "prefer-shorthand-boolean";
|
|
3341
|
+
var RULE_FEATURES51 = [
|
|
3255
3342
|
"FIX"
|
|
3256
3343
|
];
|
|
3257
3344
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3259,7 +3346,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3259
3346
|
type: "problem",
|
|
3260
3347
|
docs: {
|
|
3261
3348
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3262
|
-
[Symbol.for("rule_features")]:
|
|
3349
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3263
3350
|
},
|
|
3264
3351
|
fixable: "code",
|
|
3265
3352
|
messages: {
|
|
@@ -3267,11 +3354,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3267
3354
|
},
|
|
3268
3355
|
schema: []
|
|
3269
3356
|
},
|
|
3270
|
-
name:
|
|
3271
|
-
create:
|
|
3357
|
+
name: RULE_NAME52,
|
|
3358
|
+
create: create52,
|
|
3272
3359
|
defaultOptions: []
|
|
3273
3360
|
});
|
|
3274
|
-
function
|
|
3361
|
+
function create52(context) {
|
|
3275
3362
|
return {
|
|
3276
3363
|
JSXAttribute(node) {
|
|
3277
3364
|
const { value } = node;
|
|
@@ -3291,8 +3378,8 @@ function create50(context) {
|
|
|
3291
3378
|
}
|
|
3292
3379
|
};
|
|
3293
3380
|
}
|
|
3294
|
-
var
|
|
3295
|
-
var
|
|
3381
|
+
var RULE_NAME53 = "prefer-shorthand-fragment";
|
|
3382
|
+
var RULE_FEATURES52 = [
|
|
3296
3383
|
"FIX"
|
|
3297
3384
|
];
|
|
3298
3385
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3300,7 +3387,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3300
3387
|
type: "problem",
|
|
3301
3388
|
docs: {
|
|
3302
3389
|
description: "Enforces shorthand syntax for fragments.",
|
|
3303
|
-
[Symbol.for("rule_features")]:
|
|
3390
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3304
3391
|
},
|
|
3305
3392
|
fixable: "code",
|
|
3306
3393
|
messages: {
|
|
@@ -3308,11 +3395,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3308
3395
|
},
|
|
3309
3396
|
schema: []
|
|
3310
3397
|
},
|
|
3311
|
-
name:
|
|
3312
|
-
create:
|
|
3398
|
+
name: RULE_NAME53,
|
|
3399
|
+
create: create53,
|
|
3313
3400
|
defaultOptions: []
|
|
3314
3401
|
});
|
|
3315
|
-
function
|
|
3402
|
+
function create53(context) {
|
|
3316
3403
|
return {
|
|
3317
3404
|
JSXElement(node) {
|
|
3318
3405
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3337,46 +3424,6 @@ function create51(context) {
|
|
|
3337
3424
|
}
|
|
3338
3425
|
};
|
|
3339
3426
|
}
|
|
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
3427
|
|
|
3381
3428
|
// src/plugin.ts
|
|
3382
3429
|
var plugin = {
|
|
@@ -3406,7 +3453,6 @@ var plugin = {
|
|
|
3406
3453
|
"no-create-ref": no_create_ref_default,
|
|
3407
3454
|
"no-default-props": no_default_props_default,
|
|
3408
3455
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3409
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3410
3456
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3411
3457
|
"no-forward-ref": no_forward_ref_default,
|
|
3412
3458
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3436,18 +3482,21 @@ var plugin = {
|
|
|
3436
3482
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3437
3483
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3438
3484
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3439
|
-
|
|
3485
|
+
// Part: JSX only rules
|
|
3486
|
+
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3487
|
+
"jsx-no-undef": jsx_no_undef_default,
|
|
3488
|
+
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3440
3489
|
// Part: deprecated rules
|
|
3441
3490
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3442
3491
|
"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
3492
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3448
3493
|
"no-complicated-conditional-rendering": no_complex_conditional_rendering_default,
|
|
3494
|
+
/** @deprecated Use `jsx-no-duplicate-props` instead */
|
|
3495
|
+
"no-duplicate-jsx-props": jsx_no_duplicate_props_default,
|
|
3449
3496
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3450
|
-
"no-nested-components": no_nested_component_definitions_default
|
|
3497
|
+
"no-nested-components": no_nested_component_definitions_default,
|
|
3498
|
+
/** @deprecated Use `jsx-uses-vars` instead */
|
|
3499
|
+
"use-jsx-vars": jsx_uses_vars_default
|
|
3451
3500
|
}
|
|
3452
3501
|
};
|
|
3453
3502
|
|