A powerful vim plugin lint javascript code on the fly. It supports Windows/Linux/Mac up to Vim 8.0
-
You need install jsruntime first
-
You need install jsoncodecs first
-
Copy everything inside ftplugin to your vimfiles/ftplugin directory
-
Add following lines to your vimrc
filetype on filetype plugin on
For javascript file, jsflakes will automaticlly check errors in your code while you editing.
If you don't like this behaviour. You can toggle the Automatic Lint by <Leader>al
, your vim's <Leader> is often \
.
You can aslo disable autolint by adding let g:jsflakes_autolint = 0
to your vimrc.
The command to run jshint manaually is :JSLint
.
The current errors are added to the window's location list. You can aslo use quickfix commands, like
:lli list errors in your javascript code
:lopen open location window
Jsflakes aslo support html file, add following to your vimrc
au FileType html source $VIM\vimfiles\ftplugin\javascript\jsflakes.vim
Jsflakes use jslint to check errors. Jslint has many options, Jslint option file should be at ~/.jshintrc by default. your can change it to other location by adding following line to your vimrc
let g:jshint_rcfile = {PATH}
Jsflakes aslo provide commands to run javascript directly in VIM
-
RunJS
:RunJS run javascript code
-
RunJSBlock
:RunJS 1,2 run javascript code from line 1 to line 2
-
RunHtml
:RunHtml run html code
-
RunHtmlBlock
:RunHtmlBlock 1,2 run html code from line 1 to line 2