eslint-plugin-react-x 1.38.0-next.6 → 1.38.0-next.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 +20 -16
- package/dist/index.d.ts +20 -16
- package/dist/index.js +437 -392
- package/dist/index.mjs +436 -391
- 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-next.
|
|
115
|
+
var version = "1.38.0-next.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,25 +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
1918
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1836
1919
|
},
|
|
1837
1920
|
schema: []
|
|
1838
1921
|
},
|
|
1839
|
-
name:
|
|
1840
|
-
create:
|
|
1922
|
+
name: RULE_NAME32,
|
|
1923
|
+
create: create32,
|
|
1841
1924
|
defaultOptions: []
|
|
1842
1925
|
});
|
|
1843
|
-
function
|
|
1926
|
+
function create32(context) {
|
|
1844
1927
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1845
1928
|
const collector = useComponentCollector(context, { hint });
|
|
1846
1929
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -1936,25 +2019,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1936
2019
|
if (prop == null) return false;
|
|
1937
2020
|
return prop === call.arguments[1];
|
|
1938
2021
|
}
|
|
1939
|
-
var
|
|
1940
|
-
var
|
|
2022
|
+
var RULE_NAME33 = "no-prop-types";
|
|
2023
|
+
var RULE_FEATURES33 = [];
|
|
1941
2024
|
var no_prop_types_default = createRule({
|
|
1942
2025
|
meta: {
|
|
1943
2026
|
type: "problem",
|
|
1944
2027
|
docs: {
|
|
1945
2028
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1946
|
-
[Symbol.for("rule_features")]:
|
|
2029
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1947
2030
|
},
|
|
1948
2031
|
messages: {
|
|
1949
2032
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1950
2033
|
},
|
|
1951
2034
|
schema: []
|
|
1952
2035
|
},
|
|
1953
|
-
name:
|
|
1954
|
-
create:
|
|
2036
|
+
name: RULE_NAME33,
|
|
2037
|
+
create: create33,
|
|
1955
2038
|
defaultOptions: []
|
|
1956
2039
|
});
|
|
1957
|
-
function
|
|
2040
|
+
function create33(context) {
|
|
1958
2041
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1959
2042
|
return {};
|
|
1960
2043
|
}
|
|
@@ -1973,8 +2056,8 @@ function create31(context) {
|
|
|
1973
2056
|
if (!isComponentNameLoose(object.name)) {
|
|
1974
2057
|
return;
|
|
1975
2058
|
}
|
|
1976
|
-
const variable =
|
|
1977
|
-
const variableNode =
|
|
2059
|
+
const variable = VAR2.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2060
|
+
const variableNode = VAR2.getVariableInitNode(variable, 0);
|
|
1978
2061
|
if (variableNode != null && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
|
|
1979
2062
|
context.report({ messageId: "noPropTypes", node: property });
|
|
1980
2063
|
}
|
|
@@ -1990,8 +2073,8 @@ function create31(context) {
|
|
|
1990
2073
|
}
|
|
1991
2074
|
};
|
|
1992
2075
|
}
|
|
1993
|
-
var
|
|
1994
|
-
var
|
|
2076
|
+
var RULE_NAME34 = "no-redundant-should-component-update";
|
|
2077
|
+
var RULE_FEATURES34 = [];
|
|
1995
2078
|
function isShouldComponentUpdate(node) {
|
|
1996
2079
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
1997
2080
|
}
|
|
@@ -2000,18 +2083,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2000
2083
|
type: "problem",
|
|
2001
2084
|
docs: {
|
|
2002
2085
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2003
|
-
[Symbol.for("rule_features")]:
|
|
2086
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2004
2087
|
},
|
|
2005
2088
|
messages: {
|
|
2006
2089
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2007
2090
|
},
|
|
2008
2091
|
schema: []
|
|
2009
2092
|
},
|
|
2010
|
-
name:
|
|
2011
|
-
create:
|
|
2093
|
+
name: RULE_NAME34,
|
|
2094
|
+
create: create34,
|
|
2012
2095
|
defaultOptions: []
|
|
2013
2096
|
});
|
|
2014
|
-
function
|
|
2097
|
+
function create34(context) {
|
|
2015
2098
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2016
2099
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2017
2100
|
return {
|
|
@@ -2038,8 +2121,8 @@ function create32(context) {
|
|
|
2038
2121
|
}
|
|
2039
2122
|
};
|
|
2040
2123
|
}
|
|
2041
|
-
var
|
|
2042
|
-
var
|
|
2124
|
+
var RULE_NAME35 = "no-set-state-in-component-did-mount";
|
|
2125
|
+
var RULE_FEATURES35 = [];
|
|
2043
2126
|
function isComponentDidMount(node) {
|
|
2044
2127
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2045
2128
|
}
|
|
@@ -2048,18 +2131,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2048
2131
|
type: "problem",
|
|
2049
2132
|
docs: {
|
|
2050
2133
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2051
|
-
[Symbol.for("rule_features")]:
|
|
2134
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2052
2135
|
},
|
|
2053
2136
|
messages: {
|
|
2054
2137
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2055
2138
|
},
|
|
2056
2139
|
schema: []
|
|
2057
2140
|
},
|
|
2058
|
-
name:
|
|
2059
|
-
create:
|
|
2141
|
+
name: RULE_NAME35,
|
|
2142
|
+
create: create35,
|
|
2060
2143
|
defaultOptions: []
|
|
2061
2144
|
});
|
|
2062
|
-
function
|
|
2145
|
+
function create35(context) {
|
|
2063
2146
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2064
2147
|
return {
|
|
2065
2148
|
CallExpression(node) {
|
|
@@ -2080,8 +2163,8 @@ function create33(context) {
|
|
|
2080
2163
|
}
|
|
2081
2164
|
};
|
|
2082
2165
|
}
|
|
2083
|
-
var
|
|
2084
|
-
var
|
|
2166
|
+
var RULE_NAME36 = "no-set-state-in-component-did-update";
|
|
2167
|
+
var RULE_FEATURES36 = [];
|
|
2085
2168
|
function isComponentDidUpdate(node) {
|
|
2086
2169
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2087
2170
|
}
|
|
@@ -2090,18 +2173,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2090
2173
|
type: "problem",
|
|
2091
2174
|
docs: {
|
|
2092
2175
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2093
|
-
[Symbol.for("rule_features")]:
|
|
2176
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2094
2177
|
},
|
|
2095
2178
|
messages: {
|
|
2096
2179
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2097
2180
|
},
|
|
2098
2181
|
schema: []
|
|
2099
2182
|
},
|
|
2100
|
-
name:
|
|
2101
|
-
create:
|
|
2183
|
+
name: RULE_NAME36,
|
|
2184
|
+
create: create36,
|
|
2102
2185
|
defaultOptions: []
|
|
2103
2186
|
});
|
|
2104
|
-
function
|
|
2187
|
+
function create36(context) {
|
|
2105
2188
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2106
2189
|
return {
|
|
2107
2190
|
CallExpression(node) {
|
|
@@ -2122,8 +2205,8 @@ function create34(context) {
|
|
|
2122
2205
|
}
|
|
2123
2206
|
};
|
|
2124
2207
|
}
|
|
2125
|
-
var
|
|
2126
|
-
var
|
|
2208
|
+
var RULE_NAME37 = "no-set-state-in-component-will-update";
|
|
2209
|
+
var RULE_FEATURES37 = [];
|
|
2127
2210
|
function isComponentWillUpdate3(node) {
|
|
2128
2211
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2129
2212
|
}
|
|
@@ -2132,18 +2215,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2132
2215
|
type: "problem",
|
|
2133
2216
|
docs: {
|
|
2134
2217
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2135
|
-
[Symbol.for("rule_features")]:
|
|
2218
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2136
2219
|
},
|
|
2137
2220
|
messages: {
|
|
2138
2221
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2139
2222
|
},
|
|
2140
2223
|
schema: []
|
|
2141
2224
|
},
|
|
2142
|
-
name:
|
|
2143
|
-
create:
|
|
2225
|
+
name: RULE_NAME37,
|
|
2226
|
+
create: create37,
|
|
2144
2227
|
defaultOptions: []
|
|
2145
2228
|
});
|
|
2146
|
-
function
|
|
2229
|
+
function create37(context) {
|
|
2147
2230
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2148
2231
|
return {
|
|
2149
2232
|
CallExpression(node) {
|
|
@@ -2164,8 +2247,8 @@ function create35(context) {
|
|
|
2164
2247
|
}
|
|
2165
2248
|
};
|
|
2166
2249
|
}
|
|
2167
|
-
var
|
|
2168
|
-
var
|
|
2250
|
+
var RULE_NAME38 = "no-string-refs";
|
|
2251
|
+
var RULE_FEATURES38 = [];
|
|
2169
2252
|
function containsStringLiteral({ value }) {
|
|
2170
2253
|
return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2171
2254
|
}
|
|
@@ -2183,18 +2266,18 @@ var no_string_refs_default = createRule({
|
|
|
2183
2266
|
type: "problem",
|
|
2184
2267
|
docs: {
|
|
2185
2268
|
description: "Disallow deprecated string `refs`.",
|
|
2186
|
-
[Symbol.for("rule_features")]:
|
|
2269
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2187
2270
|
},
|
|
2188
2271
|
messages: {
|
|
2189
2272
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2190
2273
|
},
|
|
2191
2274
|
schema: []
|
|
2192
2275
|
},
|
|
2193
|
-
name:
|
|
2194
|
-
create:
|
|
2276
|
+
name: RULE_NAME38,
|
|
2277
|
+
create: create38,
|
|
2195
2278
|
defaultOptions: []
|
|
2196
2279
|
});
|
|
2197
|
-
function
|
|
2280
|
+
function create38(context) {
|
|
2198
2281
|
return {
|
|
2199
2282
|
JSXAttribute(node) {
|
|
2200
2283
|
if (node.name.name !== "ref") {
|
|
@@ -2209,8 +2292,8 @@ function create36(context) {
|
|
|
2209
2292
|
}
|
|
2210
2293
|
};
|
|
2211
2294
|
}
|
|
2212
|
-
var
|
|
2213
|
-
var
|
|
2295
|
+
var RULE_NAME39 = "no-unsafe-component-will-mount";
|
|
2296
|
+
var RULE_FEATURES39 = [];
|
|
2214
2297
|
function isUnsafeComponentWillMount(node) {
|
|
2215
2298
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2216
2299
|
}
|
|
@@ -2219,18 +2302,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2219
2302
|
type: "problem",
|
|
2220
2303
|
docs: {
|
|
2221
2304
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2222
|
-
[Symbol.for("rule_features")]:
|
|
2305
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2223
2306
|
},
|
|
2224
2307
|
messages: {
|
|
2225
2308
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2226
2309
|
},
|
|
2227
2310
|
schema: []
|
|
2228
2311
|
},
|
|
2229
|
-
name:
|
|
2230
|
-
create:
|
|
2312
|
+
name: RULE_NAME39,
|
|
2313
|
+
create: create39,
|
|
2231
2314
|
defaultOptions: []
|
|
2232
2315
|
});
|
|
2233
|
-
function
|
|
2316
|
+
function create39(context) {
|
|
2234
2317
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2235
2318
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2236
2319
|
return {
|
|
@@ -2251,8 +2334,8 @@ function create37(context) {
|
|
|
2251
2334
|
}
|
|
2252
2335
|
};
|
|
2253
2336
|
}
|
|
2254
|
-
var
|
|
2255
|
-
var
|
|
2337
|
+
var RULE_NAME40 = "no-unsafe-component-will-receive-props";
|
|
2338
|
+
var RULE_FEATURES40 = [];
|
|
2256
2339
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2257
2340
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2258
2341
|
}
|
|
@@ -2261,18 +2344,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2261
2344
|
type: "problem",
|
|
2262
2345
|
docs: {
|
|
2263
2346
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2264
|
-
[Symbol.for("rule_features")]:
|
|
2347
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2265
2348
|
},
|
|
2266
2349
|
messages: {
|
|
2267
2350
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2268
2351
|
},
|
|
2269
2352
|
schema: []
|
|
2270
2353
|
},
|
|
2271
|
-
name:
|
|
2272
|
-
create:
|
|
2354
|
+
name: RULE_NAME40,
|
|
2355
|
+
create: create40,
|
|
2273
2356
|
defaultOptions: []
|
|
2274
2357
|
});
|
|
2275
|
-
function
|
|
2358
|
+
function create40(context) {
|
|
2276
2359
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2277
2360
|
return {};
|
|
2278
2361
|
}
|
|
@@ -2295,8 +2378,8 @@ function create38(context) {
|
|
|
2295
2378
|
}
|
|
2296
2379
|
};
|
|
2297
2380
|
}
|
|
2298
|
-
var
|
|
2299
|
-
var
|
|
2381
|
+
var RULE_NAME41 = "no-unsafe-component-will-update";
|
|
2382
|
+
var RULE_FEATURES41 = [];
|
|
2300
2383
|
function isUnsafeComponentWillUpdate(node) {
|
|
2301
2384
|
return AST11.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2302
2385
|
}
|
|
@@ -2305,18 +2388,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2305
2388
|
type: "problem",
|
|
2306
2389
|
docs: {
|
|
2307
2390
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2308
|
-
[Symbol.for("rule_features")]:
|
|
2391
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2309
2392
|
},
|
|
2310
2393
|
messages: {
|
|
2311
2394
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2312
2395
|
},
|
|
2313
2396
|
schema: []
|
|
2314
2397
|
},
|
|
2315
|
-
name:
|
|
2316
|
-
create:
|
|
2398
|
+
name: RULE_NAME41,
|
|
2399
|
+
create: create41,
|
|
2317
2400
|
defaultOptions: []
|
|
2318
2401
|
});
|
|
2319
|
-
function
|
|
2402
|
+
function create41(context) {
|
|
2320
2403
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2321
2404
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2322
2405
|
return {
|
|
@@ -2337,25 +2420,25 @@ function create39(context) {
|
|
|
2337
2420
|
}
|
|
2338
2421
|
};
|
|
2339
2422
|
}
|
|
2340
|
-
var
|
|
2341
|
-
var
|
|
2423
|
+
var RULE_NAME42 = "no-unstable-context-value";
|
|
2424
|
+
var RULE_FEATURES42 = [];
|
|
2342
2425
|
var no_unstable_context_value_default = createRule({
|
|
2343
2426
|
meta: {
|
|
2344
2427
|
type: "problem",
|
|
2345
2428
|
docs: {
|
|
2346
2429
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2347
|
-
[Symbol.for("rule_features")]:
|
|
2430
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2348
2431
|
},
|
|
2349
2432
|
messages: {
|
|
2350
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}}"
|
|
2351
2434
|
},
|
|
2352
2435
|
schema: []
|
|
2353
2436
|
},
|
|
2354
|
-
name:
|
|
2355
|
-
create:
|
|
2437
|
+
name: RULE_NAME42,
|
|
2438
|
+
create: create42,
|
|
2356
2439
|
defaultOptions: []
|
|
2357
2440
|
});
|
|
2358
|
-
function
|
|
2441
|
+
function create42(context) {
|
|
2359
2442
|
const { version: version2 } = getSettingsFromContext(context);
|
|
2360
2443
|
const isReact18OrBelow = compare(version2, "19.0.0", "<");
|
|
2361
2444
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2377,7 +2460,7 @@ function create40(context) {
|
|
|
2377
2460
|
if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2378
2461
|
const valueExpression = value.expression;
|
|
2379
2462
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2380
|
-
const construction =
|
|
2463
|
+
const construction = VAR2.getValueConstruction(valueExpression, initialScope);
|
|
2381
2464
|
if (construction == null) return;
|
|
2382
2465
|
if (isReactHookCall(construction.node)) {
|
|
2383
2466
|
return;
|
|
@@ -2410,25 +2493,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2410
2493
|
}
|
|
2411
2494
|
return false;
|
|
2412
2495
|
}
|
|
2413
|
-
var
|
|
2414
|
-
var
|
|
2496
|
+
var RULE_NAME43 = "no-unstable-default-props";
|
|
2497
|
+
var RULE_FEATURES43 = [];
|
|
2415
2498
|
var no_unstable_default_props_default = createRule({
|
|
2416
2499
|
meta: {
|
|
2417
2500
|
type: "problem",
|
|
2418
2501
|
docs: {
|
|
2419
2502
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2420
|
-
[Symbol.for("rule_features")]:
|
|
2503
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2421
2504
|
},
|
|
2422
2505
|
messages: {
|
|
2423
2506
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2424
2507
|
},
|
|
2425
2508
|
schema: []
|
|
2426
2509
|
},
|
|
2427
|
-
name:
|
|
2428
|
-
create:
|
|
2510
|
+
name: RULE_NAME43,
|
|
2511
|
+
create: create43,
|
|
2429
2512
|
defaultOptions: []
|
|
2430
2513
|
});
|
|
2431
|
-
function
|
|
2514
|
+
function create43(context) {
|
|
2432
2515
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2433
2516
|
const declarators = /* @__PURE__ */ new Map();
|
|
2434
2517
|
return {
|
|
@@ -2451,10 +2534,10 @@ function create41(context) {
|
|
|
2451
2534
|
const { value } = prop;
|
|
2452
2535
|
const { right } = value;
|
|
2453
2536
|
const initialScope = context.sourceCode.getScope(value);
|
|
2454
|
-
const construction =
|
|
2537
|
+
const construction = VAR2.getValueConstruction(
|
|
2455
2538
|
value,
|
|
2456
2539
|
initialScope,
|
|
2457
|
-
|
|
2540
|
+
VAR2.ValueConstructionHint.StrictCallExpression
|
|
2458
2541
|
);
|
|
2459
2542
|
if (construction == null) {
|
|
2460
2543
|
continue;
|
|
@@ -2484,8 +2567,8 @@ function create41(context) {
|
|
|
2484
2567
|
}
|
|
2485
2568
|
};
|
|
2486
2569
|
}
|
|
2487
|
-
var
|
|
2488
|
-
var
|
|
2570
|
+
var RULE_NAME44 = "no-unused-class-component-members";
|
|
2571
|
+
var RULE_FEATURES44 = [];
|
|
2489
2572
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2490
2573
|
"componentDidCatch",
|
|
2491
2574
|
"componentDidMount",
|
|
@@ -2511,18 +2594,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2511
2594
|
type: "problem",
|
|
2512
2595
|
docs: {
|
|
2513
2596
|
description: "Warns unused class component methods and properties.",
|
|
2514
|
-
[Symbol.for("rule_features")]:
|
|
2597
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2515
2598
|
},
|
|
2516
2599
|
messages: {
|
|
2517
2600
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2518
2601
|
},
|
|
2519
2602
|
schema: []
|
|
2520
2603
|
},
|
|
2521
|
-
name:
|
|
2522
|
-
create:
|
|
2604
|
+
name: RULE_NAME44,
|
|
2605
|
+
create: create44,
|
|
2523
2606
|
defaultOptions: []
|
|
2524
2607
|
});
|
|
2525
|
-
function
|
|
2608
|
+
function create44(context) {
|
|
2526
2609
|
const classEntries = [];
|
|
2527
2610
|
const methodEntries = [];
|
|
2528
2611
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2632,8 +2715,8 @@ function create42(context) {
|
|
|
2632
2715
|
}
|
|
2633
2716
|
};
|
|
2634
2717
|
}
|
|
2635
|
-
var
|
|
2636
|
-
var
|
|
2718
|
+
var RULE_NAME45 = "no-unused-state";
|
|
2719
|
+
var RULE_FEATURES45 = [];
|
|
2637
2720
|
function isKeyLiteral3(node, key) {
|
|
2638
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);
|
|
2639
2722
|
}
|
|
@@ -2642,18 +2725,18 @@ var no_unused_state_default = createRule({
|
|
|
2642
2725
|
type: "problem",
|
|
2643
2726
|
docs: {
|
|
2644
2727
|
description: "Warns unused class component state.",
|
|
2645
|
-
[Symbol.for("rule_features")]:
|
|
2728
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2646
2729
|
},
|
|
2647
2730
|
messages: {
|
|
2648
2731
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2649
2732
|
},
|
|
2650
2733
|
schema: []
|
|
2651
2734
|
},
|
|
2652
|
-
name:
|
|
2653
|
-
create:
|
|
2735
|
+
name: RULE_NAME45,
|
|
2736
|
+
create: create45,
|
|
2654
2737
|
defaultOptions: []
|
|
2655
2738
|
});
|
|
2656
|
-
function
|
|
2739
|
+
function create45(context) {
|
|
2657
2740
|
const classEntries = [];
|
|
2658
2741
|
const methodEntries = [];
|
|
2659
2742
|
const constructorEntries = [];
|
|
@@ -2787,8 +2870,8 @@ function create43(context) {
|
|
|
2787
2870
|
}
|
|
2788
2871
|
};
|
|
2789
2872
|
}
|
|
2790
|
-
var
|
|
2791
|
-
var
|
|
2873
|
+
var RULE_NAME46 = "no-use-context";
|
|
2874
|
+
var RULE_FEATURES46 = [
|
|
2792
2875
|
"MOD"
|
|
2793
2876
|
];
|
|
2794
2877
|
var no_use_context_default = createRule({
|
|
@@ -2796,7 +2879,7 @@ var no_use_context_default = createRule({
|
|
|
2796
2879
|
type: "problem",
|
|
2797
2880
|
docs: {
|
|
2798
2881
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2799
|
-
[Symbol.for("rule_features")]:
|
|
2882
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2800
2883
|
},
|
|
2801
2884
|
fixable: "code",
|
|
2802
2885
|
messages: {
|
|
@@ -2804,11 +2887,11 @@ var no_use_context_default = createRule({
|
|
|
2804
2887
|
},
|
|
2805
2888
|
schema: []
|
|
2806
2889
|
},
|
|
2807
|
-
name:
|
|
2808
|
-
create:
|
|
2890
|
+
name: RULE_NAME46,
|
|
2891
|
+
create: create46,
|
|
2809
2892
|
defaultOptions: []
|
|
2810
2893
|
});
|
|
2811
|
-
function
|
|
2894
|
+
function create46(context) {
|
|
2812
2895
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2813
2896
|
const settings4 = getSettingsFromContext(context);
|
|
2814
2897
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2886,25 +2969,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2886
2969
|
return tokens;
|
|
2887
2970
|
}
|
|
2888
2971
|
}
|
|
2889
|
-
var
|
|
2890
|
-
var
|
|
2972
|
+
var RULE_NAME47 = "no-useless-forward-ref";
|
|
2973
|
+
var RULE_FEATURES47 = [];
|
|
2891
2974
|
var no_useless_forward_ref_default = createRule({
|
|
2892
2975
|
meta: {
|
|
2893
2976
|
type: "problem",
|
|
2894
2977
|
docs: {
|
|
2895
2978
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2896
|
-
[Symbol.for("rule_features")]:
|
|
2979
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2897
2980
|
},
|
|
2898
2981
|
messages: {
|
|
2899
2982
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2900
2983
|
},
|
|
2901
2984
|
schema: []
|
|
2902
2985
|
},
|
|
2903
|
-
name:
|
|
2904
|
-
create:
|
|
2986
|
+
name: RULE_NAME47,
|
|
2987
|
+
create: create47,
|
|
2905
2988
|
defaultOptions: []
|
|
2906
2989
|
});
|
|
2907
|
-
function
|
|
2990
|
+
function create47(context) {
|
|
2908
2991
|
return {
|
|
2909
2992
|
CallExpression(node) {
|
|
2910
2993
|
if (!isForwardRefCall(context, node)) {
|
|
@@ -2925,7 +3008,7 @@ function create45(context) {
|
|
|
2925
3008
|
}
|
|
2926
3009
|
};
|
|
2927
3010
|
}
|
|
2928
|
-
var
|
|
3011
|
+
var RULE_NAME48 = "no-useless-fragment";
|
|
2929
3012
|
var defaultOptions = [{
|
|
2930
3013
|
allowExpressions: true
|
|
2931
3014
|
}];
|
|
@@ -2951,11 +3034,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2951
3034
|
}
|
|
2952
3035
|
}]
|
|
2953
3036
|
},
|
|
2954
|
-
name:
|
|
2955
|
-
create:
|
|
3037
|
+
name: RULE_NAME48,
|
|
3038
|
+
create: create48,
|
|
2956
3039
|
defaultOptions
|
|
2957
3040
|
});
|
|
2958
|
-
function
|
|
3041
|
+
function create48(context, [option]) {
|
|
2959
3042
|
const { allowExpressions = true } = option;
|
|
2960
3043
|
return {
|
|
2961
3044
|
JSXElement(node) {
|
|
@@ -3067,8 +3150,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3067
3150
|
}
|
|
3068
3151
|
return;
|
|
3069
3152
|
}
|
|
3070
|
-
var
|
|
3071
|
-
var
|
|
3153
|
+
var RULE_NAME49 = "prefer-destructuring-assignment";
|
|
3154
|
+
var RULE_FEATURES48 = [];
|
|
3072
3155
|
function isMemberExpressionWithObjectName(node) {
|
|
3073
3156
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3074
3157
|
}
|
|
@@ -3077,18 +3160,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3077
3160
|
type: "problem",
|
|
3078
3161
|
docs: {
|
|
3079
3162
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3080
|
-
[Symbol.for("rule_features")]:
|
|
3163
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3081
3164
|
},
|
|
3082
3165
|
messages: {
|
|
3083
3166
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3084
3167
|
},
|
|
3085
3168
|
schema: []
|
|
3086
3169
|
},
|
|
3087
|
-
name:
|
|
3088
|
-
create:
|
|
3170
|
+
name: RULE_NAME49,
|
|
3171
|
+
create: create49,
|
|
3089
3172
|
defaultOptions: []
|
|
3090
3173
|
});
|
|
3091
|
-
function
|
|
3174
|
+
function create49(context) {
|
|
3092
3175
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3093
3176
|
const memberExpressionWithNames = [];
|
|
3094
3177
|
return {
|
|
@@ -3148,8 +3231,8 @@ function create47(context) {
|
|
|
3148
3231
|
}
|
|
3149
3232
|
};
|
|
3150
3233
|
}
|
|
3151
|
-
var
|
|
3152
|
-
var
|
|
3234
|
+
var RULE_NAME50 = "prefer-react-namespace-import";
|
|
3235
|
+
var RULE_FEATURES49 = [
|
|
3153
3236
|
"FIX",
|
|
3154
3237
|
"EXP"
|
|
3155
3238
|
];
|
|
@@ -3158,7 +3241,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3158
3241
|
type: "problem",
|
|
3159
3242
|
docs: {
|
|
3160
3243
|
description: "Enforces React is imported via a namespace import.",
|
|
3161
|
-
[Symbol.for("rule_features")]:
|
|
3244
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3162
3245
|
},
|
|
3163
3246
|
fixable: "code",
|
|
3164
3247
|
messages: {
|
|
@@ -3166,11 +3249,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3166
3249
|
},
|
|
3167
3250
|
schema: []
|
|
3168
3251
|
},
|
|
3169
|
-
name:
|
|
3170
|
-
create:
|
|
3252
|
+
name: RULE_NAME50,
|
|
3253
|
+
create: create50,
|
|
3171
3254
|
defaultOptions: []
|
|
3172
3255
|
});
|
|
3173
|
-
function
|
|
3256
|
+
function create50(context) {
|
|
3174
3257
|
const { importSource } = getSettingsFromContext(context);
|
|
3175
3258
|
return {
|
|
3176
3259
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3203,8 +3286,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3203
3286
|
}
|
|
3204
3287
|
};
|
|
3205
3288
|
}
|
|
3206
|
-
var
|
|
3207
|
-
var
|
|
3289
|
+
var RULE_NAME51 = "prefer-read-only-props";
|
|
3290
|
+
var RULE_FEATURES50 = [
|
|
3208
3291
|
"TSC",
|
|
3209
3292
|
"EXP"
|
|
3210
3293
|
];
|
|
@@ -3213,18 +3296,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3213
3296
|
type: "problem",
|
|
3214
3297
|
docs: {
|
|
3215
3298
|
description: "Enforces read-only props in components.",
|
|
3216
|
-
[Symbol.for("rule_features")]:
|
|
3299
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3217
3300
|
},
|
|
3218
3301
|
messages: {
|
|
3219
3302
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3220
3303
|
},
|
|
3221
3304
|
schema: []
|
|
3222
3305
|
},
|
|
3223
|
-
name:
|
|
3224
|
-
create:
|
|
3306
|
+
name: RULE_NAME51,
|
|
3307
|
+
create: create51,
|
|
3225
3308
|
defaultOptions: []
|
|
3226
3309
|
});
|
|
3227
|
-
function
|
|
3310
|
+
function create51(context) {
|
|
3228
3311
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3229
3312
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3230
3313
|
return {
|
|
@@ -3254,8 +3337,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3254
3337
|
return true;
|
|
3255
3338
|
}
|
|
3256
3339
|
}
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3340
|
+
var RULE_NAME52 = "prefer-shorthand-boolean";
|
|
3341
|
+
var RULE_FEATURES51 = [
|
|
3259
3342
|
"FIX"
|
|
3260
3343
|
];
|
|
3261
3344
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3263,7 +3346,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3263
3346
|
type: "problem",
|
|
3264
3347
|
docs: {
|
|
3265
3348
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3266
|
-
[Symbol.for("rule_features")]:
|
|
3349
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3267
3350
|
},
|
|
3268
3351
|
fixable: "code",
|
|
3269
3352
|
messages: {
|
|
@@ -3271,11 +3354,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3271
3354
|
},
|
|
3272
3355
|
schema: []
|
|
3273
3356
|
},
|
|
3274
|
-
name:
|
|
3275
|
-
create:
|
|
3357
|
+
name: RULE_NAME52,
|
|
3358
|
+
create: create52,
|
|
3276
3359
|
defaultOptions: []
|
|
3277
3360
|
});
|
|
3278
|
-
function
|
|
3361
|
+
function create52(context) {
|
|
3279
3362
|
return {
|
|
3280
3363
|
JSXAttribute(node) {
|
|
3281
3364
|
const { value } = node;
|
|
@@ -3295,8 +3378,8 @@ function create50(context) {
|
|
|
3295
3378
|
}
|
|
3296
3379
|
};
|
|
3297
3380
|
}
|
|
3298
|
-
var
|
|
3299
|
-
var
|
|
3381
|
+
var RULE_NAME53 = "prefer-shorthand-fragment";
|
|
3382
|
+
var RULE_FEATURES52 = [
|
|
3300
3383
|
"FIX"
|
|
3301
3384
|
];
|
|
3302
3385
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3304,7 +3387,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3304
3387
|
type: "problem",
|
|
3305
3388
|
docs: {
|
|
3306
3389
|
description: "Enforces shorthand syntax for fragments.",
|
|
3307
|
-
[Symbol.for("rule_features")]:
|
|
3390
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3308
3391
|
},
|
|
3309
3392
|
fixable: "code",
|
|
3310
3393
|
messages: {
|
|
@@ -3312,11 +3395,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3312
3395
|
},
|
|
3313
3396
|
schema: []
|
|
3314
3397
|
},
|
|
3315
|
-
name:
|
|
3316
|
-
create:
|
|
3398
|
+
name: RULE_NAME53,
|
|
3399
|
+
create: create53,
|
|
3317
3400
|
defaultOptions: []
|
|
3318
3401
|
});
|
|
3319
|
-
function
|
|
3402
|
+
function create53(context) {
|
|
3320
3403
|
return {
|
|
3321
3404
|
JSXElement(node) {
|
|
3322
3405
|
if (!JSX8.isFragmentElement(node)) return;
|
|
@@ -3341,46 +3424,6 @@ function create51(context) {
|
|
|
3341
3424
|
}
|
|
3342
3425
|
};
|
|
3343
3426
|
}
|
|
3344
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3345
|
-
var RULE_FEATURES51 = [];
|
|
3346
|
-
var use_jsx_vars_default = createRule({
|
|
3347
|
-
meta: {
|
|
3348
|
-
type: "problem",
|
|
3349
|
-
docs: {
|
|
3350
|
-
description: "Marks variables used in JSX as used.",
|
|
3351
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3352
|
-
},
|
|
3353
|
-
messages: {
|
|
3354
|
-
useJsxVars: ""
|
|
3355
|
-
},
|
|
3356
|
-
schema: []
|
|
3357
|
-
},
|
|
3358
|
-
name: RULE_NAME52,
|
|
3359
|
-
create: create52,
|
|
3360
|
-
defaultOptions: []
|
|
3361
|
-
});
|
|
3362
|
-
function create52(context) {
|
|
3363
|
-
return {
|
|
3364
|
-
JSXOpeningElement(node) {
|
|
3365
|
-
switch (node.name.type) {
|
|
3366
|
-
case AST_NODE_TYPES.JSXIdentifier: {
|
|
3367
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3368
|
-
return;
|
|
3369
|
-
}
|
|
3370
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3371
|
-
break;
|
|
3372
|
-
}
|
|
3373
|
-
case AST_NODE_TYPES.JSXMemberExpression: {
|
|
3374
|
-
const { object } = node.name;
|
|
3375
|
-
if (object.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
3376
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3377
|
-
}
|
|
3378
|
-
break;
|
|
3379
|
-
}
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
};
|
|
3383
|
-
}
|
|
3384
3427
|
|
|
3385
3428
|
// src/plugin.ts
|
|
3386
3429
|
var plugin = {
|
|
@@ -3410,7 +3453,6 @@ var plugin = {
|
|
|
3410
3453
|
"no-create-ref": no_create_ref_default,
|
|
3411
3454
|
"no-default-props": no_default_props_default,
|
|
3412
3455
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3413
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3414
3456
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3415
3457
|
"no-forward-ref": no_forward_ref_default,
|
|
3416
3458
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3440,18 +3482,21 @@ var plugin = {
|
|
|
3440
3482
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3441
3483
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3442
3484
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3443
|
-
|
|
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,
|
|
3444
3489
|
// Part: deprecated rules
|
|
3445
3490
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3446
3491
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3447
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3448
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3449
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3450
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3451
3492
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3452
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,
|
|
3453
3496
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3454
|
-
"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
|
|
3455
3500
|
}
|
|
3456
3501
|
};
|
|
3457
3502
|
|