Open fregante opened 9 months ago
How about allowing one-line functions?
What about
mem(async url => {
const r = await fetch(url);
return r.json();
}, {
something
};
For the purpose of this rule, this still seems readable. That's why it should probably default to "3 statements" and warn that "the inline function is too long and impacts readability" for anything longer.
Description
Initially reported in https://github.com/sindresorhus/memoize/issues/97, it's bad practice to place arguments after functions because functions tend to be inlined and eclipse the parameters that follow them.
This could actually be two rules:
foo(() => {}, {something: true})
function foo(cb, options) {}
@sindresorhus doesn't like the latter so I'll focus on the first part 😅
Fail
Pass
{maxStatements: 3}
Additional info
This might conflict with https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-callback-reference.md in some cases (reduce) if
maxStatements
defaults to 0👇