@eslint-react/core
Advanced tools
Comparing version 1.24.2-next.0 to 1.24.2-next.1
@@ -268,9 +268,9 @@ 'use strict'; | ||
const hooks = /* @__PURE__ */ new Map(); | ||
const fEntries = []; | ||
const functionEntries = []; | ||
const onFunctionEnter = (node) => { | ||
const id = AST8__namespace.getFunctionIdentifier(node); | ||
const key = shared.getId(); | ||
const name = id?.name; | ||
if (name != null && isReactHookName(name)) { | ||
const key = shared.getId(); | ||
fEntries.push({ key, node }); | ||
functionEntries.push({ key, node, isHook: true }); | ||
hooks.set(key, { | ||
@@ -288,6 +288,6 @@ id, | ||
} | ||
fEntries.push({ key: eff._, node }); | ||
functionEntries.push({ key, node, isHook: false }); | ||
}; | ||
const onFunctionExit = () => { | ||
fEntries.pop(); | ||
functionEntries.pop(); | ||
}; | ||
@@ -298,5 +298,2 @@ const ctx = { | ||
return hooks; | ||
}, | ||
getCurrentHooks() { | ||
return new Map(hooks); | ||
} | ||
@@ -311,3 +308,3 @@ }; | ||
} | ||
const fEntry = fEntries.at(-1); | ||
const fEntry = functionEntries.at(-1); | ||
if (fEntry?.key == null) { | ||
@@ -509,5 +506,3 @@ return; | ||
if (entry == null) return; | ||
if (!entry.isComponent) { | ||
return functionEntries.pop(); | ||
} | ||
if (!entry.isComponent) return functionEntries.pop(); | ||
const shouldDrop = AST8__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => { | ||
@@ -536,10 +531,6 @@ return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint); | ||
const entry = getCurrentEntry(); | ||
if (entry == null) { | ||
return; | ||
} | ||
if (entry == null) return; | ||
const { body } = entry.node; | ||
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint); | ||
if (!isComponent) { | ||
return; | ||
} | ||
if (!isComponent) return; | ||
const initPath = AST8__namespace.getFunctionInitPath(entry.node); | ||
@@ -568,5 +559,3 @@ const id = getFunctionComponentIdentifier(entry.node, context); | ||
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName); | ||
if (component == null) { | ||
return; | ||
} | ||
if (component == null) return; | ||
component.displayName = right; | ||
@@ -577,9 +566,5 @@ } | ||
"CallExpression[type]:exit"(node) { | ||
if (!isReactHookCall(node)) { | ||
return; | ||
} | ||
if (!isReactHookCall(node)) return; | ||
const entry = getCurrentEntry(); | ||
if (entry == null) { | ||
return; | ||
} | ||
if (entry == null) return; | ||
entry.hookCalls.push(node); | ||
@@ -590,11 +575,6 @@ } | ||
const entry = getCurrentEntry(); | ||
if (entry == null) { | ||
return; | ||
} | ||
if (entry == null) return; | ||
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint); | ||
if (!isComponent) { | ||
return; | ||
} | ||
functionEntries.pop(); | ||
functionEntries.push({ ...entry, isComponent }); | ||
if (!isComponent) return; | ||
entry.isComponent = true; | ||
const initPath = AST8__namespace.getFunctionInitPath(entry.node); | ||
@@ -601,0 +581,0 @@ const id = getFunctionComponentIdentifier(entry.node, context); |
{ | ||
"name": "@eslint-react/core", | ||
"version": "1.24.2-next.0", | ||
"version": "1.24.2-next.1", | ||
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.", | ||
@@ -42,10 +42,10 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"ts-pattern": "^5.6.2", | ||
"@eslint-react/ast": "1.24.2-next.0", | ||
"@eslint-react/jsx": "1.24.2-next.0", | ||
"@eslint-react/shared": "1.24.2-next.0", | ||
"@eslint-react/var": "1.24.2-next.0", | ||
"@eslint-react/eff": "1.24.2-next.0" | ||
"@eslint-react/ast": "1.24.2-next.1", | ||
"@eslint-react/eff": "1.24.2-next.1", | ||
"@eslint-react/jsx": "1.24.2-next.1", | ||
"@eslint-react/shared": "1.24.2-next.1", | ||
"@eslint-react/var": "1.24.2-next.1" | ||
}, | ||
"devDependencies": { | ||
"tsup": "^8.3.5", | ||
"tsup": "^8.3.6", | ||
"@workspace/configs": "0.0.0" | ||
@@ -52,0 +52,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
245842
3809
+ Added@eslint-react/ast@1.24.2-next.1(transitive)
+ Added@eslint-react/eff@1.24.2-next.1(transitive)
+ Added@eslint-react/jsx@1.24.2-next.1(transitive)
+ Added@eslint-react/shared@1.24.2-next.1(transitive)
+ Added@eslint-react/var@1.24.2-next.1(transitive)
- Removed@eslint-react/ast@1.24.2-next.0(transitive)
- Removed@eslint-react/eff@1.24.2-next.0(transitive)
- Removed@eslint-react/jsx@1.24.2-next.0(transitive)
- Removed@eslint-react/shared@1.24.2-next.0(transitive)
- Removed@eslint-react/var@1.24.2-next.0(transitive)