is-arrow-function icon indicating copy to clipboard operation
is-arrow-function copied to clipboard

False positive on object methods with arrow functions inside

Open ChALkeR opened this issue 5 years ago • 1 comments

const isArrow = require('is-arrow-function')
const x = {
  foo() {
    return 42
  },
  bar() {
    return (() => 10)()
  },
  buz() {
    // if this was an arrow function, it would have included => in it
    return 123
  },
}
console.log(x.foo(), x.bar(), x.buz())
console.log(isArrow(x.foo))
console.log(isArrow(x.bar)) // fail
console.log(isArrow(x.buz)) // fail

ChALkeR avatar Jun 10 '20 22:06 ChALkeR

This feels similar to #15 - short of including an actual JS parser, I'm not sure how to reliably handle cases like these.

ljharb avatar Jun 11 '20 06:06 ljharb