no-invalid-this triggers an error on a function expression constructor
See original GitHub issueWhat 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.
'use strict';
var TestClass;
TestClass = function() {
this.x = 1;
};
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
rule
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
no-invalid-this - Pluggable JavaScript Linter - ESLint
For this inside functions, this rule basically checks whether or not the function containing this keyword is a constructor or a method.
Read more >no-floating-promises | typescript-eslint
A "floating" Promise is one that is created without any code set up to handle any errors it might throw. Floating Promises can...
Read more >Adding functions to rules using the Expression Builder can ...
Problem. When you add a function to a rule using the Expression Builder, double-clicking the links for required information in the function description ......
Read more >Error() constructor - JavaScript - MDN Web Docs
Examples · Function call or new construction · Rethrowing an error with a cause · Omitting options argument.
Read more >angular-tslint-rules: a configuration preset for both ... - Medium
Do not use the built-in function constructor. ... Do not use void expressions in statement position. "no-void-expression": true.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@michaelficarra At least, we can use this to avoid conflict with (func-style: expression & func-names: never).