Skip to content
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

Closed
bharathvaj-ganesan opened this issue Jan 6, 2018 · 9 comments
Closed

Promise' is not defined. (no-undef) #9812

bharathvaj-ganesan opened this issue Jan 6, 2018 · 9 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@bharathvaj-ganesan
Copy link

bharathvaj-ganesan commented Jan 6, 2018

  • ESLint Version: 4.14.0
  • Node Version: 6.11.1
  • npm Version: 5.3.0

What parser (default, Babel-ESLint, etc.) are you using?
default

const promise = new Promise((resolve, reject) => {});

eslint config

{
	"env": {
		"browser": true,
		"node": true
	},
	"parserOptions": {
		"ecmaVersion": 6,
		"sourceType": "script"
	},
	"extends": ["kentcdodds/possible-errors", "kentcdodds/best-practices"],
	"rules": {
		"global-require": "off"
	}
}

What did you expect to happen?
No un-def error for es6 globals (Promise)

What actually happened?
Throws un-def error for 'Promise'

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 6, 2018
@platinumazure platinumazure added the needs info Not enough information has been provided to triage this issue label Jan 6, 2018
@eslint-deprecated
Copy link

eslint-deprecated bot commented Jan 6, 2018

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:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

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)

@j-f1
Copy link
Contributor

j-f1 commented Jan 6, 2018

Do you have es6: true set under the env key in your ESLint config?

@bharathvaj-ganesan
Copy link
Author

bharathvaj-ganesan commented Jan 6, 2018

@j-f1 I have updated the issue with my .eslintrc config. Yes, i have.

@j-f1
Copy link
Contributor

j-f1 commented Jan 6, 2018

@bharathvaj1995 It looks like you only have browser and node set in your env setting. Can you try adding "es6": true there, too?

@bharathvaj-ganesan
Copy link
Author

bharathvaj-ganesan commented Jan 6, 2018

@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 ?

@platinumazure
Copy link
Member

@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!

@platinumazure platinumazure added question This issue asks a question about ESLint and removed needs info Not enough information has been provided to triage this issue triage An ESLint team member will look at this issue soon labels Jan 6, 2018
7085 pushed a commit to 7085/netscan.js that referenced this issue Feb 27, 2018
@rugk
Copy link

rugk commented Apr 22, 2018

Maybe change the doc, so it is clear "ecmaVersion" does not imply "es6" globals.

So the position in the doc:
grafik
https://eslint.org/docs/user-guide/configuring#specifying-environments

Maybe change it to:

es6 - enable all ECMAScript 6 features except for modules (this automatically sets the ecmaVersion parser option to 6, but not vice-versa).

@reks-scripts
Copy link

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.

@not-an-aardvark
Copy link
Member

Feel free to open a pull request if you think the documentation could be improved!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

6 participants