gpt4 book ai didi

vim - 如何使用 JSHint 配置 Syntastic?

转载 作者:行者123 更新时间:2023-12-03 06:37:06 24 4
gpt4 key购买 nike

如何使用 Syntastic Vim 插件和 JSHint 来验证 JavaScript 代码?

环境:

  • Ubuntu 11.04
  • VIM - Vi 改进 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, col 1, 'x' is not defined.
test.js: line 4, col 5, 'nonono' is not defined.
test.js: line 6, col 1, 'a' is not defined.
test.js: line 7, col 1, 'b' is not defined.
test.js: line 8, col 5, 'a' is not defined.
test.js: line 8, col 10, 'b' is not defined.
test.js: line 8, 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

关于vim - 如何使用 JSHint 配置 Syntastic?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7233005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com