I was trying to rewrite consistent-function-scoping
rule in #1072
And I found there are too many cases "in theory" can move out, but people usually won't.
Example:
function outer() {
return {
a: function () {} // This function can move out.
}
}
function outer(foo) {
foo.bar = function () {} // This function can move out.
}
function outer(foo) {
foo.addEventListener(
function () {} // This function can move out.
)
}
// Even this
function outer() {
[].map(
x => x // This function can move out.
)
}
function outer() {
const foo = function () {} // This function can move out.
}
function outer() {
foo = function () {} // This function can move out.
}
We already have an option to ignore arrow functions, meaning many people don't want move arrow functions out.
Proposal to change this rule only check FunctionDeclaration
, no FunctionExpression
and ArrowFunctionExpression
.
Meaning
function outer() {
const foo = function () {} // Won't report this
const foo = () => {} // Won't report this
}
I think this is also the purpose of the original rule proposal
Anyway, I'm also okay if you think these cases above are necessary to check, I can ignore them one by one, but will leads to many problems.
/cc @futpib @sindresorhus
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