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
no-invalid-this triggers an error on a function expression constructor #6824
Comments
Thank you for this issue. I confirmed it. |
It seems like the rule does not check anything for anonymous functions. I was able to confirm as well with the following code on the demo page: 'use strict';
var Foo;
// this is valid
function Foo() {
this.foo = 'foo';
}
// this is invalid
Foo = function() {
this.bar = 'bar';
}; |
Yup. Currently, the rule checks whether the destination of assignments is a property or not. But it does not check whether the destination of assignments is an ES5 style constructor (i.e. starts with upper case) or not. |
Who uses this pattern? Why don't you just use a function declaration? |
@michaelficarra At least, we can use this to avoid conflict with (func-style: expression & func-names: never). |
What version of ESLint are you using?
v3.2.2
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
https://gist.github.com/swang/ab31cd9d11593568a6ada2d8badeb92c
What did you do? Please include the actual source code causing the issue.
this is smallest reproduced code that generates this error.
What did you expect to happen?
no-invalid-this
should not trigger since TestClass begins with an uppercase letter.What actually happened? Please include the actual, raw output from ESLint.
I get an error from the
no-invalid-this
ruleThe text was updated successfully, but these errors were encountered: