Skip to content
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

prefer-arrow-callback: allowUnboundThis description may be confusing #8950

Closed
vsemozhetbyt opened this issue Jul 15, 2017 · 5 comments
Closed
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules

Comments

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jul 15, 2017

http://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:

  1. "When set to false, this option allows the use of this without restriction...": does not the option apply more restrictions for using this?

  2. "...checks for dynamically assigned this values...": does "checks" mean "prohibits" or "allows"?

  3. "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.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 15, 2017
@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion good first issue Good for people who haven't worked on ESLint before documentation Relates to ESLint's documentation rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jul 16, 2017
@not-an-aardvark
Copy link
Member

not-an-aardvark commented Jul 16, 2017

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 containing this, provided that they are not explicitly bound. This is because these functions would not be directly replaceable with arrow functions.

    foo(function() { this; }) // allowed by default
    foo(function() { this; }.bind(this)) // disallowed
  • When allowUnboundThis is set to false, the rule imposes a stricter requirement by disallowing all function expressions containing this, even though those functions are not directly replaceable with arrow functions.

@webdevdaemon
Copy link
Contributor

Hello friends,

Looking to make my first ever PR on this one. Have signed the agreement and will follow the contribution guidelines to the best of my ability. If there is any objection to me taking a crack at this one - please advise.

Thanks for the opportunity,
-Charles

Also if anyone has the time, I am open to any suggestions or advice on the direction I should go in fixing this piece of the docs - but it seems pretty straightforward so I am just gonna go for it. I'll state again however, that any and all input is welcome.

@platinumazure
Copy link
Member

@webdevdaemon Thanks for volunteering! We look forward to your PR 😄 I agree this should be pretty straightforward, so I would suggest giving it a try and then we can provide suggestions as needed while reviewing the pull request.

@webdevdaemon
Copy link
Contributor

SWEET. Thx for the rapid reply - I'm on it.

@webdevdaemon
Copy link
Contributor

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!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 1, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants