question-mark
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-undef does not catch Promise

See original GitHub issue

Update (from DelvarWorld):

Since this is the first google result for “eslint promise is not defined” I feel like it would be helpful to explicitly state the solution to this error here:

add "env": { "es6": true } to your .eslintrc.


The no-undef rule allows references to the global variable “Promise” even if it’s not marked as a global (which is problematic because IE does not have a global Promise.)

Here’s a test case, which can be added to the invalid section of no-undef.js.

        { code: "new Promise();", errors: [{ message: "\"Promise\" is not defined.", type: "Identifier"}] },

If the bug is accepted I’m happy to create a patch.

ESList version: 1.6.0 (ca3cc886f0eb65088c4cbe0585a74427f93422aa)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:23
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

93reactions
AndrewRayCodecommented, May 22, 2016

Since this is the first google result for “eslint promise is not defined” I feel like it would be helpful to explicitly state the solution to this error here:

add "env": { "es6": true } to your .eslintrc.

23reactions
fregantecommented, Aug 17, 2016

Alternatively, define the global in .eslintrc:

{
  "globals": {"Promise": true}
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

'Promise' is not defined no-undef - javascript - Stack Overflow
I have an old ES5 JS repo that doesn't accept promises. The error I get is:.
Read more >
Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch() method of a Promise object schedules a function to be called when the promise is rejected. It immediately returns an equivalent ......
Read more >
no-undef - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to Fix “Promise resolver undefined is not a function” in ...
The promise executor is a function accepting two other functions: resolve and reject . If you're running into the “Promise resolver undefined is...
Read more >
Disallow Use of undefined Variable (no-undefined) - ESLint
The undefined variable in JavaScript is actually a property of the global object. As such, in ECMAScript 3 it was possible to overwrite...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found