eslint-plugin-react-x 2.7.1-next.0 → 2.7.1-next.2
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 +33 -26
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ const rules$7 = {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region package.json
|
|
70
70
|
var name$6 = "eslint-plugin-react-x";
|
|
71
|
-
var version = "2.7.1-next.
|
|
71
|
+
var version = "2.7.1-next.2";
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region src/utils/create-rule.ts
|
|
@@ -657,22 +657,22 @@ function create$53(context) {
|
|
|
657
657
|
//#region src/rules/no-array-index-key.ts
|
|
658
658
|
const RULE_NAME$52 = "no-array-index-key";
|
|
659
659
|
const REACT_CHILDREN_METHOD = ["forEach", "map"];
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
660
|
+
function getIndexParamPosition(methodName) {
|
|
661
|
+
switch (methodName) {
|
|
662
|
+
case "every":
|
|
663
|
+
case "filter":
|
|
664
|
+
case "find":
|
|
665
|
+
case "findIndex":
|
|
666
|
+
case "findLast":
|
|
667
|
+
case "findLastIndex":
|
|
668
|
+
case "flatMap":
|
|
669
|
+
case "forEach":
|
|
670
|
+
case "map":
|
|
671
|
+
case "some": return 1;
|
|
672
|
+
case "reduce":
|
|
673
|
+
case "reduceRight": return 2;
|
|
674
|
+
default: return -1;
|
|
675
|
+
}
|
|
676
676
|
}
|
|
677
677
|
function isReactChildrenMethod(name$9) {
|
|
678
678
|
return REACT_CHILDREN_METHOD.includes(name$9);
|
|
@@ -692,7 +692,7 @@ function getMapIndexParamName(context, node) {
|
|
|
692
692
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) return unit;
|
|
693
693
|
if (callee.property.type !== AST_NODE_TYPES.Identifier) return unit;
|
|
694
694
|
const { name: name$9 } = callee.property;
|
|
695
|
-
const indexPosition =
|
|
695
|
+
const indexPosition = getIndexParamPosition(name$9);
|
|
696
696
|
if (indexPosition === -1) return unit;
|
|
697
697
|
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
698
698
|
if (callbackArg == null) return unit;
|
|
@@ -2151,16 +2151,24 @@ function create$20(context) {
|
|
|
2151
2151
|
}
|
|
2152
2152
|
};
|
|
2153
2153
|
}
|
|
2154
|
+
function getArrayMethodCallbackPosition(methodName) {
|
|
2155
|
+
switch (methodName) {
|
|
2156
|
+
case "filter":
|
|
2157
|
+
case "flatMap":
|
|
2158
|
+
case "forEach":
|
|
2159
|
+
case "map":
|
|
2160
|
+
case "reduce":
|
|
2161
|
+
case "reduceRight": return 0;
|
|
2162
|
+
case "from":
|
|
2163
|
+
case "fromAsync": return 1;
|
|
2164
|
+
default: return -1;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2154
2167
|
function isArrayMethodCallback(node) {
|
|
2155
2168
|
const parent = node.parent;
|
|
2156
2169
|
if (parent?.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
2157
2170
|
if (parent.callee.type !== AST_NODE_TYPES.MemberExpression || parent.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
|
|
2158
|
-
|
|
2159
|
-
case "map":
|
|
2160
|
-
case "flatMap": return parent.arguments[0] === node;
|
|
2161
|
-
case "from": return parent.arguments[1] === node;
|
|
2162
|
-
default: return false;
|
|
2163
|
-
}
|
|
2171
|
+
return parent.arguments[getArrayMethodCallbackPosition(parent.callee.property.name)] === node;
|
|
2164
2172
|
}
|
|
2165
2173
|
|
|
2166
2174
|
//#endregion
|
|
@@ -3258,7 +3266,7 @@ function create$4(context) {
|
|
|
3258
3266
|
function isFunctionComponent(block) {
|
|
3259
3267
|
return components.some((comp) => {
|
|
3260
3268
|
if (comp.node !== block) return false;
|
|
3261
|
-
if (comp.name == null &&
|
|
3269
|
+
if (comp.name == null && comp.isExportDefault) return false;
|
|
3262
3270
|
return true;
|
|
3263
3271
|
});
|
|
3264
3272
|
}
|
|
@@ -3696,7 +3704,6 @@ const rules$2 = {
|
|
|
3696
3704
|
"react-x/no-misused-capture-owner-stack": "error",
|
|
3697
3705
|
"react-x/no-unnecessary-use-callback": "warn",
|
|
3698
3706
|
"react-x/no-unnecessary-use-memo": "warn",
|
|
3699
|
-
"react-x/no-unnecessary-use-ref": "warn",
|
|
3700
3707
|
"react-x/no-unstable-context-value": "warn",
|
|
3701
3708
|
"react-x/no-unstable-default-props": "warn",
|
|
3702
3709
|
"react-x/no-unused-class-component-members": "warn",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.7.1-next.
|
|
3
|
+
"version": "2.7.1-next.2",
|
|
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.4.0",
|
|
48
48
|
"ts-pattern": "^5.9.0",
|
|
49
|
-
"@eslint-react/ast": "2.7.1-next.
|
|
50
|
-
"@eslint-react/core": "2.7.1-next.
|
|
51
|
-
"@eslint-react/eff": "2.7.1-next.
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
49
|
+
"@eslint-react/ast": "2.7.1-next.2",
|
|
50
|
+
"@eslint-react/core": "2.7.1-next.2",
|
|
51
|
+
"@eslint-react/eff": "2.7.1-next.2",
|
|
52
|
+
"@eslint-react/shared": "2.7.1-next.2",
|
|
53
|
+
"@eslint-react/var": "2.7.1-next.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.8",
|