How to configure Syntastic with JSHint?

前端 未结 3 1835
走了就别回头了
走了就别回头了 2021-01-31 14:34

How to use the Syntastic Vim plugin with JSHint to validate JavaScript code?

Environment:

  • Ubuntu 11.04
  • VIM - Vi IMproved 7.3

What I

相关标签:
3条回答
  • 2021-01-31 15:11

    I just had this same problem. Turns out, Syntastic looks for jsl (JSLint) before it looks for jshint. If you have both installed, you'll likely be misled. I moved jsl somewhere not in my PATH, and jshint was detected just fine.

    Source:
    https://github.com/scrooloose/syntastic/pull/47

    0 讨论(0)
  • 2021-01-31 15:23

    Here is a more updated info, there is a configuration to associate a file extension to a checker,
    in your .vimrc

    let g:syntastic_javascript_checkers = ['jshint']
    

    Also to get info about what's going on run this command in vim

    :SyntasticInfo
    

    And you'll get an output similar to this:

    Syntastic info for filetype: javascript  
    Available checkers: gjslint jshint  
    Currently active checker(s): gjslint  
    Press ENTER or type command to continue
    
    0 讨论(0)
  • 2021-01-31 15:23

    I struggled with this issue for days and SyntasticInfo would not recognize jshint as an available checker even after i added let g:syntastic_javascript_checkers['jshint'] to my .vimrc. I am using Ubuntu 15.04 and I followed this tutorial to install nvm, nodejs, and jshint on Ubuntu. After I did that I discovered that if I removed the line filetype plugin indent on from my .vimrc then opened a .js file everything worked perfectly! To summarize...

    1. follow the tutorial linked above
    2. add ~/.nvm/<version_number>/bin to path in .bashrc
    3. remove filetype plugin indent on from .vimrc
    4. add let g:syntastic_javascript_checkers['jshint'] to .vimrc
    5. :so % inside vim
    6. open a .js file
    7. add filetype plugin indent on back to your .vimrc
    8. everything magically works now
    0 讨论(0)
提交回复
热议问题