Initially reported in sindresorhus/memoize#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 π
element.addEventListener('click', () => {
// long
}, {once: true})
const memoized = memoize(() => {
// long
}, {
cache: new WeakMap(),
})
element.addEventListener('click', () => {
// long
}) // No follow-up argument
const memoized = memoize(() => {
// long
}) // No follow-up argument
const handler = () => {
// long
};
element.addEventListener('click', handler, {once: true})
const raw = () => {
// long
};
const memoized = memoize(raw, {
cache: new WeakMap(),
})
element.addEventListener('click', () => short(), {once: true})
const memoized = memoize((x) => alert(x), {
cache: new WeakMap(),
})
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
const foo = array.reduce(callback, 0);
// β no-array-callback-reference
π
const foo = array.reduce((a, b) => a + b, 0);
// β no-inline-function-sometimes
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too