eslint-plugin-react-x 2.3.11-next.1 → 2.3.12-next.0
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 +232 -213
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __export = (all, symbols) => {
|
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
36
|
var name$6 = "eslint-plugin-react-x";
|
|
37
|
-
var version = "2.3.
|
|
37
|
+
var version = "2.3.12-next.0";
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/utils/create-rule.ts
|
|
@@ -125,13 +125,13 @@ function getTypeVariants(types) {
|
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/rules/jsx-dollar.ts
|
|
127
127
|
const RULE_NAME$62 = "jsx-dollar";
|
|
128
|
-
const RULE_FEATURES$
|
|
128
|
+
const RULE_FEATURES$62 = [];
|
|
129
129
|
var jsx_dollar_default = createRule({
|
|
130
130
|
meta: {
|
|
131
131
|
type: "problem",
|
|
132
132
|
docs: {
|
|
133
133
|
description: "Prevents dollar signs from being inserted as text nodes before expressions.",
|
|
134
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
134
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$62
|
|
135
135
|
},
|
|
136
136
|
fixable: "code",
|
|
137
137
|
hasSuggestions: true,
|
|
@@ -187,13 +187,13 @@ function create$62(context) {
|
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/rules/jsx-key-before-spread.ts
|
|
189
189
|
const RULE_NAME$61 = "jsx-key-before-spread";
|
|
190
|
-
const RULE_FEATURES$
|
|
190
|
+
const RULE_FEATURES$61 = ["EXP"];
|
|
191
191
|
var jsx_key_before_spread_default = createRule({
|
|
192
192
|
meta: {
|
|
193
193
|
type: "problem",
|
|
194
194
|
docs: {
|
|
195
195
|
description: "Enforces that the 'key' prop is placed before the spread prop in JSX elements.",
|
|
196
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
196
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$61
|
|
197
197
|
},
|
|
198
198
|
messages: { jsxKeyBeforeSpread: "The 'key' prop must be placed before any spread props." },
|
|
199
199
|
schema: []
|
|
@@ -222,13 +222,13 @@ function create$61(context) {
|
|
|
222
222
|
//#endregion
|
|
223
223
|
//#region src/rules/jsx-no-comment-textnodes.ts
|
|
224
224
|
const RULE_NAME$60 = "jsx-no-comment-textnodes";
|
|
225
|
-
const RULE_FEATURES$
|
|
225
|
+
const RULE_FEATURES$60 = [];
|
|
226
226
|
var jsx_no_comment_textnodes_default = createRule({
|
|
227
227
|
meta: {
|
|
228
228
|
type: "problem",
|
|
229
229
|
docs: {
|
|
230
230
|
description: "Prevents comments from being inserted as text nodes.",
|
|
231
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
231
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$60
|
|
232
232
|
},
|
|
233
233
|
messages: { jsxNoCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
234
234
|
schema: []
|
|
@@ -259,13 +259,13 @@ function create$60(context) {
|
|
|
259
259
|
//#endregion
|
|
260
260
|
//#region src/rules/jsx-no-duplicate-props.ts
|
|
261
261
|
const RULE_NAME$59 = "jsx-no-duplicate-props";
|
|
262
|
-
const RULE_FEATURES$
|
|
262
|
+
const RULE_FEATURES$59 = [];
|
|
263
263
|
var jsx_no_duplicate_props_default = createRule({
|
|
264
264
|
meta: {
|
|
265
265
|
type: "problem",
|
|
266
266
|
docs: {
|
|
267
267
|
description: "Disallow duplicate props in JSX elements.",
|
|
268
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
268
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$59
|
|
269
269
|
},
|
|
270
270
|
messages: { jsxNoDuplicateProps: "This JSX property is assigned multiple times." },
|
|
271
271
|
schema: []
|
|
@@ -296,13 +296,13 @@ function create$59(context) {
|
|
|
296
296
|
//#endregion
|
|
297
297
|
//#region src/rules/jsx-no-iife.ts
|
|
298
298
|
const RULE_NAME$58 = "jsx-no-iife";
|
|
299
|
-
const RULE_FEATURES$
|
|
299
|
+
const RULE_FEATURES$58 = ["EXP"];
|
|
300
300
|
var jsx_no_iife_default = createRule({
|
|
301
301
|
meta: {
|
|
302
302
|
type: "problem",
|
|
303
303
|
docs: {
|
|
304
304
|
description: "Disallows 'IIFE' in JSX elements.",
|
|
305
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
305
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$58
|
|
306
306
|
},
|
|
307
307
|
messages: { jsxNoIife: "Avoid using IIFE in JSX elements." },
|
|
308
308
|
schema: []
|
|
@@ -331,13 +331,13 @@ function create$58(context) {
|
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/rules/jsx-no-undef.ts
|
|
333
333
|
const RULE_NAME$57 = "jsx-no-undef";
|
|
334
|
-
const RULE_FEATURES$
|
|
334
|
+
const RULE_FEATURES$57 = [];
|
|
335
335
|
var jsx_no_undef_default = createRule({
|
|
336
336
|
meta: {
|
|
337
337
|
type: "problem",
|
|
338
338
|
docs: {
|
|
339
339
|
description: "Disallow undefined variables in JSX.",
|
|
340
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
340
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$57
|
|
341
341
|
},
|
|
342
342
|
messages: { jsxNoUndef: "JSX variable '{{name}}' is not defined." },
|
|
343
343
|
schema: []
|
|
@@ -366,9 +366,9 @@ function create$57(context) {
|
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/rules/jsx-shorthand-boolean.ts
|
|
368
368
|
const RULE_NAME$56 = "jsx-shorthand-boolean";
|
|
369
|
-
const RULE_FEATURES$
|
|
369
|
+
const RULE_FEATURES$56 = ["CFG", "FIX"];
|
|
370
370
|
const defaultOptions$4 = [1];
|
|
371
|
-
const schema$
|
|
371
|
+
const schema$3 = [{
|
|
372
372
|
type: "integer",
|
|
373
373
|
enum: [-1, 1]
|
|
374
374
|
}];
|
|
@@ -377,11 +377,11 @@ var jsx_shorthand_boolean_default = createRule({
|
|
|
377
377
|
type: "problem",
|
|
378
378
|
docs: {
|
|
379
379
|
description: "Enforces shorthand syntax for boolean attributes.",
|
|
380
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
380
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$56
|
|
381
381
|
},
|
|
382
382
|
fixable: "code",
|
|
383
383
|
messages: { jsxShorthandBoolean: "{{message}}" },
|
|
384
|
-
schema: schema$
|
|
384
|
+
schema: schema$3
|
|
385
385
|
},
|
|
386
386
|
name: RULE_NAME$56,
|
|
387
387
|
create: create$56,
|
|
@@ -416,9 +416,9 @@ function create$56(context) {
|
|
|
416
416
|
//#endregion
|
|
417
417
|
//#region src/rules/jsx-shorthand-fragment.ts
|
|
418
418
|
const RULE_NAME$55 = "jsx-shorthand-fragment";
|
|
419
|
-
const RULE_FEATURES$
|
|
419
|
+
const RULE_FEATURES$55 = ["CFG", "FIX"];
|
|
420
420
|
const defaultOptions$3 = [1];
|
|
421
|
-
const schema$
|
|
421
|
+
const schema$2 = [{
|
|
422
422
|
type: "integer",
|
|
423
423
|
enum: [-1, 1]
|
|
424
424
|
}];
|
|
@@ -427,11 +427,11 @@ var jsx_shorthand_fragment_default = createRule({
|
|
|
427
427
|
type: "problem",
|
|
428
428
|
docs: {
|
|
429
429
|
description: "Enforces shorthand syntax for fragments.",
|
|
430
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
430
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$55
|
|
431
431
|
},
|
|
432
432
|
fixable: "code",
|
|
433
433
|
messages: { jsxShorthandFragment: "{{message}}" },
|
|
434
|
-
schema: schema$
|
|
434
|
+
schema: schema$2
|
|
435
435
|
},
|
|
436
436
|
name: RULE_NAME$55,
|
|
437
437
|
create: create$55,
|
|
@@ -472,13 +472,13 @@ function create$55(context) {
|
|
|
472
472
|
//#endregion
|
|
473
473
|
//#region src/rules/jsx-uses-react.ts
|
|
474
474
|
const RULE_NAME$54 = "jsx-uses-react";
|
|
475
|
-
const RULE_FEATURES$
|
|
475
|
+
const RULE_FEATURES$54 = [];
|
|
476
476
|
var jsx_uses_react_default = createRule({
|
|
477
477
|
meta: {
|
|
478
478
|
type: "problem",
|
|
479
479
|
docs: {
|
|
480
480
|
description: "Marks React variables as used when JSX is used.",
|
|
481
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
481
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$54
|
|
482
482
|
},
|
|
483
483
|
messages: { jsxUsesReact: "Marked {{name}} as used." },
|
|
484
484
|
schema: []
|
|
@@ -519,13 +519,13 @@ function debugReport(context, node, name$7) {
|
|
|
519
519
|
//#endregion
|
|
520
520
|
//#region src/rules/jsx-uses-vars.ts
|
|
521
521
|
const RULE_NAME$53 = "jsx-uses-vars";
|
|
522
|
-
const RULE_FEATURES$
|
|
522
|
+
const RULE_FEATURES$53 = [];
|
|
523
523
|
var jsx_uses_vars_default = createRule({
|
|
524
524
|
meta: {
|
|
525
525
|
type: "problem",
|
|
526
526
|
docs: {
|
|
527
527
|
description: "Marks variables used in JSX elements as used.",
|
|
528
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
528
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$53
|
|
529
529
|
},
|
|
530
530
|
messages: { jsxUsesVars: "An identifier in JSX is marked as used." },
|
|
531
531
|
schema: []
|
|
@@ -553,7 +553,7 @@ function create$53(context) {
|
|
|
553
553
|
//#endregion
|
|
554
554
|
//#region src/rules/no-access-state-in-setstate.ts
|
|
555
555
|
const RULE_NAME$52 = "no-access-state-in-setstate";
|
|
556
|
-
const RULE_FEATURES$
|
|
556
|
+
const RULE_FEATURES$52 = [];
|
|
557
557
|
function isKeyLiteral$2(node, key) {
|
|
558
558
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
559
559
|
type: AST_NODE_TYPES.TemplateLiteral,
|
|
@@ -565,7 +565,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
565
565
|
type: "problem",
|
|
566
566
|
docs: {
|
|
567
567
|
description: "Disallow accessing `this.state` inside `setState` calls.",
|
|
568
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
568
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$52
|
|
569
569
|
},
|
|
570
570
|
messages: { noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead." },
|
|
571
571
|
schema: []
|
|
@@ -646,7 +646,7 @@ function create$52(context) {
|
|
|
646
646
|
//#endregion
|
|
647
647
|
//#region src/rules/no-array-index-key.ts
|
|
648
648
|
const RULE_NAME$51 = "no-array-index-key";
|
|
649
|
-
const RULE_FEATURES$
|
|
649
|
+
const RULE_FEATURES$51 = [];
|
|
650
650
|
const REACT_CHILDREN_METHOD = ["forEach", "map"];
|
|
651
651
|
function isReactChildrenMethod(name$7) {
|
|
652
652
|
return REACT_CHILDREN_METHOD.includes(name$7);
|
|
@@ -686,7 +686,7 @@ var no_array_index_key_default = createRule({
|
|
|
686
686
|
type: "problem",
|
|
687
687
|
docs: {
|
|
688
688
|
description: "Disallow an item's index in the array as its key.",
|
|
689
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
689
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$51
|
|
690
690
|
},
|
|
691
691
|
messages: { noArrayIndexKey: "Do not use item index in the array as its key." },
|
|
692
692
|
schema: []
|
|
@@ -762,13 +762,13 @@ function create$51(context) {
|
|
|
762
762
|
//#endregion
|
|
763
763
|
//#region src/rules/no-children-count.ts
|
|
764
764
|
const RULE_NAME$50 = "no-children-count";
|
|
765
|
-
const RULE_FEATURES$
|
|
765
|
+
const RULE_FEATURES$50 = [];
|
|
766
766
|
var no_children_count_default = createRule({
|
|
767
767
|
meta: {
|
|
768
768
|
type: "problem",
|
|
769
769
|
docs: {
|
|
770
770
|
description: "Disallow `Children.count`.",
|
|
771
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
771
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$50
|
|
772
772
|
},
|
|
773
773
|
messages: { noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
774
774
|
schema: []
|
|
@@ -789,13 +789,13 @@ function create$50(context) {
|
|
|
789
789
|
//#endregion
|
|
790
790
|
//#region src/rules/no-children-for-each.ts
|
|
791
791
|
const RULE_NAME$49 = "no-children-for-each";
|
|
792
|
-
const RULE_FEATURES$
|
|
792
|
+
const RULE_FEATURES$49 = [];
|
|
793
793
|
var no_children_for_each_default = createRule({
|
|
794
794
|
meta: {
|
|
795
795
|
type: "problem",
|
|
796
796
|
docs: {
|
|
797
797
|
description: "Disallow 'Children.forEach'.",
|
|
798
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
798
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$49
|
|
799
799
|
},
|
|
800
800
|
messages: { noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
801
801
|
schema: []
|
|
@@ -816,13 +816,13 @@ function create$49(context) {
|
|
|
816
816
|
//#endregion
|
|
817
817
|
//#region src/rules/no-children-map.ts
|
|
818
818
|
const RULE_NAME$48 = "no-children-map";
|
|
819
|
-
const RULE_FEATURES$
|
|
819
|
+
const RULE_FEATURES$48 = [];
|
|
820
820
|
var no_children_map_default = createRule({
|
|
821
821
|
meta: {
|
|
822
822
|
type: "problem",
|
|
823
823
|
docs: {
|
|
824
824
|
description: "Disallow `Children.map`.",
|
|
825
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
825
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$48
|
|
826
826
|
},
|
|
827
827
|
messages: { noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
828
828
|
schema: []
|
|
@@ -843,13 +843,13 @@ function create$48(context) {
|
|
|
843
843
|
//#endregion
|
|
844
844
|
//#region src/rules/no-children-only.ts
|
|
845
845
|
const RULE_NAME$47 = "no-children-only";
|
|
846
|
-
const RULE_FEATURES$
|
|
846
|
+
const RULE_FEATURES$47 = [];
|
|
847
847
|
var no_children_only_default = createRule({
|
|
848
848
|
meta: {
|
|
849
849
|
type: "problem",
|
|
850
850
|
docs: {
|
|
851
851
|
description: "Disallow `Children.only`.",
|
|
852
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
852
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$47
|
|
853
853
|
},
|
|
854
854
|
messages: { noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
855
855
|
schema: []
|
|
@@ -870,13 +870,13 @@ function create$47(context) {
|
|
|
870
870
|
//#endregion
|
|
871
871
|
//#region src/rules/no-children-prop.ts
|
|
872
872
|
const RULE_NAME$46 = "no-children-prop";
|
|
873
|
-
const RULE_FEATURES$
|
|
873
|
+
const RULE_FEATURES$46 = [];
|
|
874
874
|
var no_children_prop_default = createRule({
|
|
875
875
|
meta: {
|
|
876
876
|
type: "problem",
|
|
877
877
|
docs: {
|
|
878
878
|
description: "Disallow passing `children` as a prop.",
|
|
879
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
879
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$46
|
|
880
880
|
},
|
|
881
881
|
messages: { noChildrenProp: "Do not pass 'children' as props." },
|
|
882
882
|
schema: []
|
|
@@ -898,13 +898,13 @@ function create$46(context) {
|
|
|
898
898
|
//#endregion
|
|
899
899
|
//#region src/rules/no-children-to-array.ts
|
|
900
900
|
const RULE_NAME$45 = "no-children-to-array";
|
|
901
|
-
const RULE_FEATURES$
|
|
901
|
+
const RULE_FEATURES$45 = [];
|
|
902
902
|
var no_children_to_array_default = createRule({
|
|
903
903
|
meta: {
|
|
904
904
|
type: "problem",
|
|
905
905
|
docs: {
|
|
906
906
|
description: "Disallow `Children.toArray`.",
|
|
907
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
907
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$45
|
|
908
908
|
},
|
|
909
909
|
messages: { noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
910
910
|
schema: []
|
|
@@ -925,13 +925,13 @@ function create$45(context) {
|
|
|
925
925
|
//#endregion
|
|
926
926
|
//#region src/rules/no-class-component.ts
|
|
927
927
|
const RULE_NAME$44 = "no-class-component";
|
|
928
|
-
const RULE_FEATURES$
|
|
928
|
+
const RULE_FEATURES$44 = [];
|
|
929
929
|
var no_class_component_default = createRule({
|
|
930
930
|
meta: {
|
|
931
931
|
type: "problem",
|
|
932
932
|
docs: {
|
|
933
933
|
description: "Disallow class components except for error boundaries.",
|
|
934
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
934
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$44
|
|
935
935
|
},
|
|
936
936
|
messages: { noClassComponent: "Avoid using class components. Use function components instead." },
|
|
937
937
|
schema: []
|
|
@@ -961,13 +961,13 @@ function create$44(context) {
|
|
|
961
961
|
//#endregion
|
|
962
962
|
//#region src/rules/no-clone-element.ts
|
|
963
963
|
const RULE_NAME$43 = "no-clone-element";
|
|
964
|
-
const RULE_FEATURES$
|
|
964
|
+
const RULE_FEATURES$43 = [];
|
|
965
965
|
var no_clone_element_default = createRule({
|
|
966
966
|
meta: {
|
|
967
967
|
type: "problem",
|
|
968
968
|
docs: {
|
|
969
969
|
description: "Disallow `cloneElement`.",
|
|
970
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
970
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$43
|
|
971
971
|
},
|
|
972
972
|
messages: { noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
973
973
|
schema: []
|
|
@@ -988,13 +988,13 @@ function create$43(context) {
|
|
|
988
988
|
//#endregion
|
|
989
989
|
//#region src/rules/no-component-will-mount.ts
|
|
990
990
|
const RULE_NAME$42 = "no-component-will-mount";
|
|
991
|
-
const RULE_FEATURES$
|
|
991
|
+
const RULE_FEATURES$42 = ["MOD"];
|
|
992
992
|
var no_component_will_mount_default = createRule({
|
|
993
993
|
meta: {
|
|
994
994
|
type: "problem",
|
|
995
995
|
docs: {
|
|
996
996
|
description: "Replace usages of `componentWillMount` with `UNSAFE_componentWillMount`.",
|
|
997
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
997
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$42
|
|
998
998
|
},
|
|
999
999
|
fixable: "code",
|
|
1000
1000
|
messages: { noComponentWillMount: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
|
|
@@ -1028,13 +1028,13 @@ function create$42(context) {
|
|
|
1028
1028
|
//#endregion
|
|
1029
1029
|
//#region src/rules/no-component-will-receive-props.ts
|
|
1030
1030
|
const RULE_NAME$41 = "no-component-will-receive-props";
|
|
1031
|
-
const RULE_FEATURES$
|
|
1031
|
+
const RULE_FEATURES$41 = ["MOD"];
|
|
1032
1032
|
var no_component_will_receive_props_default = createRule({
|
|
1033
1033
|
meta: {
|
|
1034
1034
|
type: "problem",
|
|
1035
1035
|
docs: {
|
|
1036
1036
|
description: "Replace usages of `componentWillReceiveProps` with `UNSAFE_componentWillReceiveProps`.",
|
|
1037
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1037
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$41
|
|
1038
1038
|
},
|
|
1039
1039
|
fixable: "code",
|
|
1040
1040
|
messages: { noComponentWillReceiveProps: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
|
|
@@ -1068,13 +1068,13 @@ function create$41(context) {
|
|
|
1068
1068
|
//#endregion
|
|
1069
1069
|
//#region src/rules/no-component-will-update.ts
|
|
1070
1070
|
const RULE_NAME$40 = "no-component-will-update";
|
|
1071
|
-
const RULE_FEATURES$
|
|
1071
|
+
const RULE_FEATURES$40 = ["MOD"];
|
|
1072
1072
|
var no_component_will_update_default = createRule({
|
|
1073
1073
|
meta: {
|
|
1074
1074
|
type: "problem",
|
|
1075
1075
|
docs: {
|
|
1076
1076
|
description: "Replace usages of `componentWillUpdate` with `UNSAFE_componentWillUpdate`.",
|
|
1077
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1077
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$40
|
|
1078
1078
|
},
|
|
1079
1079
|
fixable: "code",
|
|
1080
1080
|
messages: { noComponentWillUpdate: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
|
|
@@ -1108,13 +1108,13 @@ function create$40(context) {
|
|
|
1108
1108
|
//#endregion
|
|
1109
1109
|
//#region src/rules/no-context-provider.ts
|
|
1110
1110
|
const RULE_NAME$39 = "no-context-provider";
|
|
1111
|
-
const RULE_FEATURES$
|
|
1111
|
+
const RULE_FEATURES$39 = ["MOD"];
|
|
1112
1112
|
var no_context_provider_default = createRule({
|
|
1113
1113
|
meta: {
|
|
1114
1114
|
type: "problem",
|
|
1115
1115
|
docs: {
|
|
1116
1116
|
description: "Replace usages of `<Context.Provider>` with `<Context>`.",
|
|
1117
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1117
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$39
|
|
1118
1118
|
},
|
|
1119
1119
|
fixable: "code",
|
|
1120
1120
|
messages: { noContextProvider: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'." },
|
|
@@ -1152,13 +1152,13 @@ function create$39(context) {
|
|
|
1152
1152
|
//#endregion
|
|
1153
1153
|
//#region src/rules/no-create-ref.ts
|
|
1154
1154
|
const RULE_NAME$38 = "no-create-ref";
|
|
1155
|
-
const RULE_FEATURES$
|
|
1155
|
+
const RULE_FEATURES$38 = [];
|
|
1156
1156
|
var no_create_ref_default = createRule({
|
|
1157
1157
|
meta: {
|
|
1158
1158
|
type: "problem",
|
|
1159
1159
|
docs: {
|
|
1160
1160
|
description: "Disallow `createRef` in function components.",
|
|
1161
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1161
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$38
|
|
1162
1162
|
},
|
|
1163
1163
|
messages: { noCreateRef: "[Deprecated] Use 'useRef' instead." },
|
|
1164
1164
|
schema: []
|
|
@@ -1179,13 +1179,13 @@ function create$38(context) {
|
|
|
1179
1179
|
//#endregion
|
|
1180
1180
|
//#region src/rules/no-default-props.ts
|
|
1181
1181
|
const RULE_NAME$37 = "no-default-props";
|
|
1182
|
-
const RULE_FEATURES$
|
|
1182
|
+
const RULE_FEATURES$37 = [];
|
|
1183
1183
|
var no_default_props_default = createRule({
|
|
1184
1184
|
meta: {
|
|
1185
1185
|
type: "problem",
|
|
1186
1186
|
docs: {
|
|
1187
1187
|
description: "Disallow `defaultProps` property in favor of ES6 default parameters.",
|
|
1188
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1188
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$37
|
|
1189
1189
|
},
|
|
1190
1190
|
messages: { noDefaultProps: "[Deprecated] Use ES6 default parameters instead." },
|
|
1191
1191
|
schema: []
|
|
@@ -1215,7 +1215,7 @@ function create$37(context) {
|
|
|
1215
1215
|
//#endregion
|
|
1216
1216
|
//#region src/rules/no-direct-mutation-state.ts
|
|
1217
1217
|
const RULE_NAME$36 = "no-direct-mutation-state";
|
|
1218
|
-
const RULE_FEATURES$
|
|
1218
|
+
const RULE_FEATURES$36 = [];
|
|
1219
1219
|
function isConstructorFunction(node) {
|
|
1220
1220
|
return AST.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && AST.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
1221
1221
|
}
|
|
@@ -1224,7 +1224,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
1224
1224
|
type: "problem",
|
|
1225
1225
|
docs: {
|
|
1226
1226
|
description: "Disallow direct mutation of `this.state`.",
|
|
1227
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1227
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$36
|
|
1228
1228
|
},
|
|
1229
1229
|
messages: { noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead." },
|
|
1230
1230
|
schema: []
|
|
@@ -1248,13 +1248,13 @@ function create$36(context) {
|
|
|
1248
1248
|
//#endregion
|
|
1249
1249
|
//#region src/rules/no-duplicate-key.ts
|
|
1250
1250
|
const RULE_NAME$35 = "no-duplicate-key";
|
|
1251
|
-
const RULE_FEATURES$
|
|
1251
|
+
const RULE_FEATURES$35 = [];
|
|
1252
1252
|
var no_duplicate_key_default = createRule({
|
|
1253
1253
|
meta: {
|
|
1254
1254
|
type: "problem",
|
|
1255
1255
|
docs: {
|
|
1256
1256
|
description: "Disallow duplicate `key` on elements in the same array or a list of `children`.",
|
|
1257
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1257
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$35
|
|
1258
1258
|
},
|
|
1259
1259
|
messages: { noDuplicateKey: "A key must be unique. '{{value}}' is duplicated." },
|
|
1260
1260
|
schema: []
|
|
@@ -1319,13 +1319,13 @@ function create$35(context) {
|
|
|
1319
1319
|
//#endregion
|
|
1320
1320
|
//#region src/rules/no-forward-ref.ts
|
|
1321
1321
|
const RULE_NAME$34 = "no-forward-ref";
|
|
1322
|
-
const RULE_FEATURES$
|
|
1322
|
+
const RULE_FEATURES$34 = ["MOD"];
|
|
1323
1323
|
var no_forward_ref_default = createRule({
|
|
1324
1324
|
meta: {
|
|
1325
1325
|
type: "problem",
|
|
1326
1326
|
docs: {
|
|
1327
1327
|
description: "Replaces usages of `forwardRef` with passing `ref` as a prop.",
|
|
1328
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1328
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$34
|
|
1329
1329
|
},
|
|
1330
1330
|
fixable: "code",
|
|
1331
1331
|
messages: { noForwardRef: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
|
|
@@ -1342,7 +1342,7 @@ function create$34(context) {
|
|
|
1342
1342
|
return { CallExpression(node) {
|
|
1343
1343
|
if (!isForwardRefCall(context, node)) return;
|
|
1344
1344
|
const id = AST.getFunctionId(node);
|
|
1345
|
-
const fix = canFix
|
|
1345
|
+
const fix = canFix(context, node) ? getFix(context, node) : null;
|
|
1346
1346
|
context.report({
|
|
1347
1347
|
messageId: "noForwardRef",
|
|
1348
1348
|
node: id ?? node,
|
|
@@ -1358,7 +1358,7 @@ function create$34(context) {
|
|
|
1358
1358
|
* @param node - The CallExpression node to check
|
|
1359
1359
|
* @returns True if the call can be auto-fixed, false otherwise
|
|
1360
1360
|
*/
|
|
1361
|
-
function canFix
|
|
1361
|
+
function canFix(context, node) {
|
|
1362
1362
|
const { importSource } = getSettingsFromContext(context);
|
|
1363
1363
|
const initialScope = context.sourceCode.getScope(node);
|
|
1364
1364
|
switch (node.callee.type) {
|
|
@@ -1373,7 +1373,7 @@ function canFix$1(context, node) {
|
|
|
1373
1373
|
* @param node - The `forwardRef` call expression
|
|
1374
1374
|
* @returns A fixer function that applies the changes
|
|
1375
1375
|
*/
|
|
1376
|
-
function getFix
|
|
1376
|
+
function getFix(context, node) {
|
|
1377
1377
|
return (fixer) => {
|
|
1378
1378
|
const [componentNode] = node.arguments;
|
|
1379
1379
|
if (componentNode == null || !AST.isFunction(componentNode)) return [];
|
|
@@ -1431,13 +1431,13 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1431
1431
|
//#endregion
|
|
1432
1432
|
//#region src/rules/no-implicit-key.ts
|
|
1433
1433
|
const RULE_NAME$33 = "no-implicit-key";
|
|
1434
|
-
const RULE_FEATURES$
|
|
1434
|
+
const RULE_FEATURES$33 = ["EXP"];
|
|
1435
1435
|
var no_implicit_key_default = createRule({
|
|
1436
1436
|
meta: {
|
|
1437
1437
|
type: "problem",
|
|
1438
1438
|
docs: {
|
|
1439
1439
|
description: "Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects).",
|
|
1440
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1440
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$33
|
|
1441
1441
|
},
|
|
1442
1442
|
messages: { noImplicitKey: "Do not use implicit 'key' props." },
|
|
1443
1443
|
schema: []
|
|
@@ -1460,13 +1460,13 @@ function create$33(context) {
|
|
|
1460
1460
|
//#endregion
|
|
1461
1461
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
|
1462
1462
|
const RULE_NAME$32 = "no-leaked-conditional-rendering";
|
|
1463
|
-
const RULE_FEATURES$
|
|
1463
|
+
const RULE_FEATURES$32 = ["TSC"];
|
|
1464
1464
|
var no_leaked_conditional_rendering_default = createRule({
|
|
1465
1465
|
meta: {
|
|
1466
1466
|
type: "problem",
|
|
1467
1467
|
docs: {
|
|
1468
1468
|
description: "Prevents problematic leaked values from being rendered.",
|
|
1469
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1469
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$32
|
|
1470
1470
|
},
|
|
1471
1471
|
messages: { noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
|
|
1472
1472
|
schema: []
|
|
@@ -1532,13 +1532,13 @@ function create$32(context) {
|
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region src/rules/no-missing-component-display-name.ts
|
|
1534
1534
|
const RULE_NAME$31 = "no-missing-component-display-name";
|
|
1535
|
-
const RULE_FEATURES$
|
|
1535
|
+
const RULE_FEATURES$31 = [];
|
|
1536
1536
|
var no_missing_component_display_name_default = createRule({
|
|
1537
1537
|
meta: {
|
|
1538
1538
|
type: "problem",
|
|
1539
1539
|
docs: {
|
|
1540
1540
|
description: "Enforces that all components have a `displayName` which can be used in devtools.",
|
|
1541
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1541
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$31
|
|
1542
1542
|
},
|
|
1543
1543
|
messages: { noMissingComponentDisplayName: "Add missing 'displayName' for component." },
|
|
1544
1544
|
schema: []
|
|
@@ -1574,13 +1574,13 @@ function create$31(context) {
|
|
|
1574
1574
|
//#endregion
|
|
1575
1575
|
//#region src/rules/no-missing-context-display-name.ts
|
|
1576
1576
|
const RULE_NAME$30 = "no-missing-context-display-name";
|
|
1577
|
-
const RULE_FEATURES$
|
|
1577
|
+
const RULE_FEATURES$30 = ["FIX"];
|
|
1578
1578
|
var no_missing_context_display_name_default = createRule({
|
|
1579
1579
|
meta: {
|
|
1580
1580
|
type: "problem",
|
|
1581
1581
|
docs: {
|
|
1582
1582
|
description: "Enforces that all contexts have a `displayName` which can be used in devtools.",
|
|
1583
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1583
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$30
|
|
1584
1584
|
},
|
|
1585
1585
|
fixable: "code",
|
|
1586
1586
|
messages: { noMissingContextDisplayName: "Add missing 'displayName' for context." },
|
|
@@ -1643,13 +1643,13 @@ function create$30(context) {
|
|
|
1643
1643
|
//#endregion
|
|
1644
1644
|
//#region src/rules/no-missing-key.ts
|
|
1645
1645
|
const RULE_NAME$29 = "no-missing-key";
|
|
1646
|
-
const RULE_FEATURES$
|
|
1646
|
+
const RULE_FEATURES$29 = [];
|
|
1647
1647
|
var no_missing_key_default = createRule({
|
|
1648
1648
|
meta: {
|
|
1649
1649
|
type: "problem",
|
|
1650
1650
|
docs: {
|
|
1651
1651
|
description: "Disallow missing `key` on items in list rendering.",
|
|
1652
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1652
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$29
|
|
1653
1653
|
},
|
|
1654
1654
|
messages: {
|
|
1655
1655
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1740,13 +1740,13 @@ function create$29(context) {
|
|
|
1740
1740
|
//#endregion
|
|
1741
1741
|
//#region src/rules/no-misused-capture-owner-stack.ts
|
|
1742
1742
|
const RULE_NAME$28 = "no-misused-capture-owner-stack";
|
|
1743
|
-
const RULE_FEATURES$
|
|
1743
|
+
const RULE_FEATURES$28 = ["EXP"];
|
|
1744
1744
|
var no_misused_capture_owner_stack_default = createRule({
|
|
1745
1745
|
meta: {
|
|
1746
1746
|
type: "problem",
|
|
1747
1747
|
docs: {
|
|
1748
1748
|
description: "Prevents incorrect usage of `captureOwnerStack`.",
|
|
1749
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1749
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$28
|
|
1750
1750
|
},
|
|
1751
1751
|
fixable: "code",
|
|
1752
1752
|
messages: {
|
|
@@ -1792,13 +1792,13 @@ function isDevelopmentOnlyCheck(node) {
|
|
|
1792
1792
|
//#endregion
|
|
1793
1793
|
//#region src/rules/no-nested-component-definitions.ts
|
|
1794
1794
|
const RULE_NAME$27 = "no-nested-component-definitions";
|
|
1795
|
-
const RULE_FEATURES$
|
|
1795
|
+
const RULE_FEATURES$27 = [];
|
|
1796
1796
|
var no_nested_component_definitions_default = createRule({
|
|
1797
1797
|
meta: {
|
|
1798
1798
|
type: "problem",
|
|
1799
1799
|
docs: {
|
|
1800
1800
|
description: "Disallow nesting component definitions inside other components.",
|
|
1801
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1801
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$27
|
|
1802
1802
|
},
|
|
1803
1803
|
messages: { noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}" },
|
|
1804
1804
|
schema: []
|
|
@@ -1916,13 +1916,13 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1916
1916
|
//#endregion
|
|
1917
1917
|
//#region src/rules/no-nested-lazy-component-declarations.ts
|
|
1918
1918
|
const RULE_NAME$26 = "no-nested-lazy-component-declarations";
|
|
1919
|
-
const RULE_FEATURES$
|
|
1919
|
+
const RULE_FEATURES$26 = [];
|
|
1920
1920
|
var no_nested_lazy_component_declarations_default = createRule({
|
|
1921
1921
|
meta: {
|
|
1922
1922
|
type: "problem",
|
|
1923
1923
|
docs: {
|
|
1924
1924
|
description: "Disallow nesting lazy component declarations inside other components.",
|
|
1925
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1925
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$26
|
|
1926
1926
|
},
|
|
1927
1927
|
messages: { noNestedLazyComponentDeclarations: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
|
|
1928
1928
|
schema: []
|
|
@@ -1963,13 +1963,13 @@ function create$26(context) {
|
|
|
1963
1963
|
//#endregion
|
|
1964
1964
|
//#region src/rules/no-prop-types.ts
|
|
1965
1965
|
const RULE_NAME$25 = "no-prop-types";
|
|
1966
|
-
const RULE_FEATURES$
|
|
1966
|
+
const RULE_FEATURES$25 = [];
|
|
1967
1967
|
var no_prop_types_default = createRule({
|
|
1968
1968
|
meta: {
|
|
1969
1969
|
type: "problem",
|
|
1970
1970
|
docs: {
|
|
1971
1971
|
description: "Disallow `propTypes` in favor of TypeScript or another type-checking solution.",
|
|
1972
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
1972
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$25
|
|
1973
1973
|
},
|
|
1974
1974
|
messages: { noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead." },
|
|
1975
1975
|
schema: []
|
|
@@ -2007,7 +2007,7 @@ function create$25(context) {
|
|
|
2007
2007
|
//#endregion
|
|
2008
2008
|
//#region src/rules/no-redundant-should-component-update.ts
|
|
2009
2009
|
const RULE_NAME$24 = "no-redundant-should-component-update";
|
|
2010
|
-
const RULE_FEATURES$
|
|
2010
|
+
const RULE_FEATURES$24 = [];
|
|
2011
2011
|
function isShouldComponentUpdate(node) {
|
|
2012
2012
|
return AST.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
2013
2013
|
}
|
|
@@ -2016,7 +2016,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2016
2016
|
type: "problem",
|
|
2017
2017
|
docs: {
|
|
2018
2018
|
description: "Disallow `shouldComponentUpdate` when extending `React.PureComponent`.",
|
|
2019
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2019
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$24
|
|
2020
2020
|
},
|
|
2021
2021
|
messages: { noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
|
|
2022
2022
|
schema: []
|
|
@@ -2047,13 +2047,13 @@ function create$24(context) {
|
|
|
2047
2047
|
//#endregion
|
|
2048
2048
|
//#region src/rules/no-set-state-in-component-did-mount.ts
|
|
2049
2049
|
const RULE_NAME$23 = "no-set-state-in-component-did-mount";
|
|
2050
|
-
const RULE_FEATURES$
|
|
2050
|
+
const RULE_FEATURES$23 = [];
|
|
2051
2051
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2052
2052
|
meta: {
|
|
2053
2053
|
type: "problem",
|
|
2054
2054
|
docs: {
|
|
2055
2055
|
description: "Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks.",
|
|
2056
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2056
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$23
|
|
2057
2057
|
},
|
|
2058
2058
|
messages: { noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks." },
|
|
2059
2059
|
schema: []
|
|
@@ -2081,13 +2081,13 @@ function create$23(context) {
|
|
|
2081
2081
|
//#endregion
|
|
2082
2082
|
//#region src/rules/no-set-state-in-component-did-update.ts
|
|
2083
2083
|
const RULE_NAME$22 = "no-set-state-in-component-did-update";
|
|
2084
|
-
const RULE_FEATURES$
|
|
2084
|
+
const RULE_FEATURES$22 = [];
|
|
2085
2085
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2086
2086
|
meta: {
|
|
2087
2087
|
type: "problem",
|
|
2088
2088
|
docs: {
|
|
2089
2089
|
description: "Disallow calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.",
|
|
2090
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2090
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$22
|
|
2091
2091
|
},
|
|
2092
2092
|
messages: { noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks." },
|
|
2093
2093
|
schema: []
|
|
@@ -2115,13 +2115,13 @@ function create$22(context) {
|
|
|
2115
2115
|
//#endregion
|
|
2116
2116
|
//#region src/rules/no-set-state-in-component-will-update.ts
|
|
2117
2117
|
const RULE_NAME$21 = "no-set-state-in-component-will-update";
|
|
2118
|
-
const RULE_FEATURES$
|
|
2118
|
+
const RULE_FEATURES$21 = [];
|
|
2119
2119
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2120
2120
|
meta: {
|
|
2121
2121
|
type: "problem",
|
|
2122
2122
|
docs: {
|
|
2123
2123
|
description: "Disallow calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.",
|
|
2124
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2124
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$21
|
|
2125
2125
|
},
|
|
2126
2126
|
messages: { noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks." },
|
|
2127
2127
|
schema: []
|
|
@@ -2149,13 +2149,13 @@ function create$21(context) {
|
|
|
2149
2149
|
//#endregion
|
|
2150
2150
|
//#region src/rules/no-string-refs.ts
|
|
2151
2151
|
const RULE_NAME$20 = "no-string-refs";
|
|
2152
|
-
const RULE_FEATURES$
|
|
2152
|
+
const RULE_FEATURES$20 = ["MOD"];
|
|
2153
2153
|
var no_string_refs_default = createRule({
|
|
2154
2154
|
meta: {
|
|
2155
2155
|
type: "problem",
|
|
2156
2156
|
docs: {
|
|
2157
2157
|
description: "Replaces string refs with callback refs.",
|
|
2158
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2158
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$20
|
|
2159
2159
|
},
|
|
2160
2160
|
fixable: "code",
|
|
2161
2161
|
messages: { noStringRefs: "[Deprecated] Use callback refs instead." },
|
|
@@ -2211,13 +2211,13 @@ function getJsxAttributeValueText(context, node) {
|
|
|
2211
2211
|
//#endregion
|
|
2212
2212
|
//#region src/rules/no-unnecessary-key.ts
|
|
2213
2213
|
const RULE_NAME$19 = "no-unnecessary-key";
|
|
2214
|
-
const RULE_FEATURES$
|
|
2214
|
+
const RULE_FEATURES$19 = ["EXP"];
|
|
2215
2215
|
var no_unnecessary_key_default = createRule({
|
|
2216
2216
|
meta: {
|
|
2217
2217
|
type: "problem",
|
|
2218
2218
|
docs: {
|
|
2219
2219
|
description: "Prevents the use of unnecessary `key` props on JSX elements when rendering lists.",
|
|
2220
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2220
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$19
|
|
2221
2221
|
},
|
|
2222
2222
|
messages: { noUnnecessaryKey: "Unnecessary `key` prop on this element. The `key` should be on the top-level element returned from the array." },
|
|
2223
2223
|
schema: []
|
|
@@ -2259,13 +2259,13 @@ function isMapCallback(node) {
|
|
|
2259
2259
|
//#endregion
|
|
2260
2260
|
//#region src/rules/no-unnecessary-use-callback.ts
|
|
2261
2261
|
const RULE_NAME$18 = "no-unnecessary-use-callback";
|
|
2262
|
-
const RULE_FEATURES$
|
|
2262
|
+
const RULE_FEATURES$18 = ["EXP"];
|
|
2263
2263
|
var no_unnecessary_use_callback_default = createRule({
|
|
2264
2264
|
meta: {
|
|
2265
2265
|
type: "problem",
|
|
2266
2266
|
docs: {
|
|
2267
2267
|
description: "Disallow unnecessary usage of `useCallback`.",
|
|
2268
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2268
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$18
|
|
2269
2269
|
},
|
|
2270
2270
|
messages: {
|
|
2271
2271
|
noUnnecessaryUseCallback: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary.",
|
|
@@ -2336,13 +2336,13 @@ function checkForUsageInsideUseEffect$1(sourceCode, node) {
|
|
|
2336
2336
|
//#endregion
|
|
2337
2337
|
//#region src/rules/no-unnecessary-use-memo.ts
|
|
2338
2338
|
const RULE_NAME$17 = "no-unnecessary-use-memo";
|
|
2339
|
-
const RULE_FEATURES$
|
|
2339
|
+
const RULE_FEATURES$17 = ["EXP"];
|
|
2340
2340
|
var no_unnecessary_use_memo_default = createRule({
|
|
2341
2341
|
meta: {
|
|
2342
2342
|
type: "problem",
|
|
2343
2343
|
docs: {
|
|
2344
2344
|
description: "Disallow unnecessary usage of `useMemo`.",
|
|
2345
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2345
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$17
|
|
2346
2346
|
},
|
|
2347
2347
|
messages: {
|
|
2348
2348
|
noUnnecessaryUseMemo: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary.",
|
|
@@ -2417,7 +2417,7 @@ function checkForUsageInsideUseEffect(sourceCode, node) {
|
|
|
2417
2417
|
//#endregion
|
|
2418
2418
|
//#region src/rules/no-unnecessary-use-prefix.ts
|
|
2419
2419
|
const RULE_NAME$16 = "no-unnecessary-use-prefix";
|
|
2420
|
-
const RULE_FEATURES$
|
|
2420
|
+
const RULE_FEATURES$16 = ["EXP"];
|
|
2421
2421
|
const WELL_KNOWN_HOOKS = ["useMDXComponents"];
|
|
2422
2422
|
function containsUseComments(context, node) {
|
|
2423
2423
|
return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
|
|
@@ -2427,7 +2427,7 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
2427
2427
|
type: "problem",
|
|
2428
2428
|
docs: {
|
|
2429
2429
|
description: "Enforces that a function with the `use` prefix should use at least one Hook inside of it.",
|
|
2430
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2430
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$16
|
|
2431
2431
|
},
|
|
2432
2432
|
messages: { noUnnecessaryUsePrefix: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
|
|
2433
2433
|
schema: []
|
|
@@ -2460,13 +2460,13 @@ function create$16(context) {
|
|
|
2460
2460
|
//#endregion
|
|
2461
2461
|
//#region src/rules/no-unsafe-component-will-mount.ts
|
|
2462
2462
|
const RULE_NAME$15 = "no-unsafe-component-will-mount";
|
|
2463
|
-
const RULE_FEATURES$
|
|
2463
|
+
const RULE_FEATURES$15 = [];
|
|
2464
2464
|
var no_unsafe_component_will_mount_default = createRule({
|
|
2465
2465
|
meta: {
|
|
2466
2466
|
type: "problem",
|
|
2467
2467
|
docs: {
|
|
2468
2468
|
description: "Warns the usage of `UNSAFE_componentWillMount` in class components.",
|
|
2469
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2469
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$15
|
|
2470
2470
|
},
|
|
2471
2471
|
messages: { noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'." },
|
|
2472
2472
|
schema: []
|
|
@@ -2495,13 +2495,13 @@ function create$15(context) {
|
|
|
2495
2495
|
//#endregion
|
|
2496
2496
|
//#region src/rules/no-unsafe-component-will-receive-props.ts
|
|
2497
2497
|
const RULE_NAME$14 = "no-unsafe-component-will-receive-props";
|
|
2498
|
-
const RULE_FEATURES$
|
|
2498
|
+
const RULE_FEATURES$14 = [];
|
|
2499
2499
|
var no_unsafe_component_will_receive_props_default = createRule({
|
|
2500
2500
|
meta: {
|
|
2501
2501
|
type: "problem",
|
|
2502
2502
|
docs: {
|
|
2503
2503
|
description: "Warns the usage of `UNSAFE_componentWillReceiveProps` in class components.",
|
|
2504
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2504
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$14
|
|
2505
2505
|
},
|
|
2506
2506
|
messages: { noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'." },
|
|
2507
2507
|
schema: []
|
|
@@ -2530,13 +2530,13 @@ function create$14(context) {
|
|
|
2530
2530
|
//#endregion
|
|
2531
2531
|
//#region src/rules/no-unsafe-component-will-update.ts
|
|
2532
2532
|
const RULE_NAME$13 = "no-unsafe-component-will-update";
|
|
2533
|
-
const RULE_FEATURES$
|
|
2533
|
+
const RULE_FEATURES$13 = [];
|
|
2534
2534
|
var no_unsafe_component_will_update_default = createRule({
|
|
2535
2535
|
meta: {
|
|
2536
2536
|
type: "problem",
|
|
2537
2537
|
docs: {
|
|
2538
2538
|
description: "Warns the usage of `UNSAFE_componentWillUpdate` in class components.",
|
|
2539
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2539
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$13
|
|
2540
2540
|
},
|
|
2541
2541
|
messages: { noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'." },
|
|
2542
2542
|
schema: []
|
|
@@ -2565,13 +2565,13 @@ function create$13(context) {
|
|
|
2565
2565
|
//#endregion
|
|
2566
2566
|
//#region src/rules/no-unstable-context-value.ts
|
|
2567
2567
|
const RULE_NAME$12 = "no-unstable-context-value";
|
|
2568
|
-
const RULE_FEATURES$
|
|
2568
|
+
const RULE_FEATURES$12 = [];
|
|
2569
2569
|
var no_unstable_context_value_default = createRule({
|
|
2570
2570
|
meta: {
|
|
2571
2571
|
type: "problem",
|
|
2572
2572
|
docs: {
|
|
2573
2573
|
description: "Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`.",
|
|
2574
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2574
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$12
|
|
2575
2575
|
},
|
|
2576
2576
|
messages: { unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}" },
|
|
2577
2577
|
schema: []
|
|
@@ -2628,9 +2628,9 @@ function isContextName(name$7, isReact18OrBelow) {
|
|
|
2628
2628
|
//#endregion
|
|
2629
2629
|
//#region src/rules/no-unstable-default-props.ts
|
|
2630
2630
|
const RULE_NAME$11 = "no-unstable-default-props";
|
|
2631
|
-
const RULE_FEATURES$
|
|
2631
|
+
const RULE_FEATURES$11 = [];
|
|
2632
2632
|
const defaultOptions$2 = [{ safeDefaultProps: [] }];
|
|
2633
|
-
const schema = [{
|
|
2633
|
+
const schema$1 = [{
|
|
2634
2634
|
type: "object",
|
|
2635
2635
|
additionalProperties: false,
|
|
2636
2636
|
properties: { safeDefaultProps: {
|
|
@@ -2643,10 +2643,10 @@ var no_unstable_default_props_default = createRule({
|
|
|
2643
2643
|
type: "problem",
|
|
2644
2644
|
docs: {
|
|
2645
2645
|
description: "Prevents using referential-type values as default props in object destructuring.",
|
|
2646
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2646
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$11
|
|
2647
2647
|
},
|
|
2648
2648
|
messages: { noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'." },
|
|
2649
|
-
schema
|
|
2649
|
+
schema: schema$1
|
|
2650
2650
|
},
|
|
2651
2651
|
name: RULE_NAME$11,
|
|
2652
2652
|
create: create$11,
|
|
@@ -2706,7 +2706,7 @@ function create$11(context, [options]) {
|
|
|
2706
2706
|
//#endregion
|
|
2707
2707
|
//#region src/rules/no-unused-class-component-members.ts
|
|
2708
2708
|
const RULE_NAME$10 = "no-unused-class-component-members";
|
|
2709
|
-
const RULE_FEATURES$
|
|
2709
|
+
const RULE_FEATURES$10 = [];
|
|
2710
2710
|
const LIFECYCLE_METHODS = new Set([
|
|
2711
2711
|
"componentDidCatch",
|
|
2712
2712
|
"componentDidMount",
|
|
@@ -2735,7 +2735,7 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2735
2735
|
type: "problem",
|
|
2736
2736
|
docs: {
|
|
2737
2737
|
description: "Warns unused class component methods and properties.",
|
|
2738
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2738
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$10
|
|
2739
2739
|
},
|
|
2740
2740
|
messages: { noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
|
|
2741
2741
|
schema: []
|
|
@@ -2826,13 +2826,13 @@ function create$10(context) {
|
|
|
2826
2826
|
//#endregion
|
|
2827
2827
|
//#region src/rules/no-unused-props.ts
|
|
2828
2828
|
const RULE_NAME$9 = "no-unused-props";
|
|
2829
|
-
const RULE_FEATURES$
|
|
2829
|
+
const RULE_FEATURES$9 = ["TSC", "EXP"];
|
|
2830
2830
|
var no_unused_props_default = createRule({
|
|
2831
2831
|
meta: {
|
|
2832
2832
|
type: "problem",
|
|
2833
2833
|
docs: {
|
|
2834
2834
|
description: "Warns component props that are defined but never used.",
|
|
2835
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2835
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$9
|
|
2836
2836
|
},
|
|
2837
2837
|
messages: { noUnusedProps: "Prop `{{name}}` is declared but never used" },
|
|
2838
2838
|
schema: []
|
|
@@ -2943,7 +2943,7 @@ function reportUnusedProp(context, services, prop) {
|
|
|
2943
2943
|
//#endregion
|
|
2944
2944
|
//#region src/rules/no-unused-state.ts
|
|
2945
2945
|
const RULE_NAME$8 = "no-unused-state";
|
|
2946
|
-
const RULE_FEATURES$
|
|
2946
|
+
const RULE_FEATURES$8 = [];
|
|
2947
2947
|
function isKeyLiteral(node, key) {
|
|
2948
2948
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
2949
2949
|
type: AST_NODE_TYPES.TemplateLiteral,
|
|
@@ -2955,7 +2955,7 @@ var no_unused_state_default = createRule({
|
|
|
2955
2955
|
type: "problem",
|
|
2956
2956
|
docs: {
|
|
2957
2957
|
description: "Warns unused class component state.",
|
|
2958
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
2958
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$8
|
|
2959
2959
|
},
|
|
2960
2960
|
messages: { noUnusedState: "Unused class component state in '{{className}}'" },
|
|
2961
2961
|
schema: []
|
|
@@ -3074,13 +3074,13 @@ function create$8(context) {
|
|
|
3074
3074
|
//#endregion
|
|
3075
3075
|
//#region src/rules/no-use-context.ts
|
|
3076
3076
|
const RULE_NAME$7 = "no-use-context";
|
|
3077
|
-
const RULE_FEATURES$
|
|
3077
|
+
const RULE_FEATURES$7 = ["MOD"];
|
|
3078
3078
|
var no_use_context_default = createRule({
|
|
3079
3079
|
meta: {
|
|
3080
3080
|
type: "problem",
|
|
3081
3081
|
docs: {
|
|
3082
3082
|
description: "Replaces usages of `useContext` with `use`.",
|
|
3083
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
3083
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$7
|
|
3084
3084
|
},
|
|
3085
3085
|
fixable: "code",
|
|
3086
3086
|
messages: { noUseContext: "In React 19, 'use' is preferred over 'useContext' because it is more flexible." },
|
|
@@ -3156,13 +3156,13 @@ function getCorrelativeTokens(context, node) {
|
|
|
3156
3156
|
//#endregion
|
|
3157
3157
|
//#region src/rules/no-useless-forward-ref.ts
|
|
3158
3158
|
const RULE_NAME$6 = "no-useless-forward-ref";
|
|
3159
|
-
const RULE_FEATURES$
|
|
3159
|
+
const RULE_FEATURES$6 = [];
|
|
3160
3160
|
var no_useless_forward_ref_default = createRule({
|
|
3161
3161
|
meta: {
|
|
3162
3162
|
type: "problem",
|
|
3163
3163
|
docs: {
|
|
3164
3164
|
description: "Disallow useless `forwardRef` calls on components that don't use `ref`s.",
|
|
3165
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
3165
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$6
|
|
3166
3166
|
},
|
|
3167
3167
|
messages: { noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set." },
|
|
3168
3168
|
schema: []
|
|
@@ -3187,36 +3187,117 @@ function create$6(context) {
|
|
|
3187
3187
|
//#endregion
|
|
3188
3188
|
//#region src/rules/no-useless-fragment.ts
|
|
3189
3189
|
const RULE_NAME$5 = "no-useless-fragment";
|
|
3190
|
-
const
|
|
3190
|
+
const RULE_FEATURES$5 = ["FIX", "CFG"];
|
|
3191
|
+
const defaultOptions$1 = [{
|
|
3192
|
+
allowEmptyFragment: false,
|
|
3193
|
+
allowExpressions: true
|
|
3194
|
+
}];
|
|
3195
|
+
const schema = [{
|
|
3196
|
+
type: "object",
|
|
3197
|
+
additionalProperties: false,
|
|
3198
|
+
properties: {
|
|
3199
|
+
allowEmptyFragment: {
|
|
3200
|
+
type: "boolean",
|
|
3201
|
+
description: "Allow empty fragments"
|
|
3202
|
+
},
|
|
3203
|
+
allowExpressions: {
|
|
3204
|
+
type: "boolean",
|
|
3205
|
+
description: "Allow fragments with a single expression child"
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
}];
|
|
3191
3209
|
var no_useless_fragment_default = createRule({
|
|
3192
3210
|
meta: {
|
|
3193
3211
|
type: "problem",
|
|
3194
3212
|
defaultOptions: [...defaultOptions$1],
|
|
3195
|
-
docs: {
|
|
3213
|
+
docs: {
|
|
3214
|
+
description: "Disallow useless fragment elements.",
|
|
3215
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$5
|
|
3216
|
+
},
|
|
3196
3217
|
fixable: "code",
|
|
3197
|
-
messages: {
|
|
3198
|
-
schema
|
|
3199
|
-
type: "object",
|
|
3200
|
-
additionalProperties: false,
|
|
3201
|
-
properties: { allowExpressions: {
|
|
3202
|
-
type: "boolean",
|
|
3203
|
-
description: "Allow fragments with a single expression child"
|
|
3204
|
-
} }
|
|
3205
|
-
}]
|
|
3218
|
+
messages: { noUselessFragment: "A fragment {{reason}} is useless." },
|
|
3219
|
+
schema
|
|
3206
3220
|
},
|
|
3207
3221
|
name: RULE_NAME$5,
|
|
3208
3222
|
create: create$5,
|
|
3209
3223
|
defaultOptions: defaultOptions$1
|
|
3210
3224
|
});
|
|
3211
3225
|
function create$5(context, [option]) {
|
|
3212
|
-
const { allowExpressions = true } = option;
|
|
3226
|
+
const { allowEmptyFragment = false, allowExpressions = true } = option;
|
|
3227
|
+
/**
|
|
3228
|
+
* Check if a fragment node is useless and should be reported
|
|
3229
|
+
*/
|
|
3230
|
+
function checkNode(context$1, node) {
|
|
3231
|
+
if (node.type === AST_NODE_TYPES.JSXElement && getJsxAttribute(context$1, node)("key") != null) return;
|
|
3232
|
+
if (isJsxHostElement(context$1, node.parent)) context$1.report({
|
|
3233
|
+
messageId: "noUselessFragment",
|
|
3234
|
+
node,
|
|
3235
|
+
data: { reason: "placed inside a host component" },
|
|
3236
|
+
fix: getFix$1(context$1, node)
|
|
3237
|
+
});
|
|
3238
|
+
if (node.children.length === 0) {
|
|
3239
|
+
if (allowEmptyFragment) return;
|
|
3240
|
+
context$1.report({
|
|
3241
|
+
messageId: "noUselessFragment",
|
|
3242
|
+
node,
|
|
3243
|
+
data: { reason: "contains less than two children" },
|
|
3244
|
+
fix: getFix$1(context$1, node)
|
|
3245
|
+
});
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
3248
|
+
const isChildElement = AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3249
|
+
switch (true) {
|
|
3250
|
+
case allowExpressions && !isChildElement && node.children.length === 1 && isJsxText(node.children.at(0)): return;
|
|
3251
|
+
case !allowExpressions && isChildElement:
|
|
3252
|
+
context$1.report({
|
|
3253
|
+
messageId: "noUselessFragment",
|
|
3254
|
+
node,
|
|
3255
|
+
data: { reason: "contains less than two children" },
|
|
3256
|
+
fix: getFix$1(context$1, node)
|
|
3257
|
+
});
|
|
3258
|
+
return;
|
|
3259
|
+
case !allowExpressions && !isChildElement && node.children.length === 1:
|
|
3260
|
+
context$1.report({
|
|
3261
|
+
messageId: "noUselessFragment",
|
|
3262
|
+
node,
|
|
3263
|
+
data: { reason: "contains less than two children" },
|
|
3264
|
+
fix: getFix$1(context$1, node)
|
|
3265
|
+
});
|
|
3266
|
+
return;
|
|
3267
|
+
}
|
|
3268
|
+
const nonPaddingChildren = node.children.filter((child) => !isPaddingSpaces(child));
|
|
3269
|
+
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3270
|
+
if (nonPaddingChildren.length === 0 || nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer) context$1.report({
|
|
3271
|
+
messageId: "noUselessFragment",
|
|
3272
|
+
node,
|
|
3273
|
+
data: { reason: "contains less than two children" },
|
|
3274
|
+
fix: getFix$1(context$1, node)
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
function getFix$1(context$1, node) {
|
|
3278
|
+
if (!canFix$1(context$1, node)) return null;
|
|
3279
|
+
return (fixer) => {
|
|
3280
|
+
const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
|
|
3281
|
+
const closer = node.type === AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
|
|
3282
|
+
const childrenText = opener.type === AST_NODE_TYPES.JSXOpeningElement && opener.selfClosing ? "" : context$1.sourceCode.getText().slice(opener.range[1], closer?.range[0]);
|
|
3283
|
+
return fixer.replaceText(node, trimLikeReact(childrenText));
|
|
3284
|
+
};
|
|
3285
|
+
}
|
|
3286
|
+
/**
|
|
3287
|
+
* Check if it's safe to automatically fix the fragment
|
|
3288
|
+
*/
|
|
3289
|
+
function canFix$1(context$1, node) {
|
|
3290
|
+
if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) return isJsxHostElement(context$1, node.parent);
|
|
3291
|
+
if (node.children.length === 0) return false;
|
|
3292
|
+
return !node.children.some((child) => isJsxText(child) && !isWhiteSpace(child) || AST.is(AST_NODE_TYPES.JSXExpressionContainer)(child));
|
|
3293
|
+
}
|
|
3213
3294
|
return {
|
|
3214
3295
|
JSXElement(node) {
|
|
3215
3296
|
if (!isJsxFragmentElement(context, node)) return;
|
|
3216
|
-
checkNode(context, node
|
|
3297
|
+
checkNode(context, node);
|
|
3217
3298
|
},
|
|
3218
3299
|
JSXFragment(node) {
|
|
3219
|
-
checkNode(context, node
|
|
3300
|
+
checkNode(context, node);
|
|
3220
3301
|
}
|
|
3221
3302
|
};
|
|
3222
3303
|
}
|
|
@@ -3242,77 +3323,11 @@ function trimLikeReact(text) {
|
|
|
3242
3323
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
3243
3324
|
return text.slice(start, end);
|
|
3244
3325
|
}
|
|
3245
|
-
/**
|
|
3246
|
-
* Check if a fragment node is useless and should be reported
|
|
3247
|
-
*/
|
|
3248
|
-
function checkNode(context, node, allowExpressions) {
|
|
3249
|
-
if (node.type === AST_NODE_TYPES.JSXElement && getJsxAttribute(context, node)("key") != null) return;
|
|
3250
|
-
if (isJsxHostElement(context, node.parent)) context.report({
|
|
3251
|
-
messageId: "uselessFragment",
|
|
3252
|
-
node,
|
|
3253
|
-
data: { reason: "placed inside a host component" },
|
|
3254
|
-
fix: getFix(context, node)
|
|
3255
|
-
});
|
|
3256
|
-
if (node.children.length === 0) {
|
|
3257
|
-
context.report({
|
|
3258
|
-
messageId: "uselessFragment",
|
|
3259
|
-
node,
|
|
3260
|
-
data: { reason: "contains less than two children" },
|
|
3261
|
-
fix: getFix(context, node)
|
|
3262
|
-
});
|
|
3263
|
-
return;
|
|
3264
|
-
}
|
|
3265
|
-
const isChildElement = AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3266
|
-
switch (true) {
|
|
3267
|
-
case allowExpressions && !isChildElement && node.children.length === 1 && isJsxText(node.children.at(0)): return;
|
|
3268
|
-
case !allowExpressions && isChildElement:
|
|
3269
|
-
context.report({
|
|
3270
|
-
messageId: "uselessFragment",
|
|
3271
|
-
node,
|
|
3272
|
-
data: { reason: "contains less than two children" },
|
|
3273
|
-
fix: getFix(context, node)
|
|
3274
|
-
});
|
|
3275
|
-
return;
|
|
3276
|
-
case !allowExpressions && !isChildElement && node.children.length === 1:
|
|
3277
|
-
context.report({
|
|
3278
|
-
messageId: "uselessFragment",
|
|
3279
|
-
node,
|
|
3280
|
-
data: { reason: "contains less than two children" },
|
|
3281
|
-
fix: getFix(context, node)
|
|
3282
|
-
});
|
|
3283
|
-
return;
|
|
3284
|
-
}
|
|
3285
|
-
const nonPaddingChildren = node.children.filter((child) => !isPaddingSpaces(child));
|
|
3286
|
-
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3287
|
-
if (nonPaddingChildren.length === 0 || nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer) context.report({
|
|
3288
|
-
messageId: "uselessFragment",
|
|
3289
|
-
node,
|
|
3290
|
-
data: { reason: "contains less than two children" },
|
|
3291
|
-
fix: getFix(context, node)
|
|
3292
|
-
});
|
|
3293
|
-
}
|
|
3294
|
-
function getFix(context, node) {
|
|
3295
|
-
if (!canFix(context, node)) return null;
|
|
3296
|
-
return (fixer) => {
|
|
3297
|
-
const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
|
|
3298
|
-
const closer = node.type === AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
|
|
3299
|
-
const childrenText = opener.type === AST_NODE_TYPES.JSXOpeningElement && opener.selfClosing ? "" : context.sourceCode.getText().slice(opener.range[1], closer?.range[0]);
|
|
3300
|
-
return fixer.replaceText(node, trimLikeReact(childrenText));
|
|
3301
|
-
};
|
|
3302
|
-
}
|
|
3303
|
-
/**
|
|
3304
|
-
* Check if it's safe to automatically fix the fragment
|
|
3305
|
-
*/
|
|
3306
|
-
function canFix(context, node) {
|
|
3307
|
-
if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) return isJsxHostElement(context, node.parent);
|
|
3308
|
-
if (node.children.length === 0) return false;
|
|
3309
|
-
return !node.children.some((child) => isJsxText(child) && !isWhiteSpace(child) || AST.is(AST_NODE_TYPES.JSXExpressionContainer)(child));
|
|
3310
|
-
}
|
|
3311
3326
|
|
|
3312
3327
|
//#endregion
|
|
3313
3328
|
//#region src/rules/prefer-destructuring-assignment.ts
|
|
3314
3329
|
const RULE_NAME$4 = "prefer-destructuring-assignment";
|
|
3315
|
-
const RULE_FEATURES$
|
|
3330
|
+
const RULE_FEATURES$4 = [];
|
|
3316
3331
|
function isMemberExpressionWithObjectName(node) {
|
|
3317
3332
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
3318
3333
|
}
|
|
@@ -3321,7 +3336,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3321
3336
|
type: "problem",
|
|
3322
3337
|
docs: {
|
|
3323
3338
|
description: "Enforces destructuring assignment for component props and context.",
|
|
3324
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
3339
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$4
|
|
3325
3340
|
},
|
|
3326
3341
|
messages: { preferDestructuringAssignment: "Use destructuring assignment for {{name}}." },
|
|
3327
3342
|
schema: []
|
|
@@ -3373,13 +3388,13 @@ function create$4(context) {
|
|
|
3373
3388
|
//#endregion
|
|
3374
3389
|
//#region src/rules/prefer-namespace-import.ts
|
|
3375
3390
|
const RULE_NAME$3 = "prefer-namespace-import";
|
|
3376
|
-
const RULE_FEATURES$
|
|
3391
|
+
const RULE_FEATURES$3 = ["FIX"];
|
|
3377
3392
|
var prefer_namespace_import_default = createRule({
|
|
3378
3393
|
meta: {
|
|
3379
3394
|
type: "problem",
|
|
3380
3395
|
docs: {
|
|
3381
3396
|
description: "Enforces React is imported via a namespace import.",
|
|
3382
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
3397
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$3
|
|
3383
3398
|
},
|
|
3384
3399
|
fixable: "code",
|
|
3385
3400
|
messages: { preferNamespaceImport: "Prefer importing React as 'import * as React from \"{{importSource}}\"';" },
|
|
@@ -3414,13 +3429,13 @@ function create$3(context) {
|
|
|
3414
3429
|
//#endregion
|
|
3415
3430
|
//#region src/rules/prefer-read-only-props.ts
|
|
3416
3431
|
const RULE_NAME$2 = "prefer-read-only-props";
|
|
3417
|
-
const RULE_FEATURES$
|
|
3432
|
+
const RULE_FEATURES$2 = ["TSC", "EXP"];
|
|
3418
3433
|
var prefer_read_only_props_default = createRule({
|
|
3419
3434
|
meta: {
|
|
3420
3435
|
type: "problem",
|
|
3421
3436
|
docs: {
|
|
3422
3437
|
description: "Enforces read-only props in components.",
|
|
3423
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$
|
|
3438
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$2
|
|
3424
3439
|
},
|
|
3425
3440
|
messages: { preferReadOnlyProps: "A function component's props should be read-only." },
|
|
3426
3441
|
schema: []
|
|
@@ -3474,7 +3489,7 @@ function isClassOrInterfaceReadonlyLoose(checker, type) {
|
|
|
3474
3489
|
//#endregion
|
|
3475
3490
|
//#region src/rules/prefer-use-state-lazy-initialization.ts
|
|
3476
3491
|
const RULE_NAME$1 = "prefer-use-state-lazy-initialization";
|
|
3477
|
-
const RULE_FEATURES = ["EXP"];
|
|
3492
|
+
const RULE_FEATURES$1 = ["EXP"];
|
|
3478
3493
|
const ALLOW_LIST = [
|
|
3479
3494
|
"Boolean",
|
|
3480
3495
|
"String",
|
|
@@ -3485,7 +3500,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
|
|
|
3485
3500
|
type: "problem",
|
|
3486
3501
|
docs: {
|
|
3487
3502
|
description: "Enforces function calls made inside `useState` to be wrapped in an `initializer function`.",
|
|
3488
|
-
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
3503
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$1
|
|
3489
3504
|
},
|
|
3490
3505
|
messages: { preferUseStateLazyInitialization: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'." },
|
|
3491
3506
|
schema: []
|
|
@@ -3524,6 +3539,7 @@ function create$1(context) {
|
|
|
3524
3539
|
//#endregion
|
|
3525
3540
|
//#region src/rules-removed/no-forbidden-props.ts
|
|
3526
3541
|
const RULE_NAME = "no-forbidden-props";
|
|
3542
|
+
const RULE_FEATURES = ["CFG", "EXP"];
|
|
3527
3543
|
const messageId = camelCase(RULE_NAME);
|
|
3528
3544
|
const defaultOptions = [{ forbid: [{ prop: "/_/" }] }];
|
|
3529
3545
|
var no_forbidden_props_default = createRule({
|
|
@@ -3538,7 +3554,10 @@ var no_forbidden_props_default = createRule({
|
|
|
3538
3554
|
url: "https://eslint.org/docs/latest/rules/no-restricted-syntax"
|
|
3539
3555
|
} }]
|
|
3540
3556
|
},
|
|
3541
|
-
docs: {
|
|
3557
|
+
docs: {
|
|
3558
|
+
description: "Disallow certain props on components.",
|
|
3559
|
+
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
3560
|
+
},
|
|
3542
3561
|
messages: { [messageId]: "Prop \"{{name}}\" is forbidden." },
|
|
3543
3562
|
schema: [{
|
|
3544
3563
|
type: "object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.12-next.0",
|
|
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",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"string-ts": "^2.3.1",
|
|
47
47
|
"ts-api-utils": "^2.1.0",
|
|
48
48
|
"ts-pattern": "^5.9.0",
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/eff": "2.3.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
49
|
+
"@eslint-react/core": "2.3.12-next.0",
|
|
50
|
+
"@eslint-react/eff": "2.3.12-next.0",
|
|
51
|
+
"@eslint-react/var": "2.3.12-next.0",
|
|
52
|
+
"@eslint-react/shared": "2.3.12-next.0",
|
|
53
|
+
"@eslint-react/ast": "2.3.12-next.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.7",
|