eslint-plugin-react-x 1.38.0-beta.9 → 1.38.0-next.10
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 +25 -39
- package/dist/index.mjs +24 -38
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var shared = require('@eslint-react/shared');
|
|
4
|
-
var
|
|
4
|
+
var JSX9 = require('@eslint-react/jsx');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
6
|
var types = require('@typescript-eslint/types');
|
|
7
7
|
var VAR2 = require('@eslint-react/var');
|
|
@@ -36,7 +36,7 @@ function _interopNamespace(e) {
|
|
|
36
36
|
return Object.freeze(n);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var JSX9__namespace = /*#__PURE__*/_interopNamespace(JSX9);
|
|
40
40
|
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
41
41
|
var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
42
42
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
@@ -139,7 +139,7 @@ var settings3 = {
|
|
|
139
139
|
|
|
140
140
|
// package.json
|
|
141
141
|
var name4 = "eslint-plugin-react-x";
|
|
142
|
-
var version = "1.38.0-
|
|
142
|
+
var version = "1.38.0-next.10";
|
|
143
143
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
144
144
|
|
|
145
145
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -170,7 +170,7 @@ function create(context) {
|
|
|
170
170
|
messageId: "avoidShorthandBoolean",
|
|
171
171
|
node,
|
|
172
172
|
data: {
|
|
173
|
-
propName:
|
|
173
|
+
propName: JSX9__namespace.getAttributeName(node)
|
|
174
174
|
},
|
|
175
175
|
fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
|
|
176
176
|
});
|
|
@@ -446,20 +446,6 @@ function create6(context) {
|
|
|
446
446
|
var RULE_NAME7 = "no-array-index-key";
|
|
447
447
|
var RULE_FEATURES7 = [];
|
|
448
448
|
var reactChildrenMethod = ["forEach", "map"];
|
|
449
|
-
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
450
|
-
["every", 1],
|
|
451
|
-
["filter", 1],
|
|
452
|
-
["find", 1],
|
|
453
|
-
["findIndex", 1],
|
|
454
|
-
["findLast", 1],
|
|
455
|
-
["findLastIndex", 1],
|
|
456
|
-
["flatMap", 1],
|
|
457
|
-
["forEach", 1],
|
|
458
|
-
["map", 1],
|
|
459
|
-
["reduce", 2],
|
|
460
|
-
["reduceRight", 2],
|
|
461
|
-
["some", 1]
|
|
462
|
-
]);
|
|
463
449
|
function isReactChildrenMethod(name5) {
|
|
464
450
|
return reactChildrenMethod.some((method) => method === name5);
|
|
465
451
|
}
|
|
@@ -490,7 +476,7 @@ function getMapIndexParamName(context, node) {
|
|
|
490
476
|
return eff._;
|
|
491
477
|
}
|
|
492
478
|
const { name: name5 } = callee.property;
|
|
493
|
-
if (!
|
|
479
|
+
if (!AST11__namespace.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.has(name5)) {
|
|
494
480
|
return eff._;
|
|
495
481
|
}
|
|
496
482
|
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
@@ -501,7 +487,7 @@ function getMapIndexParamName(context, node) {
|
|
|
501
487
|
return eff._;
|
|
502
488
|
}
|
|
503
489
|
const { params } = callbackArg;
|
|
504
|
-
const indexParamPosition =
|
|
490
|
+
const indexParamPosition = AST11__namespace.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.get(name5);
|
|
505
491
|
if (indexParamPosition == null) {
|
|
506
492
|
return eff._;
|
|
507
493
|
}
|
|
@@ -778,7 +764,7 @@ var no_children_prop_default = createRule({
|
|
|
778
764
|
function create12(context) {
|
|
779
765
|
return {
|
|
780
766
|
JSXElement(node) {
|
|
781
|
-
const attribute =
|
|
767
|
+
const attribute = JSX9__namespace.getAttribute(
|
|
782
768
|
"children",
|
|
783
769
|
node.openingElement.attributes,
|
|
784
770
|
context.sourceCode.getScope(node)
|
|
@@ -1164,7 +1150,7 @@ function create21(context) {
|
|
|
1164
1150
|
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
1165
1151
|
return {
|
|
1166
1152
|
JSXElement(node) {
|
|
1167
|
-
const fullName =
|
|
1153
|
+
const fullName = JSX9__namespace.getElementType(node);
|
|
1168
1154
|
const parts = fullName.split(".");
|
|
1169
1155
|
const selfName = parts.pop();
|
|
1170
1156
|
const contextFullName = parts.join(".");
|
|
@@ -1359,7 +1345,7 @@ function create25(context) {
|
|
|
1359
1345
|
break;
|
|
1360
1346
|
}
|
|
1361
1347
|
default: {
|
|
1362
|
-
const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.
|
|
1348
|
+
const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.isArrayMapCallLoose);
|
|
1363
1349
|
const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
|
|
1364
1350
|
if (!AST11__namespace.isFunction(iter)) return;
|
|
1365
1351
|
const arg0 = call?.arguments[0];
|
|
@@ -1526,7 +1512,7 @@ function create27(context) {
|
|
|
1526
1512
|
return {
|
|
1527
1513
|
JSXOpeningElement(node) {
|
|
1528
1514
|
const initialScope = context.sourceCode.getScope(node);
|
|
1529
|
-
const keyPropFound =
|
|
1515
|
+
const keyPropFound = JSX9__namespace.getAttribute("key", node.attributes, initialScope);
|
|
1530
1516
|
const keyPropOnElement = node.attributes.some(
|
|
1531
1517
|
(n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1532
1518
|
);
|
|
@@ -1826,7 +1812,7 @@ function create31(context) {
|
|
|
1826
1812
|
switch (node.type) {
|
|
1827
1813
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1828
1814
|
const initialScope = context.sourceCode.getScope(node);
|
|
1829
|
-
if (!
|
|
1815
|
+
if (!JSX9__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1830
1816
|
return {
|
|
1831
1817
|
messageId: "missingKey",
|
|
1832
1818
|
node
|
|
@@ -1883,7 +1869,7 @@ function create31(context) {
|
|
|
1883
1869
|
}
|
|
1884
1870
|
const initialScope = context.sourceCode.getScope(node);
|
|
1885
1871
|
for (const element of elements) {
|
|
1886
|
-
if (!
|
|
1872
|
+
if (!JSX9__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1887
1873
|
report({
|
|
1888
1874
|
messageId: "missingKey",
|
|
1889
1875
|
node: element
|
|
@@ -1896,7 +1882,7 @@ function create31(context) {
|
|
|
1896
1882
|
if (state.isWithinChildrenToArray) {
|
|
1897
1883
|
return;
|
|
1898
1884
|
}
|
|
1899
|
-
const isMapCall = AST11__namespace.
|
|
1885
|
+
const isMapCall = AST11__namespace.isArrayMapCallLoose(node);
|
|
1900
1886
|
if (!isMapCall && !isArrayFromCall(node)) {
|
|
1901
1887
|
return;
|
|
1902
1888
|
}
|
|
@@ -1951,7 +1937,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1951
1937
|
defaultOptions: []
|
|
1952
1938
|
});
|
|
1953
1939
|
function create32(context) {
|
|
1954
|
-
const hint = core.ERComponentHint.
|
|
1940
|
+
const hint = core.ERComponentHint.SkipArrayMapArgument | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1955
1941
|
const collector = core.useComponentCollector(context, { hint });
|
|
1956
1942
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
1957
1943
|
return {
|
|
@@ -2037,7 +2023,7 @@ function create32(context) {
|
|
|
2037
2023
|
};
|
|
2038
2024
|
}
|
|
2039
2025
|
function isInsideJSXAttributeValue(node) {
|
|
2040
|
-
return node.parent.type === types.AST_NODE_TYPES.JSXAttribute ||
|
|
2026
|
+
return node.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX9__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
2041
2027
|
}
|
|
2042
2028
|
function isInsideCreateElementProps(context, node) {
|
|
2043
2029
|
const call = AST11__namespace.findParentNode(node, core.isCreateElementCall(context));
|
|
@@ -2473,7 +2459,7 @@ function create42(context) {
|
|
|
2473
2459
|
return {
|
|
2474
2460
|
...listeners,
|
|
2475
2461
|
JSXOpeningElement(node) {
|
|
2476
|
-
const fullName =
|
|
2462
|
+
const fullName = JSX9__namespace.getElementType(node.parent);
|
|
2477
2463
|
const selfName = fullName.split(".").at(-1);
|
|
2478
2464
|
if (selfName == null) return;
|
|
2479
2465
|
if (!isContextName(selfName, isReact18OrBelow)) return;
|
|
@@ -3069,7 +3055,7 @@ function create48(context, [option]) {
|
|
|
3069
3055
|
const { allowExpressions = true } = option;
|
|
3070
3056
|
return {
|
|
3071
3057
|
JSXElement(node) {
|
|
3072
|
-
if (!
|
|
3058
|
+
if (!JSX9__namespace.isFragmentElement(node)) return;
|
|
3073
3059
|
doCheck(context, node, allowExpressions);
|
|
3074
3060
|
},
|
|
3075
3061
|
JSXFragment(node) {
|
|
@@ -3091,12 +3077,12 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3091
3077
|
return null;
|
|
3092
3078
|
}
|
|
3093
3079
|
if (node.children.some(
|
|
3094
|
-
(child) =>
|
|
3080
|
+
(child) => JSX9__namespace.isLiteral(child) && !JSX9__namespace.isWhiteSpace(child) || AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(child)
|
|
3095
3081
|
)) {
|
|
3096
3082
|
return null;
|
|
3097
3083
|
}
|
|
3098
3084
|
}
|
|
3099
|
-
if (
|
|
3085
|
+
if (JSX9__namespace.isUserDefinedElement(node.parent)) {
|
|
3100
3086
|
return null;
|
|
3101
3087
|
}
|
|
3102
3088
|
const opener = node.type === types.AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
|
|
@@ -3105,10 +3091,10 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3105
3091
|
return fixer.replaceText(node, trimLikeReact(childrenText));
|
|
3106
3092
|
}
|
|
3107
3093
|
const initialScope = context.sourceCode.getScope(node);
|
|
3108
|
-
if (
|
|
3094
|
+
if (JSX9__namespace.isKeyedElement(node, initialScope)) {
|
|
3109
3095
|
return;
|
|
3110
3096
|
}
|
|
3111
|
-
if (
|
|
3097
|
+
if (JSX9__namespace.isBuiltInElement(node.parent)) {
|
|
3112
3098
|
context.report({
|
|
3113
3099
|
messageId: "uselessFragment",
|
|
3114
3100
|
node,
|
|
@@ -3132,7 +3118,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3132
3118
|
const isChildElement = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3133
3119
|
switch (true) {
|
|
3134
3120
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3135
|
-
case (allowExpressions && !isChildElement && node.children.length === 1 &&
|
|
3121
|
+
case (allowExpressions && !isChildElement && node.children.length === 1 && JSX9__namespace.isLiteral(node.children.at(0))): {
|
|
3136
3122
|
return;
|
|
3137
3123
|
}
|
|
3138
3124
|
// <Foo><>hello, world</></Foo>
|
|
@@ -3159,7 +3145,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3159
3145
|
return;
|
|
3160
3146
|
}
|
|
3161
3147
|
}
|
|
3162
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
3148
|
+
const nonPaddingChildren = node.children.filter((child) => !JSX9__namespace.isPaddingSpaces(child));
|
|
3163
3149
|
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3164
3150
|
switch (true) {
|
|
3165
3151
|
case nonPaddingChildren.length === 0:
|
|
@@ -3389,7 +3375,7 @@ function create52(context) {
|
|
|
3389
3375
|
return {
|
|
3390
3376
|
JSXAttribute(node) {
|
|
3391
3377
|
const { value } = node;
|
|
3392
|
-
const propName =
|
|
3378
|
+
const propName = JSX9__namespace.getAttributeName(node);
|
|
3393
3379
|
const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
|
|
3394
3380
|
if (!hasValueTrue) {
|
|
3395
3381
|
return;
|
|
@@ -3429,7 +3415,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3429
3415
|
function create53(context) {
|
|
3430
3416
|
return {
|
|
3431
3417
|
JSXElement(node) {
|
|
3432
|
-
if (!
|
|
3418
|
+
if (!JSX9__namespace.isFragmentElement(node)) return;
|
|
3433
3419
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3434
3420
|
if (hasAttributes) {
|
|
3435
3421
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDocsUrl, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
|
-
import * as
|
|
2
|
+
import * as JSX9 from '@eslint-react/jsx';
|
|
3
3
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
5
|
import * as VAR2 from '@eslint-react/var';
|
|
@@ -112,7 +112,7 @@ var settings3 = {
|
|
|
112
112
|
|
|
113
113
|
// package.json
|
|
114
114
|
var name4 = "eslint-plugin-react-x";
|
|
115
|
-
var version = "1.38.0-
|
|
115
|
+
var version = "1.38.0-next.10";
|
|
116
116
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
117
117
|
|
|
118
118
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -143,7 +143,7 @@ function create(context) {
|
|
|
143
143
|
messageId: "avoidShorthandBoolean",
|
|
144
144
|
node,
|
|
145
145
|
data: {
|
|
146
|
-
propName:
|
|
146
|
+
propName: JSX9.getAttributeName(node)
|
|
147
147
|
},
|
|
148
148
|
fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
|
|
149
149
|
});
|
|
@@ -419,20 +419,6 @@ function create6(context) {
|
|
|
419
419
|
var RULE_NAME7 = "no-array-index-key";
|
|
420
420
|
var RULE_FEATURES7 = [];
|
|
421
421
|
var reactChildrenMethod = ["forEach", "map"];
|
|
422
|
-
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
423
|
-
["every", 1],
|
|
424
|
-
["filter", 1],
|
|
425
|
-
["find", 1],
|
|
426
|
-
["findIndex", 1],
|
|
427
|
-
["findLast", 1],
|
|
428
|
-
["findLastIndex", 1],
|
|
429
|
-
["flatMap", 1],
|
|
430
|
-
["forEach", 1],
|
|
431
|
-
["map", 1],
|
|
432
|
-
["reduce", 2],
|
|
433
|
-
["reduceRight", 2],
|
|
434
|
-
["some", 1]
|
|
435
|
-
]);
|
|
436
422
|
function isReactChildrenMethod(name5) {
|
|
437
423
|
return reactChildrenMethod.some((method) => method === name5);
|
|
438
424
|
}
|
|
@@ -463,7 +449,7 @@ function getMapIndexParamName(context, node) {
|
|
|
463
449
|
return _;
|
|
464
450
|
}
|
|
465
451
|
const { name: name5 } = callee.property;
|
|
466
|
-
if (!
|
|
452
|
+
if (!AST11.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.has(name5)) {
|
|
467
453
|
return _;
|
|
468
454
|
}
|
|
469
455
|
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
@@ -474,7 +460,7 @@ function getMapIndexParamName(context, node) {
|
|
|
474
460
|
return _;
|
|
475
461
|
}
|
|
476
462
|
const { params } = callbackArg;
|
|
477
|
-
const indexParamPosition =
|
|
463
|
+
const indexParamPosition = AST11.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.get(name5);
|
|
478
464
|
if (indexParamPosition == null) {
|
|
479
465
|
return _;
|
|
480
466
|
}
|
|
@@ -751,7 +737,7 @@ var no_children_prop_default = createRule({
|
|
|
751
737
|
function create12(context) {
|
|
752
738
|
return {
|
|
753
739
|
JSXElement(node) {
|
|
754
|
-
const attribute =
|
|
740
|
+
const attribute = JSX9.getAttribute(
|
|
755
741
|
"children",
|
|
756
742
|
node.openingElement.attributes,
|
|
757
743
|
context.sourceCode.getScope(node)
|
|
@@ -1137,7 +1123,7 @@ function create21(context) {
|
|
|
1137
1123
|
if (compare(version2, "19.0.0", "<")) return {};
|
|
1138
1124
|
return {
|
|
1139
1125
|
JSXElement(node) {
|
|
1140
|
-
const fullName =
|
|
1126
|
+
const fullName = JSX9.getElementType(node);
|
|
1141
1127
|
const parts = fullName.split(".");
|
|
1142
1128
|
const selfName = parts.pop();
|
|
1143
1129
|
const contextFullName = parts.join(".");
|
|
@@ -1332,7 +1318,7 @@ function create25(context) {
|
|
|
1332
1318
|
break;
|
|
1333
1319
|
}
|
|
1334
1320
|
default: {
|
|
1335
|
-
const call = AST11.findParentNode(jsxElement, AST11.
|
|
1321
|
+
const call = AST11.findParentNode(jsxElement, AST11.isArrayMapCallLoose);
|
|
1336
1322
|
const iter = AST11.findParentNode(jsxElement, (n) => n === call || AST11.isFunction(n));
|
|
1337
1323
|
if (!AST11.isFunction(iter)) return;
|
|
1338
1324
|
const arg0 = call?.arguments[0];
|
|
@@ -1499,7 +1485,7 @@ function create27(context) {
|
|
|
1499
1485
|
return {
|
|
1500
1486
|
JSXOpeningElement(node) {
|
|
1501
1487
|
const initialScope = context.sourceCode.getScope(node);
|
|
1502
|
-
const keyPropFound =
|
|
1488
|
+
const keyPropFound = JSX9.getAttribute("key", node.attributes, initialScope);
|
|
1503
1489
|
const keyPropOnElement = node.attributes.some(
|
|
1504
1490
|
(n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1505
1491
|
);
|
|
@@ -1799,7 +1785,7 @@ function create31(context) {
|
|
|
1799
1785
|
switch (node.type) {
|
|
1800
1786
|
case AST_NODE_TYPES.JSXElement: {
|
|
1801
1787
|
const initialScope = context.sourceCode.getScope(node);
|
|
1802
|
-
if (!
|
|
1788
|
+
if (!JSX9.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1803
1789
|
return {
|
|
1804
1790
|
messageId: "missingKey",
|
|
1805
1791
|
node
|
|
@@ -1856,7 +1842,7 @@ function create31(context) {
|
|
|
1856
1842
|
}
|
|
1857
1843
|
const initialScope = context.sourceCode.getScope(node);
|
|
1858
1844
|
for (const element of elements) {
|
|
1859
|
-
if (!
|
|
1845
|
+
if (!JSX9.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1860
1846
|
report({
|
|
1861
1847
|
messageId: "missingKey",
|
|
1862
1848
|
node: element
|
|
@@ -1869,7 +1855,7 @@ function create31(context) {
|
|
|
1869
1855
|
if (state.isWithinChildrenToArray) {
|
|
1870
1856
|
return;
|
|
1871
1857
|
}
|
|
1872
|
-
const isMapCall = AST11.
|
|
1858
|
+
const isMapCall = AST11.isArrayMapCallLoose(node);
|
|
1873
1859
|
if (!isMapCall && !isArrayFromCall(node)) {
|
|
1874
1860
|
return;
|
|
1875
1861
|
}
|
|
@@ -1924,7 +1910,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1924
1910
|
defaultOptions: []
|
|
1925
1911
|
});
|
|
1926
1912
|
function create32(context) {
|
|
1927
|
-
const hint = ERComponentHint.
|
|
1913
|
+
const hint = ERComponentHint.SkipArrayMapArgument | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1928
1914
|
const collector = useComponentCollector(context, { hint });
|
|
1929
1915
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
1930
1916
|
return {
|
|
@@ -2010,7 +1996,7 @@ function create32(context) {
|
|
|
2010
1996
|
};
|
|
2011
1997
|
}
|
|
2012
1998
|
function isInsideJSXAttributeValue(node) {
|
|
2013
|
-
return node.parent.type === AST_NODE_TYPES.JSXAttribute ||
|
|
1999
|
+
return node.parent.type === AST_NODE_TYPES.JSXAttribute || JSX9.findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
2014
2000
|
}
|
|
2015
2001
|
function isInsideCreateElementProps(context, node) {
|
|
2016
2002
|
const call = AST11.findParentNode(node, isCreateElementCall(context));
|
|
@@ -2446,7 +2432,7 @@ function create42(context) {
|
|
|
2446
2432
|
return {
|
|
2447
2433
|
...listeners,
|
|
2448
2434
|
JSXOpeningElement(node) {
|
|
2449
|
-
const fullName =
|
|
2435
|
+
const fullName = JSX9.getElementType(node.parent);
|
|
2450
2436
|
const selfName = fullName.split(".").at(-1);
|
|
2451
2437
|
if (selfName == null) return;
|
|
2452
2438
|
if (!isContextName(selfName, isReact18OrBelow)) return;
|
|
@@ -3042,7 +3028,7 @@ function create48(context, [option]) {
|
|
|
3042
3028
|
const { allowExpressions = true } = option;
|
|
3043
3029
|
return {
|
|
3044
3030
|
JSXElement(node) {
|
|
3045
|
-
if (!
|
|
3031
|
+
if (!JSX9.isFragmentElement(node)) return;
|
|
3046
3032
|
doCheck(context, node, allowExpressions);
|
|
3047
3033
|
},
|
|
3048
3034
|
JSXFragment(node) {
|
|
@@ -3064,12 +3050,12 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3064
3050
|
return null;
|
|
3065
3051
|
}
|
|
3066
3052
|
if (node.children.some(
|
|
3067
|
-
(child) =>
|
|
3053
|
+
(child) => JSX9.isLiteral(child) && !JSX9.isWhiteSpace(child) || AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(child)
|
|
3068
3054
|
)) {
|
|
3069
3055
|
return null;
|
|
3070
3056
|
}
|
|
3071
3057
|
}
|
|
3072
|
-
if (
|
|
3058
|
+
if (JSX9.isUserDefinedElement(node.parent)) {
|
|
3073
3059
|
return null;
|
|
3074
3060
|
}
|
|
3075
3061
|
const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
|
|
@@ -3078,10 +3064,10 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3078
3064
|
return fixer.replaceText(node, trimLikeReact(childrenText));
|
|
3079
3065
|
}
|
|
3080
3066
|
const initialScope = context.sourceCode.getScope(node);
|
|
3081
|
-
if (
|
|
3067
|
+
if (JSX9.isKeyedElement(node, initialScope)) {
|
|
3082
3068
|
return;
|
|
3083
3069
|
}
|
|
3084
|
-
if (
|
|
3070
|
+
if (JSX9.isBuiltInElement(node.parent)) {
|
|
3085
3071
|
context.report({
|
|
3086
3072
|
messageId: "uselessFragment",
|
|
3087
3073
|
node,
|
|
@@ -3105,7 +3091,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3105
3091
|
const isChildElement = AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3106
3092
|
switch (true) {
|
|
3107
3093
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3108
|
-
case (allowExpressions && !isChildElement && node.children.length === 1 &&
|
|
3094
|
+
case (allowExpressions && !isChildElement && node.children.length === 1 && JSX9.isLiteral(node.children.at(0))): {
|
|
3109
3095
|
return;
|
|
3110
3096
|
}
|
|
3111
3097
|
// <Foo><>hello, world</></Foo>
|
|
@@ -3132,7 +3118,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3132
3118
|
return;
|
|
3133
3119
|
}
|
|
3134
3120
|
}
|
|
3135
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
3121
|
+
const nonPaddingChildren = node.children.filter((child) => !JSX9.isPaddingSpaces(child));
|
|
3136
3122
|
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3137
3123
|
switch (true) {
|
|
3138
3124
|
case nonPaddingChildren.length === 0:
|
|
@@ -3362,7 +3348,7 @@ function create52(context) {
|
|
|
3362
3348
|
return {
|
|
3363
3349
|
JSXAttribute(node) {
|
|
3364
3350
|
const { value } = node;
|
|
3365
|
-
const propName =
|
|
3351
|
+
const propName = JSX9.getAttributeName(node);
|
|
3366
3352
|
const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
|
|
3367
3353
|
if (!hasValueTrue) {
|
|
3368
3354
|
return;
|
|
@@ -3402,7 +3388,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3402
3388
|
function create53(context) {
|
|
3403
3389
|
return {
|
|
3404
3390
|
JSXElement(node) {
|
|
3405
|
-
if (!
|
|
3391
|
+
if (!JSX9.isFragmentElement(node)) return;
|
|
3406
3392
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3407
3393
|
if (hasAttributes) {
|
|
3408
3394
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.38.0-
|
|
3
|
+
"version": "1.38.0-next.10",
|
|
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,13 +50,13 @@
|
|
|
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/ast": "1.38.0-
|
|
54
|
-
"@eslint-react/core": "1.38.0-
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/var": "1.38.0-
|
|
59
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.38.0-next.10",
|
|
54
|
+
"@eslint-react/core": "1.38.0-next.10",
|
|
55
|
+
"@eslint-react/jsx": "1.38.0-next.10",
|
|
56
|
+
"@eslint-react/kit": "1.38.0-next.10",
|
|
57
|
+
"@eslint-react/shared": "1.38.0-next.10",
|
|
58
|
+
"@eslint-react/var": "1.38.0-next.10",
|
|
59
|
+
"@eslint-react/eff": "1.38.0-next.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.0.12",
|