Skip to content

Lightweight, customizable and functional Vim plugin for JSHint integration.

Notifications You must be signed in to change notification settings

insertmode/jshint2.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 

Repository files navigation

jshint2.vim

Lightweight, customizable and functional Vim plugin for JSHint integration.

jshint2.vim

Features

  • Linting whole file or selected lines without saving to disk.
  • Finding configuration files inside linting file path or upper in directories.
  • Using project-specific, locally installed version of jslint (i.e. installed as dev dependency) if available.
  • Setting lint flags from command line with autocompletion.
  • Optionally opening list of linting errors with useful shortcuts.
  • Optionally validating files after reading or saving.
  • Working on Linux, Windows (with JSHint 2.1.5 and newer) and OS X.

Installation

  1. Install Node.js.
  2. Install JSHint, either globally or locally.
  3. Place .jshintrc into your ~, optionally place it into your project directory.
  4. Install Pathogen, necessarily check super-minimal example.
  5. Clone plugin into your ~/.vim/bundle/jshint2.vim/.
  6. ???
  7. PROFIT!

Usage

Use :JSHint command inside Vim to lint whole file or :'<,'>JSHint to lint only selected lines.
Add ! to suppress opening error list (number of lint errors still will be shown) — :JSHint!.
Add space and use tab key to complete space separated lint flags — :JSHint white:true eqeqeq:true.
Use - to ignore errors by their codes — :JSHint -E001 -W002 -I003.

Configuration

Set JSHint command path:

let jshint2_command = '~/path/to/jshint'

Note You don't need to set this if JSHint was installed via npm, either locally or globally. If you specified JSHint as a development dependency in your package.json, jshint2.vim will find and use that exact version.

Lint JavaScript files after reading it:

let jshint2_read = 1

Lint JavaScript files after saving it:

let jshint2_save = 1

Do not automatically close orphaned error lists:

let jshint2_close = 0

Skip lint confirmation for non JavaScript files:

let jshint2_confirm = 0

Do not use colored messages:

let jshint2_color = 0

Hide error codes in error list (if you don't use error ignoring or error codes confuses you):

let jshint2_error = 0

Set default height of error list:

let jshint2_height = 20

Error List Shortcuts

t — open error in new tab.
v — open error in new vertical split.
s — open error in new horizontal split.
i — ignore selected error.
n — scroll to selected error.
q — close error list.

Tips

Quick lint mapping:

" jshint validation
nnoremap <silent><F1> :JSHint<CR>
inoremap <silent><F1> <C-O>:JSHint<CR>
vnoremap <silent><F1> :JSHint<CR>

" show next jshint error
nnoremap <silent><F2> :lnext<CR>
inoremap <silent><F2> <C-O>:lnext<CR>
vnoremap <silent><F2> :lnext<CR>

" show previous jshint error
nnoremap <silent><F3> :lprevious<CR>
inoremap <silent><F3> <C-O>:lprevious<CR>
vnoremap <silent><F3> :lprevious<CR>

Author & License

Written by Nikolay S. Frantsev under GNU GPL 3 License.

About

Lightweight, customizable and functional Vim plugin for JSHint integration.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Vim Script 92.3%
  • JavaScript 7.7%