brackets-userland / brackets-eslint

Adds ESLint support to Brackets
MIT License
43 stars 15 forks source link

no-undef Promise #51

Open dermike opened 7 years ago

dermike commented 7 years ago

Hello!

Thanks for this great plugin! I have a, for me at least, weird problem with it. In Brackets with brackets-eslint I get this error:

ERROR: 'Promise' is not defined. [no-undef] return new Promise((resolve, reject) => {

I don't get the error however when checking it with eslint manually. As far as I can tell I'm using eslint 3.12.0 both globally and in brackets-eslint. My .eslintrc is in my ~/directory.

I can get around the error by adding /* global Promise: true */, but wish I didn't have to since it works without it in "normal" eslint. Hope this can be fixed or if anyone can spot something I've setup wrong.

cheers!

zaggino commented 7 years ago

Hi @dermike have you tried this? https://github.com/eslint/eslint/issues/4085#issuecomment-220863125

dermike commented 7 years ago

@zaggino No, that's definitely a better solution! ..but my question is kind of still the same, why it works without it with CLI eslint and not brackets-eslint. 🤔

dermike commented 7 years ago

No error with gulp-eslint either, only brackets-eslint

zaggino commented 7 years ago

If you can create a sample project I can clone and replicate the issue I'm happy to take a look. Otherwise I won't be guessing. I use this daily for a large number of projects without issue, although I must admit, all of them have .eslintrc in their project root. I have never tried using .eslintrc in home directory.

zaggino commented 7 years ago

What's your OS, Mac or Linux? I'm primary a Windows user, not sure if the node domain of Brackets doesn't run under a different user so it can't find the .eslintrc in home dir.

dermike commented 7 years ago

I'm on Mac OS. I've created this repo which also includes my .eslintrc: https://github.com/dermike/brackets-eslint-issue

Still getting the no-undef error with brackets-eslint even if it's in the project dir.

zaggino commented 7 years ago

If you have .eslintrc in your project, brackets-eslint requires you to have installed eslint in your project dir and uses that installation. It only uses global installation when there's no .eslintrc defined. Rationale is that if you specify .eslintrc file, you also need to install exact version of eslint you want to lint with.

When I do npm install eslint in your project after cloning it my result looks like this: image

Maybe you have an old version of eslint inside your project's node_modules ?

dermike commented 7 years ago

No, I only have it installed globally... installed latest version in the issue repo now and still the same error. Must be something Mac specific then I guess.

zaggino commented 7 years ago

Have you tried re-installing brackets-eslint ? Latest version should ask you to install eslint locally: https://github.com/zaggino/brackets-eslint/blob/7cf8f61a73edd4c9f1f6d3bb64c71be5784df39d/src/node/eslint.ts#L279-L283

dermike commented 7 years ago

Remove and reinstalled and same error... did not ask me to install locally.

zaggino commented 7 years ago

What version of Brackets are you on? 1.7 or 1.8? I'll check the code why that's the case.

dermike commented 7 years ago

1.8

12 dec. 2016 kl. 21:36 skrev Martin Zagora notifications@github.com<mailto:notifications@github.com>:

What version of Brackets are you on? 1.7 or 1.8? I'll check the code why that's the case.

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/zaggino/brackets-eslint/issues/51#issuecomment-266545217, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEXq9tZsEuw9Ds5kxU0_8Y69qQbkzsRvks5rHbA_gaJpZM4LKQ_r.

zaggino commented 7 years ago

Try updating to brackets-eslint@3.0.3. I can't replicate this so I won't spend any more time on this but feel free to dig around if you want and submit a PR.

dermike commented 7 years ago

Tried with 3.0.3 and it works if I open the project directory in Brackets. Both the undef and ask to install eslint in the project. So this probably worked yesterday too, only had the file from the project open, not the project itself. So try reproducing it if you have another project open (without a local .eslintrc), and just open test.js separately.

Still getting the error though if I don't have a project local .eslintrc and eslint installed, or the current project dir opened. (I usually don't switch projects completely when I open other files from other projects). It works on other files outside of the current project as long as eslint is installed in there.

Wish there was a way it worked with my home directory .eslintrc only, but adding that globals config is good enough. Thanks!