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
Promise' is not defined. (no-undef) #9812
Comments
Hi @bharathvaj1995, thanks for the issue. It looks like there's not enough information for us to know how to help you. If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. Requesting a rule change? Please see Proposing a Rule Change for instructions. If it's something else, please just provide as much additional information as possible. Thanks! (edited for emphasis by platinumazure) |
Do you have |
@j-f1 I have updated the issue with my .eslintrc config. Yes, i have. |
@bharathvaj1995 It looks like you only have |
@j-f1 It solved the issue thanks, but how is it differs from ecmaVersion inside parserOptions ? I don't get it because es6 syntax different from es6 globals ? |
@bharathvaj1995 ecmaVersion only affects the parser, so it allows ES6 syntax (such as let/const). The environment will set ecmaVersion for you, but will also enable all of the ES6 globals (such as Promise, Map, Set). If you want ES7 (or later) and ES6 globals, you would do env es6:true and ecmaVersion: (something greater than 6)... Hope that makes sense! |
Maybe change the doc, so it is clear "ecmaVersion" does not imply "es6" globals. So the position in the doc: Maybe change it to:
|
I agree with rugk. The documentation could use some clarification... I just got hung up on the exact same issue. I removed "es6": true from my config after reading the same line rugk pointed out assuming that parserOptions.ecmaVersion: 8 would override/include the es6 features and then some. |
Feel free to open a pull request if you think the documentation could be improved! |
What parser (default, Babel-ESLint, etc.) are you using?
default
eslint config
What did you expect to happen?
No un-def error for es6 globals (Promise)
What actually happened?
Throws un-def error for 'Promise'
The text was updated successfully, but these errors were encountered: