Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 996 Bytes

File metadata and controls

31 lines (23 loc) · 996 Bytes

@eslint-react/core / findEnclosingComponentOrHook

Function: findEnclosingComponentOrHook()

function findEnclosingComponentOrHook(node: Node | undefined, test?: FindEnclosingComponentOrHookFilter): 
  | ArrowFunctionExpression
  | FunctionDeclarationWithName
  | FunctionDeclarationWithOptionalName
  | FunctionExpression
  | undefined;

Find the enclosing React component or hook for a given AST node

Parameters

Parameter Type Description
node Node | undefined The AST node to start the search from
test FindEnclosingComponentOrHookFilter Optional test function to customize component or hook identification

Returns

| ArrowFunctionExpression | FunctionDeclarationWithName | FunctionDeclarationWithOptionalName | FunctionExpression | undefined

The enclosing component or hook node, or null if none is ASAST.