Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

mysticateacommented, Aug 2, 2016

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.

mysticateacommented, Aug 4, 2016

@michaelficarra At least, we can use this to avoid conflict with (func-style: expression & func-names: never).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found