Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

eslint extends is not working #445

Closed
dijs opened this issue Feb 18, 2016 · 41 comments
Closed

eslint extends is not working #445

dijs opened this issue Feb 18, 2016 · 41 comments

Comments

@dijs
Copy link

dijs commented Feb 18, 2016

Error:
Error: Cannot find module 'eslint-config-airbnb'

Seems like it cannot find the locally installed modules for eslint.

Project structure:

node_modules
   babel
   babel-eslint
   eslint
   eslint-config-airbnb
   eslint-plugin-react
src
   stuff.js
.eslintignore
.eslintrc.js
package.json
@Arcanemagus
Copy link
Member

I am unable to reproduce this with this setup: linter-eslint_GH445.zip. Is there something about your setup not captured in that archive?

@dijs
Copy link
Author

dijs commented Feb 18, 2016

Well this is frustrating... I cannot reproduce it with the test project either. But I am still getting the issue in my other project with that same setup.

Here is my stack trace, do you see anything obvisouly wrong?

Error: Cannot read config package: eslint-config-airbnb
Error: Cannot find module 'eslint-config-airbnb'
Referenced from: <User Dir>/projects/<project>/.eslintrc.js
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at loadPackage (<User Dir>/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:168:16)
    at loadConfigFile (<User Dir>/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:212:18)
    at load (<User Dir>/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:385:18)
    at <User Dir>/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:326:36
    at Array.reduceRight (native)
    at applyExtends (<User Dir>/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:309:28)

@Arcanemagus
Copy link
Member

Are you able to share the exact code you are seeing this issue with?

@dijs
Copy link
Author

dijs commented Feb 18, 2016

It is not a specific piece of code, the linter is failing with any javascript file.

@Arcanemagus
Copy link
Member

That's not entirely true, as you said you can't reproduce it with the setup above.

You can start debugging this yourself by placing a breakpoint here to see whether it is even being called at all, and here to check the output getting returned to linter-eslint from eslint.

@IanVS
Copy link
Member

IanVS commented Feb 18, 2016

I notice that it is using the version of ESLint that comes bundled with linter-eslint, which means it can't find a locally installed version of ESLint and you're not using a global version.

@dijs
Copy link
Author

dijs commented Feb 18, 2016

I thought it was proper to not use a global eslint.

@Arcanemagus
Copy link
Member

That's true, but for some reason in your error trace it's failing to find the locally installed version.

If you can't share the whole codebase can you at least share your eslint config, and package.json dependencies?

@IanVS
Copy link
Member

IanVS commented Feb 18, 2016

Normally yes, the ideal is to use the local eslint. Have you run npm
install lately?

On Thu, Feb 18, 2016, 17:30 Richard van der Dys notifications@github.com
wrote:

I thought it was proper to not use a global eslint.


Reply to this email directly or view it on GitHub
#445 (comment)
.

@dijs
Copy link
Author

dijs commented Feb 18, 2016

linter-eslint_GH445.zip

This new version has what you asked for. The problem is, it does not fail...

@Arcanemagus
Copy link
Member

Silly question, but have you restarted Atom since running npm install in your project's folder?

@dijs
Copy link
Author

dijs commented Feb 18, 2016

Yes, a few times.

@dijs
Copy link
Author

dijs commented Feb 18, 2016

Why would linter-eslint need to bundle eslint?

@Arcanemagus
Copy link
Member

Specifically for when a locally installed version can't be found, and use of the global version is disabled. It's meant as a last resort for when a user has only the most basic of eslint setups.

@dijs
Copy link
Author

dijs commented Feb 18, 2016

So the problem is that in my project, linter-eslint cannot find my local eslint?

@IanVS
Copy link
Member

IanVS commented Feb 19, 2016

Yes, for some reason.

@qimingweng
Copy link

I seem to be getting this too, linter-eslint is not finding the local eslint...

@Arcanemagus
Copy link
Member

@dijs Can you put a console.log(ESLintDirectory) above this line, to see what it thinks the path it should try loading from is?

@qimingweng without a folder structure or a zip file with the files to reproduce this it's rather hard to debug from "not working".

@dijs
Copy link
Author

dijs commented Feb 22, 2016

Where would I see the logging?

@dijs
Copy link
Author

dijs commented Feb 22, 2016

It seems that when I install the airbnb module within the linter-eslint directory, all is well...

I cannot figure why this is though.

@Arcanemagus
Copy link
Member

Because it's still failing to use the local project's version, and you don't seem to have a global version, so it's falling back to the embedded version.

The output should be in the Developer Tools console.

@dijs
Copy link
Author

dijs commented Feb 22, 2016

But when I open the dev tools, it is not even logging the directory. It fails before that line.

@dijs
Copy link
Author

dijs commented Feb 22, 2016

Error: Cannot find module 'eslint-config-airbnb/base'
Referenced from: /Users/<user>/.atom/packages/linter-eslint/package.json

I think it is trying to read/load packages from linter-eslint's package.json which includes airbnb, and is failing since airbnb only gets downloaded in dev mode, not production mode.

@Arcanemagus
Copy link
Member

Correct, but as I said the only reason it is trying to do that is because for some reason it is failing to find the installation local to your project and is falling back on the eslint bundled with this package.

@dijs
Copy link
Author

dijs commented Feb 22, 2016

By the way, it is also failing in the linter-eslint project also.

@dijs
Copy link
Author

dijs commented Feb 22, 2016

I am open to debug more, do you have any other ideas/logging I could try?

@dijs
Copy link
Author

dijs commented Feb 22, 2016

Boom. I think I have steps to reproduce the issue.

  1. apm remove linter-eslint
  2. apm install linter-eslint
  3. restart atom
  4. atom ~/.atom/packages/linter-eslint
  5. Open lib/worker-helpers.js
  6. If linter is enabled/running this is where it blows up for me

@Arcanemagus
Copy link
Member

That should fail, since apm install doesn't install the devDependencies.

@Arcanemagus
Copy link
Member

The dependencies of linter-eslint have what it needs to run, the devDependencies have what you also need to develop it, which is what you are essentially trying to do there.

@Arcanemagus
Copy link
Member

Can you put a console.log before here saying something like "failed to load local installation, falling back to bundled"?

@Arcanemagus
Copy link
Member

Could you possibly PM me a link to the exact folder you are seeing this in on Atom's Slack?

@dijs
Copy link
Author

dijs commented Feb 23, 2016

Sure, I am waiting for access to that slack.

This doesn't make sense to me. If I install linter-eslint and want to "lint" it's project source code, I feel I should be able to. If it errors out there, it doesn't have the dependencies it needs to run.

@Arcanemagus
Copy link
Member

apm is only meant to install Atom packages, the fact that it somewhat acts the same as npm is just a side effect of them wrapping an old version of npm internally.

@Arcanemagus
Copy link
Member

After some back and forth testing, it turns out this is the resurgence of #294, which is fixed in #409, which simply hasn't been released yet 😛.

@qimingweng
Copy link

Is this is the same as #447?

@dijs
Copy link
Author

dijs commented Feb 23, 2016

Yes, I believe so.

@Arcanemagus
Copy link
Member

Quite possibly, I'll be pushing out a release shortly that includes the fix.

@Arcanemagus
Copy link
Member

Can you try v6.1.0? It should fix this.

@dijs
Copy link
Author

dijs commented Feb 23, 2016

Looks like it works! Thanks for the help.

@Arcanemagus
Copy link
Member

Glad to hear it, marking this as closed.

@noahehall
Copy link

updating worked for me

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants