Syntastic does not detect JSHint as validation available

I installed Syntastic with a pathogen.

Syntastic works for Python files, but not for JavaScript files with JSHint. JSHint works through the command line or with another vim plugin, for example https://github.com/Shutnik/jshint2.vim

β†’ which jshint /usr/local/share/npm/bin/jshint β†’ jshint --version jshint v2.1.10 β†’ echo $PATH /usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 

When I run: SyntasticInfo, it does not find any checkers.

 Syntastic info for filetype: javascript Available checkers: Currently active checker(s): 

My vimrc

 set nocompatible filetype off call pathogen#infect() call pathogen#helptags() filetype plugin indent on syntax on let g:syntastic_check_on_open=1 let g:syntastic_javascript_checkers = ['jshint'] 

I don't know what I missed if you have an idea why Syntastic is not detecting JSHint. Thanks

+6
source share
2 answers

Shortly speaking; Syntastic needs a jshint path.


I ran into a similar problem in Windows 8. After installing nodejs v0.10.22 and syntastic > = 3.2.0 the Vim :SyntasticInfo would give me:

 Syntastic: active mode enabled Syntastic info for filetype: vim Available checker(s): Currently enabled checker(s): 

The documentation at jshint.com/docs suggests that this is enough to install the module.

 $ npm install jshint -g 

This is true, except for the somewhat surprising value of the -g flag, install JSHint globally on your system . This means that in the user folder% AppData%:

 (abbreviated output from previous command) C:\Users\jaroslav\AppData\Roaming\npm\jshint -> \ C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint\bin\jshint jshint@2.3.0 C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint β”œβ”€β”€ console-browserify@0.1.6 β”œβ”€β”€ underscore@1.4.4 β”œβ”€β”€ shelljs@0.1.4 β”œβ”€β”€ minimatch@0.2.12 ( sigmund@1.0.0 , lru-cache@2.5.0 ) └── cli@0.4.5 ( glob@3.2.7 ) 

Another part of the syntax FAQ 's documentation reads:

Q. I installed the syntax, but it does not report any errors ...

a. The most likely reason is that none of the syntax checks that it requires are set. For example: for python you need to install flake8, pyflakes or pylint in $ PATH as well. To find out which executables are supported, just look in the syntax_checkers // * file. Vim. Note that aliases do not work; the actual executable must be available in $ PATH. Symbolic links are in order. You can see the syntactic idea of ​​the available checkers by doing: SyntasticInfo.

The solution boils down to setting the jshint command jshint to ~ / .vimrc:

  let g:syntastic_jshint_exec='C:\Users\jaroslav\AppData\Roaming\npm\jshint.cmd' :source $HOME/_vimrc :SyntasticInfo Syntastic: active mode enabled Syntastic info for filetype: javascript Available checker(s): jshint Currently enabled checker(s): jshint 

Alternatively, one could:

 > cmd.exe > cd C:\Users\jaroslav\AppData\Roaming\npm > setx PATH "%cd%:%PATH%" 

and let g:syntastic_jshint_exec='jshint.cmd' . I have not tried the last solution with% PATH% because Winders does not like long% PATH% variables.

Hope this saves you some time.

+21
source

Unfortunately, since this is my first post, I can not comment on the previous answer, however, first of all, thanks for the answer, and I would like to add a small thing.

With this option

 let g:syntastic_jshint_exec='C:\Users\jaroslav\AppData\Roaming\npm\jshint.cmd' 

I tried to activate pylint checker for python, but I had to write it like this

 let g:syntastic_python_pylint_exec='C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\Scripts\pylint' 

So I had to add the word python before the checker

0
source

Source: https://habr.com/ru/post/953338/


All Articles