New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a --fix option for prefer-arrow-callback #7002
Comments
I can see how this would be useful, but this would be a massive fix (in terms of characters of source code affected per fix). However, the fix plan seems pretty sensible. I'll endorse (:+1:). EDIT: Per comment below, this only applies when dealing with a call to |
Note that this is only a massive fix if |
👍 |
1 similar comment
👍 |
I will champion this. |
Not fair @mysticatea, you endorsed and championed and I double-counted you. 😜 One more 👍 from the team as @mysticatea said. |
I'll 👍 this! |
I'm using Node v6.4.0 and ESLint v3.4.0.
It would be useful to have an autofix option for the
prefer-arrow-callback
rule. The fixer would attempt to convert regular callback functions to arrow functions.this
,super
,arguments
, ornew.target
, and it is not explicitly bound, it can be replaced naively:.bind(this)
, and it does not usesuper
,arguments
, ornew.target
, the binding can be removed and the function can be replaced:{allowUnboundThis: false}
is used, and the function includesthis
without being explicitly bound, the problem should not get fixed, since there is no way to be sure of the correctthis
value:super
,arguments
, ornew.target
, the rule does not report any problems, so nothing gets fixed.Other things to consider:
{allowNamedFunctions: false}
option is used and a function has a name, should the function still be changed when autofixing? (This doesn't break recursive functions, since those are ignored byprefer-arrow-callback
anyway.) I think the fixer should still fix these functions; if people want to allow named functions, then they should set{allowNamedFunctions: true}
.I would be willing to add this if the issue is accepted.
The text was updated successfully, but these errors were encountered: