eslint-plugin-react-x 1.26.3-beta.8 → 1.26.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +21 -54
- package/dist/index.mjs +21 -54
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
type MessageID$3 = "noUselessFragment" | "noUselessFragmentInBuiltIn";
|
|
4
|
+
|
|
5
|
+
type MessageID$2 = "noUnstableContextValue" | "noUnstableContextValueWithFunction" | "noUnstableContextValueWithIdentifier";
|
|
6
|
+
|
|
3
7
|
type MessageID$1 = "nestedComponent" | "nestedComponentInProps";
|
|
4
8
|
|
|
5
|
-
type MessageID = "
|
|
9
|
+
type MessageID = "noMissingKey" | "noMissingKeyWithFragment";
|
|
6
10
|
|
|
7
11
|
declare const _default: {
|
|
8
12
|
meta: {
|
|
@@ -49,12 +53,12 @@ declare const _default: {
|
|
|
49
53
|
"no-unsafe-component-will-mount": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillMount", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
50
54
|
"no-unsafe-component-will-receive-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillReceiveProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
51
55
|
"no-unsafe-component-will-update": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillUpdate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
52
|
-
"no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
56
|
+
"no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
53
57
|
"no-unstable-default-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnstableDefaultProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
54
58
|
"no-unused-class-component-members": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedClassComponentMembers", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
55
59
|
"no-unused-state": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedState", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
56
60
|
"no-use-context": _typescript_eslint_utils_ts_eslint.RuleModule<"noUseContext", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
57
|
-
"no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
61
|
+
"no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [{
|
|
58
62
|
allowExpressions: boolean;
|
|
59
63
|
}], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
60
64
|
"prefer-destructuring-assignment": _typescript_eslint_utils_ts_eslint.RuleModule<"preferDestructuringAssignment", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
type MessageID$3 = "noUselessFragment" | "noUselessFragmentInBuiltIn";
|
|
4
|
+
|
|
5
|
+
type MessageID$2 = "noUnstableContextValue" | "noUnstableContextValueWithFunction" | "noUnstableContextValueWithIdentifier";
|
|
6
|
+
|
|
3
7
|
type MessageID$1 = "nestedComponent" | "nestedComponentInProps";
|
|
4
8
|
|
|
5
|
-
type MessageID = "
|
|
9
|
+
type MessageID = "noMissingKey" | "noMissingKeyWithFragment";
|
|
6
10
|
|
|
7
11
|
declare const _default: {
|
|
8
12
|
meta: {
|
|
@@ -49,12 +53,12 @@ declare const _default: {
|
|
|
49
53
|
"no-unsafe-component-will-mount": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillMount", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
50
54
|
"no-unsafe-component-will-receive-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillReceiveProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
51
55
|
"no-unsafe-component-will-update": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillUpdate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
52
|
-
"no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
56
|
+
"no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
53
57
|
"no-unstable-default-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnstableDefaultProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
54
58
|
"no-unused-class-component-members": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedClassComponentMembers", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
55
59
|
"no-unused-state": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedState", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
56
60
|
"no-use-context": _typescript_eslint_utils_ts_eslint.RuleModule<"noUseContext", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
57
|
-
"no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
61
|
+
"no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [{
|
|
58
62
|
allowExpressions: boolean;
|
|
59
63
|
}], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
60
64
|
"prefer-destructuring-assignment": _typescript_eslint_utils_ts_eslint.RuleModule<"preferDestructuringAssignment", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
|
42
42
|
|
|
43
43
|
// package.json
|
|
44
44
|
var name = "eslint-plugin-react-x";
|
|
45
|
-
var version = "1.26.3-
|
|
45
|
+
var version = "1.26.3-next.1";
|
|
46
46
|
var createRule = shared.createRuleForPlugin("x");
|
|
47
47
|
|
|
48
48
|
// src/utils/get-associated-tokens.ts
|
|
@@ -1693,8 +1693,8 @@ var no_missing_key_default = createRule({
|
|
|
1693
1693
|
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1694
1694
|
},
|
|
1695
1695
|
messages: {
|
|
1696
|
-
|
|
1697
|
-
|
|
1696
|
+
noMissingKey: "Missing 'key' for element when rendering list.",
|
|
1697
|
+
noMissingKeyWithFragment: "Use fragment component instead of '<>' because it does not support `key`."
|
|
1698
1698
|
},
|
|
1699
1699
|
schema: []
|
|
1700
1700
|
},
|
|
@@ -1707,7 +1707,7 @@ var no_missing_key_default = createRule({
|
|
|
1707
1707
|
const initialScope = context.sourceCode.getScope(node);
|
|
1708
1708
|
if (!JSX7__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1709
1709
|
return {
|
|
1710
|
-
messageId: "
|
|
1710
|
+
messageId: "noMissingKey",
|
|
1711
1711
|
node
|
|
1712
1712
|
};
|
|
1713
1713
|
}
|
|
@@ -1715,7 +1715,7 @@ var no_missing_key_default = createRule({
|
|
|
1715
1715
|
}
|
|
1716
1716
|
case types.AST_NODE_TYPES.JSXFragment: {
|
|
1717
1717
|
return {
|
|
1718
|
-
messageId: "
|
|
1718
|
+
messageId: "noMissingKeyWithFragment",
|
|
1719
1719
|
node
|
|
1720
1720
|
};
|
|
1721
1721
|
}
|
|
@@ -1768,7 +1768,7 @@ var no_missing_key_default = createRule({
|
|
|
1768
1768
|
for (const element of elements) {
|
|
1769
1769
|
if (!JSX7__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1770
1770
|
context.report({
|
|
1771
|
-
messageId: "
|
|
1771
|
+
messageId: "noMissingKey",
|
|
1772
1772
|
node: element
|
|
1773
1773
|
});
|
|
1774
1774
|
}
|
|
@@ -1810,7 +1810,7 @@ var no_missing_key_default = createRule({
|
|
|
1810
1810
|
}
|
|
1811
1811
|
if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
|
|
1812
1812
|
context.report({
|
|
1813
|
-
messageId: "
|
|
1813
|
+
messageId: "noMissingKeyWithFragment",
|
|
1814
1814
|
node
|
|
1815
1815
|
});
|
|
1816
1816
|
}
|
|
@@ -2364,7 +2364,9 @@ var no_unstable_context_value_default = createRule({
|
|
|
2364
2364
|
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2365
2365
|
},
|
|
2366
2366
|
messages: {
|
|
2367
|
-
|
|
2367
|
+
noUnstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render.",
|
|
2368
|
+
noUnstableContextValueWithFunction: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useCallback hook.",
|
|
2369
|
+
noUnstableContextValueWithIdentifier: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useMemo hook."
|
|
2368
2370
|
},
|
|
2369
2371
|
schema: []
|
|
2370
2372
|
},
|
|
@@ -2404,13 +2406,12 @@ var no_unstable_context_value_default = createRule({
|
|
|
2404
2406
|
for (const { node: component } of components) {
|
|
2405
2407
|
for (const construction of constructions.get(component) ?? []) {
|
|
2406
2408
|
const { kind, node: constructionNode } = construction;
|
|
2407
|
-
const
|
|
2409
|
+
const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
|
|
2408
2410
|
context.report({
|
|
2409
|
-
messageId
|
|
2411
|
+
messageId,
|
|
2410
2412
|
node: constructionNode,
|
|
2411
2413
|
data: {
|
|
2412
|
-
type: AST11__namespace.toReadableNodeType(constructionNode)
|
|
2413
|
-
suggestion
|
|
2414
|
+
type: AST11__namespace.toReadableNodeType(constructionNode)
|
|
2414
2415
|
}
|
|
2415
2416
|
});
|
|
2416
2417
|
}
|
|
@@ -2949,24 +2950,10 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
2949
2950
|
return;
|
|
2950
2951
|
}
|
|
2951
2952
|
if (JSX7__namespace.isBuiltInElement(node.parent)) {
|
|
2952
|
-
context.report({
|
|
2953
|
-
messageId: "uselessFragment",
|
|
2954
|
-
node,
|
|
2955
|
-
data: {
|
|
2956
|
-
reason: "placed inside a built-in component"
|
|
2957
|
-
},
|
|
2958
|
-
fix
|
|
2959
|
-
});
|
|
2953
|
+
context.report({ messageId: "noUselessFragmentInBuiltIn", node, fix });
|
|
2960
2954
|
}
|
|
2961
2955
|
if (node.children.length === 0) {
|
|
2962
|
-
context.report({
|
|
2963
|
-
messageId: "uselessFragment",
|
|
2964
|
-
node,
|
|
2965
|
-
data: {
|
|
2966
|
-
reason: "contains less than two children"
|
|
2967
|
-
},
|
|
2968
|
-
fix
|
|
2969
|
-
});
|
|
2956
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2970
2957
|
return;
|
|
2971
2958
|
}
|
|
2972
2959
|
const isChildElement = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
@@ -2977,25 +2964,11 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
2977
2964
|
}
|
|
2978
2965
|
// <Foo><>hello, world</></Foo>
|
|
2979
2966
|
case (!allowExpressions && isChildElement): {
|
|
2980
|
-
context.report({
|
|
2981
|
-
messageId: "uselessFragment",
|
|
2982
|
-
node,
|
|
2983
|
-
data: {
|
|
2984
|
-
reason: "contains less than two children"
|
|
2985
|
-
},
|
|
2986
|
-
fix
|
|
2987
|
-
});
|
|
2967
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2988
2968
|
return;
|
|
2989
2969
|
}
|
|
2990
2970
|
case (!allowExpressions && !isChildElement && node.children.length === 1): {
|
|
2991
|
-
context.report({
|
|
2992
|
-
messageId: "uselessFragment",
|
|
2993
|
-
node,
|
|
2994
|
-
data: {
|
|
2995
|
-
reason: "contains less than two children"
|
|
2996
|
-
},
|
|
2997
|
-
fix
|
|
2998
|
-
});
|
|
2971
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2999
2972
|
return;
|
|
3000
2973
|
}
|
|
3001
2974
|
}
|
|
@@ -3004,14 +2977,7 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
3004
2977
|
switch (true) {
|
|
3005
2978
|
case nonPaddingChildren.length === 0:
|
|
3006
2979
|
case (nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== types.AST_NODE_TYPES.JSXExpressionContainer): {
|
|
3007
|
-
context.report({
|
|
3008
|
-
messageId: "uselessFragment",
|
|
3009
|
-
node,
|
|
3010
|
-
data: {
|
|
3011
|
-
reason: "contains less than two children"
|
|
3012
|
-
},
|
|
3013
|
-
fix
|
|
3014
|
-
});
|
|
2980
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
3015
2981
|
return;
|
|
3016
2982
|
}
|
|
3017
2983
|
}
|
|
@@ -3022,11 +2988,12 @@ var no_useless_fragment_default = createRule({
|
|
|
3022
2988
|
type: "problem",
|
|
3023
2989
|
defaultOptions: [...defaultOptions],
|
|
3024
2990
|
docs: {
|
|
3025
|
-
description: "disallow
|
|
2991
|
+
description: "disallow unnecessary fragments"
|
|
3026
2992
|
},
|
|
3027
2993
|
fixable: "code",
|
|
3028
2994
|
messages: {
|
|
3029
|
-
|
|
2995
|
+
noUselessFragment: "A fragment contains less than two children is unnecessary.",
|
|
2996
|
+
noUselessFragmentInBuiltIn: "A fragment placed inside a built-in component is unnecessary."
|
|
3030
2997
|
},
|
|
3031
2998
|
schema: [{
|
|
3032
2999
|
type: "object",
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
|
|
|
15
15
|
|
|
16
16
|
// package.json
|
|
17
17
|
var name = "eslint-plugin-react-x";
|
|
18
|
-
var version = "1.26.3-
|
|
18
|
+
var version = "1.26.3-next.1";
|
|
19
19
|
var createRule = createRuleForPlugin("x");
|
|
20
20
|
|
|
21
21
|
// src/utils/get-associated-tokens.ts
|
|
@@ -1666,8 +1666,8 @@ var no_missing_key_default = createRule({
|
|
|
1666
1666
|
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1667
1667
|
},
|
|
1668
1668
|
messages: {
|
|
1669
|
-
|
|
1670
|
-
|
|
1669
|
+
noMissingKey: "Missing 'key' for element when rendering list.",
|
|
1670
|
+
noMissingKeyWithFragment: "Use fragment component instead of '<>' because it does not support `key`."
|
|
1671
1671
|
},
|
|
1672
1672
|
schema: []
|
|
1673
1673
|
},
|
|
@@ -1680,7 +1680,7 @@ var no_missing_key_default = createRule({
|
|
|
1680
1680
|
const initialScope = context.sourceCode.getScope(node);
|
|
1681
1681
|
if (!JSX7.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1682
1682
|
return {
|
|
1683
|
-
messageId: "
|
|
1683
|
+
messageId: "noMissingKey",
|
|
1684
1684
|
node
|
|
1685
1685
|
};
|
|
1686
1686
|
}
|
|
@@ -1688,7 +1688,7 @@ var no_missing_key_default = createRule({
|
|
|
1688
1688
|
}
|
|
1689
1689
|
case AST_NODE_TYPES.JSXFragment: {
|
|
1690
1690
|
return {
|
|
1691
|
-
messageId: "
|
|
1691
|
+
messageId: "noMissingKeyWithFragment",
|
|
1692
1692
|
node
|
|
1693
1693
|
};
|
|
1694
1694
|
}
|
|
@@ -1741,7 +1741,7 @@ var no_missing_key_default = createRule({
|
|
|
1741
1741
|
for (const element of elements) {
|
|
1742
1742
|
if (!JSX7.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1743
1743
|
context.report({
|
|
1744
|
-
messageId: "
|
|
1744
|
+
messageId: "noMissingKey",
|
|
1745
1745
|
node: element
|
|
1746
1746
|
});
|
|
1747
1747
|
}
|
|
@@ -1783,7 +1783,7 @@ var no_missing_key_default = createRule({
|
|
|
1783
1783
|
}
|
|
1784
1784
|
if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
|
|
1785
1785
|
context.report({
|
|
1786
|
-
messageId: "
|
|
1786
|
+
messageId: "noMissingKeyWithFragment",
|
|
1787
1787
|
node
|
|
1788
1788
|
});
|
|
1789
1789
|
}
|
|
@@ -2337,7 +2337,9 @@ var no_unstable_context_value_default = createRule({
|
|
|
2337
2337
|
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2338
2338
|
},
|
|
2339
2339
|
messages: {
|
|
2340
|
-
|
|
2340
|
+
noUnstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render.",
|
|
2341
|
+
noUnstableContextValueWithFunction: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useCallback hook.",
|
|
2342
|
+
noUnstableContextValueWithIdentifier: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useMemo hook."
|
|
2341
2343
|
},
|
|
2342
2344
|
schema: []
|
|
2343
2345
|
},
|
|
@@ -2377,13 +2379,12 @@ var no_unstable_context_value_default = createRule({
|
|
|
2377
2379
|
for (const { node: component } of components) {
|
|
2378
2380
|
for (const construction of constructions.get(component) ?? []) {
|
|
2379
2381
|
const { kind, node: constructionNode } = construction;
|
|
2380
|
-
const
|
|
2382
|
+
const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
|
|
2381
2383
|
context.report({
|
|
2382
|
-
messageId
|
|
2384
|
+
messageId,
|
|
2383
2385
|
node: constructionNode,
|
|
2384
2386
|
data: {
|
|
2385
|
-
type: AST11.toReadableNodeType(constructionNode)
|
|
2386
|
-
suggestion
|
|
2387
|
+
type: AST11.toReadableNodeType(constructionNode)
|
|
2387
2388
|
}
|
|
2388
2389
|
});
|
|
2389
2390
|
}
|
|
@@ -2922,24 +2923,10 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
2922
2923
|
return;
|
|
2923
2924
|
}
|
|
2924
2925
|
if (JSX7.isBuiltInElement(node.parent)) {
|
|
2925
|
-
context.report({
|
|
2926
|
-
messageId: "uselessFragment",
|
|
2927
|
-
node,
|
|
2928
|
-
data: {
|
|
2929
|
-
reason: "placed inside a built-in component"
|
|
2930
|
-
},
|
|
2931
|
-
fix
|
|
2932
|
-
});
|
|
2926
|
+
context.report({ messageId: "noUselessFragmentInBuiltIn", node, fix });
|
|
2933
2927
|
}
|
|
2934
2928
|
if (node.children.length === 0) {
|
|
2935
|
-
context.report({
|
|
2936
|
-
messageId: "uselessFragment",
|
|
2937
|
-
node,
|
|
2938
|
-
data: {
|
|
2939
|
-
reason: "contains less than two children"
|
|
2940
|
-
},
|
|
2941
|
-
fix
|
|
2942
|
-
});
|
|
2929
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2943
2930
|
return;
|
|
2944
2931
|
}
|
|
2945
2932
|
const isChildElement = AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
@@ -2950,25 +2937,11 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
2950
2937
|
}
|
|
2951
2938
|
// <Foo><>hello, world</></Foo>
|
|
2952
2939
|
case (!allowExpressions && isChildElement): {
|
|
2953
|
-
context.report({
|
|
2954
|
-
messageId: "uselessFragment",
|
|
2955
|
-
node,
|
|
2956
|
-
data: {
|
|
2957
|
-
reason: "contains less than two children"
|
|
2958
|
-
},
|
|
2959
|
-
fix
|
|
2960
|
-
});
|
|
2940
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2961
2941
|
return;
|
|
2962
2942
|
}
|
|
2963
2943
|
case (!allowExpressions && !isChildElement && node.children.length === 1): {
|
|
2964
|
-
context.report({
|
|
2965
|
-
messageId: "uselessFragment",
|
|
2966
|
-
node,
|
|
2967
|
-
data: {
|
|
2968
|
-
reason: "contains less than two children"
|
|
2969
|
-
},
|
|
2970
|
-
fix
|
|
2971
|
-
});
|
|
2944
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2972
2945
|
return;
|
|
2973
2946
|
}
|
|
2974
2947
|
}
|
|
@@ -2977,14 +2950,7 @@ function checkAndReport(node, context, allowExpressions) {
|
|
|
2977
2950
|
switch (true) {
|
|
2978
2951
|
case nonPaddingChildren.length === 0:
|
|
2979
2952
|
case (nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer): {
|
|
2980
|
-
context.report({
|
|
2981
|
-
messageId: "uselessFragment",
|
|
2982
|
-
node,
|
|
2983
|
-
data: {
|
|
2984
|
-
reason: "contains less than two children"
|
|
2985
|
-
},
|
|
2986
|
-
fix
|
|
2987
|
-
});
|
|
2953
|
+
context.report({ messageId: "noUselessFragment", node, fix });
|
|
2988
2954
|
return;
|
|
2989
2955
|
}
|
|
2990
2956
|
}
|
|
@@ -2995,11 +2961,12 @@ var no_useless_fragment_default = createRule({
|
|
|
2995
2961
|
type: "problem",
|
|
2996
2962
|
defaultOptions: [...defaultOptions],
|
|
2997
2963
|
docs: {
|
|
2998
|
-
description: "disallow
|
|
2964
|
+
description: "disallow unnecessary fragments"
|
|
2999
2965
|
},
|
|
3000
2966
|
fixable: "code",
|
|
3001
2967
|
messages: {
|
|
3002
|
-
|
|
2968
|
+
noUselessFragment: "A fragment contains less than two children is unnecessary.",
|
|
2969
|
+
noUselessFragmentInBuiltIn: "A fragment placed inside a built-in component is unnecessary."
|
|
3003
2970
|
},
|
|
3004
2971
|
schema: [{
|
|
3005
2972
|
type: "object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.26.3-
|
|
3
|
+
"version": "1.26.3-next.1",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.6.2",
|
|
53
|
-
"@eslint-react/core": "1.26.3-
|
|
54
|
-
"@eslint-react/ast": "1.26.3-
|
|
55
|
-
"@eslint-react/eff": "1.26.3-
|
|
56
|
-
"@eslint-react/shared": "1.26.3-
|
|
57
|
-
"@eslint-react/jsx": "1.26.3-
|
|
58
|
-
"@eslint-react/var": "1.26.3-
|
|
53
|
+
"@eslint-react/core": "1.26.3-next.1",
|
|
54
|
+
"@eslint-react/ast": "1.26.3-next.1",
|
|
55
|
+
"@eslint-react/eff": "1.26.3-next.1",
|
|
56
|
+
"@eslint-react/shared": "1.26.3-next.1",
|
|
57
|
+
"@eslint-react/jsx": "1.26.3-next.1",
|
|
58
|
+
"@eslint-react/var": "1.26.3-next.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.0.8",
|
|
62
62
|
"@types/react-dom": "^19.0.3",
|
|
63
63
|
"ts-api-utils": "^2.0.1",
|
|
64
64
|
"tsup": "^8.3.6",
|
|
65
|
-
"@
|
|
65
|
+
"@workspace/configs": "0.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"eslint": "^8.57.0 || ^9.0.0",
|