eslint-plugin-react-x 2.8.2-beta.1 → 2.8.2-beta.5
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.js +142 -144
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import { getConstrainedTypeAtLocation, isTypeReadonly } from "@typescript-eslint
|
|
|
12
12
|
import { getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
|
|
13
13
|
import { isPropertyReadonlyInType, unionConstituents } from "ts-api-utils";
|
|
14
14
|
import { getTypeImmutability, isImmutable, isReadonlyDeep, isReadonlyShallow, isUnknown } from "is-immutable-type";
|
|
15
|
-
import { camelCase } from "string-ts";
|
|
16
15
|
|
|
17
16
|
//#region rolldown:runtime
|
|
18
17
|
var __defProp = Object.defineProperty;
|
|
@@ -67,7 +66,7 @@ const rules$7 = {
|
|
|
67
66
|
//#endregion
|
|
68
67
|
//#region package.json
|
|
69
68
|
var name$6 = "eslint-plugin-react-x";
|
|
70
|
-
var version = "2.8.2-beta.
|
|
69
|
+
var version = "2.8.2-beta.5";
|
|
71
70
|
|
|
72
71
|
//#endregion
|
|
73
72
|
//#region src/utils/create-rule.ts
|
|
@@ -179,7 +178,7 @@ var jsx_dollar_default = createRule({
|
|
|
179
178
|
fixable: "code",
|
|
180
179
|
hasSuggestions: true,
|
|
181
180
|
messages: {
|
|
182
|
-
|
|
181
|
+
default: "Possible unnecessary '$' character before expression.",
|
|
183
182
|
removeDollarSign: "Remove the dollar sign '$' before the expression."
|
|
184
183
|
},
|
|
185
184
|
schema: []
|
|
@@ -200,7 +199,7 @@ function create$63(context) {
|
|
|
200
199
|
if (child.value === "$" && node.children.length === 2) continue;
|
|
201
200
|
const pos = child.loc.end;
|
|
202
201
|
context.report({
|
|
203
|
-
messageId: "
|
|
202
|
+
messageId: "default",
|
|
204
203
|
node: child,
|
|
205
204
|
loc: {
|
|
206
205
|
end: {
|
|
@@ -234,7 +233,7 @@ var jsx_key_before_spread_default = createRule({
|
|
|
234
233
|
meta: {
|
|
235
234
|
type: "problem",
|
|
236
235
|
docs: { description: "Enforces 'key' prop placement before spread props." },
|
|
237
|
-
messages: {
|
|
236
|
+
messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
|
|
238
237
|
schema: []
|
|
239
238
|
},
|
|
240
239
|
name: RULE_NAME$62,
|
|
@@ -256,7 +255,7 @@ function create$62(context) {
|
|
|
256
255
|
}
|
|
257
256
|
if (firstSpreadPropIndex == null) continue;
|
|
258
257
|
if (prop.name.name === "key" && index > firstSpreadPropIndex) context.report({
|
|
259
|
-
messageId: "
|
|
258
|
+
messageId: "default",
|
|
260
259
|
node: prop
|
|
261
260
|
});
|
|
262
261
|
}
|
|
@@ -270,7 +269,7 @@ var jsx_no_comment_textnodes_default = createRule({
|
|
|
270
269
|
meta: {
|
|
271
270
|
type: "problem",
|
|
272
271
|
docs: { description: "Prevents comment strings (e.g., beginning with '//' or '/*') from being accidentally inserted into a JSX element's text nodes." },
|
|
273
|
-
messages: {
|
|
272
|
+
messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
274
273
|
schema: []
|
|
275
274
|
},
|
|
276
275
|
name: RULE_NAME$61,
|
|
@@ -286,7 +285,7 @@ function create$61(context) {
|
|
|
286
285
|
if (!ast.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) return;
|
|
287
286
|
if (!hasCommentLike(node)) return;
|
|
288
287
|
context.report({
|
|
289
|
-
messageId: "
|
|
288
|
+
messageId: "default",
|
|
290
289
|
node
|
|
291
290
|
});
|
|
292
291
|
};
|
|
@@ -303,7 +302,7 @@ var jsx_no_duplicate_props_default = createRule({
|
|
|
303
302
|
meta: {
|
|
304
303
|
type: "problem",
|
|
305
304
|
docs: { description: "Disallows duplicate props in JSX elements." },
|
|
306
|
-
messages: {
|
|
305
|
+
messages: { default: "This JSX property is assigned multiple times." },
|
|
307
306
|
schema: []
|
|
308
307
|
},
|
|
309
308
|
name: RULE_NAME$60,
|
|
@@ -322,7 +321,7 @@ function create$60(context) {
|
|
|
322
321
|
continue;
|
|
323
322
|
}
|
|
324
323
|
context.report({
|
|
325
|
-
messageId: "
|
|
324
|
+
messageId: "default",
|
|
326
325
|
node: attr
|
|
327
326
|
});
|
|
328
327
|
}
|
|
@@ -336,7 +335,7 @@ var jsx_no_iife_default = createRule({
|
|
|
336
335
|
meta: {
|
|
337
336
|
type: "problem",
|
|
338
337
|
docs: { description: "Disallows immediately-invoked function expressions in JSX." },
|
|
339
|
-
messages: {
|
|
338
|
+
messages: { default: "Avoid using immediately-invoked function expressions in JSX." },
|
|
340
339
|
schema: []
|
|
341
340
|
},
|
|
342
341
|
name: RULE_NAME$59,
|
|
@@ -347,13 +346,13 @@ function create$59(context) {
|
|
|
347
346
|
return {
|
|
348
347
|
"JSXElement :function"(node) {
|
|
349
348
|
if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
|
|
350
|
-
messageId: "
|
|
349
|
+
messageId: "default",
|
|
351
350
|
node: node.parent
|
|
352
351
|
});
|
|
353
352
|
},
|
|
354
353
|
"JSXFragment :function"(node) {
|
|
355
354
|
if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
|
|
356
|
-
messageId: "
|
|
355
|
+
messageId: "default",
|
|
357
356
|
node: node.parent
|
|
358
357
|
});
|
|
359
358
|
}
|
|
@@ -367,7 +366,7 @@ var jsx_no_undef_default = createRule({
|
|
|
367
366
|
meta: {
|
|
368
367
|
type: "problem",
|
|
369
368
|
docs: { description: "Prevents using variables in JSX that are not defined in the scope." },
|
|
370
|
-
messages: {
|
|
369
|
+
messages: { default: "JSX variable '{{name}}' is not defined." },
|
|
371
370
|
schema: []
|
|
372
371
|
},
|
|
373
372
|
name: RULE_NAME$58,
|
|
@@ -384,7 +383,7 @@ function create$58(context) {
|
|
|
384
383
|
if (name === "this") return;
|
|
385
384
|
if (/^[a-z]/u.test(name)) return;
|
|
386
385
|
if (findVariable(name, context.sourceCode.getScope(node)) == null) context.report({
|
|
387
|
-
messageId: "
|
|
386
|
+
messageId: "default",
|
|
388
387
|
node,
|
|
389
388
|
data: { name }
|
|
390
389
|
});
|
|
@@ -404,7 +403,7 @@ var jsx_shorthand_boolean_default = createRule({
|
|
|
404
403
|
type: "problem",
|
|
405
404
|
docs: { description: "Enforces shorthand syntax for boolean props." },
|
|
406
405
|
fixable: "code",
|
|
407
|
-
messages: {
|
|
406
|
+
messages: { default: "{{message}}" },
|
|
408
407
|
schema: schema$3
|
|
409
408
|
},
|
|
410
409
|
name: RULE_NAME$57,
|
|
@@ -419,7 +418,7 @@ function create$57(context) {
|
|
|
419
418
|
switch (true) {
|
|
420
419
|
case policy === 1 && value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true:
|
|
421
420
|
context.report({
|
|
422
|
-
messageId: "
|
|
421
|
+
messageId: "default",
|
|
423
422
|
node,
|
|
424
423
|
data: { message: `Omit attribute value for '${propName}'.` },
|
|
425
424
|
fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
|
|
@@ -427,7 +426,7 @@ function create$57(context) {
|
|
|
427
426
|
break;
|
|
428
427
|
case policy === -1 && value === null:
|
|
429
428
|
context.report({
|
|
430
|
-
messageId: "
|
|
429
|
+
messageId: "default",
|
|
431
430
|
node: node.value ?? node,
|
|
432
431
|
data: { message: `Set attribute value for '${propName}'.` },
|
|
433
432
|
fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
|
|
@@ -450,7 +449,7 @@ var jsx_shorthand_fragment_default = createRule({
|
|
|
450
449
|
type: "problem",
|
|
451
450
|
docs: { description: "Enforces shorthand syntax for fragment elements." },
|
|
452
451
|
fixable: "code",
|
|
453
|
-
messages: {
|
|
452
|
+
messages: { default: "{{message}}" },
|
|
454
453
|
schema: schema$2
|
|
455
454
|
},
|
|
456
455
|
name: RULE_NAME$56,
|
|
@@ -468,7 +467,7 @@ function create$56(context) {
|
|
|
468
467
|
if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
|
|
469
468
|
if (node.openingElement.attributes.length > 0) return;
|
|
470
469
|
context.report({
|
|
471
|
-
messageId: "
|
|
470
|
+
messageId: "default",
|
|
472
471
|
node,
|
|
473
472
|
data: { message: "Use fragment shorthand syntax instead of 'Fragment' component." },
|
|
474
473
|
fix: (fixer) => {
|
|
@@ -479,7 +478,7 @@ function create$56(context) {
|
|
|
479
478
|
});
|
|
480
479
|
} })).with(-1, () => ({ JSXFragment(node) {
|
|
481
480
|
context.report({
|
|
482
|
-
messageId: "
|
|
481
|
+
messageId: "default",
|
|
483
482
|
node,
|
|
484
483
|
data: { message: "Use 'Fragment' component instead of fragment shorthand syntax." },
|
|
485
484
|
fix: (fixer) => {
|
|
@@ -497,7 +496,7 @@ var jsx_uses_react_default = createRule({
|
|
|
497
496
|
meta: {
|
|
498
497
|
type: "problem",
|
|
499
498
|
docs: { description: "Marks React variables as used when JSX is present." },
|
|
500
|
-
messages: {
|
|
499
|
+
messages: { default: "Marked {{name}} as used." },
|
|
501
500
|
schema: []
|
|
502
501
|
},
|
|
503
502
|
name: RULE_NAME$55,
|
|
@@ -527,7 +526,7 @@ function create$55(context) {
|
|
|
527
526
|
function debugReport(context, node, name) {
|
|
528
527
|
if (process.env["ESLINT_REACT_DEBUG"] !== "1") return;
|
|
529
528
|
context.report({
|
|
530
|
-
messageId: "
|
|
529
|
+
messageId: "default",
|
|
531
530
|
node,
|
|
532
531
|
data: { name }
|
|
533
532
|
});
|
|
@@ -540,7 +539,7 @@ var jsx_uses_vars_default = createRule({
|
|
|
540
539
|
meta: {
|
|
541
540
|
type: "problem",
|
|
542
541
|
docs: { description: "Marks JSX element variables as used." },
|
|
543
|
-
messages: {
|
|
542
|
+
messages: { default: "An identifier in JSX is marked as used." },
|
|
544
543
|
schema: []
|
|
545
544
|
},
|
|
546
545
|
name: RULE_NAME$54,
|
|
@@ -576,7 +575,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
576
575
|
meta: {
|
|
577
576
|
type: "problem",
|
|
578
577
|
docs: { description: "Disallows accessing 'this.state' inside 'setState' calls." },
|
|
579
|
-
messages: {
|
|
578
|
+
messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
|
|
580
579
|
schema: []
|
|
581
580
|
},
|
|
582
581
|
name: RULE_NAME$53,
|
|
@@ -619,7 +618,7 @@ function create$53(context) {
|
|
|
619
618
|
if (setState == null || hasThisState) return;
|
|
620
619
|
if (ast.getPropertyName(node.property) !== "state") return;
|
|
621
620
|
context.report({
|
|
622
|
-
messageId: "
|
|
621
|
+
messageId: "default",
|
|
623
622
|
node
|
|
624
623
|
});
|
|
625
624
|
},
|
|
@@ -645,7 +644,7 @@ function create$53(context) {
|
|
|
645
644
|
if (node.init == null || !ast.isThisExpressionLoose(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
|
|
646
645
|
if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && ast.getPropertyName(prop.key) === "state")) return;
|
|
647
646
|
context.report({
|
|
648
|
-
messageId: "
|
|
647
|
+
messageId: "default",
|
|
649
648
|
node
|
|
650
649
|
});
|
|
651
650
|
}
|
|
@@ -710,7 +709,7 @@ var no_array_index_key_default = createRule({
|
|
|
710
709
|
meta: {
|
|
711
710
|
type: "problem",
|
|
712
711
|
docs: { description: "Disallows using an item's index in the array as its key." },
|
|
713
|
-
messages: {
|
|
712
|
+
messages: { default: "Do not use item index in the array as its key." },
|
|
714
713
|
schema: []
|
|
715
714
|
},
|
|
716
715
|
name: RULE_NAME$52,
|
|
@@ -729,7 +728,7 @@ function create$52(context) {
|
|
|
729
728
|
switch (node.type) {
|
|
730
729
|
case AST_NODE_TYPES.Identifier:
|
|
731
730
|
if (indexParamNames.some((name) => name != null && name === node.name)) return [{
|
|
732
|
-
messageId: "
|
|
731
|
+
messageId: "default",
|
|
733
732
|
node
|
|
734
733
|
}];
|
|
735
734
|
return [];
|
|
@@ -738,18 +737,18 @@ function create$52(context) {
|
|
|
738
737
|
const descriptors = [];
|
|
739
738
|
const expressions = node.type === AST_NODE_TYPES.TemplateLiteral ? node.expressions : getIdentifiersFromBinaryExpression(node);
|
|
740
739
|
for (const expression of expressions) if (isArrayIndex(expression)) descriptors.push({
|
|
741
|
-
messageId: "
|
|
740
|
+
messageId: "default",
|
|
742
741
|
node: expression
|
|
743
742
|
});
|
|
744
743
|
return descriptors;
|
|
745
744
|
}
|
|
746
745
|
case AST_NODE_TYPES.CallExpression: switch (true) {
|
|
747
746
|
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "toString" && isArrayIndex(node.callee.object): return [{
|
|
748
|
-
messageId: "
|
|
747
|
+
messageId: "default",
|
|
749
748
|
node: node.callee.object
|
|
750
749
|
}];
|
|
751
750
|
case node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "String" && node.arguments[0] != null && isArrayIndex(node.arguments[0]): return [{
|
|
752
|
-
messageId: "
|
|
751
|
+
messageId: "default",
|
|
753
752
|
node: node.arguments[0]
|
|
754
753
|
}];
|
|
755
754
|
}
|
|
@@ -788,7 +787,7 @@ var no_children_count_default = createRule({
|
|
|
788
787
|
meta: {
|
|
789
788
|
type: "problem",
|
|
790
789
|
docs: { description: "Disallows the use of 'Children.count' from the 'react' package." },
|
|
791
|
-
messages: {
|
|
790
|
+
messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
792
791
|
schema: []
|
|
793
792
|
},
|
|
794
793
|
name: RULE_NAME$51,
|
|
@@ -798,7 +797,7 @@ var no_children_count_default = createRule({
|
|
|
798
797
|
function create$51(context) {
|
|
799
798
|
return { MemberExpression(node) {
|
|
800
799
|
if (core.isChildrenCount(context, node)) context.report({
|
|
801
|
-
messageId: "
|
|
800
|
+
messageId: "default",
|
|
802
801
|
node: node.property
|
|
803
802
|
});
|
|
804
803
|
} };
|
|
@@ -811,7 +810,7 @@ var no_children_for_each_default = createRule({
|
|
|
811
810
|
meta: {
|
|
812
811
|
type: "problem",
|
|
813
812
|
docs: { description: "Disallows the use of 'Children.forEach' from the 'react' package." },
|
|
814
|
-
messages: {
|
|
813
|
+
messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
815
814
|
schema: []
|
|
816
815
|
},
|
|
817
816
|
name: RULE_NAME$50,
|
|
@@ -821,7 +820,7 @@ var no_children_for_each_default = createRule({
|
|
|
821
820
|
function create$50(context) {
|
|
822
821
|
return { MemberExpression(node) {
|
|
823
822
|
if (core.isChildrenForEach(context, node)) context.report({
|
|
824
|
-
messageId: "
|
|
823
|
+
messageId: "default",
|
|
825
824
|
node: node.property
|
|
826
825
|
});
|
|
827
826
|
} };
|
|
@@ -834,7 +833,7 @@ var no_children_map_default = createRule({
|
|
|
834
833
|
meta: {
|
|
835
834
|
type: "problem",
|
|
836
835
|
docs: { description: "Disallows the use of 'Children.map' from the 'react' package." },
|
|
837
|
-
messages: {
|
|
836
|
+
messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
838
837
|
schema: []
|
|
839
838
|
},
|
|
840
839
|
name: RULE_NAME$49,
|
|
@@ -844,7 +843,7 @@ var no_children_map_default = createRule({
|
|
|
844
843
|
function create$49(context) {
|
|
845
844
|
return { MemberExpression(node) {
|
|
846
845
|
if (core.isChildrenMap(context, node)) context.report({
|
|
847
|
-
messageId: "
|
|
846
|
+
messageId: "default",
|
|
848
847
|
node: node.property
|
|
849
848
|
});
|
|
850
849
|
} };
|
|
@@ -857,7 +856,7 @@ var no_children_only_default = createRule({
|
|
|
857
856
|
meta: {
|
|
858
857
|
type: "problem",
|
|
859
858
|
docs: { description: "Disallows the use of 'Children.only' from the 'react' package." },
|
|
860
|
-
messages: {
|
|
859
|
+
messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
861
860
|
schema: []
|
|
862
861
|
},
|
|
863
862
|
name: RULE_NAME$48,
|
|
@@ -867,7 +866,7 @@ var no_children_only_default = createRule({
|
|
|
867
866
|
function create$48(context) {
|
|
868
867
|
return { MemberExpression(node) {
|
|
869
868
|
if (core.isChildrenOnly(context, node)) context.report({
|
|
870
|
-
messageId: "
|
|
869
|
+
messageId: "default",
|
|
871
870
|
node: node.property
|
|
872
871
|
});
|
|
873
872
|
} };
|
|
@@ -880,7 +879,7 @@ var no_children_prop_default = createRule({
|
|
|
880
879
|
meta: {
|
|
881
880
|
type: "problem",
|
|
882
881
|
docs: { description: "Disallows passing 'children' as a prop." },
|
|
883
|
-
messages: {
|
|
882
|
+
messages: { default: "Do not pass 'children' as props." },
|
|
884
883
|
schema: []
|
|
885
884
|
},
|
|
886
885
|
name: RULE_NAME$47,
|
|
@@ -891,7 +890,7 @@ function create$47(context) {
|
|
|
891
890
|
return { JSXElement(node) {
|
|
892
891
|
const childrenProp = core.getJsxAttribute(context, node)("children");
|
|
893
892
|
if (childrenProp != null) context.report({
|
|
894
|
-
messageId: "
|
|
893
|
+
messageId: "default",
|
|
895
894
|
node: childrenProp
|
|
896
895
|
});
|
|
897
896
|
} };
|
|
@@ -904,7 +903,7 @@ var no_children_to_array_default = createRule({
|
|
|
904
903
|
meta: {
|
|
905
904
|
type: "problem",
|
|
906
905
|
docs: { description: "Disallows the use of 'Children.toArray' from the 'react' package." },
|
|
907
|
-
messages: {
|
|
906
|
+
messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
908
907
|
schema: []
|
|
909
908
|
},
|
|
910
909
|
name: RULE_NAME$46,
|
|
@@ -914,7 +913,7 @@ var no_children_to_array_default = createRule({
|
|
|
914
913
|
function create$46(context) {
|
|
915
914
|
return { MemberExpression(node) {
|
|
916
915
|
if (core.isChildrenToArray(context, node)) context.report({
|
|
917
|
-
messageId: "
|
|
916
|
+
messageId: "default",
|
|
918
917
|
node: node.property
|
|
919
918
|
});
|
|
920
919
|
} };
|
|
@@ -927,7 +926,7 @@ var no_class_component_default = createRule({
|
|
|
927
926
|
meta: {
|
|
928
927
|
type: "problem",
|
|
929
928
|
docs: { description: "Disallows class components except for error boundaries." },
|
|
930
|
-
messages: {
|
|
929
|
+
messages: { default: "Avoid using class components. Use function components instead." },
|
|
931
930
|
schema: []
|
|
932
931
|
},
|
|
933
932
|
name: RULE_NAME$45,
|
|
@@ -941,7 +940,7 @@ function create$45(context) {
|
|
|
941
940
|
for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) {
|
|
942
941
|
if (component.body.body.some((m) => core.isComponentDidCatch(m) || core.isGetDerivedStateFromError(m))) continue;
|
|
943
942
|
context.report({
|
|
944
|
-
messageId: "
|
|
943
|
+
messageId: "default",
|
|
945
944
|
node: component,
|
|
946
945
|
data: { name }
|
|
947
946
|
});
|
|
@@ -956,7 +955,7 @@ var no_clone_element_default = createRule({
|
|
|
956
955
|
meta: {
|
|
957
956
|
type: "problem",
|
|
958
957
|
docs: { description: "Disallows 'cloneElement'." },
|
|
959
|
-
messages: {
|
|
958
|
+
messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
960
959
|
schema: []
|
|
961
960
|
},
|
|
962
961
|
name: RULE_NAME$44,
|
|
@@ -966,7 +965,7 @@ var no_clone_element_default = createRule({
|
|
|
966
965
|
function create$44(context) {
|
|
967
966
|
return { CallExpression(node) {
|
|
968
967
|
if (core.isCloneElementCall(context, node)) context.report({
|
|
969
|
-
messageId: "
|
|
968
|
+
messageId: "default",
|
|
970
969
|
node
|
|
971
970
|
});
|
|
972
971
|
} };
|
|
@@ -980,7 +979,7 @@ var no_component_will_mount_default = createRule({
|
|
|
980
979
|
type: "problem",
|
|
981
980
|
docs: { description: "Replaces usage of 'componentWillMount' with 'UNSAFE_componentWillMount'." },
|
|
982
981
|
fixable: "code",
|
|
983
|
-
messages: {
|
|
982
|
+
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
|
|
984
983
|
schema: []
|
|
985
984
|
},
|
|
986
985
|
name: RULE_NAME$43,
|
|
@@ -994,7 +993,7 @@ function create$43(context) {
|
|
|
994
993
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
995
994
|
const { body } = component.body;
|
|
996
995
|
for (const member of body) if (core.isComponentWillMount(member)) context.report({
|
|
997
|
-
messageId: "
|
|
996
|
+
messageId: "default",
|
|
998
997
|
node: member,
|
|
999
998
|
fix(fixer) {
|
|
1000
999
|
if (!("key" in member)) return null;
|
|
@@ -1013,7 +1012,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1013
1012
|
type: "problem",
|
|
1014
1013
|
docs: { description: "Replaces usage of 'componentWillReceiveProps' with 'UNSAFE_componentWillReceiveProps'." },
|
|
1015
1014
|
fixable: "code",
|
|
1016
|
-
messages: {
|
|
1015
|
+
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
|
|
1017
1016
|
schema: []
|
|
1018
1017
|
},
|
|
1019
1018
|
name: RULE_NAME$42,
|
|
@@ -1027,7 +1026,7 @@ function create$42(context) {
|
|
|
1027
1026
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
1028
1027
|
const { body } = component.body;
|
|
1029
1028
|
for (const member of body) if (core.isComponentWillReceiveProps(member)) context.report({
|
|
1030
|
-
messageId: "
|
|
1029
|
+
messageId: "default",
|
|
1031
1030
|
node: member,
|
|
1032
1031
|
fix(fixer) {
|
|
1033
1032
|
if (!("key" in member)) return null;
|
|
@@ -1046,7 +1045,7 @@ var no_component_will_update_default = createRule({
|
|
|
1046
1045
|
type: "problem",
|
|
1047
1046
|
docs: { description: "Replaces usage of 'componentWillUpdate' with 'UNSAFE_componentWillUpdate'." },
|
|
1048
1047
|
fixable: "code",
|
|
1049
|
-
messages: {
|
|
1048
|
+
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
|
|
1050
1049
|
schema: []
|
|
1051
1050
|
},
|
|
1052
1051
|
name: RULE_NAME$41,
|
|
@@ -1060,7 +1059,7 @@ function create$41(context) {
|
|
|
1060
1059
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
1061
1060
|
const { body } = component.body;
|
|
1062
1061
|
for (const member of body) if (core.isComponentWillUpdate(member)) context.report({
|
|
1063
|
-
messageId: "
|
|
1062
|
+
messageId: "default",
|
|
1064
1063
|
node: member,
|
|
1065
1064
|
fix(fixer) {
|
|
1066
1065
|
if (!("key" in member)) return null;
|
|
@@ -1079,7 +1078,7 @@ var no_context_provider_default = createRule({
|
|
|
1079
1078
|
type: "problem",
|
|
1080
1079
|
docs: { description: "Replaces usage of '<Context.Provider>' with '<Context>'." },
|
|
1081
1080
|
fixable: "code",
|
|
1082
|
-
messages: {
|
|
1081
|
+
messages: { default: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'." },
|
|
1083
1082
|
schema: []
|
|
1084
1083
|
},
|
|
1085
1084
|
name: RULE_NAME$40,
|
|
@@ -1098,7 +1097,7 @@ function create$40(context) {
|
|
|
1098
1097
|
if (selfName !== "Provider") return;
|
|
1099
1098
|
if (contextSelfName == null || !contextSelfName.endsWith("Context")) return;
|
|
1100
1099
|
context.report({
|
|
1101
|
-
messageId: "
|
|
1100
|
+
messageId: "default",
|
|
1102
1101
|
node,
|
|
1103
1102
|
fix(fixer) {
|
|
1104
1103
|
if (!core.isComponentNameLoose(contextSelfName)) return null;
|
|
@@ -1118,7 +1117,7 @@ var no_create_ref_default = createRule({
|
|
|
1118
1117
|
meta: {
|
|
1119
1118
|
type: "problem",
|
|
1120
1119
|
docs: { description: "Disallows 'createRef' in function components." },
|
|
1121
|
-
messages: {
|
|
1120
|
+
messages: { default: "[Deprecated] Use 'useRef' instead." },
|
|
1122
1121
|
schema: []
|
|
1123
1122
|
},
|
|
1124
1123
|
name: RULE_NAME$39,
|
|
@@ -1128,7 +1127,7 @@ var no_create_ref_default = createRule({
|
|
|
1128
1127
|
function create$39(context) {
|
|
1129
1128
|
return { CallExpression(node) {
|
|
1130
1129
|
if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
|
|
1131
|
-
messageId: "
|
|
1130
|
+
messageId: "default",
|
|
1132
1131
|
node
|
|
1133
1132
|
});
|
|
1134
1133
|
} };
|
|
@@ -1141,7 +1140,7 @@ var no_default_props_default = createRule({
|
|
|
1141
1140
|
meta: {
|
|
1142
1141
|
type: "problem",
|
|
1143
1142
|
docs: { description: "Disallows the 'defaultProps' property in favor of ES6 default parameters." },
|
|
1144
|
-
messages: {
|
|
1143
|
+
messages: { default: "[Deprecated] Use ES6 default parameters instead." },
|
|
1145
1144
|
schema: []
|
|
1146
1145
|
},
|
|
1147
1146
|
name: RULE_NAME$38,
|
|
@@ -1160,7 +1159,7 @@ function create$38(context) {
|
|
|
1160
1159
|
if (variableNode == null) return;
|
|
1161
1160
|
if (!ast.isFunction(variableNode)) return;
|
|
1162
1161
|
context.report({
|
|
1163
|
-
messageId: "
|
|
1162
|
+
messageId: "default",
|
|
1164
1163
|
node: property
|
|
1165
1164
|
});
|
|
1166
1165
|
} };
|
|
@@ -1176,7 +1175,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1176
1175
|
meta: {
|
|
1177
1176
|
type: "problem",
|
|
1178
1177
|
docs: { description: "Disallows direct mutation of 'this.state'." },
|
|
1179
|
-
messages: {
|
|
1178
|
+
messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
|
|
1180
1179
|
schema: []
|
|
1181
1180
|
},
|
|
1182
1181
|
name: RULE_NAME$37,
|
|
@@ -1189,7 +1188,7 @@ function create$37(context) {
|
|
|
1189
1188
|
const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
|
|
1190
1189
|
if (parentClass == null) return;
|
|
1191
1190
|
if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== ast.findParentNode(node, isConstructorFunction)) context.report({
|
|
1192
|
-
messageId: "
|
|
1191
|
+
messageId: "default",
|
|
1193
1192
|
node
|
|
1194
1193
|
});
|
|
1195
1194
|
} };
|
|
@@ -1202,7 +1201,7 @@ var no_duplicate_key_default = createRule({
|
|
|
1202
1201
|
meta: {
|
|
1203
1202
|
type: "problem",
|
|
1204
1203
|
docs: { description: "Prevents duplicate 'key' props on sibling elements when rendering lists." },
|
|
1205
|
-
messages: {
|
|
1204
|
+
messages: { default: "The 'key' prop must be unique to its sibling elements." },
|
|
1206
1205
|
schema: []
|
|
1207
1206
|
},
|
|
1208
1207
|
name: RULE_NAME$36,
|
|
@@ -1253,7 +1252,7 @@ function create$36(context) {
|
|
|
1253
1252
|
for (const { hasDuplicate, keys } of keyedEntries.values()) {
|
|
1254
1253
|
if (!hasDuplicate) continue;
|
|
1255
1254
|
for (const key of keys) context.report({
|
|
1256
|
-
messageId: "
|
|
1255
|
+
messageId: "default",
|
|
1257
1256
|
node: key,
|
|
1258
1257
|
data: { value: context.sourceCode.getText(key) }
|
|
1259
1258
|
});
|
|
@@ -1270,7 +1269,7 @@ var no_forward_ref_default = createRule({
|
|
|
1270
1269
|
type: "problem",
|
|
1271
1270
|
docs: { description: "Replaces usage of 'forwardRef' with passing 'ref' as a prop." },
|
|
1272
1271
|
fixable: "code",
|
|
1273
|
-
messages: {
|
|
1272
|
+
messages: { default: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
|
|
1274
1273
|
schema: []
|
|
1275
1274
|
},
|
|
1276
1275
|
name: RULE_NAME$35,
|
|
@@ -1286,7 +1285,7 @@ function create$35(context) {
|
|
|
1286
1285
|
const id = ast.getFunctionId(node);
|
|
1287
1286
|
const fix = canFix(context, node) ? getFix(context, node) : null;
|
|
1288
1287
|
context.report({
|
|
1289
|
-
messageId: "
|
|
1288
|
+
messageId: "default",
|
|
1290
1289
|
node: id ?? node,
|
|
1291
1290
|
fix
|
|
1292
1291
|
});
|
|
@@ -1377,7 +1376,7 @@ var no_implicit_key_default = createRule({
|
|
|
1377
1376
|
meta: {
|
|
1378
1377
|
type: "problem",
|
|
1379
1378
|
docs: { description: "Prevents 'key' from not being explicitly specified (e.g., spreading 'key' from objects)." },
|
|
1380
|
-
messages: {
|
|
1379
|
+
messages: { default: "Do not use implicit 'key' props." },
|
|
1381
1380
|
schema: []
|
|
1382
1381
|
},
|
|
1383
1382
|
name: RULE_NAME$34,
|
|
@@ -1389,7 +1388,7 @@ function create$34(context) {
|
|
|
1389
1388
|
const keyProp = core.getJsxAttribute(context, node.parent)("key");
|
|
1390
1389
|
const isKeyPropOnElement = node.attributes.some((n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key");
|
|
1391
1390
|
if (keyProp != null && !isKeyPropOnElement) context.report({
|
|
1392
|
-
messageId: "
|
|
1391
|
+
messageId: "default",
|
|
1393
1392
|
node: keyProp
|
|
1394
1393
|
});
|
|
1395
1394
|
} };
|
|
@@ -1402,7 +1401,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1402
1401
|
meta: {
|
|
1403
1402
|
type: "problem",
|
|
1404
1403
|
docs: { description: "Prevents problematic leaked values from being rendered." },
|
|
1405
|
-
messages: {
|
|
1404
|
+
messages: { default: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
|
|
1406
1405
|
schema: []
|
|
1407
1406
|
},
|
|
1408
1407
|
name: RULE_NAME$33,
|
|
@@ -1443,14 +1442,14 @@ function create$33(context) {
|
|
|
1443
1442
|
if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!") return getReportDescriptor(right);
|
|
1444
1443
|
const initialScope = context.sourceCode.getScope(left);
|
|
1445
1444
|
if (ast.isIdentifier(left, "NaN") || getStaticValue(left, initialScope)?.value === "NaN") return {
|
|
1446
|
-
messageId: "
|
|
1445
|
+
messageId: "default",
|
|
1447
1446
|
node: left,
|
|
1448
1447
|
data: { value: context.sourceCode.getText(left) }
|
|
1449
1448
|
};
|
|
1450
1449
|
const leftTypeVariants = getTypeVariants(unionConstituents(getConstrainedTypeAtLocation(services, left)));
|
|
1451
1450
|
if (Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type))) return getReportDescriptor(right);
|
|
1452
1451
|
return {
|
|
1453
|
-
messageId: "
|
|
1452
|
+
messageId: "default",
|
|
1454
1453
|
node: left,
|
|
1455
1454
|
data: { value: context.sourceCode.getText(left) }
|
|
1456
1455
|
};
|
|
@@ -1471,7 +1470,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1471
1470
|
meta: {
|
|
1472
1471
|
type: "problem",
|
|
1473
1472
|
docs: { description: "Enforces that all components have a 'displayName' that can be used in DevTools." },
|
|
1474
|
-
messages: {
|
|
1473
|
+
messages: { default: "Add missing 'displayName' for component." },
|
|
1475
1474
|
schema: []
|
|
1476
1475
|
},
|
|
1477
1476
|
name: RULE_NAME$32,
|
|
@@ -1491,7 +1490,7 @@ function create$32(context) {
|
|
|
1491
1490
|
if (id != null) continue;
|
|
1492
1491
|
if (!isMemoOrForwardRef) continue;
|
|
1493
1492
|
if (displayName == null) context.report({
|
|
1494
|
-
messageId: "
|
|
1493
|
+
messageId: "default",
|
|
1495
1494
|
node
|
|
1496
1495
|
});
|
|
1497
1496
|
}
|
|
@@ -1506,7 +1505,7 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1506
1505
|
type: "problem",
|
|
1507
1506
|
docs: { description: "Enforces that all contexts have a 'displayName' that can be used in DevTools." },
|
|
1508
1507
|
fixable: "code",
|
|
1509
|
-
messages: {
|
|
1508
|
+
messages: { default: "Add missing 'displayName' for context." },
|
|
1510
1509
|
schema: []
|
|
1511
1510
|
},
|
|
1512
1511
|
name: RULE_NAME$31,
|
|
@@ -1530,7 +1529,7 @@ function create$31(context) {
|
|
|
1530
1529
|
const id = findEnclosingAssignmentTarget(call);
|
|
1531
1530
|
if (id == null) {
|
|
1532
1531
|
context.report({
|
|
1533
|
-
messageId: "
|
|
1532
|
+
messageId: "default",
|
|
1534
1533
|
node: call
|
|
1535
1534
|
});
|
|
1536
1535
|
continue;
|
|
@@ -1541,7 +1540,7 @@ function create$31(context) {
|
|
|
1541
1540
|
const object = left.object;
|
|
1542
1541
|
return isAssignmentTargetEqual(context, id, object);
|
|
1543
1542
|
})) context.report({
|
|
1544
|
-
messageId: "
|
|
1543
|
+
messageId: "default",
|
|
1545
1544
|
node: id,
|
|
1546
1545
|
fix(fixer) {
|
|
1547
1546
|
if (id.type !== AST_NODE_TYPES.Identifier || id.parent !== call.parent) return [];
|
|
@@ -1695,7 +1694,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1695
1694
|
meta: {
|
|
1696
1695
|
type: "problem",
|
|
1697
1696
|
docs: { description: "Disallows nesting component definitions inside other components." },
|
|
1698
|
-
messages: {
|
|
1697
|
+
messages: { default: "Do not nest component definitions inside other components or props. {{suggestion}}" },
|
|
1699
1698
|
schema: []
|
|
1700
1699
|
},
|
|
1701
1700
|
name: RULE_NAME$28,
|
|
@@ -1720,7 +1719,7 @@ function create$28(context) {
|
|
|
1720
1719
|
if (core.isDirectValueOfRenderPropertyLoose(component)) continue;
|
|
1721
1720
|
if (isInsideJSXAttributeValue(component)) {
|
|
1722
1721
|
if (!core.isDeclaredInRenderPropLoose(component)) context.report({
|
|
1723
|
-
messageId: "
|
|
1722
|
+
messageId: "default",
|
|
1724
1723
|
node: component,
|
|
1725
1724
|
data: {
|
|
1726
1725
|
name,
|
|
@@ -1731,7 +1730,7 @@ function create$28(context) {
|
|
|
1731
1730
|
}
|
|
1732
1731
|
if (isInsideCreateElementProps(context, component)) {
|
|
1733
1732
|
context.report({
|
|
1734
|
-
messageId: "
|
|
1733
|
+
messageId: "default",
|
|
1735
1734
|
node: component,
|
|
1736
1735
|
data: {
|
|
1737
1736
|
name,
|
|
@@ -1743,7 +1742,7 @@ function create$28(context) {
|
|
|
1743
1742
|
const parentComponent = ast.findParentNode(component, isFunctionComponent);
|
|
1744
1743
|
if (parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent)) {
|
|
1745
1744
|
context.report({
|
|
1746
|
-
messageId: "
|
|
1745
|
+
messageId: "default",
|
|
1747
1746
|
node: component,
|
|
1748
1747
|
data: {
|
|
1749
1748
|
name,
|
|
@@ -1753,7 +1752,7 @@ function create$28(context) {
|
|
|
1753
1752
|
continue;
|
|
1754
1753
|
}
|
|
1755
1754
|
if (isInsideRenderMethod(component)) context.report({
|
|
1756
|
-
messageId: "
|
|
1755
|
+
messageId: "default",
|
|
1757
1756
|
node: component,
|
|
1758
1757
|
data: {
|
|
1759
1758
|
name,
|
|
@@ -1764,7 +1763,7 @@ function create$28(context) {
|
|
|
1764
1763
|
for (const { name = "unknown", node: component } of cComponents) {
|
|
1765
1764
|
if (ast.findParentNode(component, (n) => isClassComponent(n) || isFunctionComponent(n)) == null) continue;
|
|
1766
1765
|
context.report({
|
|
1767
|
-
messageId: "
|
|
1766
|
+
messageId: "default",
|
|
1768
1767
|
node: component,
|
|
1769
1768
|
data: {
|
|
1770
1769
|
name,
|
|
@@ -1812,7 +1811,7 @@ var no_nested_lazy_component_declarations_default = createRule({
|
|
|
1812
1811
|
meta: {
|
|
1813
1812
|
type: "problem",
|
|
1814
1813
|
docs: { description: "Disallows nesting lazy component declarations inside other components." },
|
|
1815
|
-
messages: {
|
|
1814
|
+
messages: { default: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
|
|
1816
1815
|
schema: []
|
|
1817
1816
|
},
|
|
1818
1817
|
name: RULE_NAME$27,
|
|
@@ -1839,7 +1838,7 @@ function create$27(context) {
|
|
|
1839
1838
|
if (ast.isClass(n)) return classComponents.some((c) => c.node === n);
|
|
1840
1839
|
return false;
|
|
1841
1840
|
}) != null) context.report({
|
|
1842
|
-
messageId: "
|
|
1841
|
+
messageId: "default",
|
|
1843
1842
|
node: lazy
|
|
1844
1843
|
});
|
|
1845
1844
|
}
|
|
@@ -1853,7 +1852,7 @@ var no_prop_types_default = createRule({
|
|
|
1853
1852
|
meta: {
|
|
1854
1853
|
type: "problem",
|
|
1855
1854
|
docs: { description: "Disallows 'propTypes' in favor of TypeScript or another type-checking solution." },
|
|
1856
|
-
messages: {
|
|
1855
|
+
messages: { default: "[Deprecated] Use TypeScript or another type-checking solution instead." },
|
|
1857
1856
|
schema: []
|
|
1858
1857
|
},
|
|
1859
1858
|
name: RULE_NAME$26,
|
|
@@ -1871,7 +1870,7 @@ function create$26(context) {
|
|
|
1871
1870
|
if (!core.isComponentNameLoose(object.name)) return;
|
|
1872
1871
|
const variableNode = getVariableDefinitionNode(findVariable(object.name, context.sourceCode.getScope(node)), 0);
|
|
1873
1872
|
if (variableNode != null && (ast.isFunction(variableNode) || core.isClassComponent(variableNode))) context.report({
|
|
1874
|
-
messageId: "
|
|
1873
|
+
messageId: "default",
|
|
1875
1874
|
node: property
|
|
1876
1875
|
});
|
|
1877
1876
|
},
|
|
@@ -1879,7 +1878,7 @@ function create$26(context) {
|
|
|
1879
1878
|
if (!core.isClassComponent(node.parent.parent)) return;
|
|
1880
1879
|
if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") return;
|
|
1881
1880
|
context.report({
|
|
1882
|
-
messageId: "
|
|
1881
|
+
messageId: "default",
|
|
1883
1882
|
node
|
|
1884
1883
|
});
|
|
1885
1884
|
}
|
|
@@ -1896,7 +1895,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1896
1895
|
meta: {
|
|
1897
1896
|
type: "problem",
|
|
1898
1897
|
docs: { description: "Disallows 'shouldComponentUpdate' when extending 'React.PureComponent'." },
|
|
1899
|
-
messages: {
|
|
1898
|
+
messages: { default: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
|
|
1900
1899
|
schema: []
|
|
1901
1900
|
},
|
|
1902
1901
|
name: RULE_NAME$25,
|
|
@@ -1911,7 +1910,7 @@ function create$25(context) {
|
|
|
1911
1910
|
if ((flag & core.ComponentFlag.PureComponent) === 0n) continue;
|
|
1912
1911
|
const { body } = component.body;
|
|
1913
1912
|
for (const member of body) if (isShouldComponentUpdate(member)) context.report({
|
|
1914
|
-
messageId: "
|
|
1913
|
+
messageId: "default",
|
|
1915
1914
|
node: member,
|
|
1916
1915
|
data: { componentName: name }
|
|
1917
1916
|
});
|
|
@@ -1926,7 +1925,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1926
1925
|
meta: {
|
|
1927
1926
|
type: "problem",
|
|
1928
1927
|
docs: { description: "Disallows calling 'this.setState' in 'componentDidMount' outside functions such as callbacks." },
|
|
1929
|
-
messages: {
|
|
1928
|
+
messages: { default: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
|
|
1930
1929
|
schema: []
|
|
1931
1930
|
},
|
|
1932
1931
|
name: RULE_NAME$24,
|
|
@@ -1943,7 +1942,7 @@ function create$24(context) {
|
|
|
1943
1942
|
const enclosingMethodScope = context.sourceCode.getScope(enclosingMethodNode);
|
|
1944
1943
|
const setStateCallParentScope = context.sourceCode.getScope(node).upper;
|
|
1945
1944
|
if (enclosingMethodNode.parent === enclosingClassNode.body && setStateCallParentScope === enclosingMethodScope) context.report({
|
|
1946
|
-
messageId: "
|
|
1945
|
+
messageId: "default",
|
|
1947
1946
|
node
|
|
1948
1947
|
});
|
|
1949
1948
|
} };
|
|
@@ -1956,7 +1955,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1956
1955
|
meta: {
|
|
1957
1956
|
type: "problem",
|
|
1958
1957
|
docs: { description: "Disallows calling 'this.setState' in 'componentDidUpdate' outside functions such as callbacks." },
|
|
1959
|
-
messages: {
|
|
1958
|
+
messages: { default: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
|
|
1960
1959
|
schema: []
|
|
1961
1960
|
},
|
|
1962
1961
|
name: RULE_NAME$23,
|
|
@@ -1973,7 +1972,7 @@ function create$23(context) {
|
|
|
1973
1972
|
const enclosingMethodScope = context.sourceCode.getScope(enclosingMethodNode);
|
|
1974
1973
|
const setStateCallParentScope = context.sourceCode.getScope(node).upper;
|
|
1975
1974
|
if (enclosingMethodNode.parent === enclosingClassNode.body && setStateCallParentScope === enclosingMethodScope) context.report({
|
|
1976
|
-
messageId: "
|
|
1975
|
+
messageId: "default",
|
|
1977
1976
|
node
|
|
1978
1977
|
});
|
|
1979
1978
|
} };
|
|
@@ -1986,7 +1985,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1986
1985
|
meta: {
|
|
1987
1986
|
type: "problem",
|
|
1988
1987
|
docs: { description: "Disallows calling 'this.setState' in 'componentWillUpdate' outside functions such as callbacks." },
|
|
1989
|
-
messages: {
|
|
1988
|
+
messages: { default: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
|
|
1990
1989
|
schema: []
|
|
1991
1990
|
},
|
|
1992
1991
|
name: RULE_NAME$22,
|
|
@@ -2003,7 +2002,7 @@ function create$22(context) {
|
|
|
2003
2002
|
const enclosingMethodScope = context.sourceCode.getScope(enclosingMethodNode);
|
|
2004
2003
|
const setStateCallParentScope = context.sourceCode.getScope(node).upper;
|
|
2005
2004
|
if (enclosingMethodNode.parent === enclosingClassNode.body && setStateCallParentScope === enclosingMethodScope) context.report({
|
|
2006
|
-
messageId: "
|
|
2005
|
+
messageId: "default",
|
|
2007
2006
|
node
|
|
2008
2007
|
});
|
|
2009
2008
|
} };
|
|
@@ -2017,7 +2016,7 @@ var no_string_refs_default = createRule({
|
|
|
2017
2016
|
type: "problem",
|
|
2018
2017
|
docs: { description: "Replaces string refs with callback refs." },
|
|
2019
2018
|
fixable: "code",
|
|
2020
|
-
messages: {
|
|
2019
|
+
messages: { default: "[Deprecated] Use callback refs instead." },
|
|
2021
2020
|
schema: []
|
|
2022
2021
|
},
|
|
2023
2022
|
name: RULE_NAME$21,
|
|
@@ -2040,7 +2039,7 @@ function create$21(context) {
|
|
|
2040
2039
|
const refName = getJsxAttributeValueText(context, node.value);
|
|
2041
2040
|
if (refName == null) return;
|
|
2042
2041
|
context.report({
|
|
2043
|
-
messageId: "
|
|
2042
|
+
messageId: "default",
|
|
2044
2043
|
node,
|
|
2045
2044
|
fix(fixer) {
|
|
2046
2045
|
if (node.value == null) return null;
|
|
@@ -2074,7 +2073,7 @@ var no_unnecessary_key_default = createRule({
|
|
|
2074
2073
|
meta: {
|
|
2075
2074
|
type: "problem",
|
|
2076
2075
|
docs: { description: "Disallows unnecessary 'key' props on nested child elements when rendering lists." },
|
|
2077
|
-
messages: {
|
|
2076
|
+
messages: { default: "Unnecessary `key` prop on this element. {{reason}}" },
|
|
2078
2077
|
schema: []
|
|
2079
2078
|
},
|
|
2080
2079
|
name: RULE_NAME$20,
|
|
@@ -2102,7 +2101,7 @@ function create$20(context) {
|
|
|
2102
2101
|
});
|
|
2103
2102
|
if (keyedElementOrElse == null || keyedElementOrElse === mapCallback) return;
|
|
2104
2103
|
context.report({
|
|
2105
|
-
messageId: "
|
|
2104
|
+
messageId: "default",
|
|
2106
2105
|
node,
|
|
2107
2106
|
data: { reason: "A parent element already has a `key` prop in the same list rendering context." }
|
|
2108
2107
|
});
|
|
@@ -2136,7 +2135,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
2136
2135
|
type: "problem",
|
|
2137
2136
|
docs: { description: "Disallows unnecessary usage of 'useCallback'." },
|
|
2138
2137
|
messages: {
|
|
2139
|
-
|
|
2138
|
+
default: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary.",
|
|
2140
2139
|
noUnnecessaryUseCallbackInsideUseEffect: "{{name}} is only used inside 1 useEffect, which may be unnecessary. You can move the computation into useEffect directly and merge the dependency arrays."
|
|
2141
2140
|
},
|
|
2142
2141
|
schema: []
|
|
@@ -2177,7 +2176,7 @@ function create$19(context) {
|
|
|
2177
2176
|
if (arg0Node == null) return;
|
|
2178
2177
|
if (!getChildScopes(context.sourceCode.getScope(arg0Node)).flatMap((x) => x.references).some((x) => x.resolved?.scope.block === component)) {
|
|
2179
2178
|
context.report({
|
|
2180
|
-
messageId: "
|
|
2179
|
+
messageId: "default",
|
|
2181
2180
|
node
|
|
2182
2181
|
});
|
|
2183
2182
|
return;
|
|
@@ -2213,7 +2212,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
2213
2212
|
type: "problem",
|
|
2214
2213
|
docs: { description: "Disallows unnecessary usage of 'useMemo'." },
|
|
2215
2214
|
messages: {
|
|
2216
|
-
|
|
2215
|
+
default: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary.",
|
|
2217
2216
|
noUnnecessaryUseMemoInsideUseEffect: "{{name}} is only used inside 1 useEffect, which may be unnecessary. You can move the computation into useEffect directly and merge the dependency arrays."
|
|
2218
2217
|
},
|
|
2219
2218
|
schema: []
|
|
@@ -2258,7 +2257,7 @@ function create$18(context) {
|
|
|
2258
2257
|
if (arg0Node == null) return;
|
|
2259
2258
|
if (!getChildScopes(context.sourceCode.getScope(arg0Node)).flatMap((x) => x.references).some((x) => x.resolved?.scope.block === component)) {
|
|
2260
2259
|
context.report({
|
|
2261
|
-
messageId: "
|
|
2260
|
+
messageId: "default",
|
|
2262
2261
|
node
|
|
2263
2262
|
});
|
|
2264
2263
|
return;
|
|
@@ -2297,7 +2296,7 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
2297
2296
|
meta: {
|
|
2298
2297
|
type: "problem",
|
|
2299
2298
|
docs: { description: "Enforces that a function with the 'use' prefix uses at least one Hook inside it." },
|
|
2300
|
-
messages: {
|
|
2299
|
+
messages: { default: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
|
|
2301
2300
|
schema: []
|
|
2302
2301
|
},
|
|
2303
2302
|
name: RULE_NAME$17,
|
|
@@ -2314,7 +2313,7 @@ function create$17(context) {
|
|
|
2314
2313
|
if (containsUseComments(context, node)) continue;
|
|
2315
2314
|
if (ast.findParentNode(node, ast.isViMockCallback) != null) continue;
|
|
2316
2315
|
context.report({
|
|
2317
|
-
messageId: "
|
|
2316
|
+
messageId: "default",
|
|
2318
2317
|
node: id ?? node,
|
|
2319
2318
|
data: { name }
|
|
2320
2319
|
});
|
|
@@ -2329,7 +2328,7 @@ var no_unnecessary_use_ref_default = createRule({
|
|
|
2329
2328
|
meta: {
|
|
2330
2329
|
type: "problem",
|
|
2331
2330
|
docs: { description: "Disallows unnecessary usage of 'useRef'." },
|
|
2332
|
-
messages: {
|
|
2331
|
+
messages: { default: "Unnecessary use of 'useRef'. Instead, co-locate the value inside the effect that uses it." },
|
|
2333
2332
|
schema: []
|
|
2334
2333
|
},
|
|
2335
2334
|
name: RULE_NAME$16,
|
|
@@ -2354,7 +2353,7 @@ function create$16(context) {
|
|
|
2354
2353
|
}
|
|
2355
2354
|
if (globalUsages > 0 || effects.size !== 1) return;
|
|
2356
2355
|
context.report({
|
|
2357
|
-
messageId: "
|
|
2356
|
+
messageId: "default",
|
|
2358
2357
|
node: node.parent
|
|
2359
2358
|
});
|
|
2360
2359
|
} };
|
|
@@ -2367,7 +2366,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2367
2366
|
meta: {
|
|
2368
2367
|
type: "problem",
|
|
2369
2368
|
docs: { description: "Warns about the use of 'UNSAFE_componentWillMount' in class components." },
|
|
2370
|
-
messages: {
|
|
2369
|
+
messages: { default: "Do not use 'UNSAFE_componentWillMount'." },
|
|
2371
2370
|
schema: []
|
|
2372
2371
|
},
|
|
2373
2372
|
name: RULE_NAME$15,
|
|
@@ -2381,7 +2380,7 @@ function create$15(context) {
|
|
|
2381
2380
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
2382
2381
|
const { body } = component.body;
|
|
2383
2382
|
for (const member of body) if (core.isUnsafeComponentWillMount(member)) context.report({
|
|
2384
|
-
messageId: "
|
|
2383
|
+
messageId: "default",
|
|
2385
2384
|
node: member
|
|
2386
2385
|
});
|
|
2387
2386
|
}
|
|
@@ -2395,7 +2394,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2395
2394
|
meta: {
|
|
2396
2395
|
type: "problem",
|
|
2397
2396
|
docs: { description: "Warns about the use of 'UNSAFE_componentWillReceiveProps' in class components." },
|
|
2398
|
-
messages: {
|
|
2397
|
+
messages: { default: "Do not use 'UNSAFE_componentWillReceiveProps'." },
|
|
2399
2398
|
schema: []
|
|
2400
2399
|
},
|
|
2401
2400
|
name: RULE_NAME$14,
|
|
@@ -2409,7 +2408,7 @@ function create$14(context) {
|
|
|
2409
2408
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
2410
2409
|
const { body } = component.body;
|
|
2411
2410
|
for (const member of body) if (core.isUnsafeComponentWillReceiveProps(member)) context.report({
|
|
2412
|
-
messageId: "
|
|
2411
|
+
messageId: "default",
|
|
2413
2412
|
node: member
|
|
2414
2413
|
});
|
|
2415
2414
|
}
|
|
@@ -2423,7 +2422,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2423
2422
|
meta: {
|
|
2424
2423
|
type: "problem",
|
|
2425
2424
|
docs: { description: "Warns about the use of 'UNSAFE_componentWillUpdate' in class components." },
|
|
2426
|
-
messages: {
|
|
2425
|
+
messages: { default: "Do not use 'UNSAFE_componentWillUpdate'." },
|
|
2427
2426
|
schema: []
|
|
2428
2427
|
},
|
|
2429
2428
|
name: RULE_NAME$13,
|
|
@@ -2437,7 +2436,7 @@ function create$13(context) {
|
|
|
2437
2436
|
for (const { node: component } of ctx.getAllComponents(program)) {
|
|
2438
2437
|
const { body } = component.body;
|
|
2439
2438
|
for (const member of body) if (core.isUnsafeComponentWillUpdate(member)) context.report({
|
|
2440
|
-
messageId: "
|
|
2439
|
+
messageId: "default",
|
|
2441
2440
|
node: member
|
|
2442
2441
|
});
|
|
2443
2442
|
}
|
|
@@ -2520,7 +2519,7 @@ var no_unstable_default_props_default = createRule({
|
|
|
2520
2519
|
meta: {
|
|
2521
2520
|
type: "problem",
|
|
2522
2521
|
docs: { description: "Prevents using referential-type values as default props in object destructuring." },
|
|
2523
|
-
messages: {
|
|
2522
|
+
messages: { default: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'." },
|
|
2524
2523
|
schema: schema$1
|
|
2525
2524
|
},
|
|
2526
2525
|
name: RULE_NAME$11,
|
|
@@ -2568,7 +2567,7 @@ function create$11(context, [options]) {
|
|
|
2568
2567
|
}
|
|
2569
2568
|
const forbiddenType = ast.toDelimiterFormat(right);
|
|
2570
2569
|
context.report({
|
|
2571
|
-
messageId: "
|
|
2570
|
+
messageId: "default",
|
|
2572
2571
|
node: right,
|
|
2573
2572
|
data: { forbiddenType }
|
|
2574
2573
|
});
|
|
@@ -2608,7 +2607,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2608
2607
|
meta: {
|
|
2609
2608
|
type: "problem",
|
|
2610
2609
|
docs: { description: "Warns about unused class component methods and properties." },
|
|
2611
|
-
messages: {
|
|
2610
|
+
messages: { default: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
|
|
2612
2611
|
schema: []
|
|
2613
2612
|
},
|
|
2614
2613
|
name: RULE_NAME$10,
|
|
@@ -2638,7 +2637,7 @@ function create$10(context) {
|
|
|
2638
2637
|
if (methodName == null) continue;
|
|
2639
2638
|
if ((usages?.has(methodName) ?? false) || LIFECYCLE_METHODS.has(methodName)) continue;
|
|
2640
2639
|
context.report({
|
|
2641
|
-
messageId: "
|
|
2640
|
+
messageId: "default",
|
|
2642
2641
|
node: def,
|
|
2643
2642
|
data: {
|
|
2644
2643
|
className: id != null ? context.sourceCode.getText(id) : "Component",
|
|
@@ -2701,7 +2700,7 @@ var no_unused_props_default = createRule({
|
|
|
2701
2700
|
meta: {
|
|
2702
2701
|
type: "problem",
|
|
2703
2702
|
docs: { description: "Warns about component props that are defined but never used." },
|
|
2704
|
-
messages: {
|
|
2703
|
+
messages: { default: "Prop `{{name}}` is declared but never used" },
|
|
2705
2704
|
schema: []
|
|
2706
2705
|
},
|
|
2707
2706
|
name: RULE_NAME$9,
|
|
@@ -2798,7 +2797,7 @@ function reportUnusedProp(context, services, prop) {
|
|
|
2798
2797
|
if (declarationNode == null) return;
|
|
2799
2798
|
const nodeToReport = declarationNode.type === AST_NODE_TYPES.TSPropertySignature ? declarationNode.key : declarationNode;
|
|
2800
2799
|
context.report({
|
|
2801
|
-
messageId: "
|
|
2800
|
+
messageId: "default",
|
|
2802
2801
|
node: nodeToReport,
|
|
2803
2802
|
data: { name: prop.name }
|
|
2804
2803
|
});
|
|
@@ -2817,7 +2816,7 @@ var no_unused_state_default = createRule({
|
|
|
2817
2816
|
meta: {
|
|
2818
2817
|
type: "problem",
|
|
2819
2818
|
docs: { description: "Warns about unused class component state." },
|
|
2820
|
-
messages: {
|
|
2819
|
+
messages: { default: "Unused class component state in '{{className}}'" },
|
|
2821
2820
|
schema: []
|
|
2822
2821
|
},
|
|
2823
2822
|
name: RULE_NAME$8,
|
|
@@ -2839,7 +2838,7 @@ function create$8(context) {
|
|
|
2839
2838
|
const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
|
|
2840
2839
|
if (defNode == null || isUsed) return;
|
|
2841
2840
|
context.report({
|
|
2842
|
-
messageId: "
|
|
2841
|
+
messageId: "default",
|
|
2843
2842
|
node: defNode,
|
|
2844
2843
|
data: { className: id != null ? context.sourceCode.getText(id) : "Component" }
|
|
2845
2844
|
});
|
|
@@ -2939,7 +2938,7 @@ var no_use_context_default = createRule({
|
|
|
2939
2938
|
type: "problem",
|
|
2940
2939
|
docs: { description: "Replaces usage of 'useContext' with 'use'." },
|
|
2941
2940
|
fixable: "code",
|
|
2942
|
-
messages: {
|
|
2941
|
+
messages: { default: "In React 19, 'use' is preferred over 'useContext' because it is more flexible." },
|
|
2943
2942
|
schema: []
|
|
2944
2943
|
},
|
|
2945
2944
|
name: RULE_NAME$7,
|
|
@@ -2966,7 +2965,7 @@ function create$7(context) {
|
|
|
2966
2965
|
if (specifier.type !== AST_NODE_TYPES.ImportSpecifier) continue;
|
|
2967
2966
|
if (specifier.imported.type !== AST_NODE_TYPES.Identifier) continue;
|
|
2968
2967
|
if (specifier.imported.name === "useContext") context.report({
|
|
2969
|
-
messageId: "
|
|
2968
|
+
messageId: "default",
|
|
2970
2969
|
node: specifier,
|
|
2971
2970
|
fix(fixer) {
|
|
2972
2971
|
if (isUseImported) {
|
|
@@ -2986,7 +2985,7 @@ function create$7(context) {
|
|
|
2986
2985
|
for (const node of hookCalls) {
|
|
2987
2986
|
if (!core.isUseContextCall(node)) continue;
|
|
2988
2987
|
context.report({
|
|
2989
|
-
messageId: "
|
|
2988
|
+
messageId: "default",
|
|
2990
2989
|
node: node.callee,
|
|
2991
2990
|
fix(fixer) {
|
|
2992
2991
|
switch (node.callee.type) {
|
|
@@ -3016,7 +3015,7 @@ var no_useless_forward_ref_default = createRule({
|
|
|
3016
3015
|
meta: {
|
|
3017
3016
|
type: "problem",
|
|
3018
3017
|
docs: { description: "Disallows useless 'forwardRef' calls on components that don't use 'ref's." },
|
|
3019
|
-
messages: {
|
|
3018
|
+
messages: { default: "A 'forwardRef' is used with this component but no 'ref' parameter is set." },
|
|
3020
3019
|
schema: []
|
|
3021
3020
|
},
|
|
3022
3021
|
name: RULE_NAME$6,
|
|
@@ -3030,7 +3029,7 @@ function create$6(context) {
|
|
|
3030
3029
|
if (component == null || !ast.isFunction(component)) return;
|
|
3031
3030
|
if (component.params[1] != null) return;
|
|
3032
3031
|
context.report({
|
|
3033
|
-
messageId: "
|
|
3032
|
+
messageId: "default",
|
|
3034
3033
|
node: node.callee
|
|
3035
3034
|
});
|
|
3036
3035
|
} };
|
|
@@ -3063,7 +3062,7 @@ var no_useless_fragment_default = createRule({
|
|
|
3063
3062
|
defaultOptions: [...defaultOptions$1],
|
|
3064
3063
|
docs: { description: "Disallows useless fragment elements." },
|
|
3065
3064
|
fixable: "code",
|
|
3066
|
-
messages: {
|
|
3065
|
+
messages: { default: "A fragment {{reason}} is useless." },
|
|
3067
3066
|
schema
|
|
3068
3067
|
},
|
|
3069
3068
|
name: RULE_NAME$5,
|
|
@@ -3082,7 +3081,7 @@ function create$5(context, [option]) {
|
|
|
3082
3081
|
function checkNode(context, node) {
|
|
3083
3082
|
if (node.type === AST_NODE_TYPES.JSXElement && core.getJsxAttribute(context, node)("key") != null) return;
|
|
3084
3083
|
if (core.isJsxHostElement(context, node.parent)) context.report({
|
|
3085
|
-
messageId: "
|
|
3084
|
+
messageId: "default",
|
|
3086
3085
|
node,
|
|
3087
3086
|
data: { reason: "placed inside a host component" },
|
|
3088
3087
|
fix: getFix(context, node)
|
|
@@ -3090,7 +3089,7 @@ function create$5(context, [option]) {
|
|
|
3090
3089
|
if (node.children.length === 0) {
|
|
3091
3090
|
if (allowEmptyFragment) return;
|
|
3092
3091
|
context.report({
|
|
3093
|
-
messageId: "
|
|
3092
|
+
messageId: "default",
|
|
3094
3093
|
node,
|
|
3095
3094
|
data: { reason: "contains less than two children" },
|
|
3096
3095
|
fix: getFix(context, node)
|
|
@@ -3102,7 +3101,7 @@ function create$5(context, [option]) {
|
|
|
3102
3101
|
case allowExpressions && !isChildElement && node.children.length === 1 && core.isJsxText(node.children.at(0)): return;
|
|
3103
3102
|
case !allowExpressions && isChildElement:
|
|
3104
3103
|
context.report({
|
|
3105
|
-
messageId: "
|
|
3104
|
+
messageId: "default",
|
|
3106
3105
|
node,
|
|
3107
3106
|
data: { reason: "contains less than two children" },
|
|
3108
3107
|
fix: getFix(context, node)
|
|
@@ -3110,7 +3109,7 @@ function create$5(context, [option]) {
|
|
|
3110
3109
|
return;
|
|
3111
3110
|
case !allowExpressions && !isChildElement && node.children.length === 1:
|
|
3112
3111
|
context.report({
|
|
3113
|
-
messageId: "
|
|
3112
|
+
messageId: "default",
|
|
3114
3113
|
node,
|
|
3115
3114
|
data: { reason: "contains less than two children" },
|
|
3116
3115
|
fix: getFix(context, node)
|
|
@@ -3120,7 +3119,7 @@ function create$5(context, [option]) {
|
|
|
3120
3119
|
const nonPaddingChildren = node.children.filter((child) => !isPaddingSpaces(child));
|
|
3121
3120
|
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3122
3121
|
if (nonPaddingChildren.length === 0 || nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer) context.report({
|
|
3123
|
-
messageId: "
|
|
3122
|
+
messageId: "default",
|
|
3124
3123
|
node,
|
|
3125
3124
|
data: { reason: "contains less than two children" },
|
|
3126
3125
|
fix: getFix(context, node)
|
|
@@ -3183,7 +3182,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3183
3182
|
meta: {
|
|
3184
3183
|
type: "problem",
|
|
3185
3184
|
docs: { description: "Enforces destructuring assignment for component props and context." },
|
|
3186
|
-
messages: {
|
|
3185
|
+
messages: { default: "Use destructuring assignment for component props." },
|
|
3187
3186
|
schema: []
|
|
3188
3187
|
},
|
|
3189
3188
|
name: RULE_NAME$4,
|
|
@@ -3204,7 +3203,7 @@ function create$4(context) {
|
|
|
3204
3203
|
const { name, parent } = ref.identifier;
|
|
3205
3204
|
if (parent.type !== AST_NODE_TYPES.MemberExpression) continue;
|
|
3206
3205
|
context.report({
|
|
3207
|
-
messageId: "
|
|
3206
|
+
messageId: "default",
|
|
3208
3207
|
node: parent
|
|
3209
3208
|
});
|
|
3210
3209
|
}
|
|
@@ -3220,7 +3219,7 @@ var prefer_namespace_import_default = createRule({
|
|
|
3220
3219
|
type: "problem",
|
|
3221
3220
|
docs: { description: "Enforces importing React via a namespace import." },
|
|
3222
3221
|
fixable: "code",
|
|
3223
|
-
messages: {
|
|
3222
|
+
messages: { default: "Prefer importing React as 'import * as React from \"{{importSource}}\"';" },
|
|
3224
3223
|
schema: []
|
|
3225
3224
|
},
|
|
3226
3225
|
name: RULE_NAME$3,
|
|
@@ -3232,7 +3231,7 @@ function create$3(context) {
|
|
|
3232
3231
|
return { [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3233
3232
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
3234
3233
|
context.report({
|
|
3235
|
-
messageId: "
|
|
3234
|
+
messageId: "default",
|
|
3236
3235
|
node: hasOtherSpecifiers ? node : node.parent,
|
|
3237
3236
|
data: { importSource },
|
|
3238
3237
|
fix(fixer) {
|
|
@@ -3256,7 +3255,7 @@ var prefer_read_only_props_default = createRule({
|
|
|
3256
3255
|
meta: {
|
|
3257
3256
|
type: "problem",
|
|
3258
3257
|
docs: { description: "Enforces read-only props in components." },
|
|
3259
|
-
messages: {
|
|
3258
|
+
messages: { default: "A function component's props should be read-only." },
|
|
3260
3259
|
schema: []
|
|
3261
3260
|
},
|
|
3262
3261
|
name: RULE_NAME$2,
|
|
@@ -3277,7 +3276,7 @@ function create$2(context) {
|
|
|
3277
3276
|
if (isTypeReadonlyLoose(services, propsType)) continue;
|
|
3278
3277
|
if (propsType.isClassOrInterface() && isClassOrInterfaceReadonlyLoose(checker, propsType)) continue;
|
|
3279
3278
|
context.report({
|
|
3280
|
-
messageId: "
|
|
3279
|
+
messageId: "default",
|
|
3281
3280
|
node: props
|
|
3282
3281
|
});
|
|
3283
3282
|
}
|
|
@@ -3314,7 +3313,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
|
|
|
3314
3313
|
meta: {
|
|
3315
3314
|
type: "problem",
|
|
3316
3315
|
docs: { description: "Enforces wrapping function calls made inside 'useState' in an 'initializer function'." },
|
|
3317
|
-
messages: {
|
|
3316
|
+
messages: { default: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'." },
|
|
3318
3317
|
schema: []
|
|
3319
3318
|
},
|
|
3320
3319
|
name: RULE_NAME$1,
|
|
@@ -3331,7 +3330,7 @@ function create$1(context) {
|
|
|
3331
3330
|
if (ALLOW_LIST.includes(expr.callee.name)) continue;
|
|
3332
3331
|
if (ast.findParentNode(expr, core.isUseCall) != null) continue;
|
|
3333
3332
|
context.report({
|
|
3334
|
-
messageId: "
|
|
3333
|
+
messageId: "default",
|
|
3335
3334
|
node: expr
|
|
3336
3335
|
});
|
|
3337
3336
|
}
|
|
@@ -3341,7 +3340,7 @@ function create$1(context) {
|
|
|
3341
3340
|
if (ALLOW_LIST.includes(expr.callee.name)) continue;
|
|
3342
3341
|
if (ast.findParentNode(expr, core.isUseCall) != null) continue;
|
|
3343
3342
|
context.report({
|
|
3344
|
-
messageId: "
|
|
3343
|
+
messageId: "default",
|
|
3345
3344
|
node: expr
|
|
3346
3345
|
});
|
|
3347
3346
|
}
|
|
@@ -3351,7 +3350,6 @@ function create$1(context) {
|
|
|
3351
3350
|
//#endregion
|
|
3352
3351
|
//#region src/rules-removed/no-forbidden-props.ts
|
|
3353
3352
|
const RULE_NAME = "no-forbidden-props";
|
|
3354
|
-
const messageId = camelCase(RULE_NAME);
|
|
3355
3353
|
const defaultOptions = [{ forbid: [{ prop: "/_/" }] }];
|
|
3356
3354
|
var no_forbidden_props_default = createRule({
|
|
3357
3355
|
meta: {
|
|
@@ -3366,7 +3364,7 @@ var no_forbidden_props_default = createRule({
|
|
|
3366
3364
|
} }]
|
|
3367
3365
|
},
|
|
3368
3366
|
docs: { description: "Disallows certain props on components." },
|
|
3369
|
-
messages: {
|
|
3367
|
+
messages: { default: "Prop \"{{name}}\" is forbidden." },
|
|
3370
3368
|
schema: [{
|
|
3371
3369
|
type: "object",
|
|
3372
3370
|
additionalProperties: false,
|
|
@@ -3424,7 +3422,7 @@ function create(context, [option]) {
|
|
|
3424
3422
|
if ("includedNodes" in forbiddenPropItem && !forbiddenPropItem.includedNodes.includes(nodeName)) continue;
|
|
3425
3423
|
}
|
|
3426
3424
|
if (toRegExp(typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop).test(name)) context.report({
|
|
3427
|
-
messageId,
|
|
3425
|
+
messageId: "default",
|
|
3428
3426
|
node: attr,
|
|
3429
3427
|
data: { name }
|
|
3430
3428
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.8.2-beta.
|
|
3
|
+
"version": "2.8.2-beta.5",
|
|
4
4
|
"description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,14 +43,13 @@
|
|
|
43
43
|
"@typescript-eslint/utils": "^8.54.0",
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"is-immutable-type": "^5.0.1",
|
|
46
|
-
"string-ts": "^2.3.1",
|
|
47
46
|
"ts-api-utils": "^2.4.0",
|
|
48
47
|
"ts-pattern": "^5.9.0",
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/var": "2.8.2-beta.
|
|
53
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/core": "2.8.2-beta.5",
|
|
49
|
+
"@eslint-react/ast": "2.8.2-beta.5",
|
|
50
|
+
"@eslint-react/shared": "2.8.2-beta.5",
|
|
51
|
+
"@eslint-react/var": "2.8.2-beta.5",
|
|
52
|
+
"@eslint-react/eff": "2.8.2-beta.5"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@types/react": "^19.2.10",
|