@eslint-react/core
Advanced tools
Comparing version 0.9.6-beta.0 to 0.9.6-beta.1
@@ -261,2 +261,10 @@ import { RuleContext } from '@eslint-react/shared'; | ||
type ERHook = { | ||
_: string; | ||
id: TSESTree.Identifier; | ||
node: TSESTreeFunction; | ||
name: string; | ||
hookCalls: TSESTree.CallExpression[]; | ||
}; | ||
declare function isReactHookCallWithName(name: string): (node: TSESTree.CallExpression, context: RuleContext, pragma: string) => boolean; | ||
@@ -273,13 +281,16 @@ declare const isUseMemoCall: (node: TSESTree.CallExpression, context: RuleContext, pragma: string) => boolean; | ||
declare const isUseDebugValueCall: (node: TSESTree.CallExpression, context: RuleContext, pragma: string) => boolean; | ||
/** | ||
* Check if the given node is a React Hook call by its name. | ||
* @param node The node to check. | ||
* @returns `true` if the node is a React hook call, `false` otherwise. | ||
*/ | ||
declare function unsafeIsReactHookCall(node: TSESTree.CallExpression): boolean; | ||
/** | ||
* TODO: Implement this function. | ||
* Check if the given node is a React Hook call by its name and its hierarchy. | ||
* @param node The node to check. | ||
*/ | ||
declare function isReactHookCall(node: TSESTree.CallExpression): void; | ||
declare function isMemoOrForwardRefCall(node: TSESTree.Node, context: RuleContext): boolean; | ||
type ERHook = { | ||
_: string; | ||
id: TSESTree.Identifier; | ||
node: TSESTreeFunction; | ||
name: string; | ||
cost: number; | ||
}; | ||
declare function hookCollector(): { | ||
@@ -348,2 +359,2 @@ ctx: { | ||
export { DEFAULT_COMPONENT_COLLECTOR_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentCollectorHint, type ERComponentInitPath, type ERComponentKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, RE_COMPONENT_NAME, RE_HOOK_NAME, componentCollector, componentCollectorLegacy, getComponentInitPath, getComponentNameFromIdentifier, getFunctionComponentIdentifier, getParentClassComponent, hasCallInInitPath, hasNoneOrValidComponentName, hookCollector, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isClassComponent, isCreateContext, isFunctionOfRenderMethod, isInsideRenderMethod, isMemberExpressionOfReactMember, isMemoOrForwardRefCall, isPureComponent, isReactHookCallWithName, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseEffectCall, isUseImperativeHandleCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isValidComponentName, isValidReactHookName, unsafeIsDeclaredInRenderProp, unsafeIsDirectValueOfRenderProperty, unsafeIsInsideReactHookCall, unsafeIsReactHookCall, unsafeIsRenderFunction, unsafeIsRenderProp }; | ||
export { DEFAULT_COMPONENT_COLLECTOR_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentCollectorHint, type ERComponentInitPath, type ERComponentKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, RE_COMPONENT_NAME, RE_HOOK_NAME, componentCollector, componentCollectorLegacy, getComponentInitPath, getComponentNameFromIdentifier, getFunctionComponentIdentifier, getParentClassComponent, hasCallInInitPath, hasNoneOrValidComponentName, hookCollector, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isClassComponent, isCreateContext, isFunctionOfRenderMethod, isInsideRenderMethod, isMemberExpressionOfReactMember, isMemoOrForwardRefCall, isPureComponent, isReactHookCall, isReactHookCallWithName, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseEffectCall, isUseImperativeHandleCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isValidComponentName, isValidReactHookName, unsafeIsDeclaredInRenderProp, unsafeIsDirectValueOfRenderProperty, unsafeIsInsideReactHookCall, unsafeIsReactHookCall, unsafeIsRenderFunction, unsafeIsRenderProp }; |
@@ -63,3 +63,7 @@ 'use strict'; | ||
const isUseDebugValueCall = isReactHookCallWithName("useDebugValue"); | ||
function unsafeIsReactHookCall(node) { | ||
/** | ||
* Check if the given node is a React Hook call by its name. | ||
* @param node The node to check. | ||
* @returns `true` if the node is a React hook call, `false` otherwise. | ||
*/ function unsafeIsReactHookCall(node) { | ||
if (node.callee.type === ast.NodeType.Identifier) { | ||
@@ -73,2 +77,11 @@ return isValidReactHookName(node.callee.name); | ||
} | ||
/** | ||
* TODO: Implement this function. | ||
* Check if the given node is a React Hook call by its name and its hierarchy. | ||
* @param node The node to check. | ||
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function isReactHookCall(node) { | ||
// eslint-disable-next-line functional/no-throw-statements | ||
throw new Error("Not implemented"); | ||
} | ||
function isMemoOrForwardRefCall$1(node, context) { | ||
@@ -102,3 +115,3 @@ return jsx.isCallFromPragma("memo")(node, context) || jsx.isCallFromPragma("forwardRef")(node, context); | ||
name, | ||
cost: 1, | ||
hookCalls: [], | ||
node: currentFn | ||
@@ -139,3 +152,6 @@ }); | ||
...hook, | ||
cost: hook.cost + 1 | ||
hookCalls: [ | ||
...hook.hookCalls, | ||
node | ||
] | ||
}); | ||
@@ -754,2 +770,3 @@ } | ||
exports.isPureComponent = isPureComponent; | ||
exports.isReactHookCall = isReactHookCall; | ||
exports.isReactHookCallWithName = isReactHookCallWithName; | ||
@@ -756,0 +773,0 @@ exports.isUseCallbackCall = isUseCallbackCall; |
{ | ||
"name": "@eslint-react/core", | ||
"version": "0.9.6-beta.0", | ||
"version": "0.9.6-beta.1", | ||
"description": "ESLint React's ESLint utility module for static analysis of React core API and Patterns.", | ||
@@ -42,7 +42,7 @@ "homepage": "https://github.com/rel1cx/eslint-react", | ||
"@typescript-eslint/utils": "6.13.2", | ||
"@eslint-react/ast": "0.9.6-beta.0", | ||
"@eslint-react/jsx": "0.9.6-beta.0", | ||
"@eslint-react/shared": "0.9.6-beta.0", | ||
"@eslint-react/types": "0.9.6-beta.0", | ||
"@eslint-react/tools": "0.9.6-beta.0" | ||
"@eslint-react/ast": "0.9.6-beta.1", | ||
"@eslint-react/jsx": "0.9.6-beta.1", | ||
"@eslint-react/shared": "0.9.6-beta.1", | ||
"@eslint-react/tools": "0.9.6-beta.1", | ||
"@eslint-react/types": "0.9.6-beta.1" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
125298
2597
+ Added@eslint-react/ast@0.9.6-beta.1(transitive)
+ Added@eslint-react/jsx@0.9.6-beta.1(transitive)
+ Added@eslint-react/shared@0.9.6-beta.1(transitive)
+ Added@eslint-react/tools@0.9.6-beta.1(transitive)
+ Added@eslint-react/types@0.9.6-beta.1(transitive)
- Removed@eslint-react/ast@0.9.6-beta.0(transitive)
- Removed@eslint-react/jsx@0.9.6-beta.0(transitive)
- Removed@eslint-react/shared@0.9.6-beta.0(transitive)
- Removed@eslint-react/tools@0.9.6-beta.0(transitive)
- Removed@eslint-react/types@0.9.6-beta.0(transitive)