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

eslint path problems #1692

Closed
acthp opened this Issue Feb 11, 2016 · 28 comments

Comments

Projects
None yet
9 participants
@acthp

acthp commented Feb 11, 2016

As noted in another issue, global eslint will not run the eslint version installed in a project. The recommended way to run the correct version is via npm, like npm run lint, after creating a lint script directive in package.json, like {'lint': 'eslint'}.

However, setting javascript_eslint_exec to npm run lint in syntastic results in syntastic not finding the executable. Setting it to npm and javascript_eslint_args to run lint -- results in command line

npm -f compat run lint -- foo.js

which is wrong. It needs to be

npm run lint -- -f compat foo.js

The args_before call botches the order.

We need better control of the command line to make it work.

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Feb 11, 2016

Collaborator

Use javascript_eslint_exe (not to be confused with *_exec).

Collaborator

lcd047 commented Feb 11, 2016

Use javascript_eslint_exe (not to be confused with *_exec).

@acthp

This comment has been minimized.

Show comment
Hide comment
@acthp

acthp Feb 11, 2016

Thank you!

let g:syntastic_javascript_eslint_exe = 'npm run eslint --'

This works.

acthp commented Feb 11, 2016

Thank you!

let g:syntastic_javascript_eslint_exe = 'npm run eslint --'

This works.

@gurpreetatwal

This comment has been minimized.

Show comment
Hide comment
@gurpreetatwal

gurpreetatwal Aug 23, 2016

If you don't want to add a custom task to your package scripts, the following setting will always run the locally installed eslint

let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'

gurpreetatwal commented Aug 23, 2016

If you don't want to add a custom task to your package scripts, the following setting will always run the locally installed eslint

let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'
@stuartsan

This comment has been minimized.

Show comment
Hide comment
@stuartsan

stuartsan Sep 15, 2016

Note that may help someone else: for me the approaches described by @acthp and @gurpreetatwal, which are aimed at using a project's local version of eslint, did not work until I also had eslint installed globally (npm install -g eslint). Before installing globally, eslint did not show up as an available checker.

stuartsan commented Sep 15, 2016

Note that may help someone else: for me the approaches described by @acthp and @gurpreetatwal, which are aimed at using a project's local version of eslint, did not work until I also had eslint installed globally (npm install -g eslint). Before installing globally, eslint did not show up as an available checker.

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Sep 15, 2016

Collaborator

@stuartsan Just point *_exec (not *_exe) to a valid binary:

let g:syntastic_javascript_eslint_exec = '/bin/ls'
Collaborator

lcd047 commented Sep 15, 2016

@stuartsan Just point *_exec (not *_exe) to a valid binary:

let g:syntastic_javascript_eslint_exec = '/bin/ls'
@stuartsan

This comment has been minimized.

Show comment
Hide comment
@stuartsan

stuartsan Sep 15, 2016

Ahh gtk, thanks @lcd047 !

stuartsan commented Sep 15, 2016

Ahh gtk, thanks @lcd047 !

@kogakure

This comment has been minimized.

Show comment
Hide comment
@kogakure

kogakure Dec 22, 2016

I wrote a solution to use the local node_module script or fallback to the global installation, when not available:

let g:syntastic_javascript_eslint_exe = '[ -f $(npm bin)/eslint ] && $(npm bin)/eslint || eslint'

kogakure commented Dec 22, 2016

I wrote a solution to use the local node_module script or fallback to the global installation, when not available:

let g:syntastic_javascript_eslint_exe = '[ -f $(npm bin)/eslint ] && $(npm bin)/eslint || eslint'
@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Dec 27, 2016

Collaborator

@kogakure Alternatively, write a wrapper script and point g:syntastic_javascript_eslint_exec to it.

Collaborator

lcd047 commented Dec 27, 2016

@kogakure Alternatively, write a wrapper script and point g:syntastic_javascript_eslint_exec to it.

@ezmiller

This comment has been minimized.

Show comment
Hide comment
@ezmiller

ezmiller Jan 15, 2017

I have tried a couple of these examples for getting syntastic to use the local eslint but to no avail. The above:

let g:syntastic_javascript_eslint_exe = '[ -f $(npm bin)/eslint ] && $(npm bin)/eslint || eslint'

Led to output like this:

syntastic: 7.221055: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 7.221276: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1
| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote =
 '', &autochdir = 0, &shellxescape = ''
syntastic: 7.222215: UpdateErrors (auto): default checkers
syntastic: 7.222640: CacheErrors: default checkers
syntastic: 7.223323: g:syntastic_aggregate_errors = 0
syntastic: 7.223588: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 7.234459: CacheErrors: Checker javascript/eslint is not available
syntastic: 7.234702: CacheErrors: no checkers available for javascript.jsx

Like @stuartsan, I've only been able to get eslint to work with syntastic if I have it installed globally, which is not ideal.

ezmiller commented Jan 15, 2017

I have tried a couple of these examples for getting syntastic to use the local eslint but to no avail. The above:

let g:syntastic_javascript_eslint_exe = '[ -f $(npm bin)/eslint ] && $(npm bin)/eslint || eslint'

Led to output like this:

syntastic: 7.221055: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 7.221276: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1
| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote =
 '', &autochdir = 0, &shellxescape = ''
syntastic: 7.222215: UpdateErrors (auto): default checkers
syntastic: 7.222640: CacheErrors: default checkers
syntastic: 7.223323: g:syntastic_aggregate_errors = 0
syntastic: 7.223588: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 7.234459: CacheErrors: Checker javascript/eslint is not available
syntastic: 7.234702: CacheErrors: no checkers available for javascript.jsx

Like @stuartsan, I've only been able to get eslint to work with syntastic if I have it installed globally, which is not ideal.

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Jan 16, 2017

Collaborator

Like @stuartsan, I've only been able to get eslint to work with syntastic if I have it installed globally, which is not ideal.

@ezmiller Like @stuartsan, you can just point *_exec (not *_exe) to some valid binary, f.i.:

let g:syntastic_javascript_eslint_exec = '/bin/ls'

That's because *_exec has to point to an executable file before syntastic would consider enabling the checker. When you install eslint locally there is no eslint in your $PATH, and thus you get:

syntastic: 7.234459: CacheErrors: Checker javascript/eslint is not available
Collaborator

lcd047 commented Jan 16, 2017

Like @stuartsan, I've only been able to get eslint to work with syntastic if I have it installed globally, which is not ideal.

@ezmiller Like @stuartsan, you can just point *_exec (not *_exe) to some valid binary, f.i.:

let g:syntastic_javascript_eslint_exec = '/bin/ls'

That's because *_exec has to point to an executable file before syntastic would consider enabling the checker. When you install eslint locally there is no eslint in your $PATH, and thus you get:

syntastic: 7.234459: CacheErrors: Checker javascript/eslint is not available
@ezmiller

This comment has been minimized.

Show comment
Hide comment
@ezmiller

ezmiller Jan 16, 2017

@lcd047 I tried the *_exec as well with this output:

syntastic: 7.757566: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 7.757836: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1
| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote =
 '', &autochdir = 0, &shellxescape = ''
syntastic: 7.758561: UpdateErrors (auto): default checkers
syntastic: 7.758999: CacheErrors: default checkers
syntastic: 7.759670: g:syntastic_aggregate_errors = 0
syntastic: 7.759912: getcwd() = '/Users/.../Projects/.../...' // (I removed some stuff here for privacy)
syntastic: 7.779182: CacheErrors: Checker javascript/eslint is not available
syntastic: 7.779530: CacheErrors: no checkers available for javascript.jsx
syntastic: 7.779716: aggregated: {'_sorted': 0, '_name': '', '_owner': 3, '_column
s': 1, '_rawLoclist': []}

I also wanted to see if for some reason npm bin wasn't working when vim ran (actually I'm running neovim), so I tried:

:echo syntastic#util#system('$(npm bin)/eslint --version')

And it worked. So I'm not sure what might be going wrong here. Thoughts?

ezmiller commented Jan 16, 2017

@lcd047 I tried the *_exec as well with this output:

syntastic: 7.757566: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 7.757836: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1
| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote =
 '', &autochdir = 0, &shellxescape = ''
syntastic: 7.758561: UpdateErrors (auto): default checkers
syntastic: 7.758999: CacheErrors: default checkers
syntastic: 7.759670: g:syntastic_aggregate_errors = 0
syntastic: 7.759912: getcwd() = '/Users/.../Projects/.../...' // (I removed some stuff here for privacy)
syntastic: 7.779182: CacheErrors: Checker javascript/eslint is not available
syntastic: 7.779530: CacheErrors: no checkers available for javascript.jsx
syntastic: 7.779716: aggregated: {'_sorted': 0, '_name': '', '_owner': 3, '_column
s': 1, '_rawLoclist': []}

I also wanted to see if for some reason npm bin wasn't working when vim ran (actually I'm running neovim), so I tried:

:echo syntastic#util#system('$(npm bin)/eslint --version')

And it worked. So I'm not sure what might be going wrong here. Thoughts?

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Jan 16, 2017

Collaborator

You also have to set g:syntastic_javascript_eslint_generic to 1. It isn't like node is a lesser mess, you know. 😄

Collaborator

lcd047 commented Jan 16, 2017

You also have to set g:syntastic_javascript_eslint_generic to 1. It isn't like node is a lesser mess, you know. 😄

@ezmiller

This comment has been minimized.

Show comment
Hide comment
@ezmiller

ezmiller Jan 16, 2017

@lcd047 thanks. Is this stuff in the docs somewhere? You are right node is also a mess.

ezmiller commented Jan 16, 2017

@lcd047 thanks. Is this stuff in the docs somewhere? You are right node is also a mess.

@ezmiller

This comment has been minimized.

Show comment
Hide comment
@ezmiller

ezmiller Jan 16, 2017

@lcd047 adding that line doesn't get things working unfortunately. The error output seems virtually identical:

 "~/Projects/motologic/enzo/client/app/bundles/Moto/components/ListSearchResults/ListSearch
Results.jsx" 86L, 2366C
syntastic: 8.056502: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 8.056757: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee',
&shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir
= 0, &shellxescape = ''
syntastic: 8.057520: UpdateErrors (auto): default checkers
syntastic: 8.057959: CacheErrors: default checkers
syntastic: 8.058722: g:syntastic_aggregate_errors = 0
syntastic: 8.058954: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 8.076664: CacheErrors: Checker javascript/eslint is not available
syntastic: 8.076996: CacheErrors: no checkers available for javascript.jsx
syntastic: 8.077217: aggregated: {'_sorted': 0, '_name': '', '_owner': 1, '_columns': 1, '
_rawLoclist': []}
"~/.vimrc" 203L, 6066C
syntastic: 29.017198: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 29.017469: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee',
 &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir
 = 0, &shellxescape = ''
syntastic: 29.018205: UpdateErrors (auto): default checkers
syntastic: 29.018742: CacheErrors: default checkers
syntastic: 29.019432: g:syntastic_aggregate_errors = 0
syntastic: 29.019695: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 29.024159: CacheErrors: Checker vim/vimlint is not available
syntastic: 29.024502: CacheErrors: no checkers available for vim
syntastic: 29.024668: aggregated: {'_sorted': 0, '_name': '', '_owner': 3, '_columns': 1,
'_rawLoclist': []}

ezmiller commented Jan 16, 2017

@lcd047 adding that line doesn't get things working unfortunately. The error output seems virtually identical:

 "~/Projects/motologic/enzo/client/app/bundles/Moto/components/ListSearchResults/ListSearch
Results.jsx" 86L, 2366C
syntastic: 8.056502: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 8.056757: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee',
&shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir
= 0, &shellxescape = ''
syntastic: 8.057520: UpdateErrors (auto): default checkers
syntastic: 8.057959: CacheErrors: default checkers
syntastic: 8.058722: g:syntastic_aggregate_errors = 0
syntastic: 8.058954: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 8.076664: CacheErrors: Checker javascript/eslint is not available
syntastic: 8.076996: CacheErrors: no checkers available for javascript.jsx
syntastic: 8.077217: aggregated: {'_sorted': 0, '_name': '', '_owner': 1, '_columns': 1, '
_rawLoclist': []}
"~/.vimrc" 203L, 6066C
syntastic: 29.017198: g:syntastic_version = '3.8.0-14 (Vim 704, Neovim, Darwin)'
syntastic: 29.017469: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee',
 &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir
 = 0, &shellxescape = ''
syntastic: 29.018205: UpdateErrors (auto): default checkers
syntastic: 29.018742: CacheErrors: default checkers
syntastic: 29.019432: g:syntastic_aggregate_errors = 0
syntastic: 29.019695: getcwd() = '/Users/ethan/Projects/motologic/enzo'
syntastic: 29.024159: CacheErrors: Checker vim/vimlint is not available
syntastic: 29.024502: CacheErrors: no checkers available for vim
syntastic: 29.024668: aggregated: {'_sorted': 0, '_name': '', '_owner': 3, '_columns': 1,
'_rawLoclist': []}
@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Jan 16, 2017

Collaborator

@ezmiller Setting g:syntastic_debug to 33 might tell you why.

Collaborator

lcd047 commented Jan 16, 2017

@ezmiller Setting g:syntastic_debug to 33 might tell you why.

@gareth

This comment has been minimized.

Show comment
Hide comment
@gareth

gareth Jul 27, 2017

From my testing, this approach (setting generic eslint) doesn't pass the -f compact option and I guess the errors aren't extracted properly

gareth commented Jul 27, 2017

From my testing, this approach (setting generic eslint) doesn't pass the -f compact option and I guess the errors aren't extracted properly

@gurpreetatwal

This comment has been minimized.

Show comment
Hide comment
@gurpreetatwal

gurpreetatwal Jul 27, 2017

hmm that's odd, what properties are you setting exactly? This solution was worked fine for me for as long as I used syntastic. (Using ALE these days)

gurpreetatwal commented Jul 27, 2017

hmm that's odd, what properties are you setting exactly? This solution was worked fine for me for as long as I used syntastic. (Using ALE these days)

@gareth

This comment has been minimized.

Show comment
Hide comment
@gareth

gareth Jul 27, 2017

That basically comes from here as far as I can see.

let g:syntastic_javascript_checkers  = ['eslint']
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'
let g:syntastic_javascript_eslint_exec='/bin/ls'
let g:syntastic_javascript_eslint_generic = 1

leads to

syntastic: 0.206305: g:syntastic_version = '3.8.0-63 (Vim 800, Darwin, GUI)'
syntastic: 0.206450: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = ''
syntastic: 0.206930: UpdateErrors (auto): default checkers
syntastic: 0.207296: CacheErrors: default checkers
syntastic: 0.208292: g:syntastic_aggregate_errors = 0
syntastic: 0.208441: $TERM = 'xterm-256color'
syntastic: 0.208528: $TMPDIR = '/var/folders/4v/jj7x0j1j2gnd8c9ztht3rr2r0000gn/T/'
syntastic: 0.208609: $PATH = '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:/Users/gareth/bin:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/gareth/.go/bin'
syntastic: 0.208711: getcwd() = '/Users/gareth/project'
syntastic: 0.214614: javascript/eslint: generic eslint, exec = '/bin/ls'
syntastic: 0.214850: CacheErrors: Invoking checker: javascript/eslint
syntastic: 0.215573: SyntasticMake: called with options: {'postprocess': ['guards'], 'errorformat': '%E%f: line %l\, col %c\, Error - %m,%W%f: line %l\, col %c\, Warning - %m', 'makeprg': '$(npm bin)/eslint app/assets/javascripts/components/direct_upload.js'}
syntastic: 1.794736: system: command run in 1.578781s
syntastic: 1.796100: getLocList: checker javascript/eslint returned 1
syntastic: 1.796379: getLocList: checker javascript/eslint run in 1.581400s

Note: 'makeprg': '$(npm bin)/eslint app/assets/javascripts/components/direct_upload.js' doesn't have an -f compact. Maybe the "generic" approach doesn't want to assume that compact is available?

gareth commented Jul 27, 2017

That basically comes from here as far as I can see.

let g:syntastic_javascript_checkers  = ['eslint']
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'
let g:syntastic_javascript_eslint_exec='/bin/ls'
let g:syntastic_javascript_eslint_generic = 1

leads to

syntastic: 0.206305: g:syntastic_version = '3.8.0-63 (Vim 800, Darwin, GUI)'
syntastic: 0.206450: &shell = '/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = ''
syntastic: 0.206930: UpdateErrors (auto): default checkers
syntastic: 0.207296: CacheErrors: default checkers
syntastic: 0.208292: g:syntastic_aggregate_errors = 0
syntastic: 0.208441: $TERM = 'xterm-256color'
syntastic: 0.208528: $TMPDIR = '/var/folders/4v/jj7x0j1j2gnd8c9ztht3rr2r0000gn/T/'
syntastic: 0.208609: $PATH = '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:/Users/gareth/bin:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/gareth/.go/bin'
syntastic: 0.208711: getcwd() = '/Users/gareth/project'
syntastic: 0.214614: javascript/eslint: generic eslint, exec = '/bin/ls'
syntastic: 0.214850: CacheErrors: Invoking checker: javascript/eslint
syntastic: 0.215573: SyntasticMake: called with options: {'postprocess': ['guards'], 'errorformat': '%E%f: line %l\, col %c\, Error - %m,%W%f: line %l\, col %c\, Warning - %m', 'makeprg': '$(npm bin)/eslint app/assets/javascripts/components/direct_upload.js'}
syntastic: 1.794736: system: command run in 1.578781s
syntastic: 1.796100: getLocList: checker javascript/eslint returned 1
syntastic: 1.796379: getLocList: checker javascript/eslint run in 1.581400s

Note: 'makeprg': '$(npm bin)/eslint app/assets/javascripts/components/direct_upload.js' doesn't have an -f compact. Maybe the "generic" approach doesn't want to assume that compact is available?

@gurpreetatwal

This comment has been minimized.

Show comment
Hide comment
@gurpreetatwal

gurpreetatwal Jul 27, 2017

Interestingly enough I never had the generic option set, this is what used to be in my vimrc for syntastic:

let g:syntastic_check_on_wq=1
let g:syntastic_auto_loc_list=2
let g:syntastic_javascript_checkers=['eslint']	
let g:syntastic_javascript_eslint_exe='eslint_d'
let g:syntastic_javascript_eslint_args=['--cache']

If you're having issues with the -f compact flag being missing try just adding it back in with syntastic_javascript_eslint_args

gurpreetatwal commented Jul 27, 2017

Interestingly enough I never had the generic option set, this is what used to be in my vimrc for syntastic:

let g:syntastic_check_on_wq=1
let g:syntastic_auto_loc_list=2
let g:syntastic_javascript_checkers=['eslint']	
let g:syntastic_javascript_eslint_exe='eslint_d'
let g:syntastic_javascript_eslint_args=['--cache']

If you're having issues with the -f compact flag being missing try just adding it back in with syntastic_javascript_eslint_args

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Jul 27, 2017

Collaborator

From my testing, this approach (setting generic eslint) doesn't pass the -f compact option and I guess the errors aren't extracted properly

@gareth The recommended approach is the one in the first post above. It takes a time investment of ~2 minutes to understand and apply correctly. Most of the reminder of the thread is just people trying random other things they picked up elsewhere, hoping to avoid spending those ~2 minutes. shrug

Collaborator

lcd047 commented Jul 27, 2017

From my testing, this approach (setting generic eslint) doesn't pass the -f compact option and I guess the errors aren't extracted properly

@gareth The recommended approach is the one in the first post above. It takes a time investment of ~2 minutes to understand and apply correctly. Most of the reminder of the thread is just people trying random other things they picked up elsewhere, hoping to avoid spending those ~2 minutes. shrug

@gareth

This comment has been minimized.

Show comment
Hide comment
@gareth

gareth Jul 27, 2017

@lcd047 The approach in the first post seems to rely on eslint being installed globally, so that the executable check - and the subsequent --version check can succeed. If the value of _exec isn't a route to a copy of eslint that you can pass --version to, then you have to use the _generic option - which as I pointed out, doesn't return errors in a format that Syntastic can use unless the -f compact option is passed.

Am I right that having a globally accessible install of eslint is required to use Syntastic's integration - even if that version is completely ignored by overriding it using _exe?

Maybe if you've used npm a lot, and maybe if you know vimscript, and maybe if you wrote Syntastic then it only takes 2 minutes to understand and apply these concepts, but for someone who hasn't made a thousand commits to this project I did spend a couple of hours actually trying to work out the execution flow before posting here. I just didn't detail everything I tried in my message because, well, who wants to read an essay? It's a little offputting to try asking the author of a plugin for help and basically be told "You're not clever enough to use my plugin" ☹️

gareth commented Jul 27, 2017

@lcd047 The approach in the first post seems to rely on eslint being installed globally, so that the executable check - and the subsequent --version check can succeed. If the value of _exec isn't a route to a copy of eslint that you can pass --version to, then you have to use the _generic option - which as I pointed out, doesn't return errors in a format that Syntastic can use unless the -f compact option is passed.

Am I right that having a globally accessible install of eslint is required to use Syntastic's integration - even if that version is completely ignored by overriding it using _exe?

Maybe if you've used npm a lot, and maybe if you know vimscript, and maybe if you wrote Syntastic then it only takes 2 minutes to understand and apply these concepts, but for someone who hasn't made a thousand commits to this project I did spend a couple of hours actually trying to work out the execution flow before posting here. I just didn't detail everything I tried in my message because, well, who wants to read an essay? It's a little offputting to try asking the author of a plugin for help and basically be told "You're not clever enough to use my plugin" ☹️

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Jul 27, 2017

Collaborator

@gareth Ah, so the problem is generic is used to disable both the initial version check and the subsequent output format option. Well that used to make sense, since the point of generic was to allow people to run the myriad eslint-derived linters within syntastic's eslint-checker, without having to add a corresponding myriad of syntastic checkers.

Am I right that having a globally accessible install of eslint is required to use Syntastic's integration - even if that version is completely ignored by overriding it using _exe?

It isn't strictly required, you can also write a wrapper script that handles all those executable-finding contortions, and point syntastic's exec to it. But yes, installing a global eslint would work.

The other solution if you don't want to install a global eslint is the mess above, with /bin/ls and generic, and then add back -f compact via g:syntastic_javascript_eslint_args. I'm not sure which one is uglier.

It's a little offputting to try asking the author of a plugin for help and basically be told "You're not clever enough to use my plugin"

Sorry if you read it that way. I suppose it was the result of my idle meditation on how everybody complains about syntastic not being able to handle all this crap automatically, or at least smoothly, while nobody ever questions why node makes said crap necessary to begin with. Oh well, as somebody else points out, there are better alternatives to syntastic these days.

Collaborator

lcd047 commented Jul 27, 2017

@gareth Ah, so the problem is generic is used to disable both the initial version check and the subsequent output format option. Well that used to make sense, since the point of generic was to allow people to run the myriad eslint-derived linters within syntastic's eslint-checker, without having to add a corresponding myriad of syntastic checkers.

Am I right that having a globally accessible install of eslint is required to use Syntastic's integration - even if that version is completely ignored by overriding it using _exe?

It isn't strictly required, you can also write a wrapper script that handles all those executable-finding contortions, and point syntastic's exec to it. But yes, installing a global eslint would work.

The other solution if you don't want to install a global eslint is the mess above, with /bin/ls and generic, and then add back -f compact via g:syntastic_javascript_eslint_args. I'm not sure which one is uglier.

It's a little offputting to try asking the author of a plugin for help and basically be told "You're not clever enough to use my plugin"

Sorry if you read it that way. I suppose it was the result of my idle meditation on how everybody complains about syntastic not being able to handle all this crap automatically, or at least smoothly, while nobody ever questions why node makes said crap necessary to begin with. Oh well, as somebody else points out, there are better alternatives to syntastic these days.

@gareth

This comment has been minimized.

Show comment
Hide comment
@gareth

gareth Jul 27, 2017

Thanks for the considered reply, that's a great summary of my options.

Believe me, I also have a lot of opinions about the amount of crap that node forces on you 😉 But I think asking questions about large projects is even harder because of the weight of development behind those, and speaking up is pretty intimidating.

But that's not a topic for this thread, which I have a solution for now 😄

gareth commented Jul 27, 2017

Thanks for the considered reply, that's a great summary of my options.

Believe me, I also have a lot of opinions about the amount of crap that node forces on you 😉 But I think asking questions about large projects is even harder because of the weight of development behind those, and speaking up is pretty intimidating.

But that's not a topic for this thread, which I have a solution for now 😄

@timwis

This comment has been minimized.

Show comment
Hide comment
@timwis

timwis Sep 2, 2017

Hey folks, just wanted to let you know that since npm v5 ships with npx you can use this in place of $(npm bin), ie:

let g:syntastic_javascript_eslint_exe = 'npx standard'

timwis commented Sep 2, 2017

Hey folks, just wanted to let you know that since npm v5 ships with npx you can use this in place of $(npm bin), ie:

let g:syntastic_javascript_eslint_exe = 'npx standard'
@ericandrewlewis

This comment has been minimized.

Show comment
Hide comment
@ericandrewlewis

ericandrewlewis Dec 8, 2017

To summarize: you have two options to get vim-syntastic to use a locally installed version of ESLint.

With ESLint installed globally

Install ESLint globally. Syntastic won't use this version, it just checks it for a few things.

npm install -g eslint

In your ~.vimrc:

" Enable the eslint checker
let g:syntastic_javascript_checkers=['eslint']
" Point the checker to the locally installed version of eslint
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'

Without global ESLint installed

In your ~.vimrc:

" Enable the eslint checker
let g:syntastic_javascript_checkers=['eslint']
let g:syntastic_javascript_eslint_generic = 1
let g:syntastic_javascript_eslint_exec = '/bin/ls'
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'
let g:syntastic_javascript_eslint_args='-f compact'

Set g:syntastic_javascript_eslint_exec to a wrapper script

I'm not sure how this option would work but it's described above.

ericandrewlewis commented Dec 8, 2017

To summarize: you have two options to get vim-syntastic to use a locally installed version of ESLint.

With ESLint installed globally

Install ESLint globally. Syntastic won't use this version, it just checks it for a few things.

npm install -g eslint

In your ~.vimrc:

" Enable the eslint checker
let g:syntastic_javascript_checkers=['eslint']
" Point the checker to the locally installed version of eslint
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'

Without global ESLint installed

In your ~.vimrc:

" Enable the eslint checker
let g:syntastic_javascript_checkers=['eslint']
let g:syntastic_javascript_eslint_generic = 1
let g:syntastic_javascript_eslint_exec = '/bin/ls'
let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'
let g:syntastic_javascript_eslint_args='-f compact'

Set g:syntastic_javascript_eslint_exec to a wrapper script

I'm not sure how this option would work but it's described above.

@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Dec 8, 2017

Collaborator

@ericandrewlewis Please don't make authoritative statements until you understand exactly what's going on. Setting exe to $(npm bin)/eslint breaks when you're switching projects from withing Vim, because npm bin is only run once.

Collaborator

lcd047 commented Dec 8, 2017

@ericandrewlewis Please don't make authoritative statements until you understand exactly what's going on. Setting exe to $(npm bin)/eslint breaks when you're switching projects from withing Vim, because npm bin is only run once.

@ericandrewlewis

This comment has been minimized.

Show comment
Hide comment
@ericandrewlewis

ericandrewlewis Dec 8, 2017

@lcd047 good point. If I open a file in a separate project ESLint is not run properly against it. If I change the working directory for that buffer and run :SyntasticCheck, that project's ESLint is invoked and the results show as expected. This solution depends on automatically changing the working directory for each window, which sounds like it can cause trouble with other plugins.

Alternatively I gave a shot to making a wrapper script which does the trick. To set this up:

In ~/bin/eslint-wrapper-for-vim-syntastic (make sure it's executable with chmod +x)

#!/bin/bash
if [ "$1" = "--version" ] 
	then
		echo '1.0.0'
		exit
fi

$(npm bin)/eslint $@

then in .vimrc

let g:syntastic_javascript_eslint_exec = '~/bin/eslint-wrapper-for-vim-syntastic'

ericandrewlewis commented Dec 8, 2017

@lcd047 good point. If I open a file in a separate project ESLint is not run properly against it. If I change the working directory for that buffer and run :SyntasticCheck, that project's ESLint is invoked and the results show as expected. This solution depends on automatically changing the working directory for each window, which sounds like it can cause trouble with other plugins.

Alternatively I gave a shot to making a wrapper script which does the trick. To set this up:

In ~/bin/eslint-wrapper-for-vim-syntastic (make sure it's executable with chmod +x)

#!/bin/bash
if [ "$1" = "--version" ] 
	then
		echo '1.0.0'
		exit
fi

$(npm bin)/eslint $@

then in .vimrc

let g:syntastic_javascript_eslint_exec = '~/bin/eslint-wrapper-for-vim-syntastic'
@lcd047

This comment has been minimized.

Show comment
Hide comment
@lcd047

lcd047 Dec 8, 2017

Collaborator

@ericandrewlewis Most syntastic checkers would work with autochdir, but not all.

A simple-minded wrapper as above still won't work, unless you change Vim's idea of current directory with :lcd. A better solution would be to examine arguments passed to the script, identify the files among them (something like if [ "$1" ] && [ -f "$1" ]; then ...), and run npm bin from the dirname of said files (except dirname is not portable, so you might need to play shell games, such as %{1%/*}). There's a reason why this thread is so long: a single size doesn't really fit all. 😄

Also, you don't need /bin/bash, plain /bin/sh is enough. And you need to quote $@.

Collaborator

lcd047 commented Dec 8, 2017

@ericandrewlewis Most syntastic checkers would work with autochdir, but not all.

A simple-minded wrapper as above still won't work, unless you change Vim's idea of current directory with :lcd. A better solution would be to examine arguments passed to the script, identify the files among them (something like if [ "$1" ] && [ -f "$1" ]; then ...), and run npm bin from the dirname of said files (except dirname is not portable, so you might need to play shell games, such as %{1%/*}). There's a reason why this thread is so long: a single size doesn't really fit all. 😄

Also, you don't need /bin/bash, plain /bin/sh is enough. And you need to quote $@.

redeyes2015 added a commit to redeyes2015/DotFiles that referenced this issue Feb 5, 2018

Let syntastic support `.vue` files
Making syntastic support "in-project" eslint needs a few configurations.

With 'yarn', it looks easier... for a bit.

Ref: vim-syntastic/syntastic#1692

getkey added a commit to getkey/dotfiles that referenced this issue Feb 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment