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

Can't get it to work with babel-eslint parser #18

Open
mderazon opened this issue Oct 8, 2015 · 8 comments
Open

Can't get it to work with babel-eslint parser #18

mderazon opened this issue Oct 8, 2015 · 8 comments

Comments

@mderazon
Copy link

mderazon commented Oct 8, 2015

I have the following:

  1. This package installed in SublimeText3
  2. standard v5.3.1 installed globally
  3. standard v5.3.1 installed locally in package.json
  4. babel-eslint v4.1.3 installed globally
  5. babel-eslint v4.1.3 installed locally in package.json
  6. I have babel-eslint explicitly defined as standard's parser defined in package.json

My project uses React and some ES7 features as well (stage 0).

In my package.json I have defined standard to run as a script so I can run it by doing npm run lint

When doing npm run lint all is working fine.
In sublime, i get the following error in debug console

SublimeLinter: standard: export.js ['/usr/local/var/nvm/versions/node/v4.0.0/bin/standard', '--stdin', '--verbose'] 
SublimeLinter: standard output:
module.js:338
    throw err;
    ^

Error: Cannot find module 'eslint'
    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 Object.<anonymous> (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/standard/node_modules/standard-engine/index.js:8:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17) 
@Flet
Copy link
Owner

Flet commented Oct 8, 2015

Can you try installing the latest version of standard globally? Looks like you have 4.0.0 and the latest is 5.3.1

@Flet
Copy link
Owner

Flet commented Oct 8, 2015

Oops, nevermind, I misread the stack trace. I see that its node v4.0.0 :) OK back to pondering this

@Flet
Copy link
Owner

Flet commented Oct 8, 2015

Does it work just running standard by itself (instead of running via npm run, which adds node_modules to the path)?

This might be funky peer dependencies thing...? npm install eslint -g maybe?

@mderazon
Copy link
Author

mderazon commented Oct 8, 2015

when just running standard I have

Error: Cannot find module 'eslint'
    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 Object.<anonymous> (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/standard/node_modules/standard-engine/index.js:8:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

from there, it's a waterfall of dependencies. Installing eslint globally I then get

Error: Cannot find module 'eslint-config-standard-react'
Referenced from: /usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/standard/rc/.eslintrc
    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 readConfigFromFile (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/eslint/lib/config.js:151:44)
    at loadConfig (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/eslint/lib/config.js:172:22)
    at /usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/eslint/lib/config.js:203:46
    at Array.reduceRight (native)
    at loadConfig (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/eslint/lib/config.js:187:36)
    at new Config (/usr/local/var/nvm/versions/node/v4.0.0/lib/node_modules/eslint/lib/config.js:381:38)

then same thing happens when installing eslint-config-standard-react. It's missing eslint-config-standard. After I install it as well, standard works as expected. But Sublimelinter package doesn't work as expected, it's complaining about some ES6 / ES7 features, probably it doesn't know that it needs to use the babel-eslint parser :-)

My top level package.json where I run npm run lint literally has 2 pacakges : babel-eslint and standard so what kind of peer dependencies can cause this weird behaviour ?

I spent couple of good hours here today trying to understand what's going on here, but couldn't

@Flet
Copy link
Owner

Flet commented Oct 8, 2015

I don't see how to turn on stage 0 babel features with babel-eslint. Do you know how?

@Flet
Copy link
Owner

Flet commented Oct 8, 2015

ES6 features should be allowed with the latest eslint... standard specifies env: es6 which makes them all allowable.

I ran into a small issue as I left the eslint linter on at the same time as the standard linter in sublime... It kept saying "const" was not recognized... I disabled the eslint linter (CTRL+P linter disable) and I'm seeing that ES6 features get parsed OK now...

@mderazon
Copy link
Author

mderazon commented Oct 9, 2015

I don't have eslint linter. My only linter is standard.

Another thing i've noticed is this:
Here's a partial picture of my folder structue

├── client
│   ├── node_modules
│   ├── package.json
└── server
|   ├── node_modules
|   ├── package.json
├── node_modules
│   ├── babel-eslint
│   └── standard
├── package.json

I have the top level package.json that has just two dep: standard and babel-eslint It also has the parser definition

"standard": {
    "parser": "babel-eslint"
  }

My client package.json where all the React code sits and the one that's been giving me linting errors has no standard parser definition. When I add the parser definition there as well, the linting errors go away.
This makes somewhat sense as standard is being run on a specific file and it probably looks up the dir structure for the first package.json. Maybe it also explains the bad behaviour I mentioned originally, it finds a local package.json then looks at the bin folder for executables ? Just a thought

@taoeffect
Copy link

FYI I had to change my SublimeLinter.sublime-settings to explicitly use babel-eslint for it to properly lint files:

            "standard": {
                "@disable": false,
                "args": ["--parser", "babel-eslint"],
                "chdir": "${home}",
                "excludes": []
            }

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

No branches or pull requests

3 participants