no-undef does not catch Promise
See original GitHub issueUpdate (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:
- Created 8 years ago
- Reactions:23
- Comments:19 (17 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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
.Alternatively, define the global in
.eslintrc
: