简体   繁体   English

更改Vim的Syntastic以使用基于文件扩展名的特定检查器?

[英]Change Vim's Syntastic to use a certain checker based on file extension?

I have vim's syntastic installed properly along with eslint and jshint. 我已经将eslint和jshint一起正确安装了vim的syntastic。 I prefer jshint for most of my javascript programming. 我更喜欢jshint来进行大多数JavaScript编程。 However, I'm starting to learn React, and would like to use eslint with syntastic (eslint has superior/proper linting for react). 但是,我开始学习React,并且希望将eslint与syntastic一起使用(eslint具有对React的优越/正确的掉毛)。

Is it possible to set vim to use jshint for *.js files, and eslint for *.jsx files? 是否可以将vim设置为对* .js文件使用jshint,对* .jsx文件使用eslint?

I see from :help syntastic-checkers that react gets lumped in javascript. 我从反应中的:help syntastic-checkers中看到,它们混在了javascript中。 Chaining the linters is not what I want, either. 拴短绒也不是我想要的。

Found it! 找到了! You were very close @lcd047, but your comment lead me down the right path! 您与@ lcd047的距离非常近,但您的评论将我引向了正确的道路! To enable eslint on only *jsx files, putting the following in my .vimrc works: 要仅在* jsx文件上启用eslint ,请将以下内容放入我的.vimrc

au BufEnter *.jsx let b:syntastic_checkers = ['eslint']

In my case, syntastic will use jshint on javascript by default even if a checker is not set in .vimrc . 就我而言,即使未在.vimrc设置检查器,syntastic也会默认在javascript上使用jshint Setting the above works even if g:syntastic_javascript_checkers is unset or even if it is set, in my case, to jshint. 即使g:syntastic_javascript_checkers设置g:syntastic_javascript_checkers ,或者就我而言,即使将其设置为jshint,也可以进行上述设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM