sbdchd / eslint-plugin-cake

:cake: Sweet rules for ESLint
MIT License
1 stars 0 forks source link

unnecessary-func #6

Open sbdchd opened 3 years ago

sbdchd commented 3 years ago
// err
function bar(param: Foo) {}
function foo(param: Foo) {
    bar(param)
}

// ok
const foo = bar

// ok
function bar(param: Foo, buzz?: Buzz) {}
function foo(param: Foo) {
    bar(param)
}

<Foo onEvent={() => bar()} />

// Where either `onEvent` has no params for the callback, or bar() takes no params

I think the heuristic can be: if the function body only calls another function and the other function has the same number of params & same return type, then we error