inspect-js / inspect-js/is-arrow-function
False negative for arrow function with closing parenthesis in parameter list
- Dominant language
- JavaScript
- Stars
- 24
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
For instance, if a default parameter value uses a function:
```js
const isArrow = require("is-arrow-function");
const arrow = (a = Math.random(10)) => {};
console.log(isArrow(arrow)); // false, should be true
```
There are lots of ways to include a `)` in the parameter list. For instance, `(a, b = (a)) => {}` (but who would write that? ... you know someone would :-) ).
Sadly, I think the only way to deal with this would be to fire up a full parser, since a default can be anything, including a function definition with arbitrary code in it:
```js
const isArrow = require("is-arrow-function");
const arrow = (a = function() {
if (Math.random() < 0.5) {
return 42;
}
return "something else";
}) => a();
console.log(isArrow(arrow)); // false, should be true
```
Contributor guide
Assessment
This issue has not been assessed yet.