Rule: no-unnecessary-callback-wrapper

Replaces x => f(x) with just f. To catch more cases, enable only-arrow-functions and arrow-return-shorthand too.

Rationale

There’s generally no reason to wrap a function with a callback wrapper if it’s directly called anyway. Doing so creates extra inline lambdas that slow the runtime down.

Config

Not configurable.

Config examples
"no-unnecessary-callback-wrapper": true
Schema
null

Code examples:

Disallows unnecessary callback wrappers
"rules": { "no-unnecessary-callback-wrapper": true }
Passes
const handleContent = (content) => console.log('Handle content:', content);
const handleError = (error) => console.log('Handle error:', error);
promise.then(handleContent).catch(handleError);
Fails
const handleContent = (content) => console.log('Handle content:', content);
const handleError = (error) => console.log('Handle error:', error);
promise.then((content) => handleContent(content)).catch((error) => handleError(error));