prefer-arrow-callback: allowUnboundThis description may be confusing
See original GitHub issuehttp://eslint.org/docs/rules/prefer-arrow-callback#allowunboundthis
I’ve read this paragraph several times and by comparison with the code example it seems a bit confusing:
-
“When set to
false
, this option allows the use ofthis
without restriction…”: does not the option apply more restrictions for usingthis
? -
“…checks for dynamically assigned
this
values…”: does “checks” mean “prohibits” or “allows”? -
“Normally, the rule will flag…”: does “Normally” mean “true” or “false” for this option?
The code example is clear, but the description seems to be vague.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
prefer-arrow-callback - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >prefer-arrow-callback
Allows function expressions containing this to be used as callbacks, as long as the function in question has not been explicitly bound. Rule...
Read more >Avoid 'unbound function' ESLint warning when passing a ...
I am confused as to why ESLint warns me about the static function as it has no "this" at all. What can I...
Read more >Sound Typing for “this” in Flow
Similarly, in the below code, Flow would allow you to call the exported ... like arrow functions and classes that discourage its use....
Read more >arrow function syntax simplified
Use => only with an expression body (do-expressions if accepted allow ... We don't need thin arrow and we really don't need the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting, I agree that the documentation is unclear/misleading here. To answer your questions:
The default behavior is
{allowUnboundThis: true}
. With the default behavior, the rule allows function expressions containingthis
, provided that they are not explicitly bound. This is because these functions would not be directly replaceable with arrow functions.When
allowUnboundThis
is set tofalse
, the rule imposes a stricter requirement by disallowing all function expressions containingthis
, even though those functions are not directly replaceable with arrow functions.I just realized that i PR’d 4 commits rather than just one… I’m sure you’ll let me know if I need to fix that…
1000 apologies.
PR submitted though!