4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JSHintでJavaScriptのソースコードをチェックする

Last updated at Posted at 2012-01-15

最初は jslint.vim を使っていたんだけど、jslint-core.js を最新にするのが面倒だったので
npm で簡単に管理できる node-jshint を使う設定を書いてみた。
errormarker.vim とあわせて使うとなかなか快適。

jslint.vim みたいに書いたはしからチェックかけるようにするにはどうすればいいんだろう……

install-jshint.sh
npm install -g jshint
.vim/compiler/jslint.vim
if exists("current_compiler")
  finish
endif
let current_compiler = "jshint"

let s:save_cpo = &cpo
set cpo&vim

if exists(":CompilerSet") != 2
  command -nargs=* CompilerSet setlocal <args>
endif

CompilerSet makeprg=jshint\ %

CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%+Z%p^,%+C%.%#,%-G%.%#

let &cpo = s:save_cpo
.vim/ftplugin/javascript.vim
if exists("b:did_ftplugin")
  finish
endif
let b:did_ftplugin = 1

let s:save_cpo = &cpo
set cpo&vim

if !exists("current_compiler")
  compiler jshint
endif

autocmd BufWritePost <buffer> silent make

let &cpo = s:save_cpo

久しぶりにVim Script書いてみたけど、作法とか良くわからない……
Vim Script テクニックバイブルとかでないかなぁ

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?