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

Fix: no-invalid-this false positive (fixes #6824) #6827

Merged
merged 1 commit into from Aug 4, 2016
Merged

Conversation

mysticatea
Copy link
Member

Fixes #6824.

This PR fixes the false positive of no-invalid-this rule. (reduces warnings)

var Foo = function() { this; }

If an anonymous function is assigned to a variable that the name starts with uppercase, the rule comes to handle the function as a constructor (i.e. this in the function is valid.).

This is similar to an existing behavior; a function that the name starts with uppercase is handled as a constructor.

@mention-bot
Copy link

@mysticatea, thanks for your PR! By analyzing the annotation information on this pull request, we identified @kevinoid, @nzakas and @nre to be potential reviewers

@eslintbot
Copy link

LGTM

@vitorbal
Copy link
Member

vitorbal commented Aug 2, 2016

LGTM, but waiting for others to review.

@@ -11,12 +11,13 @@ Basically this rule checks whether or not a function which are containing `this`
This rule judges from following conditions whether or not the function is a constructor:

* The name of the function starts with uppercase.
* The function is assigned to a variable the name starts with uppercase.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small grammar improvement if you're interested: "The function is assigned to a variable which starts with an uppercase letter."

Copy link
Member Author

@mysticatea mysticatea Aug 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for correction!

@platinumazure
Copy link
Member

Just one or two small things, otherwise LGTM. Thanks for turning this around so quickly!

@kevinoid
Copy link
Contributor

kevinoid commented Aug 3, 2016

LGTM, excluding existing comments. Nice work @mysticatea!

@eslintbot
Copy link

LGTM

@mysticatea
Copy link
Member Author

I modified those.

@vitorbal
Copy link
Member

vitorbal commented Aug 4, 2016

LGTM. Thanks @mysticatea!

@platinumazure
Copy link
Member

LGTM, thanks!

@gyandeeps
Copy link
Member

LGTM 👍
Thanks for contributing.

@gyandeeps gyandeeps merged commit 8581f4f into master Aug 4, 2016
@mysticatea mysticatea deleted the issue6824 branch August 4, 2016 23:06
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-invalid-this triggers an error on a function expression constructor
8 participants