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

mdjermanovic commented Sep 24, 2019

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
Copy link
Member Author

mdjermanovic commented Sep 25, 2019

Seems like GitHub macOS is going to fail again.

@mdjermanovic
Copy link
Member Author

mdjermanovic commented Sep 26, 2019

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

kaicataldo commented Sep 26, 2019

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.

@mdjermanovic mdjermanovic force-pushed the issue12271 branch from 0ca98b4 to 7ca0cd5 Oct 4, 2019
Copy link
Member

kaicataldo left a comment

LGTM, thanks!

@kaicataldo kaicataldo merged commit 94ff921 into master Nov 1, 2019
16 checks passed
16 checks passed
Verify Files
Details
Test (ubuntu-latest, 8.x)
Details
Test (ubuntu-latest, 10.x)
Details
Test (ubuntu-latest, 12.x)
Details
Test (windows-latest, 12.x)
Details
Test (macOS-latest, 12.x)
Details
Browser Test
Details
commit-message PR title follows commit message guidelines
Details
continuous-integration Build #20191004.8 succeeded
Details
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details
@kaicataldo kaicataldo deleted the issue12271 branch Nov 1, 2019
@eslint eslint bot locked and limited conversation to collaborators May 1, 2020
@eslint eslint bot added the archived due to age label May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.