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.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
var shared = require('@eslint-react/shared');
|
|
4
4
|
var JSX8 = require('@eslint-react/jsx');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
|
+
var types = require('@typescript-eslint/types');
|
|
7
|
+
var VAR2 = require('@eslint-react/var');
|
|
6
8
|
var AST11 = require('@eslint-react/ast');
|
|
7
9
|
var core = require('@eslint-react/core');
|
|
8
10
|
var eff = require('@eslint-react/eff');
|
|
9
|
-
var types = require('@typescript-eslint/types');
|
|
10
11
|
var tsPattern = require('ts-pattern');
|
|
11
12
|
var kit = require('@eslint-react/kit');
|
|
12
13
|
var compareVersions = require('compare-versions');
|
|
13
|
-
var VAR = require('@eslint-react/var');
|
|
14
14
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
15
15
|
var tsApiUtils = require('ts-api-utils');
|
|
16
16
|
var ts = require('typescript');
|
|
@@ -37,8 +37,8 @@ function _interopNamespace(e) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
|
|
40
|
+
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
40
41
|
var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
41
|
-
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
42
42
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
43
43
|
|
|
44
44
|
var __defProp = Object.defineProperty;
|
|
@@ -56,6 +56,9 @@ __export(recommended_exports, {
|
|
|
56
56
|
});
|
|
57
57
|
var name = "react-x/recommended";
|
|
58
58
|
var rules = {
|
|
59
|
+
"react-x/jsx-no-duplicate-props": "warn",
|
|
60
|
+
"react-x/jsx-no-undef": "error",
|
|
61
|
+
"react-x/jsx-uses-vars": "warn",
|
|
59
62
|
"react-x/no-access-state-in-setstate": "error",
|
|
60
63
|
"react-x/no-array-index-key": "warn",
|
|
61
64
|
"react-x/no-children-count": "warn",
|
|
@@ -72,7 +75,6 @@ var rules = {
|
|
|
72
75
|
"react-x/no-create-ref": "error",
|
|
73
76
|
"react-x/no-default-props": "error",
|
|
74
77
|
"react-x/no-direct-mutation-state": "error",
|
|
75
|
-
"react-x/no-duplicate-jsx-props": "warn",
|
|
76
78
|
"react-x/no-duplicate-key": "warn",
|
|
77
79
|
"react-x/no-forward-ref": "warn",
|
|
78
80
|
"react-x/no-implicit-key": "warn",
|
|
@@ -92,8 +94,7 @@ var rules = {
|
|
|
92
94
|
"react-x/no-unused-class-component-members": "warn",
|
|
93
95
|
"react-x/no-unused-state": "warn",
|
|
94
96
|
"react-x/no-use-context": "warn",
|
|
95
|
-
"react-x/no-useless-forward-ref": "warn"
|
|
96
|
-
"react-x/use-jsx-vars": "warn"
|
|
97
|
+
"react-x/no-useless-forward-ref": "warn"
|
|
97
98
|
};
|
|
98
99
|
var settings = {
|
|
99
100
|
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
|
|
@@ -117,8 +118,9 @@ __export(recommended_typescript_exports, {
|
|
|
117
118
|
var name2 = "react-x/recommended-typescript";
|
|
118
119
|
var rules2 = {
|
|
119
120
|
...rules,
|
|
120
|
-
"react-x/no-duplicate-
|
|
121
|
-
"react-x/
|
|
121
|
+
"react-x/jsx-no-duplicate-props": "off",
|
|
122
|
+
"react-x/jsx-no-undef": "off",
|
|
123
|
+
"react-x/jsx-uses-vars": "off"
|
|
122
124
|
};
|
|
123
125
|
var settings2 = {
|
|
124
126
|
...settings
|
|
@@ -137,7 +139,7 @@ var settings3 = {
|
|
|
137
139
|
|
|
138
140
|
// package.json
|
|
139
141
|
var name4 = "eslint-plugin-react-x";
|
|
140
|
-
var version = "1.38.0-beta.
|
|
142
|
+
var version = "1.38.0-beta.8";
|
|
141
143
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
142
144
|
|
|
143
145
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -206,8 +208,131 @@ function create2(context) {
|
|
|
206
208
|
}
|
|
207
209
|
};
|
|
208
210
|
}
|
|
209
|
-
var RULE_NAME3 = "no-
|
|
211
|
+
var RULE_NAME3 = "jsx-no-duplicate-props";
|
|
210
212
|
var RULE_FEATURES3 = [];
|
|
213
|
+
var jsx_no_duplicate_props_default = createRule({
|
|
214
|
+
meta: {
|
|
215
|
+
type: "problem",
|
|
216
|
+
docs: {
|
|
217
|
+
description: "Disallow duplicate props in JSX elements.",
|
|
218
|
+
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
219
|
+
},
|
|
220
|
+
messages: {
|
|
221
|
+
jsxNoDuplicateProps: "This JSX property is assigned multiple times."
|
|
222
|
+
},
|
|
223
|
+
schema: []
|
|
224
|
+
},
|
|
225
|
+
name: RULE_NAME3,
|
|
226
|
+
create: create3,
|
|
227
|
+
defaultOptions: []
|
|
228
|
+
});
|
|
229
|
+
function create3(context) {
|
|
230
|
+
return {
|
|
231
|
+
JSXOpeningElement(node) {
|
|
232
|
+
const props = [];
|
|
233
|
+
for (const attr of node.attributes) {
|
|
234
|
+
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const name5 = attr.name.name;
|
|
238
|
+
if (typeof name5 !== "string") {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (!props.includes(name5)) {
|
|
242
|
+
props.push(name5);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
context.report({
|
|
246
|
+
messageId: "jsxNoDuplicateProps",
|
|
247
|
+
node: attr
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
var RULE_NAME4 = "jsx-no-undef";
|
|
254
|
+
var RULE_FEATURES4 = [];
|
|
255
|
+
var jsx_no_undef_default = createRule({
|
|
256
|
+
meta: {
|
|
257
|
+
type: "problem",
|
|
258
|
+
docs: {
|
|
259
|
+
description: "Disallow undefined variables in JSX.",
|
|
260
|
+
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
261
|
+
},
|
|
262
|
+
messages: {
|
|
263
|
+
jsxNoUndef: "JSX variable {{name}} is not defined."
|
|
264
|
+
},
|
|
265
|
+
schema: []
|
|
266
|
+
},
|
|
267
|
+
name: RULE_NAME4,
|
|
268
|
+
create: create4,
|
|
269
|
+
defaultOptions: []
|
|
270
|
+
});
|
|
271
|
+
function create4(context) {
|
|
272
|
+
return {
|
|
273
|
+
JSXIdentifier(node) {
|
|
274
|
+
if (node.name === "this") {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (/^[a-z]/u.test(node.name)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (node.parent.type === types.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
284
|
+
if (VAR2__namespace.findVariable(node.name, initialScope) == null) {
|
|
285
|
+
context.report({
|
|
286
|
+
messageId: "jsxNoUndef",
|
|
287
|
+
node,
|
|
288
|
+
data: { name: node.name }
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
var RULE_NAME5 = "jsx-uses-vars";
|
|
295
|
+
var RULE_FEATURES5 = [];
|
|
296
|
+
var jsx_uses_vars_default = createRule({
|
|
297
|
+
meta: {
|
|
298
|
+
type: "problem",
|
|
299
|
+
docs: {
|
|
300
|
+
description: "Marks variables used in JSX as used.",
|
|
301
|
+
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
302
|
+
},
|
|
303
|
+
messages: {
|
|
304
|
+
jsxUsesVars: "JSX variables should be marked as used."
|
|
305
|
+
},
|
|
306
|
+
schema: []
|
|
307
|
+
},
|
|
308
|
+
name: RULE_NAME5,
|
|
309
|
+
create: create5,
|
|
310
|
+
defaultOptions: []
|
|
311
|
+
});
|
|
312
|
+
function create5(context) {
|
|
313
|
+
return {
|
|
314
|
+
JSXOpeningElement(node) {
|
|
315
|
+
switch (node.name.type) {
|
|
316
|
+
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
317
|
+
if (/^[a-z]/u.test(node.name.name)) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
324
|
+
const { object } = node.name;
|
|
325
|
+
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
326
|
+
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
327
|
+
}
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
var RULE_NAME6 = "no-access-state-in-setstate";
|
|
335
|
+
var RULE_FEATURES6 = [];
|
|
211
336
|
function isKeyLiteral(node, key) {
|
|
212
337
|
return tsPattern.match(key).with({ type: types.AST_NODE_TYPES.Literal }, eff.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.constFalse);
|
|
213
338
|
}
|
|
@@ -216,18 +341,18 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
216
341
|
type: "problem",
|
|
217
342
|
docs: {
|
|
218
343
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
219
|
-
[Symbol.for("rule_features")]:
|
|
344
|
+
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
220
345
|
},
|
|
221
346
|
messages: {
|
|
222
347
|
noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead."
|
|
223
348
|
},
|
|
224
349
|
schema: []
|
|
225
350
|
},
|
|
226
|
-
name:
|
|
227
|
-
create:
|
|
351
|
+
name: RULE_NAME6,
|
|
352
|
+
create: create6,
|
|
228
353
|
defaultOptions: []
|
|
229
354
|
});
|
|
230
|
-
function
|
|
355
|
+
function create6(context) {
|
|
231
356
|
if (!context.sourceCode.text.includes("setState")) {
|
|
232
357
|
return {};
|
|
233
358
|
}
|
|
@@ -318,8 +443,8 @@ function create3(context) {
|
|
|
318
443
|
}
|
|
319
444
|
};
|
|
320
445
|
}
|
|
321
|
-
var
|
|
322
|
-
var
|
|
446
|
+
var RULE_NAME7 = "no-array-index-key";
|
|
447
|
+
var RULE_FEATURES7 = [];
|
|
323
448
|
var reactChildrenMethod = ["forEach", "map"];
|
|
324
449
|
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
325
450
|
["every", 1],
|
|
@@ -403,18 +528,18 @@ var no_array_index_key_default = createRule({
|
|
|
403
528
|
type: "problem",
|
|
404
529
|
docs: {
|
|
405
530
|
description: "Disallow an item's index in the array as its key.",
|
|
406
|
-
[Symbol.for("rule_features")]:
|
|
531
|
+
[Symbol.for("rule_features")]: RULE_FEATURES7
|
|
407
532
|
},
|
|
408
533
|
messages: {
|
|
409
534
|
noArrayIndexKey: "Do not use item index in the array as its key."
|
|
410
535
|
},
|
|
411
536
|
schema: []
|
|
412
537
|
},
|
|
413
|
-
name:
|
|
414
|
-
create:
|
|
538
|
+
name: RULE_NAME7,
|
|
539
|
+
create: create7,
|
|
415
540
|
defaultOptions: []
|
|
416
541
|
});
|
|
417
|
-
function
|
|
542
|
+
function create7(context) {
|
|
418
543
|
const report = kit.createReport(context);
|
|
419
544
|
const indexParamNames = [];
|
|
420
545
|
function isArrayIndex(node) {
|
|
@@ -512,25 +637,25 @@ function create4(context) {
|
|
|
512
637
|
}
|
|
513
638
|
};
|
|
514
639
|
}
|
|
515
|
-
var
|
|
516
|
-
var
|
|
640
|
+
var RULE_NAME8 = "no-children-count";
|
|
641
|
+
var RULE_FEATURES8 = [];
|
|
517
642
|
var no_children_count_default = createRule({
|
|
518
643
|
meta: {
|
|
519
644
|
type: "problem",
|
|
520
645
|
docs: {
|
|
521
646
|
description: "Disallow `Children.count`.",
|
|
522
|
-
[Symbol.for("rule_features")]:
|
|
647
|
+
[Symbol.for("rule_features")]: RULE_FEATURES8
|
|
523
648
|
},
|
|
524
649
|
messages: {
|
|
525
650
|
noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
526
651
|
},
|
|
527
652
|
schema: []
|
|
528
653
|
},
|
|
529
|
-
name:
|
|
530
|
-
create:
|
|
654
|
+
name: RULE_NAME8,
|
|
655
|
+
create: create8,
|
|
531
656
|
defaultOptions: []
|
|
532
657
|
});
|
|
533
|
-
function
|
|
658
|
+
function create8(context) {
|
|
534
659
|
return {
|
|
535
660
|
MemberExpression(node) {
|
|
536
661
|
if (core.isChildrenCount(context, node)) {
|
|
@@ -542,25 +667,25 @@ function create5(context) {
|
|
|
542
667
|
}
|
|
543
668
|
};
|
|
544
669
|
}
|
|
545
|
-
var
|
|
546
|
-
var
|
|
670
|
+
var RULE_NAME9 = "no-children-for-each";
|
|
671
|
+
var RULE_FEATURES9 = [];
|
|
547
672
|
var no_children_for_each_default = createRule({
|
|
548
673
|
meta: {
|
|
549
674
|
type: "problem",
|
|
550
675
|
docs: {
|
|
551
676
|
description: "Disallow 'Children.forEach'.",
|
|
552
|
-
[Symbol.for("rule_features")]:
|
|
677
|
+
[Symbol.for("rule_features")]: RULE_FEATURES9
|
|
553
678
|
},
|
|
554
679
|
messages: {
|
|
555
680
|
noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
556
681
|
},
|
|
557
682
|
schema: []
|
|
558
683
|
},
|
|
559
|
-
name:
|
|
560
|
-
create:
|
|
684
|
+
name: RULE_NAME9,
|
|
685
|
+
create: create9,
|
|
561
686
|
defaultOptions: []
|
|
562
687
|
});
|
|
563
|
-
function
|
|
688
|
+
function create9(context) {
|
|
564
689
|
return {
|
|
565
690
|
MemberExpression(node) {
|
|
566
691
|
if (core.isChildrenForEach(context, node)) {
|
|
@@ -572,25 +697,25 @@ function create6(context) {
|
|
|
572
697
|
}
|
|
573
698
|
};
|
|
574
699
|
}
|
|
575
|
-
var
|
|
576
|
-
var
|
|
700
|
+
var RULE_NAME10 = "no-children-map";
|
|
701
|
+
var RULE_FEATURES10 = [];
|
|
577
702
|
var no_children_map_default = createRule({
|
|
578
703
|
meta: {
|
|
579
704
|
type: "problem",
|
|
580
705
|
docs: {
|
|
581
706
|
description: "Disallow `Children.map`.",
|
|
582
|
-
[Symbol.for("rule_features")]:
|
|
707
|
+
[Symbol.for("rule_features")]: RULE_FEATURES10
|
|
583
708
|
},
|
|
584
709
|
messages: {
|
|
585
710
|
noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
586
711
|
},
|
|
587
712
|
schema: []
|
|
588
713
|
},
|
|
589
|
-
name:
|
|
590
|
-
create:
|
|
714
|
+
name: RULE_NAME10,
|
|
715
|
+
create: create10,
|
|
591
716
|
defaultOptions: []
|
|
592
717
|
});
|
|
593
|
-
function
|
|
718
|
+
function create10(context) {
|
|
594
719
|
return {
|
|
595
720
|
MemberExpression(node) {
|
|
596
721
|
if (core.isChildrenMap(context, node)) {
|
|
@@ -602,25 +727,25 @@ function create7(context) {
|
|
|
602
727
|
}
|
|
603
728
|
};
|
|
604
729
|
}
|
|
605
|
-
var
|
|
606
|
-
var
|
|
730
|
+
var RULE_NAME11 = "no-children-only";
|
|
731
|
+
var RULE_FEATURES11 = [];
|
|
607
732
|
var no_children_only_default = createRule({
|
|
608
733
|
meta: {
|
|
609
734
|
type: "problem",
|
|
610
735
|
docs: {
|
|
611
736
|
description: "Disallow `Children.only`.",
|
|
612
|
-
[Symbol.for("rule_features")]:
|
|
737
|
+
[Symbol.for("rule_features")]: RULE_FEATURES11
|
|
613
738
|
},
|
|
614
739
|
messages: {
|
|
615
740
|
noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
616
741
|
},
|
|
617
742
|
schema: []
|
|
618
743
|
},
|
|
619
|
-
name:
|
|
620
|
-
create:
|
|
744
|
+
name: RULE_NAME11,
|
|
745
|
+
create: create11,
|
|
621
746
|
defaultOptions: []
|
|
622
747
|
});
|
|
623
|
-
function
|
|
748
|
+
function create11(context) {
|
|
624
749
|
return {
|
|
625
750
|
MemberExpression(node) {
|
|
626
751
|
if (core.isChildrenOnly(context, node)) {
|
|
@@ -632,25 +757,25 @@ function create8(context) {
|
|
|
632
757
|
}
|
|
633
758
|
};
|
|
634
759
|
}
|
|
635
|
-
var
|
|
636
|
-
var
|
|
760
|
+
var RULE_NAME12 = "no-children-prop";
|
|
761
|
+
var RULE_FEATURES12 = [];
|
|
637
762
|
var no_children_prop_default = createRule({
|
|
638
763
|
meta: {
|
|
639
764
|
type: "problem",
|
|
640
765
|
docs: {
|
|
641
766
|
description: "Disallow passing `children` as a prop.",
|
|
642
|
-
[Symbol.for("rule_features")]:
|
|
767
|
+
[Symbol.for("rule_features")]: RULE_FEATURES12
|
|
643
768
|
},
|
|
644
769
|
messages: {
|
|
645
770
|
noChildrenProp: "Do not pass 'children' as props."
|
|
646
771
|
},
|
|
647
772
|
schema: []
|
|
648
773
|
},
|
|
649
|
-
name:
|
|
650
|
-
create:
|
|
774
|
+
name: RULE_NAME12,
|
|
775
|
+
create: create12,
|
|
651
776
|
defaultOptions: []
|
|
652
777
|
});
|
|
653
|
-
function
|
|
778
|
+
function create12(context) {
|
|
654
779
|
return {
|
|
655
780
|
JSXElement(node) {
|
|
656
781
|
const attribute = JSX8__namespace.getAttribute(
|
|
@@ -667,25 +792,25 @@ function create9(context) {
|
|
|
667
792
|
}
|
|
668
793
|
};
|
|
669
794
|
}
|
|
670
|
-
var
|
|
671
|
-
var
|
|
795
|
+
var RULE_NAME13 = "no-children-to-array";
|
|
796
|
+
var RULE_FEATURES13 = [];
|
|
672
797
|
var no_children_to_array_default = createRule({
|
|
673
798
|
meta: {
|
|
674
799
|
type: "problem",
|
|
675
800
|
docs: {
|
|
676
801
|
description: "Disallow `Children.toArray`.",
|
|
677
|
-
[Symbol.for("rule_features")]:
|
|
802
|
+
[Symbol.for("rule_features")]: RULE_FEATURES13
|
|
678
803
|
},
|
|
679
804
|
messages: {
|
|
680
805
|
noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
681
806
|
},
|
|
682
807
|
schema: []
|
|
683
808
|
},
|
|
684
|
-
name:
|
|
685
|
-
create:
|
|
809
|
+
name: RULE_NAME13,
|
|
810
|
+
create: create13,
|
|
686
811
|
defaultOptions: []
|
|
687
812
|
});
|
|
688
|
-
function
|
|
813
|
+
function create13(context) {
|
|
689
814
|
return {
|
|
690
815
|
MemberExpression(node) {
|
|
691
816
|
if (core.isChildrenToArray(context, node)) {
|
|
@@ -697,25 +822,25 @@ function create10(context) {
|
|
|
697
822
|
}
|
|
698
823
|
};
|
|
699
824
|
}
|
|
700
|
-
var
|
|
701
|
-
var
|
|
825
|
+
var RULE_NAME14 = "no-class-component";
|
|
826
|
+
var RULE_FEATURES14 = [];
|
|
702
827
|
var no_class_component_default = createRule({
|
|
703
828
|
meta: {
|
|
704
829
|
type: "problem",
|
|
705
830
|
docs: {
|
|
706
831
|
description: "Disallow class components.",
|
|
707
|
-
[Symbol.for("rule_features")]:
|
|
832
|
+
[Symbol.for("rule_features")]: RULE_FEATURES14
|
|
708
833
|
},
|
|
709
834
|
messages: {
|
|
710
835
|
noClassComponent: "Do not use class components. Use function components instead."
|
|
711
836
|
},
|
|
712
837
|
schema: []
|
|
713
838
|
},
|
|
714
|
-
name:
|
|
715
|
-
create:
|
|
839
|
+
name: RULE_NAME14,
|
|
840
|
+
create: create14,
|
|
716
841
|
defaultOptions: []
|
|
717
842
|
});
|
|
718
|
-
function
|
|
843
|
+
function create14(context) {
|
|
719
844
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
720
845
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
721
846
|
return {
|
|
@@ -737,25 +862,25 @@ function create11(context) {
|
|
|
737
862
|
}
|
|
738
863
|
};
|
|
739
864
|
}
|
|
740
|
-
var
|
|
741
|
-
var
|
|
865
|
+
var RULE_NAME15 = "no-clone-element";
|
|
866
|
+
var RULE_FEATURES15 = [];
|
|
742
867
|
var no_clone_element_default = createRule({
|
|
743
868
|
meta: {
|
|
744
869
|
type: "problem",
|
|
745
870
|
docs: {
|
|
746
871
|
description: "Disallow `cloneElement`.",
|
|
747
|
-
[Symbol.for("rule_features")]:
|
|
872
|
+
[Symbol.for("rule_features")]: RULE_FEATURES15
|
|
748
873
|
},
|
|
749
874
|
messages: {
|
|
750
875
|
noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead."
|
|
751
876
|
},
|
|
752
877
|
schema: []
|
|
753
878
|
},
|
|
754
|
-
name:
|
|
755
|
-
create:
|
|
879
|
+
name: RULE_NAME15,
|
|
880
|
+
create: create15,
|
|
756
881
|
defaultOptions: []
|
|
757
882
|
});
|
|
758
|
-
function
|
|
883
|
+
function create15(context) {
|
|
759
884
|
return {
|
|
760
885
|
CallExpression(node) {
|
|
761
886
|
if (!core.isCloneElementCall(context, node)) {
|
|
@@ -768,25 +893,25 @@ function create12(context) {
|
|
|
768
893
|
}
|
|
769
894
|
};
|
|
770
895
|
}
|
|
771
|
-
var
|
|
772
|
-
var
|
|
896
|
+
var RULE_NAME16 = "no-comment-textnodes";
|
|
897
|
+
var RULE_FEATURES16 = [];
|
|
773
898
|
var no_comment_textnodes_default = createRule({
|
|
774
899
|
meta: {
|
|
775
900
|
type: "problem",
|
|
776
901
|
docs: {
|
|
777
902
|
description: "Prevents comments from being inserted as text nodes.",
|
|
778
|
-
[Symbol.for("rule_features")]:
|
|
903
|
+
[Symbol.for("rule_features")]: RULE_FEATURES16
|
|
779
904
|
},
|
|
780
905
|
messages: {
|
|
781
906
|
noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
|
|
782
907
|
},
|
|
783
908
|
schema: []
|
|
784
909
|
},
|
|
785
|
-
name:
|
|
786
|
-
create:
|
|
910
|
+
name: RULE_NAME16,
|
|
911
|
+
create: create16,
|
|
787
912
|
defaultOptions: []
|
|
788
913
|
});
|
|
789
|
-
function
|
|
914
|
+
function create16(context) {
|
|
790
915
|
function hasCommentLike(node) {
|
|
791
916
|
if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
|
|
792
917
|
return false;
|
|
@@ -814,8 +939,8 @@ function create13(context) {
|
|
|
814
939
|
Literal: visitorFunction
|
|
815
940
|
};
|
|
816
941
|
}
|
|
817
|
-
var
|
|
818
|
-
var
|
|
942
|
+
var RULE_NAME17 = "no-complex-conditional-rendering";
|
|
943
|
+
var RULE_FEATURES17 = [
|
|
819
944
|
"EXP"
|
|
820
945
|
];
|
|
821
946
|
var no_complex_conditional_rendering_default = createRule({
|
|
@@ -823,18 +948,18 @@ var no_complex_conditional_rendering_default = createRule({
|
|
|
823
948
|
type: "problem",
|
|
824
949
|
docs: {
|
|
825
950
|
description: "Disallow complex conditional rendering in JSX expressions.",
|
|
826
|
-
[Symbol.for("rule_features")]:
|
|
951
|
+
[Symbol.for("rule_features")]: RULE_FEATURES17
|
|
827
952
|
},
|
|
828
953
|
messages: {
|
|
829
954
|
noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
|
|
830
955
|
},
|
|
831
956
|
schema: []
|
|
832
957
|
},
|
|
833
|
-
name:
|
|
834
|
-
create:
|
|
958
|
+
name: RULE_NAME17,
|
|
959
|
+
create: create17,
|
|
835
960
|
defaultOptions: []
|
|
836
961
|
});
|
|
837
|
-
function
|
|
962
|
+
function create17(context) {
|
|
838
963
|
const visitorFunction = (node) => {
|
|
839
964
|
const jsxExpContainer = node.parent?.parent;
|
|
840
965
|
if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
|
|
@@ -859,8 +984,8 @@ function create14(context) {
|
|
|
859
984
|
"JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
|
|
860
985
|
};
|
|
861
986
|
}
|
|
862
|
-
var
|
|
863
|
-
var
|
|
987
|
+
var RULE_NAME18 = "no-component-will-mount";
|
|
988
|
+
var RULE_FEATURES18 = [
|
|
864
989
|
"MOD"
|
|
865
990
|
];
|
|
866
991
|
function isComponentWillMount(node) {
|
|
@@ -871,7 +996,7 @@ var no_component_will_mount_default = createRule({
|
|
|
871
996
|
type: "problem",
|
|
872
997
|
docs: {
|
|
873
998
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
874
|
-
[Symbol.for("rule_features")]:
|
|
999
|
+
[Symbol.for("rule_features")]: RULE_FEATURES18
|
|
875
1000
|
},
|
|
876
1001
|
fixable: "code",
|
|
877
1002
|
messages: {
|
|
@@ -879,11 +1004,11 @@ var no_component_will_mount_default = createRule({
|
|
|
879
1004
|
},
|
|
880
1005
|
schema: []
|
|
881
1006
|
},
|
|
882
|
-
name:
|
|
883
|
-
create:
|
|
1007
|
+
name: RULE_NAME18,
|
|
1008
|
+
create: create18,
|
|
884
1009
|
defaultOptions: []
|
|
885
1010
|
});
|
|
886
|
-
function
|
|
1011
|
+
function create18(context) {
|
|
887
1012
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
888
1013
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
889
1014
|
return {
|
|
@@ -910,8 +1035,8 @@ function create15(context) {
|
|
|
910
1035
|
}
|
|
911
1036
|
};
|
|
912
1037
|
}
|
|
913
|
-
var
|
|
914
|
-
var
|
|
1038
|
+
var RULE_NAME19 = "no-component-will-receive-props";
|
|
1039
|
+
var RULE_FEATURES19 = [
|
|
915
1040
|
"MOD"
|
|
916
1041
|
];
|
|
917
1042
|
function isComponentWillUpdate(node) {
|
|
@@ -922,7 +1047,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
922
1047
|
type: "problem",
|
|
923
1048
|
docs: {
|
|
924
1049
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
925
|
-
[Symbol.for("rule_features")]:
|
|
1050
|
+
[Symbol.for("rule_features")]: RULE_FEATURES19
|
|
926
1051
|
},
|
|
927
1052
|
fixable: "code",
|
|
928
1053
|
messages: {
|
|
@@ -930,11 +1055,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
930
1055
|
},
|
|
931
1056
|
schema: []
|
|
932
1057
|
},
|
|
933
|
-
name:
|
|
934
|
-
create:
|
|
1058
|
+
name: RULE_NAME19,
|
|
1059
|
+
create: create19,
|
|
935
1060
|
defaultOptions: []
|
|
936
1061
|
});
|
|
937
|
-
function
|
|
1062
|
+
function create19(context) {
|
|
938
1063
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
939
1064
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
940
1065
|
return {
|
|
@@ -961,8 +1086,8 @@ function create16(context) {
|
|
|
961
1086
|
}
|
|
962
1087
|
};
|
|
963
1088
|
}
|
|
964
|
-
var
|
|
965
|
-
var
|
|
1089
|
+
var RULE_NAME20 = "no-component-will-update";
|
|
1090
|
+
var RULE_FEATURES20 = [
|
|
966
1091
|
"MOD"
|
|
967
1092
|
];
|
|
968
1093
|
function isComponentWillUpdate2(node) {
|
|
@@ -973,7 +1098,7 @@ var no_component_will_update_default = createRule({
|
|
|
973
1098
|
type: "problem",
|
|
974
1099
|
docs: {
|
|
975
1100
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
976
|
-
[Symbol.for("rule_features")]:
|
|
1101
|
+
[Symbol.for("rule_features")]: RULE_FEATURES20
|
|
977
1102
|
},
|
|
978
1103
|
fixable: "code",
|
|
979
1104
|
messages: {
|
|
@@ -981,11 +1106,11 @@ var no_component_will_update_default = createRule({
|
|
|
981
1106
|
},
|
|
982
1107
|
schema: []
|
|
983
1108
|
},
|
|
984
|
-
name:
|
|
985
|
-
create:
|
|
1109
|
+
name: RULE_NAME20,
|
|
1110
|
+
create: create20,
|
|
986
1111
|
defaultOptions: []
|
|
987
1112
|
});
|
|
988
|
-
function
|
|
1113
|
+
function create20(context) {
|
|
989
1114
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
990
1115
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
991
1116
|
return {
|
|
@@ -1012,8 +1137,8 @@ function create17(context) {
|
|
|
1012
1137
|
}
|
|
1013
1138
|
};
|
|
1014
1139
|
}
|
|
1015
|
-
var
|
|
1016
|
-
var
|
|
1140
|
+
var RULE_NAME21 = "no-context-provider";
|
|
1141
|
+
var RULE_FEATURES21 = [
|
|
1017
1142
|
"MOD"
|
|
1018
1143
|
];
|
|
1019
1144
|
var no_context_provider_default = createRule({
|
|
@@ -1021,7 +1146,7 @@ var no_context_provider_default = createRule({
|
|
|
1021
1146
|
type: "problem",
|
|
1022
1147
|
docs: {
|
|
1023
1148
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1024
|
-
[Symbol.for("rule_features")]:
|
|
1149
|
+
[Symbol.for("rule_features")]: RULE_FEATURES21
|
|
1025
1150
|
},
|
|
1026
1151
|
fixable: "code",
|
|
1027
1152
|
messages: {
|
|
@@ -1029,11 +1154,11 @@ var no_context_provider_default = createRule({
|
|
|
1029
1154
|
},
|
|
1030
1155
|
schema: []
|
|
1031
1156
|
},
|
|
1032
|
-
name:
|
|
1033
|
-
create:
|
|
1157
|
+
name: RULE_NAME21,
|
|
1158
|
+
create: create21,
|
|
1034
1159
|
defaultOptions: []
|
|
1035
1160
|
});
|
|
1036
|
-
function
|
|
1161
|
+
function create21(context) {
|
|
1037
1162
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1038
1163
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1039
1164
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
@@ -1065,25 +1190,25 @@ function create18(context) {
|
|
|
1065
1190
|
}
|
|
1066
1191
|
};
|
|
1067
1192
|
}
|
|
1068
|
-
var
|
|
1069
|
-
var
|
|
1193
|
+
var RULE_NAME22 = "no-create-ref";
|
|
1194
|
+
var RULE_FEATURES22 = [];
|
|
1070
1195
|
var no_create_ref_default = createRule({
|
|
1071
1196
|
meta: {
|
|
1072
1197
|
type: "problem",
|
|
1073
1198
|
docs: {
|
|
1074
1199
|
description: "Disallow `createRef` in function components.",
|
|
1075
|
-
[Symbol.for("rule_features")]:
|
|
1200
|
+
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1076
1201
|
},
|
|
1077
1202
|
messages: {
|
|
1078
1203
|
noCreateRef: "[Deprecated] Use 'useRef' instead."
|
|
1079
1204
|
},
|
|
1080
1205
|
schema: []
|
|
1081
1206
|
},
|
|
1082
|
-
name:
|
|
1083
|
-
create:
|
|
1207
|
+
name: RULE_NAME22,
|
|
1208
|
+
create: create22,
|
|
1084
1209
|
defaultOptions: []
|
|
1085
1210
|
});
|
|
1086
|
-
function
|
|
1211
|
+
function create22(context) {
|
|
1087
1212
|
return {
|
|
1088
1213
|
CallExpression(node) {
|
|
1089
1214
|
if (core.isCreateRefCall(context, node) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
|
|
@@ -1092,25 +1217,25 @@ function create19(context) {
|
|
|
1092
1217
|
}
|
|
1093
1218
|
};
|
|
1094
1219
|
}
|
|
1095
|
-
var
|
|
1096
|
-
var
|
|
1220
|
+
var RULE_NAME23 = "no-default-props";
|
|
1221
|
+
var RULE_FEATURES23 = [];
|
|
1097
1222
|
var no_default_props_default = createRule({
|
|
1098
1223
|
meta: {
|
|
1099
1224
|
type: "problem",
|
|
1100
1225
|
docs: {
|
|
1101
1226
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1102
|
-
[Symbol.for("rule_features")]:
|
|
1227
|
+
[Symbol.for("rule_features")]: RULE_FEATURES23
|
|
1103
1228
|
},
|
|
1104
1229
|
messages: {
|
|
1105
1230
|
noDefaultProps: "[Deprecated] Use ES6 default parameters instead."
|
|
1106
1231
|
},
|
|
1107
1232
|
schema: []
|
|
1108
1233
|
},
|
|
1109
|
-
name:
|
|
1110
|
-
create:
|
|
1234
|
+
name: RULE_NAME23,
|
|
1235
|
+
create: create23,
|
|
1111
1236
|
defaultOptions: []
|
|
1112
1237
|
});
|
|
1113
|
-
function
|
|
1238
|
+
function create23(context) {
|
|
1114
1239
|
if (!context.sourceCode.text.includes("defaultProps")) return {};
|
|
1115
1240
|
return {
|
|
1116
1241
|
AssignmentExpression(node) {
|
|
@@ -1127,8 +1252,8 @@ function create20(context) {
|
|
|
1127
1252
|
if (!core.isComponentNameLoose(object.name)) {
|
|
1128
1253
|
return;
|
|
1129
1254
|
}
|
|
1130
|
-
const variable =
|
|
1131
|
-
const variableNode =
|
|
1255
|
+
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1256
|
+
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
1132
1257
|
if (variableNode == null) return;
|
|
1133
1258
|
if (!AST11__namespace.isFunction(variableNode) && !core.isClassComponent(variableNode)) return;
|
|
1134
1259
|
context.report({ messageId: "noDefaultProps", node: property });
|
|
@@ -1144,8 +1269,8 @@ function create20(context) {
|
|
|
1144
1269
|
}
|
|
1145
1270
|
};
|
|
1146
1271
|
}
|
|
1147
|
-
var
|
|
1148
|
-
var
|
|
1272
|
+
var RULE_NAME24 = "no-direct-mutation-state";
|
|
1273
|
+
var RULE_FEATURES24 = [];
|
|
1149
1274
|
function isConstructorFunction(node) {
|
|
1150
1275
|
return AST11__namespace.isOneOf([types.AST_NODE_TYPES.FunctionDeclaration, types.AST_NODE_TYPES.FunctionExpression])(node) && AST11__namespace.isMethodOrProperty(node.parent) && node.parent.key.type === types.AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1151
1276
|
}
|
|
@@ -1154,18 +1279,18 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1154
1279
|
type: "problem",
|
|
1155
1280
|
docs: {
|
|
1156
1281
|
description: "Disallow direct mutation of `this.state`.",
|
|
1157
|
-
[Symbol.for("rule_features")]:
|
|
1282
|
+
[Symbol.for("rule_features")]: RULE_FEATURES24
|
|
1158
1283
|
},
|
|
1159
1284
|
messages: {
|
|
1160
1285
|
noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead."
|
|
1161
1286
|
},
|
|
1162
1287
|
schema: []
|
|
1163
1288
|
},
|
|
1164
|
-
name:
|
|
1165
|
-
create:
|
|
1289
|
+
name: RULE_NAME24,
|
|
1290
|
+
create: create24,
|
|
1166
1291
|
defaultOptions: []
|
|
1167
1292
|
});
|
|
1168
|
-
function
|
|
1293
|
+
function create24(context) {
|
|
1169
1294
|
return {
|
|
1170
1295
|
AssignmentExpression(node) {
|
|
1171
1296
|
if (!core.isAssignmentToThisState(node)) return;
|
|
@@ -1186,67 +1311,25 @@ function create21(context) {
|
|
|
1186
1311
|
}
|
|
1187
1312
|
};
|
|
1188
1313
|
}
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1191
|
-
var no_duplicate_jsx_props_default = createRule({
|
|
1192
|
-
meta: {
|
|
1193
|
-
type: "problem",
|
|
1194
|
-
docs: {
|
|
1195
|
-
description: "Disallow duplicate props in JSX elements.",
|
|
1196
|
-
[Symbol.for("rule_features")]: RULE_FEATURES22
|
|
1197
|
-
},
|
|
1198
|
-
messages: {
|
|
1199
|
-
noDuplicateJsxProps: "This JSX property is assigned multiple times."
|
|
1200
|
-
},
|
|
1201
|
-
schema: []
|
|
1202
|
-
},
|
|
1203
|
-
name: RULE_NAME22,
|
|
1204
|
-
create: create22,
|
|
1205
|
-
defaultOptions: []
|
|
1206
|
-
});
|
|
1207
|
-
function create22(context) {
|
|
1208
|
-
return {
|
|
1209
|
-
JSXOpeningElement(node) {
|
|
1210
|
-
const props = [];
|
|
1211
|
-
for (const attr of node.attributes) {
|
|
1212
|
-
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
const name5 = attr.name.name;
|
|
1216
|
-
if (typeof name5 !== "string") {
|
|
1217
|
-
continue;
|
|
1218
|
-
}
|
|
1219
|
-
if (!props.includes(name5)) {
|
|
1220
|
-
props.push(name5);
|
|
1221
|
-
continue;
|
|
1222
|
-
}
|
|
1223
|
-
context.report({
|
|
1224
|
-
messageId: "noDuplicateJsxProps",
|
|
1225
|
-
node: attr
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
var RULE_NAME23 = "no-duplicate-key";
|
|
1232
|
-
var RULE_FEATURES23 = [];
|
|
1314
|
+
var RULE_NAME25 = "no-duplicate-key";
|
|
1315
|
+
var RULE_FEATURES25 = [];
|
|
1233
1316
|
var no_duplicate_key_default = createRule({
|
|
1234
1317
|
meta: {
|
|
1235
1318
|
type: "problem",
|
|
1236
1319
|
docs: {
|
|
1237
1320
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1238
|
-
[Symbol.for("rule_features")]:
|
|
1321
|
+
[Symbol.for("rule_features")]: RULE_FEATURES25
|
|
1239
1322
|
},
|
|
1240
1323
|
messages: {
|
|
1241
1324
|
noDuplicateKey: "A key must be unique. '{{value}}' is duplicated."
|
|
1242
1325
|
},
|
|
1243
1326
|
schema: []
|
|
1244
1327
|
},
|
|
1245
|
-
name:
|
|
1246
|
-
create:
|
|
1328
|
+
name: RULE_NAME25,
|
|
1329
|
+
create: create25,
|
|
1247
1330
|
defaultOptions: []
|
|
1248
1331
|
});
|
|
1249
|
-
function
|
|
1332
|
+
function create25(context) {
|
|
1250
1333
|
if (!context.sourceCode.getText().includes("key=")) {
|
|
1251
1334
|
return {};
|
|
1252
1335
|
}
|
|
@@ -1310,8 +1393,8 @@ function create23(context) {
|
|
|
1310
1393
|
}
|
|
1311
1394
|
};
|
|
1312
1395
|
}
|
|
1313
|
-
var
|
|
1314
|
-
var
|
|
1396
|
+
var RULE_NAME26 = "no-forward-ref";
|
|
1397
|
+
var RULE_FEATURES26 = [
|
|
1315
1398
|
"MOD"
|
|
1316
1399
|
];
|
|
1317
1400
|
var no_forward_ref_default = createRule({
|
|
@@ -1319,7 +1402,7 @@ var no_forward_ref_default = createRule({
|
|
|
1319
1402
|
type: "problem",
|
|
1320
1403
|
docs: {
|
|
1321
1404
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1322
|
-
[Symbol.for("rule_features")]:
|
|
1405
|
+
[Symbol.for("rule_features")]: RULE_FEATURES26
|
|
1323
1406
|
},
|
|
1324
1407
|
fixable: "code",
|
|
1325
1408
|
messages: {
|
|
@@ -1327,11 +1410,11 @@ var no_forward_ref_default = createRule({
|
|
|
1327
1410
|
},
|
|
1328
1411
|
schema: []
|
|
1329
1412
|
},
|
|
1330
|
-
name:
|
|
1331
|
-
create:
|
|
1413
|
+
name: RULE_NAME26,
|
|
1414
|
+
create: create26,
|
|
1332
1415
|
defaultOptions: []
|
|
1333
1416
|
});
|
|
1334
|
-
function
|
|
1417
|
+
function create26(context) {
|
|
1335
1418
|
if (!context.sourceCode.text.includes("forwardRef")) {
|
|
1336
1419
|
return {};
|
|
1337
1420
|
}
|
|
@@ -1419,8 +1502,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1419
1502
|
...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]
|
|
1420
1503
|
];
|
|
1421
1504
|
}
|
|
1422
|
-
var
|
|
1423
|
-
var
|
|
1505
|
+
var RULE_NAME27 = "no-implicit-key";
|
|
1506
|
+
var RULE_FEATURES27 = [
|
|
1424
1507
|
"EXP"
|
|
1425
1508
|
];
|
|
1426
1509
|
var no_implicit_key_default = createRule({
|
|
@@ -1428,18 +1511,18 @@ var no_implicit_key_default = createRule({
|
|
|
1428
1511
|
type: "problem",
|
|
1429
1512
|
docs: {
|
|
1430
1513
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1431
|
-
[Symbol.for("rule_features")]:
|
|
1514
|
+
[Symbol.for("rule_features")]: RULE_FEATURES27
|
|
1432
1515
|
},
|
|
1433
1516
|
messages: {
|
|
1434
1517
|
noImplicitKey: "Do not use implicit 'key' props."
|
|
1435
1518
|
},
|
|
1436
1519
|
schema: []
|
|
1437
1520
|
},
|
|
1438
|
-
name:
|
|
1439
|
-
create:
|
|
1521
|
+
name: RULE_NAME27,
|
|
1522
|
+
create: create27,
|
|
1440
1523
|
defaultOptions: []
|
|
1441
1524
|
});
|
|
1442
|
-
function
|
|
1525
|
+
function create27(context) {
|
|
1443
1526
|
return {
|
|
1444
1527
|
JSXOpeningElement(node) {
|
|
1445
1528
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1453,8 +1536,8 @@ function create25(context) {
|
|
|
1453
1536
|
}
|
|
1454
1537
|
};
|
|
1455
1538
|
}
|
|
1456
|
-
var
|
|
1457
|
-
var
|
|
1539
|
+
var RULE_NAME28 = "no-leaked-conditional-rendering";
|
|
1540
|
+
var RULE_FEATURES28 = [
|
|
1458
1541
|
"TSC"
|
|
1459
1542
|
];
|
|
1460
1543
|
var tsHelpers = {
|
|
@@ -1540,18 +1623,18 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1540
1623
|
type: "problem",
|
|
1541
1624
|
docs: {
|
|
1542
1625
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1543
|
-
[Symbol.for("rule_features")]:
|
|
1626
|
+
[Symbol.for("rule_features")]: RULE_FEATURES28
|
|
1544
1627
|
},
|
|
1545
1628
|
messages: {
|
|
1546
1629
|
noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes."
|
|
1547
1630
|
},
|
|
1548
1631
|
schema: []
|
|
1549
1632
|
},
|
|
1550
|
-
name:
|
|
1551
|
-
create:
|
|
1633
|
+
name: RULE_NAME28,
|
|
1634
|
+
create: create28,
|
|
1552
1635
|
defaultOptions: []
|
|
1553
1636
|
});
|
|
1554
|
-
function
|
|
1637
|
+
function create28(context) {
|
|
1555
1638
|
if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
|
|
1556
1639
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1557
1640
|
const allowedVariants = [
|
|
@@ -1575,7 +1658,7 @@ function create26(context) {
|
|
|
1575
1658
|
return getReportDescriptor(right);
|
|
1576
1659
|
}
|
|
1577
1660
|
const initialScope = context.sourceCode.getScope(left);
|
|
1578
|
-
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" ||
|
|
1661
|
+
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR2__namespace.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1579
1662
|
if (isLeftNan) {
|
|
1580
1663
|
return {
|
|
1581
1664
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1597,7 +1680,7 @@ function create26(context) {
|
|
|
1597
1680
|
}).with({ type: types.AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
|
|
1598
1681
|
return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
|
|
1599
1682
|
}).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
1600
|
-
const variable =
|
|
1683
|
+
const variable = VAR2__namespace.findVariable(n.name, context.sourceCode.getScope(n));
|
|
1601
1684
|
const variableDefNode = variable?.defs.at(0)?.node;
|
|
1602
1685
|
return tsPattern.match(variableDefNode).with({ init: tsPattern.P.select({ type: tsPattern.P.not(types.AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => eff._);
|
|
1603
1686
|
}).otherwise(() => eff._);
|
|
@@ -1608,25 +1691,25 @@ function create26(context) {
|
|
|
1608
1691
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
1609
1692
|
};
|
|
1610
1693
|
}
|
|
1611
|
-
var
|
|
1612
|
-
var
|
|
1694
|
+
var RULE_NAME29 = "no-missing-component-display-name";
|
|
1695
|
+
var RULE_FEATURES29 = [];
|
|
1613
1696
|
var no_missing_component_display_name_default = createRule({
|
|
1614
1697
|
meta: {
|
|
1615
1698
|
type: "problem",
|
|
1616
1699
|
docs: {
|
|
1617
1700
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1618
|
-
[Symbol.for("rule_features")]:
|
|
1701
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1619
1702
|
},
|
|
1620
1703
|
messages: {
|
|
1621
1704
|
noMissingComponentDisplayName: "Add missing 'displayName' for component."
|
|
1622
1705
|
},
|
|
1623
1706
|
schema: []
|
|
1624
1707
|
},
|
|
1625
|
-
name:
|
|
1626
|
-
create:
|
|
1708
|
+
name: RULE_NAME29,
|
|
1709
|
+
create: create29,
|
|
1627
1710
|
defaultOptions: []
|
|
1628
1711
|
});
|
|
1629
|
-
function
|
|
1712
|
+
function create29(context) {
|
|
1630
1713
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1631
1714
|
const {
|
|
1632
1715
|
ctx,
|
|
@@ -1661,25 +1744,25 @@ function create27(context) {
|
|
|
1661
1744
|
}
|
|
1662
1745
|
};
|
|
1663
1746
|
}
|
|
1664
|
-
var
|
|
1665
|
-
var
|
|
1747
|
+
var RULE_NAME30 = "no-missing-context-display-name";
|
|
1748
|
+
var RULE_FEATURES30 = [];
|
|
1666
1749
|
var no_missing_context_display_name_default = createRule({
|
|
1667
1750
|
meta: {
|
|
1668
1751
|
type: "problem",
|
|
1669
1752
|
docs: {
|
|
1670
1753
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1671
|
-
[Symbol.for("rule_features")]:
|
|
1754
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1672
1755
|
},
|
|
1673
1756
|
messages: {
|
|
1674
1757
|
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1675
1758
|
},
|
|
1676
1759
|
schema: []
|
|
1677
1760
|
},
|
|
1678
|
-
name:
|
|
1679
|
-
create:
|
|
1761
|
+
name: RULE_NAME30,
|
|
1762
|
+
create: create30,
|
|
1680
1763
|
defaultOptions: []
|
|
1681
1764
|
});
|
|
1682
|
-
function
|
|
1765
|
+
function create30(context) {
|
|
1683
1766
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1684
1767
|
const createCalls = [];
|
|
1685
1768
|
const displayNameAssignments = [];
|
|
@@ -1717,14 +1800,14 @@ function create28(context) {
|
|
|
1717
1800
|
}
|
|
1718
1801
|
};
|
|
1719
1802
|
}
|
|
1720
|
-
var
|
|
1721
|
-
var
|
|
1803
|
+
var RULE_NAME31 = "no-missing-key";
|
|
1804
|
+
var RULE_FEATURES31 = [];
|
|
1722
1805
|
var no_missing_key_default = createRule({
|
|
1723
1806
|
meta: {
|
|
1724
1807
|
type: "problem",
|
|
1725
1808
|
docs: {
|
|
1726
1809
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1727
|
-
[Symbol.for("rule_features")]:
|
|
1810
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1728
1811
|
},
|
|
1729
1812
|
messages: {
|
|
1730
1813
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1732,11 +1815,11 @@ var no_missing_key_default = createRule({
|
|
|
1732
1815
|
},
|
|
1733
1816
|
schema: []
|
|
1734
1817
|
},
|
|
1735
|
-
name:
|
|
1736
|
-
create:
|
|
1818
|
+
name: RULE_NAME31,
|
|
1819
|
+
create: create31,
|
|
1737
1820
|
defaultOptions: []
|
|
1738
1821
|
});
|
|
1739
|
-
function
|
|
1822
|
+
function create31(context) {
|
|
1740
1823
|
const report = kit.createReport(context);
|
|
1741
1824
|
const state = { isWithinChildrenToArray: false };
|
|
1742
1825
|
function checkIteratorElement(node) {
|
|
@@ -1849,26 +1932,25 @@ function create29(context) {
|
|
|
1849
1932
|
function isArrayFromCall(node) {
|
|
1850
1933
|
return node.type === types.AST_NODE_TYPES.CallExpression && node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1851
1934
|
}
|
|
1852
|
-
var
|
|
1853
|
-
var
|
|
1935
|
+
var RULE_NAME32 = "no-nested-component-definitions";
|
|
1936
|
+
var RULE_FEATURES32 = [];
|
|
1854
1937
|
var no_nested_component_definitions_default = createRule({
|
|
1855
1938
|
meta: {
|
|
1856
1939
|
type: "problem",
|
|
1857
1940
|
docs: {
|
|
1858
1941
|
description: "Disallow nesting component definitions inside other components.",
|
|
1859
|
-
[Symbol.for("rule_features")]:
|
|
1942
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1860
1943
|
},
|
|
1861
1944
|
messages: {
|
|
1862
|
-
|
|
1863
|
-
noNestedComponentDefinitionInProps: "Do not nest component definitions inside props. Move it to the top level or pass it as a prop."
|
|
1945
|
+
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1864
1946
|
},
|
|
1865
1947
|
schema: []
|
|
1866
1948
|
},
|
|
1867
|
-
name:
|
|
1868
|
-
create:
|
|
1949
|
+
name: RULE_NAME32,
|
|
1950
|
+
create: create32,
|
|
1869
1951
|
defaultOptions: []
|
|
1870
1952
|
});
|
|
1871
|
-
function
|
|
1953
|
+
function create32(context) {
|
|
1872
1954
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1873
1955
|
const collector = core.useComponentCollector(context, { hint });
|
|
1874
1956
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
@@ -1894,10 +1976,11 @@ function create30(context) {
|
|
|
1894
1976
|
if (isInsideJSXAttributeValue(component)) {
|
|
1895
1977
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1896
1978
|
context.report({
|
|
1897
|
-
messageId: "
|
|
1979
|
+
messageId: "noNestedComponentDefinitions",
|
|
1898
1980
|
node: component,
|
|
1899
1981
|
data: {
|
|
1900
|
-
name: name5
|
|
1982
|
+
name: name5,
|
|
1983
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1901
1984
|
}
|
|
1902
1985
|
});
|
|
1903
1986
|
}
|
|
@@ -1905,10 +1988,11 @@ function create30(context) {
|
|
|
1905
1988
|
}
|
|
1906
1989
|
if (isInsideCreateElementProps(context, component)) {
|
|
1907
1990
|
context.report({
|
|
1908
|
-
messageId: "
|
|
1991
|
+
messageId: "noNestedComponentDefinitions",
|
|
1909
1992
|
node: component,
|
|
1910
1993
|
data: {
|
|
1911
|
-
name: name5
|
|
1994
|
+
name: name5,
|
|
1995
|
+
suggestion: "Move it to the top level or pass it as a prop."
|
|
1912
1996
|
}
|
|
1913
1997
|
});
|
|
1914
1998
|
continue;
|
|
@@ -1916,20 +2000,22 @@ function create30(context) {
|
|
|
1916
2000
|
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
1917
2001
|
if (parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1918
2002
|
context.report({
|
|
1919
|
-
messageId:
|
|
2003
|
+
messageId: "noNestedComponentDefinitions",
|
|
1920
2004
|
node: component,
|
|
1921
2005
|
data: {
|
|
1922
|
-
name: name5
|
|
2006
|
+
name: name5,
|
|
2007
|
+
suggestion: component.parent.type === types.AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1923
2008
|
}
|
|
1924
2009
|
});
|
|
1925
2010
|
continue;
|
|
1926
2011
|
}
|
|
1927
2012
|
if (core.isInsideRenderMethod(component)) {
|
|
1928
2013
|
context.report({
|
|
1929
|
-
messageId: "
|
|
2014
|
+
messageId: "noNestedComponentDefinitions",
|
|
1930
2015
|
node: component,
|
|
1931
2016
|
data: {
|
|
1932
|
-
name: name5
|
|
2017
|
+
name: name5,
|
|
2018
|
+
suggestion: "Move it to the top level."
|
|
1933
2019
|
}
|
|
1934
2020
|
});
|
|
1935
2021
|
}
|
|
@@ -1939,10 +2025,11 @@ function create30(context) {
|
|
|
1939
2025
|
continue;
|
|
1940
2026
|
}
|
|
1941
2027
|
context.report({
|
|
1942
|
-
messageId: "
|
|
2028
|
+
messageId: "noNestedComponentDefinitions",
|
|
1943
2029
|
node: component,
|
|
1944
2030
|
data: {
|
|
1945
|
-
name: name5
|
|
2031
|
+
name: name5,
|
|
2032
|
+
suggestion: component.parent.type === types.AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
1946
2033
|
}
|
|
1947
2034
|
});
|
|
1948
2035
|
}
|
|
@@ -1959,25 +2046,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1959
2046
|
if (prop == null) return false;
|
|
1960
2047
|
return prop === call.arguments[1];
|
|
1961
2048
|
}
|
|
1962
|
-
var
|
|
1963
|
-
var
|
|
2049
|
+
var RULE_NAME33 = "no-prop-types";
|
|
2050
|
+
var RULE_FEATURES33 = [];
|
|
1964
2051
|
var no_prop_types_default = createRule({
|
|
1965
2052
|
meta: {
|
|
1966
2053
|
type: "problem",
|
|
1967
2054
|
docs: {
|
|
1968
2055
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1969
|
-
[Symbol.for("rule_features")]:
|
|
2056
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1970
2057
|
},
|
|
1971
2058
|
messages: {
|
|
1972
2059
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1973
2060
|
},
|
|
1974
2061
|
schema: []
|
|
1975
2062
|
},
|
|
1976
|
-
name:
|
|
1977
|
-
create:
|
|
2063
|
+
name: RULE_NAME33,
|
|
2064
|
+
create: create33,
|
|
1978
2065
|
defaultOptions: []
|
|
1979
2066
|
});
|
|
1980
|
-
function
|
|
2067
|
+
function create33(context) {
|
|
1981
2068
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1982
2069
|
return {};
|
|
1983
2070
|
}
|
|
@@ -1996,8 +2083,8 @@ function create31(context) {
|
|
|
1996
2083
|
if (!core.isComponentNameLoose(object.name)) {
|
|
1997
2084
|
return;
|
|
1998
2085
|
}
|
|
1999
|
-
const variable =
|
|
2000
|
-
const variableNode =
|
|
2086
|
+
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2087
|
+
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
2001
2088
|
if (variableNode != null && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
|
|
2002
2089
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2003
2090
|
}
|
|
@@ -2013,8 +2100,8 @@ function create31(context) {
|
|
|
2013
2100
|
}
|
|
2014
2101
|
};
|
|
2015
2102
|
}
|
|
2016
|
-
var
|
|
2017
|
-
var
|
|
2103
|
+
var RULE_NAME34 = "no-redundant-should-component-update";
|
|
2104
|
+
var RULE_FEATURES34 = [];
|
|
2018
2105
|
function isShouldComponentUpdate(node) {
|
|
2019
2106
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2020
2107
|
}
|
|
@@ -2023,18 +2110,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2023
2110
|
type: "problem",
|
|
2024
2111
|
docs: {
|
|
2025
2112
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2026
|
-
[Symbol.for("rule_features")]:
|
|
2113
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2027
2114
|
},
|
|
2028
2115
|
messages: {
|
|
2029
2116
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2030
2117
|
},
|
|
2031
2118
|
schema: []
|
|
2032
2119
|
},
|
|
2033
|
-
name:
|
|
2034
|
-
create:
|
|
2120
|
+
name: RULE_NAME34,
|
|
2121
|
+
create: create34,
|
|
2035
2122
|
defaultOptions: []
|
|
2036
2123
|
});
|
|
2037
|
-
function
|
|
2124
|
+
function create34(context) {
|
|
2038
2125
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2039
2126
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2040
2127
|
return {
|
|
@@ -2061,8 +2148,8 @@ function create32(context) {
|
|
|
2061
2148
|
}
|
|
2062
2149
|
};
|
|
2063
2150
|
}
|
|
2064
|
-
var
|
|
2065
|
-
var
|
|
2151
|
+
var RULE_NAME35 = "no-set-state-in-component-did-mount";
|
|
2152
|
+
var RULE_FEATURES35 = [];
|
|
2066
2153
|
function isComponentDidMount(node) {
|
|
2067
2154
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2068
2155
|
}
|
|
@@ -2071,18 +2158,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2071
2158
|
type: "problem",
|
|
2072
2159
|
docs: {
|
|
2073
2160
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2074
|
-
[Symbol.for("rule_features")]:
|
|
2161
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2075
2162
|
},
|
|
2076
2163
|
messages: {
|
|
2077
2164
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2078
2165
|
},
|
|
2079
2166
|
schema: []
|
|
2080
2167
|
},
|
|
2081
|
-
name:
|
|
2082
|
-
create:
|
|
2168
|
+
name: RULE_NAME35,
|
|
2169
|
+
create: create35,
|
|
2083
2170
|
defaultOptions: []
|
|
2084
2171
|
});
|
|
2085
|
-
function
|
|
2172
|
+
function create35(context) {
|
|
2086
2173
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2087
2174
|
return {
|
|
2088
2175
|
CallExpression(node) {
|
|
@@ -2103,8 +2190,8 @@ function create33(context) {
|
|
|
2103
2190
|
}
|
|
2104
2191
|
};
|
|
2105
2192
|
}
|
|
2106
|
-
var
|
|
2107
|
-
var
|
|
2193
|
+
var RULE_NAME36 = "no-set-state-in-component-did-update";
|
|
2194
|
+
var RULE_FEATURES36 = [];
|
|
2108
2195
|
function isComponentDidUpdate(node) {
|
|
2109
2196
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2110
2197
|
}
|
|
@@ -2113,18 +2200,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2113
2200
|
type: "problem",
|
|
2114
2201
|
docs: {
|
|
2115
2202
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2116
|
-
[Symbol.for("rule_features")]:
|
|
2203
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2117
2204
|
},
|
|
2118
2205
|
messages: {
|
|
2119
2206
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2120
2207
|
},
|
|
2121
2208
|
schema: []
|
|
2122
2209
|
},
|
|
2123
|
-
name:
|
|
2124
|
-
create:
|
|
2210
|
+
name: RULE_NAME36,
|
|
2211
|
+
create: create36,
|
|
2125
2212
|
defaultOptions: []
|
|
2126
2213
|
});
|
|
2127
|
-
function
|
|
2214
|
+
function create36(context) {
|
|
2128
2215
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2129
2216
|
return {
|
|
2130
2217
|
CallExpression(node) {
|
|
@@ -2145,8 +2232,8 @@ function create34(context) {
|
|
|
2145
2232
|
}
|
|
2146
2233
|
};
|
|
2147
2234
|
}
|
|
2148
|
-
var
|
|
2149
|
-
var
|
|
2235
|
+
var RULE_NAME37 = "no-set-state-in-component-will-update";
|
|
2236
|
+
var RULE_FEATURES37 = [];
|
|
2150
2237
|
function isComponentWillUpdate3(node) {
|
|
2151
2238
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2152
2239
|
}
|
|
@@ -2155,18 +2242,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2155
2242
|
type: "problem",
|
|
2156
2243
|
docs: {
|
|
2157
2244
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2158
|
-
[Symbol.for("rule_features")]:
|
|
2245
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2159
2246
|
},
|
|
2160
2247
|
messages: {
|
|
2161
2248
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2162
2249
|
},
|
|
2163
2250
|
schema: []
|
|
2164
2251
|
},
|
|
2165
|
-
name:
|
|
2166
|
-
create:
|
|
2252
|
+
name: RULE_NAME37,
|
|
2253
|
+
create: create37,
|
|
2167
2254
|
defaultOptions: []
|
|
2168
2255
|
});
|
|
2169
|
-
function
|
|
2256
|
+
function create37(context) {
|
|
2170
2257
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2171
2258
|
return {
|
|
2172
2259
|
CallExpression(node) {
|
|
@@ -2187,8 +2274,8 @@ function create35(context) {
|
|
|
2187
2274
|
}
|
|
2188
2275
|
};
|
|
2189
2276
|
}
|
|
2190
|
-
var
|
|
2191
|
-
var
|
|
2277
|
+
var RULE_NAME38 = "no-string-refs";
|
|
2278
|
+
var RULE_FEATURES38 = [];
|
|
2192
2279
|
function containsStringLiteral({ value }) {
|
|
2193
2280
|
return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2194
2281
|
}
|
|
@@ -2206,18 +2293,18 @@ var no_string_refs_default = createRule({
|
|
|
2206
2293
|
type: "problem",
|
|
2207
2294
|
docs: {
|
|
2208
2295
|
description: "Disallow deprecated string `refs`.",
|
|
2209
|
-
[Symbol.for("rule_features")]:
|
|
2296
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2210
2297
|
},
|
|
2211
2298
|
messages: {
|
|
2212
2299
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2213
2300
|
},
|
|
2214
2301
|
schema: []
|
|
2215
2302
|
},
|
|
2216
|
-
name:
|
|
2217
|
-
create:
|
|
2303
|
+
name: RULE_NAME38,
|
|
2304
|
+
create: create38,
|
|
2218
2305
|
defaultOptions: []
|
|
2219
2306
|
});
|
|
2220
|
-
function
|
|
2307
|
+
function create38(context) {
|
|
2221
2308
|
return {
|
|
2222
2309
|
JSXAttribute(node) {
|
|
2223
2310
|
if (node.name.name !== "ref") {
|
|
@@ -2232,8 +2319,8 @@ function create36(context) {
|
|
|
2232
2319
|
}
|
|
2233
2320
|
};
|
|
2234
2321
|
}
|
|
2235
|
-
var
|
|
2236
|
-
var
|
|
2322
|
+
var RULE_NAME39 = "no-unsafe-component-will-mount";
|
|
2323
|
+
var RULE_FEATURES39 = [];
|
|
2237
2324
|
function isUnsafeComponentWillMount(node) {
|
|
2238
2325
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2239
2326
|
}
|
|
@@ -2242,18 +2329,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2242
2329
|
type: "problem",
|
|
2243
2330
|
docs: {
|
|
2244
2331
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2245
|
-
[Symbol.for("rule_features")]:
|
|
2332
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2246
2333
|
},
|
|
2247
2334
|
messages: {
|
|
2248
2335
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2249
2336
|
},
|
|
2250
2337
|
schema: []
|
|
2251
2338
|
},
|
|
2252
|
-
name:
|
|
2253
|
-
create:
|
|
2339
|
+
name: RULE_NAME39,
|
|
2340
|
+
create: create39,
|
|
2254
2341
|
defaultOptions: []
|
|
2255
2342
|
});
|
|
2256
|
-
function
|
|
2343
|
+
function create39(context) {
|
|
2257
2344
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2258
2345
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2259
2346
|
return {
|
|
@@ -2274,8 +2361,8 @@ function create37(context) {
|
|
|
2274
2361
|
}
|
|
2275
2362
|
};
|
|
2276
2363
|
}
|
|
2277
|
-
var
|
|
2278
|
-
var
|
|
2364
|
+
var RULE_NAME40 = "no-unsafe-component-will-receive-props";
|
|
2365
|
+
var RULE_FEATURES40 = [];
|
|
2279
2366
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2280
2367
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2281
2368
|
}
|
|
@@ -2284,18 +2371,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2284
2371
|
type: "problem",
|
|
2285
2372
|
docs: {
|
|
2286
2373
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2287
|
-
[Symbol.for("rule_features")]:
|
|
2374
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2288
2375
|
},
|
|
2289
2376
|
messages: {
|
|
2290
2377
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2291
2378
|
},
|
|
2292
2379
|
schema: []
|
|
2293
2380
|
},
|
|
2294
|
-
name:
|
|
2295
|
-
create:
|
|
2381
|
+
name: RULE_NAME40,
|
|
2382
|
+
create: create40,
|
|
2296
2383
|
defaultOptions: []
|
|
2297
2384
|
});
|
|
2298
|
-
function
|
|
2385
|
+
function create40(context) {
|
|
2299
2386
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2300
2387
|
return {};
|
|
2301
2388
|
}
|
|
@@ -2318,8 +2405,8 @@ function create38(context) {
|
|
|
2318
2405
|
}
|
|
2319
2406
|
};
|
|
2320
2407
|
}
|
|
2321
|
-
var
|
|
2322
|
-
var
|
|
2408
|
+
var RULE_NAME41 = "no-unsafe-component-will-update";
|
|
2409
|
+
var RULE_FEATURES41 = [];
|
|
2323
2410
|
function isUnsafeComponentWillUpdate(node) {
|
|
2324
2411
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2325
2412
|
}
|
|
@@ -2328,18 +2415,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2328
2415
|
type: "problem",
|
|
2329
2416
|
docs: {
|
|
2330
2417
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2331
|
-
[Symbol.for("rule_features")]:
|
|
2418
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2332
2419
|
},
|
|
2333
2420
|
messages: {
|
|
2334
2421
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2335
2422
|
},
|
|
2336
2423
|
schema: []
|
|
2337
2424
|
},
|
|
2338
|
-
name:
|
|
2339
|
-
create:
|
|
2425
|
+
name: RULE_NAME41,
|
|
2426
|
+
create: create41,
|
|
2340
2427
|
defaultOptions: []
|
|
2341
2428
|
});
|
|
2342
|
-
function
|
|
2429
|
+
function create41(context) {
|
|
2343
2430
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2344
2431
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2345
2432
|
return {
|
|
@@ -2360,25 +2447,25 @@ function create39(context) {
|
|
|
2360
2447
|
}
|
|
2361
2448
|
};
|
|
2362
2449
|
}
|
|
2363
|
-
var
|
|
2364
|
-
var
|
|
2450
|
+
var RULE_NAME42 = "no-unstable-context-value";
|
|
2451
|
+
var RULE_FEATURES42 = [];
|
|
2365
2452
|
var no_unstable_context_value_default = createRule({
|
|
2366
2453
|
meta: {
|
|
2367
2454
|
type: "problem",
|
|
2368
2455
|
docs: {
|
|
2369
2456
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2370
|
-
[Symbol.for("rule_features")]:
|
|
2457
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2371
2458
|
},
|
|
2372
2459
|
messages: {
|
|
2373
2460
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2374
2461
|
},
|
|
2375
2462
|
schema: []
|
|
2376
2463
|
},
|
|
2377
|
-
name:
|
|
2378
|
-
create:
|
|
2464
|
+
name: RULE_NAME42,
|
|
2465
|
+
create: create42,
|
|
2379
2466
|
defaultOptions: []
|
|
2380
2467
|
});
|
|
2381
|
-
function
|
|
2468
|
+
function create42(context) {
|
|
2382
2469
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2383
2470
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2384
2471
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2400,7 +2487,7 @@ function create40(context) {
|
|
|
2400
2487
|
if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2401
2488
|
const valueExpression = value.expression;
|
|
2402
2489
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2403
|
-
const construction =
|
|
2490
|
+
const construction = VAR2__namespace.getValueConstruction(valueExpression, initialScope);
|
|
2404
2491
|
if (construction == null) return;
|
|
2405
2492
|
if (core.isReactHookCall(construction.node)) {
|
|
2406
2493
|
return;
|
|
@@ -2433,25 +2520,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2433
2520
|
}
|
|
2434
2521
|
return false;
|
|
2435
2522
|
}
|
|
2436
|
-
var
|
|
2437
|
-
var
|
|
2523
|
+
var RULE_NAME43 = "no-unstable-default-props";
|
|
2524
|
+
var RULE_FEATURES43 = [];
|
|
2438
2525
|
var no_unstable_default_props_default = createRule({
|
|
2439
2526
|
meta: {
|
|
2440
2527
|
type: "problem",
|
|
2441
2528
|
docs: {
|
|
2442
2529
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2443
|
-
[Symbol.for("rule_features")]:
|
|
2530
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2444
2531
|
},
|
|
2445
2532
|
messages: {
|
|
2446
2533
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2447
2534
|
},
|
|
2448
2535
|
schema: []
|
|
2449
2536
|
},
|
|
2450
|
-
name:
|
|
2451
|
-
create:
|
|
2537
|
+
name: RULE_NAME43,
|
|
2538
|
+
create: create43,
|
|
2452
2539
|
defaultOptions: []
|
|
2453
2540
|
});
|
|
2454
|
-
function
|
|
2541
|
+
function create43(context) {
|
|
2455
2542
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2456
2543
|
const declarators = /* @__PURE__ */ new Map();
|
|
2457
2544
|
return {
|
|
@@ -2474,10 +2561,10 @@ function create41(context) {
|
|
|
2474
2561
|
const { value } = prop;
|
|
2475
2562
|
const { right } = value;
|
|
2476
2563
|
const initialScope = context.sourceCode.getScope(value);
|
|
2477
|
-
const construction =
|
|
2564
|
+
const construction = VAR2__namespace.getValueConstruction(
|
|
2478
2565
|
value,
|
|
2479
2566
|
initialScope,
|
|
2480
|
-
|
|
2567
|
+
VAR2__namespace.ValueConstructionHint.StrictCallExpression
|
|
2481
2568
|
);
|
|
2482
2569
|
if (construction == null) {
|
|
2483
2570
|
continue;
|
|
@@ -2507,8 +2594,8 @@ function create41(context) {
|
|
|
2507
2594
|
}
|
|
2508
2595
|
};
|
|
2509
2596
|
}
|
|
2510
|
-
var
|
|
2511
|
-
var
|
|
2597
|
+
var RULE_NAME44 = "no-unused-class-component-members";
|
|
2598
|
+
var RULE_FEATURES44 = [];
|
|
2512
2599
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2513
2600
|
"componentDidCatch",
|
|
2514
2601
|
"componentDidMount",
|
|
@@ -2534,18 +2621,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2534
2621
|
type: "problem",
|
|
2535
2622
|
docs: {
|
|
2536
2623
|
description: "Warns unused class component methods and properties.",
|
|
2537
|
-
[Symbol.for("rule_features")]:
|
|
2624
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2538
2625
|
},
|
|
2539
2626
|
messages: {
|
|
2540
2627
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2541
2628
|
},
|
|
2542
2629
|
schema: []
|
|
2543
2630
|
},
|
|
2544
|
-
name:
|
|
2545
|
-
create:
|
|
2631
|
+
name: RULE_NAME44,
|
|
2632
|
+
create: create44,
|
|
2546
2633
|
defaultOptions: []
|
|
2547
2634
|
});
|
|
2548
|
-
function
|
|
2635
|
+
function create44(context) {
|
|
2549
2636
|
const classEntries = [];
|
|
2550
2637
|
const methodEntries = [];
|
|
2551
2638
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2655,8 +2742,8 @@ function create42(context) {
|
|
|
2655
2742
|
}
|
|
2656
2743
|
};
|
|
2657
2744
|
}
|
|
2658
|
-
var
|
|
2659
|
-
var
|
|
2745
|
+
var RULE_NAME45 = "no-unused-state";
|
|
2746
|
+
var RULE_FEATURES45 = [];
|
|
2660
2747
|
function isKeyLiteral3(node, key) {
|
|
2661
2748
|
return tsPattern.match(key).with({ type: types.AST_NODE_TYPES.Literal }, eff.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.constFalse);
|
|
2662
2749
|
}
|
|
@@ -2665,18 +2752,18 @@ var no_unused_state_default = createRule({
|
|
|
2665
2752
|
type: "problem",
|
|
2666
2753
|
docs: {
|
|
2667
2754
|
description: "Warns unused class component state.",
|
|
2668
|
-
[Symbol.for("rule_features")]:
|
|
2755
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2669
2756
|
},
|
|
2670
2757
|
messages: {
|
|
2671
2758
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2672
2759
|
},
|
|
2673
2760
|
schema: []
|
|
2674
2761
|
},
|
|
2675
|
-
name:
|
|
2676
|
-
create:
|
|
2762
|
+
name: RULE_NAME45,
|
|
2763
|
+
create: create45,
|
|
2677
2764
|
defaultOptions: []
|
|
2678
2765
|
});
|
|
2679
|
-
function
|
|
2766
|
+
function create45(context) {
|
|
2680
2767
|
const classEntries = [];
|
|
2681
2768
|
const methodEntries = [];
|
|
2682
2769
|
const constructorEntries = [];
|
|
@@ -2810,8 +2897,8 @@ function create43(context) {
|
|
|
2810
2897
|
}
|
|
2811
2898
|
};
|
|
2812
2899
|
}
|
|
2813
|
-
var
|
|
2814
|
-
var
|
|
2900
|
+
var RULE_NAME46 = "no-use-context";
|
|
2901
|
+
var RULE_FEATURES46 = [
|
|
2815
2902
|
"MOD"
|
|
2816
2903
|
];
|
|
2817
2904
|
var no_use_context_default = createRule({
|
|
@@ -2819,7 +2906,7 @@ var no_use_context_default = createRule({
|
|
|
2819
2906
|
type: "problem",
|
|
2820
2907
|
docs: {
|
|
2821
2908
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2822
|
-
[Symbol.for("rule_features")]:
|
|
2909
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2823
2910
|
},
|
|
2824
2911
|
fixable: "code",
|
|
2825
2912
|
messages: {
|
|
@@ -2827,11 +2914,11 @@ var no_use_context_default = createRule({
|
|
|
2827
2914
|
},
|
|
2828
2915
|
schema: []
|
|
2829
2916
|
},
|
|
2830
|
-
name:
|
|
2831
|
-
create:
|
|
2917
|
+
name: RULE_NAME46,
|
|
2918
|
+
create: create46,
|
|
2832
2919
|
defaultOptions: []
|
|
2833
2920
|
});
|
|
2834
|
-
function
|
|
2921
|
+
function create46(context) {
|
|
2835
2922
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2836
2923
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2837
2924
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2909,25 +2996,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2909
2996
|
return tokens;
|
|
2910
2997
|
}
|
|
2911
2998
|
}
|
|
2912
|
-
var
|
|
2913
|
-
var
|
|
2999
|
+
var RULE_NAME47 = "no-useless-forward-ref";
|
|
3000
|
+
var RULE_FEATURES47 = [];
|
|
2914
3001
|
var no_useless_forward_ref_default = createRule({
|
|
2915
3002
|
meta: {
|
|
2916
3003
|
type: "problem",
|
|
2917
3004
|
docs: {
|
|
2918
3005
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2919
|
-
[Symbol.for("rule_features")]:
|
|
3006
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2920
3007
|
},
|
|
2921
3008
|
messages: {
|
|
2922
3009
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2923
3010
|
},
|
|
2924
3011
|
schema: []
|
|
2925
3012
|
},
|
|
2926
|
-
name:
|
|
2927
|
-
create:
|
|
3013
|
+
name: RULE_NAME47,
|
|
3014
|
+
create: create47,
|
|
2928
3015
|
defaultOptions: []
|
|
2929
3016
|
});
|
|
2930
|
-
function
|
|
3017
|
+
function create47(context) {
|
|
2931
3018
|
return {
|
|
2932
3019
|
CallExpression(node) {
|
|
2933
3020
|
if (!core.isForwardRefCall(context, node)) {
|
|
@@ -2948,7 +3035,7 @@ function create45(context) {
|
|
|
2948
3035
|
}
|
|
2949
3036
|
};
|
|
2950
3037
|
}
|
|
2951
|
-
var
|
|
3038
|
+
var RULE_NAME48 = "no-useless-fragment";
|
|
2952
3039
|
var defaultOptions = [{
|
|
2953
3040
|
allowExpressions: true
|
|
2954
3041
|
}];
|
|
@@ -2974,11 +3061,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2974
3061
|
}
|
|
2975
3062
|
}]
|
|
2976
3063
|
},
|
|
2977
|
-
name:
|
|
2978
|
-
create:
|
|
3064
|
+
name: RULE_NAME48,
|
|
3065
|
+
create: create48,
|
|
2979
3066
|
defaultOptions
|
|
2980
3067
|
});
|
|
2981
|
-
function
|
|
3068
|
+
function create48(context, [option]) {
|
|
2982
3069
|
const { allowExpressions = true } = option;
|
|
2983
3070
|
return {
|
|
2984
3071
|
JSXElement(node) {
|
|
@@ -3090,8 +3177,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3090
3177
|
}
|
|
3091
3178
|
return;
|
|
3092
3179
|
}
|
|
3093
|
-
var
|
|
3094
|
-
var
|
|
3180
|
+
var RULE_NAME49 = "prefer-destructuring-assignment";
|
|
3181
|
+
var RULE_FEATURES48 = [];
|
|
3095
3182
|
function isMemberExpressionWithObjectName(node) {
|
|
3096
3183
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3097
3184
|
}
|
|
@@ -3100,18 +3187,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3100
3187
|
type: "problem",
|
|
3101
3188
|
docs: {
|
|
3102
3189
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3103
|
-
[Symbol.for("rule_features")]:
|
|
3190
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3104
3191
|
},
|
|
3105
3192
|
messages: {
|
|
3106
3193
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3107
3194
|
},
|
|
3108
3195
|
schema: []
|
|
3109
3196
|
},
|
|
3110
|
-
name:
|
|
3111
|
-
create:
|
|
3197
|
+
name: RULE_NAME49,
|
|
3198
|
+
create: create49,
|
|
3112
3199
|
defaultOptions: []
|
|
3113
3200
|
});
|
|
3114
|
-
function
|
|
3201
|
+
function create49(context) {
|
|
3115
3202
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3116
3203
|
const memberExpressionWithNames = [];
|
|
3117
3204
|
return {
|
|
@@ -3171,8 +3258,8 @@ function create47(context) {
|
|
|
3171
3258
|
}
|
|
3172
3259
|
};
|
|
3173
3260
|
}
|
|
3174
|
-
var
|
|
3175
|
-
var
|
|
3261
|
+
var RULE_NAME50 = "prefer-react-namespace-import";
|
|
3262
|
+
var RULE_FEATURES49 = [
|
|
3176
3263
|
"FIX",
|
|
3177
3264
|
"EXP"
|
|
3178
3265
|
];
|
|
@@ -3181,7 +3268,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3181
3268
|
type: "problem",
|
|
3182
3269
|
docs: {
|
|
3183
3270
|
description: "Enforces React is imported via a namespace import.",
|
|
3184
|
-
[Symbol.for("rule_features")]:
|
|
3271
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3185
3272
|
},
|
|
3186
3273
|
fixable: "code",
|
|
3187
3274
|
messages: {
|
|
@@ -3189,11 +3276,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3189
3276
|
},
|
|
3190
3277
|
schema: []
|
|
3191
3278
|
},
|
|
3192
|
-
name:
|
|
3193
|
-
create:
|
|
3279
|
+
name: RULE_NAME50,
|
|
3280
|
+
create: create50,
|
|
3194
3281
|
defaultOptions: []
|
|
3195
3282
|
});
|
|
3196
|
-
function
|
|
3283
|
+
function create50(context) {
|
|
3197
3284
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3198
3285
|
return {
|
|
3199
3286
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3226,8 +3313,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3226
3313
|
}
|
|
3227
3314
|
};
|
|
3228
3315
|
}
|
|
3229
|
-
var
|
|
3230
|
-
var
|
|
3316
|
+
var RULE_NAME51 = "prefer-read-only-props";
|
|
3317
|
+
var RULE_FEATURES50 = [
|
|
3231
3318
|
"TSC",
|
|
3232
3319
|
"EXP"
|
|
3233
3320
|
];
|
|
@@ -3236,18 +3323,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3236
3323
|
type: "problem",
|
|
3237
3324
|
docs: {
|
|
3238
3325
|
description: "Enforces read-only props in components.",
|
|
3239
|
-
[Symbol.for("rule_features")]:
|
|
3326
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3240
3327
|
},
|
|
3241
3328
|
messages: {
|
|
3242
3329
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3243
3330
|
},
|
|
3244
3331
|
schema: []
|
|
3245
3332
|
},
|
|
3246
|
-
name:
|
|
3247
|
-
create:
|
|
3333
|
+
name: RULE_NAME51,
|
|
3334
|
+
create: create51,
|
|
3248
3335
|
defaultOptions: []
|
|
3249
3336
|
});
|
|
3250
|
-
function
|
|
3337
|
+
function create51(context) {
|
|
3251
3338
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3252
3339
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3253
3340
|
return {
|
|
@@ -3277,8 +3364,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3277
3364
|
return true;
|
|
3278
3365
|
}
|
|
3279
3366
|
}
|
|
3280
|
-
var
|
|
3281
|
-
var
|
|
3367
|
+
var RULE_NAME52 = "prefer-shorthand-boolean";
|
|
3368
|
+
var RULE_FEATURES51 = [
|
|
3282
3369
|
"FIX"
|
|
3283
3370
|
];
|
|
3284
3371
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3286,7 +3373,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3286
3373
|
type: "problem",
|
|
3287
3374
|
docs: {
|
|
3288
3375
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3289
|
-
[Symbol.for("rule_features")]:
|
|
3376
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3290
3377
|
},
|
|
3291
3378
|
fixable: "code",
|
|
3292
3379
|
messages: {
|
|
@@ -3294,11 +3381,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3294
3381
|
},
|
|
3295
3382
|
schema: []
|
|
3296
3383
|
},
|
|
3297
|
-
name:
|
|
3298
|
-
create:
|
|
3384
|
+
name: RULE_NAME52,
|
|
3385
|
+
create: create52,
|
|
3299
3386
|
defaultOptions: []
|
|
3300
3387
|
});
|
|
3301
|
-
function
|
|
3388
|
+
function create52(context) {
|
|
3302
3389
|
return {
|
|
3303
3390
|
JSXAttribute(node) {
|
|
3304
3391
|
const { value } = node;
|
|
@@ -3318,8 +3405,8 @@ function create50(context) {
|
|
|
3318
3405
|
}
|
|
3319
3406
|
};
|
|
3320
3407
|
}
|
|
3321
|
-
var
|
|
3322
|
-
var
|
|
3408
|
+
var RULE_NAME53 = "prefer-shorthand-fragment";
|
|
3409
|
+
var RULE_FEATURES52 = [
|
|
3323
3410
|
"FIX"
|
|
3324
3411
|
];
|
|
3325
3412
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3327,7 +3414,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3327
3414
|
type: "problem",
|
|
3328
3415
|
docs: {
|
|
3329
3416
|
description: "Enforces shorthand syntax for fragments.",
|
|
3330
|
-
[Symbol.for("rule_features")]:
|
|
3417
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3331
3418
|
},
|
|
3332
3419
|
fixable: "code",
|
|
3333
3420
|
messages: {
|
|
@@ -3335,11 +3422,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3335
3422
|
},
|
|
3336
3423
|
schema: []
|
|
3337
3424
|
},
|
|
3338
|
-
name:
|
|
3339
|
-
create:
|
|
3425
|
+
name: RULE_NAME53,
|
|
3426
|
+
create: create53,
|
|
3340
3427
|
defaultOptions: []
|
|
3341
3428
|
});
|
|
3342
|
-
function
|
|
3429
|
+
function create53(context) {
|
|
3343
3430
|
return {
|
|
3344
3431
|
JSXElement(node) {
|
|
3345
3432
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
@@ -3364,46 +3451,6 @@ function create51(context) {
|
|
|
3364
3451
|
}
|
|
3365
3452
|
};
|
|
3366
3453
|
}
|
|
3367
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3368
|
-
var RULE_FEATURES51 = [];
|
|
3369
|
-
var use_jsx_vars_default = createRule({
|
|
3370
|
-
meta: {
|
|
3371
|
-
type: "problem",
|
|
3372
|
-
docs: {
|
|
3373
|
-
description: "Marks variables used in JSX as used.",
|
|
3374
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3375
|
-
},
|
|
3376
|
-
messages: {
|
|
3377
|
-
useJsxVars: ""
|
|
3378
|
-
},
|
|
3379
|
-
schema: []
|
|
3380
|
-
},
|
|
3381
|
-
name: RULE_NAME52,
|
|
3382
|
-
create: create52,
|
|
3383
|
-
defaultOptions: []
|
|
3384
|
-
});
|
|
3385
|
-
function create52(context) {
|
|
3386
|
-
return {
|
|
3387
|
-
JSXOpeningElement(node) {
|
|
3388
|
-
switch (node.name.type) {
|
|
3389
|
-
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
3390
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3391
|
-
return;
|
|
3392
|
-
}
|
|
3393
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3394
|
-
break;
|
|
3395
|
-
}
|
|
3396
|
-
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
3397
|
-
const { object } = node.name;
|
|
3398
|
-
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
3399
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3400
|
-
}
|
|
3401
|
-
break;
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
};
|
|
3406
|
-
}
|
|
3407
3454
|
|
|
3408
3455
|
// src/plugin.ts
|
|
3409
3456
|
var plugin = {
|
|
@@ -3433,7 +3480,6 @@ var plugin = {
|
|
|
3433
3480
|
"no-create-ref": no_create_ref_default,
|
|
3434
3481
|
"no-default-props": no_default_props_default,
|
|
3435
3482
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3436
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3437
3483
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3438
3484
|
"no-forward-ref": no_forward_ref_default,
|
|
3439
3485
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3463,18 +3509,21 @@ var plugin = {
|
|
|
3463
3509
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3464
3510
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3465
3511
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3466
|
-
|
|
3512
|
+
// Part: JSX only rules
|
|
3513
|
+
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
3514
|
+
"jsx-no-undef": jsx_no_undef_default,
|
|
3515
|
+
"jsx-uses-vars": jsx_uses_vars_default,
|
|
3467
3516
|
// Part: deprecated rules
|
|
3468
3517
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3469
3518
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3470
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3471
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3472
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3473
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3474
3519
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3475
3520
|
"no-complicated-conditional-rendering": no_complex_conditional_rendering_default,
|
|
3521
|
+
/** @deprecated Use `jsx-no-duplicate-props` instead */
|
|
3522
|
+
"no-duplicate-jsx-props": jsx_no_duplicate_props_default,
|
|
3476
3523
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3477
|
-
"no-nested-components": no_nested_component_definitions_default
|
|
3524
|
+
"no-nested-components": no_nested_component_definitions_default,
|
|
3525
|
+
/** @deprecated Use `jsx-uses-vars` instead */
|
|
3526
|
+
"use-jsx-vars": jsx_uses_vars_default
|
|
3478
3527
|
}
|
|
3479
3528
|
};
|
|
3480
3529
|
|