加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 如何使用JSHint配置Syntastic?

发布时间:2020-12-15 16:23:17 所属栏目:安全 来源:网络整理
导读:如何使用Synthetic Vim插件与JSHint验证JavaScript代码? 环境: Ubuntu 11.04 VIM – Vi IMproved 7.3 我安装了,在VIM + JSLint?的解决方案: Vundle node.js 节点程序包管理器 jshint,全局 通过Vundle安装的Syntastic(在Vim中使用:BundleInstall命令,
如何使用Synthetic Vim插件与JSHint验证JavaScript代码?

环境:

> Ubuntu 11.04
> VIM – Vi IMproved 7.3

我安装了,在VIM + JSLint?的解决方案:

> Vundle
> node.js
>节点程序包管理器
> jshint,全局
>通过Vundle安装的Syntastic(在Vim中使用:BundleInstall命令,以确保已安装Syntastic)。

.vimrc:

set nocompatible               " be iMproved
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" My Bundles here:
Bundle 'scrooloose/syntastic'

filetype plugin indent on     " required! 

let g:syntastic_enable_signs=1
let g:syntastic_auto_jump=1
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{,}%W{Warn: %fw #%w}]'

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

寻找已安装的可执行文件:

$ which gjslint
$ which jslint
$ which jsl
$ which jshint
/home/fernando/local/node/bin/jshint
$ 


$ echo $PATH

>/home/fernando/local/bin:/home/fernando/local/node/bin:/home/fernando/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

$ jshint test.js

test.js: line 3,col 1,‘blbla’ is not defined.
test.js: line 4,‘x’ is not defined.
test.js: line 4,col 5,‘nonono’ is not defined.
test.js: line 6,‘a’ is not defined.
test.js: line 7,‘b’ is not defined.
test.js: line 8,‘a’ is not defined.
test.js: line 8,col 10,col 7,Expected ‘===’ and instead saw ‘==’.

8 errors

$ vi test.js -- no error message shown

:SyntasticEnable -- Vim exits and restarts,opening the same file,but still no message

:w -- still no error message

:Errors -- the location list opens but it is empty

jshint和Syntastic似乎都已安装,但可能缺少某些东西。它会是什么?

这里有一个更新的信息,有一个配置文件扩展名关联到检查器,
在.vimrc中
let g:syntastic_javascript_checkers = ['jshint']

还要获得有关发生什么运行在vim中运行此命令

:SyntasticInfo

你会得到类似这样的输出:

Syntastic info for filetype: javascript  
Available checkers: gjslint jshint  
Currently active checker(s): gjslint  
Press ENTER or type command to continue

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读