JSHint 在 vim 中不起作用

JSHint doesn't work in vim

在调用 :SyntasticInfo 时:

Syntastic version: 3.8.0-94 (Vim 800, Linux, GUI)
Info for filetype: javascript
Global mode: active
Filetype javascript is active
The current file will be checked automatically
Available checker: jshint
Currently enabled checker: jshint

我已经通过 vim-pathogen 安装了 JSHint 和 Syntastic。

要进行语法检查,应该配置什么?

Syntastic's documentation on JSHint中,除了

之外,没有特别提到配置

This checker is initialised using the "makeprgBuild()" function and thus it accepts the standard options described at |syntastic-config-makeprg|.

附带说明一下,语法检查确实适用于 TypeScript,使用 Syntastic。

.vimrc:

syntax on
colorscheme industry

execute pathogen#infect()
filetype plugin on

set textwidth=0
set softtabstop=4
let &shiftwidth=&softtabstop
set autoindent
set number

" Used for using buffers and tabs the right way.
set hidden

" Enable airline
let g:airline#extensions#tabline#enabled = 1

" Use powerline fonts
let g:airline_powerline_fonts = 1

"Open NERDTree on startup
"autocmd vimenter * NERDTree

map <C-n> :NERDTreeToggle<CR>

:let mapleader = "/"

" Mappings to access buffers (don't use "\p" because a
" delay before pressing "p" would accidentally paste).
" \l       : list buffers
" \b \f \g : go back/forward/last-used
"    : go to buffer 1/2/3 etc
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" It's useful to show the buffer number in the status line.
"set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P

" Enable color highlighting by Powerline in vim.
set t_Co=256

" Display buffer number in Airline
 let g:airline#extensions#tabline#buffer_nr_show = 1

" Enable tab support in Airline
let g:airline#extensions#tabline#enabled = 1

autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript

" Close a buffer without closing its window
map <Leader>q :bp<bar>sp<bar>bn<bar>bd<CR>

" Split a window without resizing the others
set noequalalways

" Don't autoindent when editing text files --- no suffix filenames.
set noautoindent
augroup vimrc_indent
    au!
    autocmd FileType * set autoindent
augroup END

"Toggle scrolling by display lines instead of file lines.
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
  if &wrap
    echo "Wrap OFF"
    setlocal nowrap
    set virtualedit=all
    silent! nunmap <buffer> <Up>
    silent! nunmap <buffer> <Down>
    silent! nunmap <buffer> <Home>
    silent! nunmap <buffer> <End>
    silent! iunmap <buffer> <Up>
    silent! iunmap <buffer> <Down>
    silent! iunmap <buffer> <Home>
    silent! iunmap <buffer> <End>
  else
    echo "Wrap ON"
    setlocal wrap linebreak nolist
    set virtualedit=
    setlocal display+=lastline
    noremap  <buffer> <silent> <Up>   gk
    noremap  <buffer> <silent> <Down> gj
    noremap  <buffer> <silent> <Home> g<Home>
    noremap  <buffer> <silent> <End>  g<End>
    inoremap <buffer> <silent> <Up>   <C-o>gk
    inoremap <buffer> <silent> <Down> <C-o>gj
    inoremap <buffer> <silent> <Home> <C-o>g<Home>
    inoremap <buffer> <silent> <End>  <C-o>g<End>
    noremap  <buffer> <silent> k gk
    noremap  <buffer> <silent> j gj
    noremap  <buffer> <silent> 0 g0
    noremap  <buffer> <silent> $ g$
  endif
endfunction

"Disable folding
set foldenable

"JS syntax checking
let g:syntastic_javascript_checkers = ['jshint']

您没有任何 Syntastic 的配置告诉它 运行。当您 运行 :help syntastic-recommended:

时,您可能会从列出的推荐设置开始
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

您也可以使用 :SyntasticCheck

手动调用 Syntastic

如果您希望根据其中一条评论的建议进行即时检查,那么您应该从 Syntastic 切换到 ALE(我通常推荐 ALE)