Open tomek-he-him opened 9 years ago
Makes sense to me :+1:
If we used trine, or if function bind syntax was a more advanced proposal than stage zero (which indicates that it is in flux, and shouldn't be relied upon just yet), then I'd agree. However, absent either of those two, it seems like this is a change that you should feel free to fork the guide and make, but not one we should make in the guide directly?
This rule should be added regardless. We currently allow anonymous function expressions if you need this scope to be bound or called.
This rule can't differentiate currently between a function expression that's passed as a callback, and a normal function expression.
If we remove this rule, then we'd be allowing all anonymous functions. Do we want to do that, for the few cases where we have to invent an obscure name? (I ask this having certainly added more than a few sorryButTheThisKeywordIsNeededHere
and pleaseDontUseTheThisKeywordInSpecs
function names into the airbnb codebase while enabling this rule)
Maybe we should add this to eslint then?
That seems like a good idea.
At the moment you forbid unnamed function expressions like
function() {}
. That’s a good thing.But when using the new function bind syntax with trine-style libraries, you can’t use arrow functions because they inherit
this
from the outer scope.So a good old anonymous function expression:
…often feels more natural than inventing obscure names: