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

Update: Add capIsConstructor option to no-invalid-this (fixes #12271) #12308

Merged
merged 3 commits into from Nov 1, 2019

Conversation

mdjermanovic
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Changes an existing rule #12271

What rule do you want to change?

no-invalid-this

Does this change cause the rule to produce more or fewer warnings?

More if the option is set to false (default is true).

How will the change be implemented? (New option, new default behavior, etc.)?

New option.

Please provide some example code that this change will affect:

/*eslint no-invalid-this: ["error", { "capIsConstructor": false }]*/

"use strict";

function Foo() {
    this.a = 0;
}

var bar = function Foo() {
    this.a = 0;
}

var Bar = function() {
    this.a = 0;
};

Baz = function() {
    this.a = 0;
};

What does the rule currently do for this code?

No errors.

What will the rule do after it's changed?

4 errors.

Setting the option to false means that functions which name starts with an uppercase (or are assigned to such variables) are just regular functions, not constructor functions.

What changes did you make? (Give an overview)

Implemented the new option.

Is there anything you'd like reviewers to focus on?

astUtils.isDefaultThisBinding signature. This looked to me like a good case for an options object and default value, but both are not used much in the codebase so I'm not sure is it okay?

Also I couldn't find existing tests for the function, I guess it would be too complex to do that directly and that the rules' tests are good enough.

@mdjermanovic mdjermanovic added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Sep 24, 2019
@mdjermanovic
Copy link
Member Author

Seems like GitHub macOS is going to fail again.

@mdjermanovic
Copy link
Member Author

I can't see what exactly failed this time, seems that Test didn't even start after 48 min. What could we do about this?

@kaicataldo
Copy link
Member

I’ll submit a support ticket and see if GitHub can help us. Seems strange that this only happens in macOS and that the reason for failure seems so inconsistent.

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kaicataldo kaicataldo merged commit 94ff921 into master Nov 1, 2019
@kaicataldo kaicataldo deleted the issue12271 branch November 1, 2019 19:18
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 1, 2020
@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 May 1, 2020
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants