Whether an anonymous function is the whole value of a `variable_declarator` with a plain identifier name — `const NAME = () => {…}` / `= function () {…}`.
(&self, node: Node<'t>)
| 874 | /// `variable_declarator` with a plain identifier name — |
| 875 | /// `const NAME = () => {…}` / `= function () {…}`. |
| 876 | fn declarator_bound_function(&self, node: Node<'t>) -> bool { |
| 877 | if !matches!(node.kind(), "arrow_function" | "function_expression") { |
| 878 | return false; |
| 879 | } |
| 880 | let Some(declarator) = node.parent() else { return false }; |
| 881 | if declarator.kind() != "variable_declarator" { |
| 882 | return false; |
| 883 | } |
| 884 | let Some(value) = declarator.child_by_field_name("value") else { return false }; |
| 885 | if value.start_byte() != node.start_byte() || value.end_byte() != node.end_byte() { |
| 886 | return false; |
| 887 | } |
| 888 | declarator |
| 889 | .child_by_field_name("name") |
| 890 | .map(|n| n.kind() == "identifier") |
| 891 | .unwrap_or(false) |
| 892 | } |
| 893 | |
| 894 | /// The declarator name a React handler hook binds an anonymous function |
| 895 | /// to — `const NAME = useCallback(<node>, [...])` (also `React.useCallback`, |
no test coverage detected