@eslint-react/core 1.40.4-next.2 → 1.40.4-next.3
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 +5 -8
- package/dist/index.mjs +5 -8
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1088,7 +1088,6 @@ function useComponentCollector(context, options = {}) {
|
|
|
1088
1088
|
collectHookCalls = false,
|
|
1089
1089
|
hint = DEFAULT_COMPONENT_DETECTION_HINT
|
|
1090
1090
|
} = options;
|
|
1091
|
-
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
1092
1091
|
const components = /* @__PURE__ */ new Map();
|
|
1093
1092
|
const functionEntries = [];
|
|
1094
1093
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
@@ -1101,7 +1100,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1101
1100
|
if (entry == null) return;
|
|
1102
1101
|
if (!entry.isComponent) return functionEntries.pop();
|
|
1103
1102
|
const shouldDrop = AST6__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
1104
|
-
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.
|
|
1103
|
+
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJsxLike(context.sourceCode, r.argument, hint);
|
|
1105
1104
|
});
|
|
1106
1105
|
if (shouldDrop) {
|
|
1107
1106
|
components.delete(entry.key);
|
|
@@ -1125,7 +1124,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1125
1124
|
const entry = getCurrentEntry();
|
|
1126
1125
|
if (entry == null) return;
|
|
1127
1126
|
const { body } = entry.node;
|
|
1128
|
-
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.
|
|
1127
|
+
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
1129
1128
|
if (!isComponent) return;
|
|
1130
1129
|
const initPath = AST6__namespace.getFunctionInitPath(entry.node);
|
|
1131
1130
|
const id = getFunctionComponentId(context, entry.node);
|
|
@@ -1165,7 +1164,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1165
1164
|
"ReturnStatement[type]"(node) {
|
|
1166
1165
|
const entry = getCurrentEntry();
|
|
1167
1166
|
if (entry == null) return;
|
|
1168
|
-
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.
|
|
1167
|
+
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
1169
1168
|
if (!isComponent) return;
|
|
1170
1169
|
entry.isComponent = true;
|
|
1171
1170
|
const initPath = AST6__namespace.getFunctionInitPath(entry.node);
|
|
@@ -1235,11 +1234,9 @@ function isRenderFunctionLoose(context, node) {
|
|
|
1235
1234
|
if (AST6__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
1236
1235
|
return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
1237
1236
|
}
|
|
1238
|
-
return JSX3__namespace.
|
|
1237
|
+
return JSX3__namespace.isJsxLike(
|
|
1238
|
+
context.sourceCode,
|
|
1239
1239
|
body,
|
|
1240
|
-
{
|
|
1241
|
-
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
1242
|
-
},
|
|
1243
1240
|
JSX3__namespace.JSXDetectionHint.SkipNullLiteral | JSX3__namespace.JSXDetectionHint.SkipUndefined | JSX3__namespace.JSXDetectionHint.StrictLogical | JSX3__namespace.JSXDetectionHint.StrictConditional
|
|
1244
1241
|
);
|
|
1245
1242
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1061,7 +1061,6 @@ function useComponentCollector(context, options = {}) {
|
|
|
1061
1061
|
collectHookCalls = false,
|
|
1062
1062
|
hint = DEFAULT_COMPONENT_DETECTION_HINT
|
|
1063
1063
|
} = options;
|
|
1064
|
-
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
1065
1064
|
const components = /* @__PURE__ */ new Map();
|
|
1066
1065
|
const functionEntries = [];
|
|
1067
1066
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
@@ -1074,7 +1073,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1074
1073
|
if (entry == null) return;
|
|
1075
1074
|
if (!entry.isComponent) return functionEntries.pop();
|
|
1076
1075
|
const shouldDrop = AST6.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
1077
|
-
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.
|
|
1076
|
+
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJsxLike(context.sourceCode, r.argument, hint);
|
|
1078
1077
|
});
|
|
1079
1078
|
if (shouldDrop) {
|
|
1080
1079
|
components.delete(entry.key);
|
|
@@ -1098,7 +1097,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1098
1097
|
const entry = getCurrentEntry();
|
|
1099
1098
|
if (entry == null) return;
|
|
1100
1099
|
const { body } = entry.node;
|
|
1101
|
-
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.
|
|
1100
|
+
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
1102
1101
|
if (!isComponent) return;
|
|
1103
1102
|
const initPath = AST6.getFunctionInitPath(entry.node);
|
|
1104
1103
|
const id = getFunctionComponentId(context, entry.node);
|
|
@@ -1138,7 +1137,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1138
1137
|
"ReturnStatement[type]"(node) {
|
|
1139
1138
|
const entry = getCurrentEntry();
|
|
1140
1139
|
if (entry == null) return;
|
|
1141
|
-
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.
|
|
1140
|
+
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
1142
1141
|
if (!isComponent) return;
|
|
1143
1142
|
entry.isComponent = true;
|
|
1144
1143
|
const initPath = AST6.getFunctionInitPath(entry.node);
|
|
@@ -1208,11 +1207,9 @@ function isRenderFunctionLoose(context, node) {
|
|
|
1208
1207
|
if (AST6.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
1209
1208
|
return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
1210
1209
|
}
|
|
1211
|
-
return JSX3.
|
|
1210
|
+
return JSX3.isJsxLike(
|
|
1211
|
+
context.sourceCode,
|
|
1212
1212
|
body,
|
|
1213
|
-
{
|
|
1214
|
-
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
1215
|
-
},
|
|
1216
1213
|
JSX3.JSXDetectionHint.SkipNullLiteral | JSX3.JSXDetectionHint.SkipUndefined | JSX3.JSXDetectionHint.StrictLogical | JSX3.JSXDetectionHint.StrictConditional
|
|
1217
1214
|
);
|
|
1218
1215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.40.4-next.
|
|
3
|
+
"version": "1.40.4-next.3",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.29.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.7.0",
|
|
44
|
-
"@eslint-react/ast": "1.40.4-next.
|
|
45
|
-
"@eslint-react/eff": "1.40.4-next.
|
|
46
|
-
"@eslint-react/jsx": "1.40.4-next.
|
|
47
|
-
"@eslint-react/kit": "1.40.4-next.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/ast": "1.40.4-next.3",
|
|
45
|
+
"@eslint-react/eff": "1.40.4-next.3",
|
|
46
|
+
"@eslint-react/jsx": "1.40.4-next.3",
|
|
47
|
+
"@eslint-react/kit": "1.40.4-next.3",
|
|
48
|
+
"@eslint-react/shared": "1.40.4-next.3",
|
|
49
|
+
"@eslint-react/var": "1.40.4-next.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.4.0",
|