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.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-next.
|
|
142
|
+
var version = "1.38.0-next.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,25 +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
1945
|
noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}"
|
|
1863
1946
|
},
|
|
1864
1947
|
schema: []
|
|
1865
1948
|
},
|
|
1866
|
-
name:
|
|
1867
|
-
create:
|
|
1949
|
+
name: RULE_NAME32,
|
|
1950
|
+
create: create32,
|
|
1868
1951
|
defaultOptions: []
|
|
1869
1952
|
});
|
|
1870
|
-
function
|
|
1953
|
+
function create32(context) {
|
|
1871
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;
|
|
1872
1955
|
const collector = core.useComponentCollector(context, { hint });
|
|
1873
1956
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
@@ -1963,25 +2046,25 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1963
2046
|
if (prop == null) return false;
|
|
1964
2047
|
return prop === call.arguments[1];
|
|
1965
2048
|
}
|
|
1966
|
-
var
|
|
1967
|
-
var
|
|
2049
|
+
var RULE_NAME33 = "no-prop-types";
|
|
2050
|
+
var RULE_FEATURES33 = [];
|
|
1968
2051
|
var no_prop_types_default = createRule({
|
|
1969
2052
|
meta: {
|
|
1970
2053
|
type: "problem",
|
|
1971
2054
|
docs: {
|
|
1972
2055
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1973
|
-
[Symbol.for("rule_features")]:
|
|
2056
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1974
2057
|
},
|
|
1975
2058
|
messages: {
|
|
1976
2059
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1977
2060
|
},
|
|
1978
2061
|
schema: []
|
|
1979
2062
|
},
|
|
1980
|
-
name:
|
|
1981
|
-
create:
|
|
2063
|
+
name: RULE_NAME33,
|
|
2064
|
+
create: create33,
|
|
1982
2065
|
defaultOptions: []
|
|
1983
2066
|
});
|
|
1984
|
-
function
|
|
2067
|
+
function create33(context) {
|
|
1985
2068
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1986
2069
|
return {};
|
|
1987
2070
|
}
|
|
@@ -2000,8 +2083,8 @@ function create31(context) {
|
|
|
2000
2083
|
if (!core.isComponentNameLoose(object.name)) {
|
|
2001
2084
|
return;
|
|
2002
2085
|
}
|
|
2003
|
-
const variable =
|
|
2004
|
-
const variableNode =
|
|
2086
|
+
const variable = VAR2__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2087
|
+
const variableNode = VAR2__namespace.getVariableInitNode(variable, 0);
|
|
2005
2088
|
if (variableNode != null && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
|
|
2006
2089
|
context.report({ messageId: "noPropTypes", node: property });
|
|
2007
2090
|
}
|
|
@@ -2017,8 +2100,8 @@ function create31(context) {
|
|
|
2017
2100
|
}
|
|
2018
2101
|
};
|
|
2019
2102
|
}
|
|
2020
|
-
var
|
|
2021
|
-
var
|
|
2103
|
+
var RULE_NAME34 = "no-redundant-should-component-update";
|
|
2104
|
+
var RULE_FEATURES34 = [];
|
|
2022
2105
|
function isShouldComponentUpdate(node) {
|
|
2023
2106
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2024
2107
|
}
|
|
@@ -2027,18 +2110,18 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2027
2110
|
type: "problem",
|
|
2028
2111
|
docs: {
|
|
2029
2112
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2030
|
-
[Symbol.for("rule_features")]:
|
|
2113
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2031
2114
|
},
|
|
2032
2115
|
messages: {
|
|
2033
2116
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2034
2117
|
},
|
|
2035
2118
|
schema: []
|
|
2036
2119
|
},
|
|
2037
|
-
name:
|
|
2038
|
-
create:
|
|
2120
|
+
name: RULE_NAME34,
|
|
2121
|
+
create: create34,
|
|
2039
2122
|
defaultOptions: []
|
|
2040
2123
|
});
|
|
2041
|
-
function
|
|
2124
|
+
function create34(context) {
|
|
2042
2125
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2043
2126
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2044
2127
|
return {
|
|
@@ -2065,8 +2148,8 @@ function create32(context) {
|
|
|
2065
2148
|
}
|
|
2066
2149
|
};
|
|
2067
2150
|
}
|
|
2068
|
-
var
|
|
2069
|
-
var
|
|
2151
|
+
var RULE_NAME35 = "no-set-state-in-component-did-mount";
|
|
2152
|
+
var RULE_FEATURES35 = [];
|
|
2070
2153
|
function isComponentDidMount(node) {
|
|
2071
2154
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
2072
2155
|
}
|
|
@@ -2075,18 +2158,18 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2075
2158
|
type: "problem",
|
|
2076
2159
|
docs: {
|
|
2077
2160
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2078
|
-
[Symbol.for("rule_features")]:
|
|
2161
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2079
2162
|
},
|
|
2080
2163
|
messages: {
|
|
2081
2164
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2082
2165
|
},
|
|
2083
2166
|
schema: []
|
|
2084
2167
|
},
|
|
2085
|
-
name:
|
|
2086
|
-
create:
|
|
2168
|
+
name: RULE_NAME35,
|
|
2169
|
+
create: create35,
|
|
2087
2170
|
defaultOptions: []
|
|
2088
2171
|
});
|
|
2089
|
-
function
|
|
2172
|
+
function create35(context) {
|
|
2090
2173
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2091
2174
|
return {
|
|
2092
2175
|
CallExpression(node) {
|
|
@@ -2107,8 +2190,8 @@ function create33(context) {
|
|
|
2107
2190
|
}
|
|
2108
2191
|
};
|
|
2109
2192
|
}
|
|
2110
|
-
var
|
|
2111
|
-
var
|
|
2193
|
+
var RULE_NAME36 = "no-set-state-in-component-did-update";
|
|
2194
|
+
var RULE_FEATURES36 = [];
|
|
2112
2195
|
function isComponentDidUpdate(node) {
|
|
2113
2196
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
2114
2197
|
}
|
|
@@ -2117,18 +2200,18 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2117
2200
|
type: "problem",
|
|
2118
2201
|
docs: {
|
|
2119
2202
|
description: "Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2120
|
-
[Symbol.for("rule_features")]:
|
|
2203
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2121
2204
|
},
|
|
2122
2205
|
messages: {
|
|
2123
2206
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2124
2207
|
},
|
|
2125
2208
|
schema: []
|
|
2126
2209
|
},
|
|
2127
|
-
name:
|
|
2128
|
-
create:
|
|
2210
|
+
name: RULE_NAME36,
|
|
2211
|
+
create: create36,
|
|
2129
2212
|
defaultOptions: []
|
|
2130
2213
|
});
|
|
2131
|
-
function
|
|
2214
|
+
function create36(context) {
|
|
2132
2215
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2133
2216
|
return {
|
|
2134
2217
|
CallExpression(node) {
|
|
@@ -2149,8 +2232,8 @@ function create34(context) {
|
|
|
2149
2232
|
}
|
|
2150
2233
|
};
|
|
2151
2234
|
}
|
|
2152
|
-
var
|
|
2153
|
-
var
|
|
2235
|
+
var RULE_NAME37 = "no-set-state-in-component-will-update";
|
|
2236
|
+
var RULE_FEATURES37 = [];
|
|
2154
2237
|
function isComponentWillUpdate3(node) {
|
|
2155
2238
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
2156
2239
|
}
|
|
@@ -2159,18 +2242,18 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2159
2242
|
type: "problem",
|
|
2160
2243
|
docs: {
|
|
2161
2244
|
description: "Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2162
|
-
[Symbol.for("rule_features")]:
|
|
2245
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2163
2246
|
},
|
|
2164
2247
|
messages: {
|
|
2165
2248
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2166
2249
|
},
|
|
2167
2250
|
schema: []
|
|
2168
2251
|
},
|
|
2169
|
-
name:
|
|
2170
|
-
create:
|
|
2252
|
+
name: RULE_NAME37,
|
|
2253
|
+
create: create37,
|
|
2171
2254
|
defaultOptions: []
|
|
2172
2255
|
});
|
|
2173
|
-
function
|
|
2256
|
+
function create37(context) {
|
|
2174
2257
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2175
2258
|
return {
|
|
2176
2259
|
CallExpression(node) {
|
|
@@ -2191,8 +2274,8 @@ function create35(context) {
|
|
|
2191
2274
|
}
|
|
2192
2275
|
};
|
|
2193
2276
|
}
|
|
2194
|
-
var
|
|
2195
|
-
var
|
|
2277
|
+
var RULE_NAME38 = "no-string-refs";
|
|
2278
|
+
var RULE_FEATURES38 = [];
|
|
2196
2279
|
function containsStringLiteral({ value }) {
|
|
2197
2280
|
return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
|
|
2198
2281
|
}
|
|
@@ -2210,18 +2293,18 @@ var no_string_refs_default = createRule({
|
|
|
2210
2293
|
type: "problem",
|
|
2211
2294
|
docs: {
|
|
2212
2295
|
description: "Disallow deprecated string `refs`.",
|
|
2213
|
-
[Symbol.for("rule_features")]:
|
|
2296
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2214
2297
|
},
|
|
2215
2298
|
messages: {
|
|
2216
2299
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2217
2300
|
},
|
|
2218
2301
|
schema: []
|
|
2219
2302
|
},
|
|
2220
|
-
name:
|
|
2221
|
-
create:
|
|
2303
|
+
name: RULE_NAME38,
|
|
2304
|
+
create: create38,
|
|
2222
2305
|
defaultOptions: []
|
|
2223
2306
|
});
|
|
2224
|
-
function
|
|
2307
|
+
function create38(context) {
|
|
2225
2308
|
return {
|
|
2226
2309
|
JSXAttribute(node) {
|
|
2227
2310
|
if (node.name.name !== "ref") {
|
|
@@ -2236,8 +2319,8 @@ function create36(context) {
|
|
|
2236
2319
|
}
|
|
2237
2320
|
};
|
|
2238
2321
|
}
|
|
2239
|
-
var
|
|
2240
|
-
var
|
|
2322
|
+
var RULE_NAME39 = "no-unsafe-component-will-mount";
|
|
2323
|
+
var RULE_FEATURES39 = [];
|
|
2241
2324
|
function isUnsafeComponentWillMount(node) {
|
|
2242
2325
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
2243
2326
|
}
|
|
@@ -2246,18 +2329,18 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2246
2329
|
type: "problem",
|
|
2247
2330
|
docs: {
|
|
2248
2331
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2249
|
-
[Symbol.for("rule_features")]:
|
|
2332
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2250
2333
|
},
|
|
2251
2334
|
messages: {
|
|
2252
2335
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2253
2336
|
},
|
|
2254
2337
|
schema: []
|
|
2255
2338
|
},
|
|
2256
|
-
name:
|
|
2257
|
-
create:
|
|
2339
|
+
name: RULE_NAME39,
|
|
2340
|
+
create: create39,
|
|
2258
2341
|
defaultOptions: []
|
|
2259
2342
|
});
|
|
2260
|
-
function
|
|
2343
|
+
function create39(context) {
|
|
2261
2344
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2262
2345
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2263
2346
|
return {
|
|
@@ -2278,8 +2361,8 @@ function create37(context) {
|
|
|
2278
2361
|
}
|
|
2279
2362
|
};
|
|
2280
2363
|
}
|
|
2281
|
-
var
|
|
2282
|
-
var
|
|
2364
|
+
var RULE_NAME40 = "no-unsafe-component-will-receive-props";
|
|
2365
|
+
var RULE_FEATURES40 = [];
|
|
2283
2366
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
2284
2367
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
2285
2368
|
}
|
|
@@ -2288,18 +2371,18 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2288
2371
|
type: "problem",
|
|
2289
2372
|
docs: {
|
|
2290
2373
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2291
|
-
[Symbol.for("rule_features")]:
|
|
2374
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2292
2375
|
},
|
|
2293
2376
|
messages: {
|
|
2294
2377
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2295
2378
|
},
|
|
2296
2379
|
schema: []
|
|
2297
2380
|
},
|
|
2298
|
-
name:
|
|
2299
|
-
create:
|
|
2381
|
+
name: RULE_NAME40,
|
|
2382
|
+
create: create40,
|
|
2300
2383
|
defaultOptions: []
|
|
2301
2384
|
});
|
|
2302
|
-
function
|
|
2385
|
+
function create40(context) {
|
|
2303
2386
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2304
2387
|
return {};
|
|
2305
2388
|
}
|
|
@@ -2322,8 +2405,8 @@ function create38(context) {
|
|
|
2322
2405
|
}
|
|
2323
2406
|
};
|
|
2324
2407
|
}
|
|
2325
|
-
var
|
|
2326
|
-
var
|
|
2408
|
+
var RULE_NAME41 = "no-unsafe-component-will-update";
|
|
2409
|
+
var RULE_FEATURES41 = [];
|
|
2327
2410
|
function isUnsafeComponentWillUpdate(node) {
|
|
2328
2411
|
return AST11__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
2329
2412
|
}
|
|
@@ -2332,18 +2415,18 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2332
2415
|
type: "problem",
|
|
2333
2416
|
docs: {
|
|
2334
2417
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2335
|
-
[Symbol.for("rule_features")]:
|
|
2418
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2336
2419
|
},
|
|
2337
2420
|
messages: {
|
|
2338
2421
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2339
2422
|
},
|
|
2340
2423
|
schema: []
|
|
2341
2424
|
},
|
|
2342
|
-
name:
|
|
2343
|
-
create:
|
|
2425
|
+
name: RULE_NAME41,
|
|
2426
|
+
create: create41,
|
|
2344
2427
|
defaultOptions: []
|
|
2345
2428
|
});
|
|
2346
|
-
function
|
|
2429
|
+
function create41(context) {
|
|
2347
2430
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2348
2431
|
const { ctx, listeners } = core.useComponentCollectorLegacy();
|
|
2349
2432
|
return {
|
|
@@ -2364,25 +2447,25 @@ function create39(context) {
|
|
|
2364
2447
|
}
|
|
2365
2448
|
};
|
|
2366
2449
|
}
|
|
2367
|
-
var
|
|
2368
|
-
var
|
|
2450
|
+
var RULE_NAME42 = "no-unstable-context-value";
|
|
2451
|
+
var RULE_FEATURES42 = [];
|
|
2369
2452
|
var no_unstable_context_value_default = createRule({
|
|
2370
2453
|
meta: {
|
|
2371
2454
|
type: "problem",
|
|
2372
2455
|
docs: {
|
|
2373
2456
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2374
|
-
[Symbol.for("rule_features")]:
|
|
2457
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2375
2458
|
},
|
|
2376
2459
|
messages: {
|
|
2377
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}}"
|
|
2378
2461
|
},
|
|
2379
2462
|
schema: []
|
|
2380
2463
|
},
|
|
2381
|
-
name:
|
|
2382
|
-
create:
|
|
2464
|
+
name: RULE_NAME42,
|
|
2465
|
+
create: create42,
|
|
2383
2466
|
defaultOptions: []
|
|
2384
2467
|
});
|
|
2385
|
-
function
|
|
2468
|
+
function create42(context) {
|
|
2386
2469
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
2387
2470
|
const isReact18OrBelow = compareVersions.compare(version2, "19.0.0", "<");
|
|
2388
2471
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -2404,7 +2487,7 @@ function create40(context) {
|
|
|
2404
2487
|
if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2405
2488
|
const valueExpression = value.expression;
|
|
2406
2489
|
const initialScope = context.sourceCode.getScope(valueExpression);
|
|
2407
|
-
const construction =
|
|
2490
|
+
const construction = VAR2__namespace.getValueConstruction(valueExpression, initialScope);
|
|
2408
2491
|
if (construction == null) return;
|
|
2409
2492
|
if (core.isReactHookCall(construction.node)) {
|
|
2410
2493
|
return;
|
|
@@ -2437,25 +2520,25 @@ function isContextName(name5, isReact18OrBelow) {
|
|
|
2437
2520
|
}
|
|
2438
2521
|
return false;
|
|
2439
2522
|
}
|
|
2440
|
-
var
|
|
2441
|
-
var
|
|
2523
|
+
var RULE_NAME43 = "no-unstable-default-props";
|
|
2524
|
+
var RULE_FEATURES43 = [];
|
|
2442
2525
|
var no_unstable_default_props_default = createRule({
|
|
2443
2526
|
meta: {
|
|
2444
2527
|
type: "problem",
|
|
2445
2528
|
docs: {
|
|
2446
2529
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2447
|
-
[Symbol.for("rule_features")]:
|
|
2530
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2448
2531
|
},
|
|
2449
2532
|
messages: {
|
|
2450
2533
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2451
2534
|
},
|
|
2452
2535
|
schema: []
|
|
2453
2536
|
},
|
|
2454
|
-
name:
|
|
2455
|
-
create:
|
|
2537
|
+
name: RULE_NAME43,
|
|
2538
|
+
create: create43,
|
|
2456
2539
|
defaultOptions: []
|
|
2457
2540
|
});
|
|
2458
|
-
function
|
|
2541
|
+
function create43(context) {
|
|
2459
2542
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2460
2543
|
const declarators = /* @__PURE__ */ new Map();
|
|
2461
2544
|
return {
|
|
@@ -2478,10 +2561,10 @@ function create41(context) {
|
|
|
2478
2561
|
const { value } = prop;
|
|
2479
2562
|
const { right } = value;
|
|
2480
2563
|
const initialScope = context.sourceCode.getScope(value);
|
|
2481
|
-
const construction =
|
|
2564
|
+
const construction = VAR2__namespace.getValueConstruction(
|
|
2482
2565
|
value,
|
|
2483
2566
|
initialScope,
|
|
2484
|
-
|
|
2567
|
+
VAR2__namespace.ValueConstructionHint.StrictCallExpression
|
|
2485
2568
|
);
|
|
2486
2569
|
if (construction == null) {
|
|
2487
2570
|
continue;
|
|
@@ -2511,8 +2594,8 @@ function create41(context) {
|
|
|
2511
2594
|
}
|
|
2512
2595
|
};
|
|
2513
2596
|
}
|
|
2514
|
-
var
|
|
2515
|
-
var
|
|
2597
|
+
var RULE_NAME44 = "no-unused-class-component-members";
|
|
2598
|
+
var RULE_FEATURES44 = [];
|
|
2516
2599
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
2517
2600
|
"componentDidCatch",
|
|
2518
2601
|
"componentDidMount",
|
|
@@ -2538,18 +2621,18 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2538
2621
|
type: "problem",
|
|
2539
2622
|
docs: {
|
|
2540
2623
|
description: "Warns unused class component methods and properties.",
|
|
2541
|
-
[Symbol.for("rule_features")]:
|
|
2624
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2542
2625
|
},
|
|
2543
2626
|
messages: {
|
|
2544
2627
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2545
2628
|
},
|
|
2546
2629
|
schema: []
|
|
2547
2630
|
},
|
|
2548
|
-
name:
|
|
2549
|
-
create:
|
|
2631
|
+
name: RULE_NAME44,
|
|
2632
|
+
create: create44,
|
|
2550
2633
|
defaultOptions: []
|
|
2551
2634
|
});
|
|
2552
|
-
function
|
|
2635
|
+
function create44(context) {
|
|
2553
2636
|
const classEntries = [];
|
|
2554
2637
|
const methodEntries = [];
|
|
2555
2638
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2659,8 +2742,8 @@ function create42(context) {
|
|
|
2659
2742
|
}
|
|
2660
2743
|
};
|
|
2661
2744
|
}
|
|
2662
|
-
var
|
|
2663
|
-
var
|
|
2745
|
+
var RULE_NAME45 = "no-unused-state";
|
|
2746
|
+
var RULE_FEATURES45 = [];
|
|
2664
2747
|
function isKeyLiteral3(node, key) {
|
|
2665
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);
|
|
2666
2749
|
}
|
|
@@ -2669,18 +2752,18 @@ var no_unused_state_default = createRule({
|
|
|
2669
2752
|
type: "problem",
|
|
2670
2753
|
docs: {
|
|
2671
2754
|
description: "Warns unused class component state.",
|
|
2672
|
-
[Symbol.for("rule_features")]:
|
|
2755
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2673
2756
|
},
|
|
2674
2757
|
messages: {
|
|
2675
2758
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2676
2759
|
},
|
|
2677
2760
|
schema: []
|
|
2678
2761
|
},
|
|
2679
|
-
name:
|
|
2680
|
-
create:
|
|
2762
|
+
name: RULE_NAME45,
|
|
2763
|
+
create: create45,
|
|
2681
2764
|
defaultOptions: []
|
|
2682
2765
|
});
|
|
2683
|
-
function
|
|
2766
|
+
function create45(context) {
|
|
2684
2767
|
const classEntries = [];
|
|
2685
2768
|
const methodEntries = [];
|
|
2686
2769
|
const constructorEntries = [];
|
|
@@ -2814,8 +2897,8 @@ function create43(context) {
|
|
|
2814
2897
|
}
|
|
2815
2898
|
};
|
|
2816
2899
|
}
|
|
2817
|
-
var
|
|
2818
|
-
var
|
|
2900
|
+
var RULE_NAME46 = "no-use-context";
|
|
2901
|
+
var RULE_FEATURES46 = [
|
|
2819
2902
|
"MOD"
|
|
2820
2903
|
];
|
|
2821
2904
|
var no_use_context_default = createRule({
|
|
@@ -2823,7 +2906,7 @@ var no_use_context_default = createRule({
|
|
|
2823
2906
|
type: "problem",
|
|
2824
2907
|
docs: {
|
|
2825
2908
|
description: "Replaces usages of `useContext` with `use`.",
|
|
2826
|
-
[Symbol.for("rule_features")]:
|
|
2909
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
2827
2910
|
},
|
|
2828
2911
|
fixable: "code",
|
|
2829
2912
|
messages: {
|
|
@@ -2831,11 +2914,11 @@ var no_use_context_default = createRule({
|
|
|
2831
2914
|
},
|
|
2832
2915
|
schema: []
|
|
2833
2916
|
},
|
|
2834
|
-
name:
|
|
2835
|
-
create:
|
|
2917
|
+
name: RULE_NAME46,
|
|
2918
|
+
create: create46,
|
|
2836
2919
|
defaultOptions: []
|
|
2837
2920
|
});
|
|
2838
|
-
function
|
|
2921
|
+
function create46(context) {
|
|
2839
2922
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2840
2923
|
const settings4 = shared.getSettingsFromContext(context);
|
|
2841
2924
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
@@ -2913,25 +2996,25 @@ function getAssociatedTokens(context, node) {
|
|
|
2913
2996
|
return tokens;
|
|
2914
2997
|
}
|
|
2915
2998
|
}
|
|
2916
|
-
var
|
|
2917
|
-
var
|
|
2999
|
+
var RULE_NAME47 = "no-useless-forward-ref";
|
|
3000
|
+
var RULE_FEATURES47 = [];
|
|
2918
3001
|
var no_useless_forward_ref_default = createRule({
|
|
2919
3002
|
meta: {
|
|
2920
3003
|
type: "problem",
|
|
2921
3004
|
docs: {
|
|
2922
3005
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
2923
|
-
[Symbol.for("rule_features")]:
|
|
3006
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
2924
3007
|
},
|
|
2925
3008
|
messages: {
|
|
2926
3009
|
noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set."
|
|
2927
3010
|
},
|
|
2928
3011
|
schema: []
|
|
2929
3012
|
},
|
|
2930
|
-
name:
|
|
2931
|
-
create:
|
|
3013
|
+
name: RULE_NAME47,
|
|
3014
|
+
create: create47,
|
|
2932
3015
|
defaultOptions: []
|
|
2933
3016
|
});
|
|
2934
|
-
function
|
|
3017
|
+
function create47(context) {
|
|
2935
3018
|
return {
|
|
2936
3019
|
CallExpression(node) {
|
|
2937
3020
|
if (!core.isForwardRefCall(context, node)) {
|
|
@@ -2952,7 +3035,7 @@ function create45(context) {
|
|
|
2952
3035
|
}
|
|
2953
3036
|
};
|
|
2954
3037
|
}
|
|
2955
|
-
var
|
|
3038
|
+
var RULE_NAME48 = "no-useless-fragment";
|
|
2956
3039
|
var defaultOptions = [{
|
|
2957
3040
|
allowExpressions: true
|
|
2958
3041
|
}];
|
|
@@ -2978,11 +3061,11 @@ var no_useless_fragment_default = createRule({
|
|
|
2978
3061
|
}
|
|
2979
3062
|
}]
|
|
2980
3063
|
},
|
|
2981
|
-
name:
|
|
2982
|
-
create:
|
|
3064
|
+
name: RULE_NAME48,
|
|
3065
|
+
create: create48,
|
|
2983
3066
|
defaultOptions
|
|
2984
3067
|
});
|
|
2985
|
-
function
|
|
3068
|
+
function create48(context, [option]) {
|
|
2986
3069
|
const { allowExpressions = true } = option;
|
|
2987
3070
|
return {
|
|
2988
3071
|
JSXElement(node) {
|
|
@@ -3094,8 +3177,8 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3094
3177
|
}
|
|
3095
3178
|
return;
|
|
3096
3179
|
}
|
|
3097
|
-
var
|
|
3098
|
-
var
|
|
3180
|
+
var RULE_NAME49 = "prefer-destructuring-assignment";
|
|
3181
|
+
var RULE_FEATURES48 = [];
|
|
3099
3182
|
function isMemberExpressionWithObjectName(node) {
|
|
3100
3183
|
return node.object.type === types.AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3101
3184
|
}
|
|
@@ -3104,18 +3187,18 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3104
3187
|
type: "problem",
|
|
3105
3188
|
docs: {
|
|
3106
3189
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3107
|
-
[Symbol.for("rule_features")]:
|
|
3190
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3108
3191
|
},
|
|
3109
3192
|
messages: {
|
|
3110
3193
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3111
3194
|
},
|
|
3112
3195
|
schema: []
|
|
3113
3196
|
},
|
|
3114
|
-
name:
|
|
3115
|
-
create:
|
|
3197
|
+
name: RULE_NAME49,
|
|
3198
|
+
create: create49,
|
|
3116
3199
|
defaultOptions: []
|
|
3117
3200
|
});
|
|
3118
|
-
function
|
|
3201
|
+
function create49(context) {
|
|
3119
3202
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3120
3203
|
const memberExpressionWithNames = [];
|
|
3121
3204
|
return {
|
|
@@ -3175,8 +3258,8 @@ function create47(context) {
|
|
|
3175
3258
|
}
|
|
3176
3259
|
};
|
|
3177
3260
|
}
|
|
3178
|
-
var
|
|
3179
|
-
var
|
|
3261
|
+
var RULE_NAME50 = "prefer-react-namespace-import";
|
|
3262
|
+
var RULE_FEATURES49 = [
|
|
3180
3263
|
"FIX",
|
|
3181
3264
|
"EXP"
|
|
3182
3265
|
];
|
|
@@ -3185,7 +3268,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3185
3268
|
type: "problem",
|
|
3186
3269
|
docs: {
|
|
3187
3270
|
description: "Enforces React is imported via a namespace import.",
|
|
3188
|
-
[Symbol.for("rule_features")]:
|
|
3271
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3189
3272
|
},
|
|
3190
3273
|
fixable: "code",
|
|
3191
3274
|
messages: {
|
|
@@ -3193,11 +3276,11 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3193
3276
|
},
|
|
3194
3277
|
schema: []
|
|
3195
3278
|
},
|
|
3196
|
-
name:
|
|
3197
|
-
create:
|
|
3279
|
+
name: RULE_NAME50,
|
|
3280
|
+
create: create50,
|
|
3198
3281
|
defaultOptions: []
|
|
3199
3282
|
});
|
|
3200
|
-
function
|
|
3283
|
+
function create50(context) {
|
|
3201
3284
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3202
3285
|
return {
|
|
3203
3286
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
@@ -3230,8 +3313,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3230
3313
|
}
|
|
3231
3314
|
};
|
|
3232
3315
|
}
|
|
3233
|
-
var
|
|
3234
|
-
var
|
|
3316
|
+
var RULE_NAME51 = "prefer-read-only-props";
|
|
3317
|
+
var RULE_FEATURES50 = [
|
|
3235
3318
|
"TSC",
|
|
3236
3319
|
"EXP"
|
|
3237
3320
|
];
|
|
@@ -3240,18 +3323,18 @@ var prefer_read_only_props_default = createRule({
|
|
|
3240
3323
|
type: "problem",
|
|
3241
3324
|
docs: {
|
|
3242
3325
|
description: "Enforces read-only props in components.",
|
|
3243
|
-
[Symbol.for("rule_features")]:
|
|
3326
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3244
3327
|
},
|
|
3245
3328
|
messages: {
|
|
3246
3329
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3247
3330
|
},
|
|
3248
3331
|
schema: []
|
|
3249
3332
|
},
|
|
3250
|
-
name:
|
|
3251
|
-
create:
|
|
3333
|
+
name: RULE_NAME51,
|
|
3334
|
+
create: create51,
|
|
3252
3335
|
defaultOptions: []
|
|
3253
3336
|
});
|
|
3254
|
-
function
|
|
3337
|
+
function create51(context) {
|
|
3255
3338
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3256
3339
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3257
3340
|
return {
|
|
@@ -3281,8 +3364,8 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3281
3364
|
return true;
|
|
3282
3365
|
}
|
|
3283
3366
|
}
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3367
|
+
var RULE_NAME52 = "prefer-shorthand-boolean";
|
|
3368
|
+
var RULE_FEATURES51 = [
|
|
3286
3369
|
"FIX"
|
|
3287
3370
|
];
|
|
3288
3371
|
var prefer_shorthand_boolean_default = createRule({
|
|
@@ -3290,7 +3373,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3290
3373
|
type: "problem",
|
|
3291
3374
|
docs: {
|
|
3292
3375
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
3293
|
-
[Symbol.for("rule_features")]:
|
|
3376
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3294
3377
|
},
|
|
3295
3378
|
fixable: "code",
|
|
3296
3379
|
messages: {
|
|
@@ -3298,11 +3381,11 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3298
3381
|
},
|
|
3299
3382
|
schema: []
|
|
3300
3383
|
},
|
|
3301
|
-
name:
|
|
3302
|
-
create:
|
|
3384
|
+
name: RULE_NAME52,
|
|
3385
|
+
create: create52,
|
|
3303
3386
|
defaultOptions: []
|
|
3304
3387
|
});
|
|
3305
|
-
function
|
|
3388
|
+
function create52(context) {
|
|
3306
3389
|
return {
|
|
3307
3390
|
JSXAttribute(node) {
|
|
3308
3391
|
const { value } = node;
|
|
@@ -3322,8 +3405,8 @@ function create50(context) {
|
|
|
3322
3405
|
}
|
|
3323
3406
|
};
|
|
3324
3407
|
}
|
|
3325
|
-
var
|
|
3326
|
-
var
|
|
3408
|
+
var RULE_NAME53 = "prefer-shorthand-fragment";
|
|
3409
|
+
var RULE_FEATURES52 = [
|
|
3327
3410
|
"FIX"
|
|
3328
3411
|
];
|
|
3329
3412
|
var prefer_shorthand_fragment_default = createRule({
|
|
@@ -3331,7 +3414,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3331
3414
|
type: "problem",
|
|
3332
3415
|
docs: {
|
|
3333
3416
|
description: "Enforces shorthand syntax for fragments.",
|
|
3334
|
-
[Symbol.for("rule_features")]:
|
|
3417
|
+
[Symbol.for("rule_features")]: RULE_FEATURES52
|
|
3335
3418
|
},
|
|
3336
3419
|
fixable: "code",
|
|
3337
3420
|
messages: {
|
|
@@ -3339,11 +3422,11 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3339
3422
|
},
|
|
3340
3423
|
schema: []
|
|
3341
3424
|
},
|
|
3342
|
-
name:
|
|
3343
|
-
create:
|
|
3425
|
+
name: RULE_NAME53,
|
|
3426
|
+
create: create53,
|
|
3344
3427
|
defaultOptions: []
|
|
3345
3428
|
});
|
|
3346
|
-
function
|
|
3429
|
+
function create53(context) {
|
|
3347
3430
|
return {
|
|
3348
3431
|
JSXElement(node) {
|
|
3349
3432
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
@@ -3368,46 +3451,6 @@ function create51(context) {
|
|
|
3368
3451
|
}
|
|
3369
3452
|
};
|
|
3370
3453
|
}
|
|
3371
|
-
var RULE_NAME52 = "use-jsx-vars";
|
|
3372
|
-
var RULE_FEATURES51 = [];
|
|
3373
|
-
var use_jsx_vars_default = createRule({
|
|
3374
|
-
meta: {
|
|
3375
|
-
type: "problem",
|
|
3376
|
-
docs: {
|
|
3377
|
-
description: "Marks variables used in JSX as used.",
|
|
3378
|
-
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3379
|
-
},
|
|
3380
|
-
messages: {
|
|
3381
|
-
useJsxVars: ""
|
|
3382
|
-
},
|
|
3383
|
-
schema: []
|
|
3384
|
-
},
|
|
3385
|
-
name: RULE_NAME52,
|
|
3386
|
-
create: create52,
|
|
3387
|
-
defaultOptions: []
|
|
3388
|
-
});
|
|
3389
|
-
function create52(context) {
|
|
3390
|
-
return {
|
|
3391
|
-
JSXOpeningElement(node) {
|
|
3392
|
-
switch (node.name.type) {
|
|
3393
|
-
case types.AST_NODE_TYPES.JSXIdentifier: {
|
|
3394
|
-
if (/^[a-z]/u.test(node.name.name)) {
|
|
3395
|
-
return;
|
|
3396
|
-
}
|
|
3397
|
-
context.sourceCode.markVariableAsUsed(node.name.name, node);
|
|
3398
|
-
break;
|
|
3399
|
-
}
|
|
3400
|
-
case types.AST_NODE_TYPES.JSXMemberExpression: {
|
|
3401
|
-
const { object } = node.name;
|
|
3402
|
-
if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
|
|
3403
|
-
context.sourceCode.markVariableAsUsed(object.name, node);
|
|
3404
|
-
}
|
|
3405
|
-
break;
|
|
3406
|
-
}
|
|
3407
|
-
}
|
|
3408
|
-
}
|
|
3409
|
-
};
|
|
3410
|
-
}
|
|
3411
3454
|
|
|
3412
3455
|
// src/plugin.ts
|
|
3413
3456
|
var plugin = {
|
|
@@ -3437,7 +3480,6 @@ var plugin = {
|
|
|
3437
3480
|
"no-create-ref": no_create_ref_default,
|
|
3438
3481
|
"no-default-props": no_default_props_default,
|
|
3439
3482
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
3440
|
-
"no-duplicate-jsx-props": no_duplicate_jsx_props_default,
|
|
3441
3483
|
"no-duplicate-key": no_duplicate_key_default,
|
|
3442
3484
|
"no-forward-ref": no_forward_ref_default,
|
|
3443
3485
|
"no-implicit-key": no_implicit_key_default,
|
|
@@ -3467,18 +3509,21 @@ var plugin = {
|
|
|
3467
3509
|
"prefer-read-only-props": prefer_read_only_props_default,
|
|
3468
3510
|
"prefer-shorthand-boolean": prefer_shorthand_boolean_default,
|
|
3469
3511
|
"prefer-shorthand-fragment": prefer_shorthand_fragment_default,
|
|
3470
|
-
|
|
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,
|
|
3471
3516
|
// Part: deprecated rules
|
|
3472
3517
|
/** @deprecated Use `no-useless-forward-ref` instead */
|
|
3473
3518
|
"ensure-forward-ref-using-ref": no_useless_forward_ref_default,
|
|
3474
|
-
/** @deprecated Use `no-duplicate-jsx-props` instead */
|
|
3475
|
-
"jsx-no-duplicate-props": no_duplicate_jsx_props_default,
|
|
3476
|
-
/** @deprecated Use `use-jsx-vars` instead */
|
|
3477
|
-
"jsx-uses-vars": use_jsx_vars_default,
|
|
3478
3519
|
/** @deprecated Use `no-complex-conditional-rendering` instead */
|
|
3479
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,
|
|
3480
3523
|
/** @deprecated Use `no-nested-component-definitions` instead */
|
|
3481
|
-
"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
|
|
3482
3527
|
}
|
|
3483
3528
|
};
|
|
3484
3529
|
|