Whether an anonymous function is the whole value of a `variable_declarator` with a plain identifier name — `const NAME = () => {…}` / `= function () {…}`.
(&self, node: Node<'t>)
| 900 | /// `variable_declarator` with a plain identifier name — |
| 901 | /// `const NAME = () => {…}` / `= function () {…}`. |
| 902 | fn declarator_bound_function(&self, node: Node<'t>) -> bool { |
| 903 | if !matches!(node.kind(), "arrow_function" | "function_expression") { |
| 904 | return false; |
| 905 | } |
| 906 | let Some(declarator) = node.parent() else { return false }; |
| 907 | if declarator.kind() != "variable_declarator" { |
| 908 | return false; |
| 909 | } |
| 910 | let Some(value) = declarator.child_by_field_name("value") else { return false }; |
| 911 | if value.start_byte() != node.start_byte() || value.end_byte() != node.end_byte() { |
| 912 | return false; |
| 913 | } |
| 914 | declarator |
| 915 | .child_by_field_name("name") |
| 916 | .map(|n| n.kind() == "identifier") |
| 917 | .unwrap_or(false) |
| 918 | } |
| 919 | |
| 920 | /// The declarator name a React handler hook binds an anonymous function |
| 921 | /// to — `const NAME = useCallback(<node>, [...])` (also `React.useCallback`, |
no test coverage detected