Whether an anonymous function is the whole value of a `variable_declarator` with a plain identifier name — `const NAME = () => {…}` / `= function () {…}`.
(&self, node: Node<'t>)
| 1008 | /// `variable_declarator` with a plain identifier name — |
| 1009 | /// `const NAME = () => {…}` / `= function () {…}`. |
| 1010 | fn declarator_bound_function(&self, node: Node<'t>) -> bool { |
| 1011 | if !matches!(node.kind(), "arrow_function" | "function_expression") { |
| 1012 | return false; |
| 1013 | } |
| 1014 | let Some(declarator) = node.parent() else { return false }; |
| 1015 | if declarator.kind() != "variable_declarator" { |
| 1016 | return false; |
| 1017 | } |
| 1018 | let Some(value) = declarator.child_by_field_name("value") else { return false }; |
| 1019 | if value.start_byte() != node.start_byte() || value.end_byte() != node.end_byte() { |
| 1020 | return false; |
| 1021 | } |
| 1022 | declarator |
| 1023 | .child_by_field_name("name") |
| 1024 | .map(|n| n.kind() == "identifier") |
| 1025 | .unwrap_or(false) |
| 1026 | } |
| 1027 | |
| 1028 | /// The declarator name a React handler hook binds an anonymous function |
| 1029 | /// to — `const NAME = useCallback(<node>, [...])` (also `React.useCallback`, |
no test coverage detected