1
0

jsxhint.vim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "============================================================================
  2. "File: jsxhint.vim
  3. "Description: Javascript syntax checker - using jsxhint
  4. "Maintainer: Thomas Boyt <me@thomasboyt.com>
  5. "License: This program is free software. It comes without any warranty,
  6. " to the extent permitted by applicable law. You can redistribute
  7. " it and/or modify it under the terms of the Do What The Fuck You
  8. " Want To Public License, Version 2, as published by Sam Hocevar.
  9. " See http://sam.zoy.org/wtfpl/COPYING for more details.
  10. "============================================================================
  11. if exists('g:loaded_syntastic_javascript_jsxhint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_jsxhint_checker = 1
  15. let s:save_cpo = &cpo
  16. set cpo&vim
  17. function! SyntaxCheckers_javascript_jsxhint_IsAvailable() dict
  18. let jsxhint_version = syntastic#util#system(self.getExecEscaped() . ' --version')
  19. if v:shell_error || (jsxhint_version !~# '\m^JSXHint\>')
  20. return 0
  21. endif
  22. let ver = syntastic#util#parseVersion(jsxhint_version)
  23. call self.setVersion(ver)
  24. return syntastic#util#versionIsAtLeast(ver, [0, 4, 1])
  25. endfunction
  26. function! SyntaxCheckers_javascript_jsxhint_GetLocList() dict
  27. let makeprg = self.makeprgBuild({
  28. \ 'args_after': '--verbose' })
  29. let errorformat = '%A%f: line %l\, col %v\, %m \(%t%*\d\)'
  30. return SyntasticMake({
  31. \ 'makeprg': makeprg,
  32. \ 'errorformat': errorformat,
  33. \ 'defaults': {'bufnr': bufnr('')} })
  34. endfunction
  35. call g:SyntasticRegistry.CreateAndRegisterChecker({
  36. \ 'filetype': 'javascript',
  37. \ 'name': 'jsxhint'})
  38. let &cpo = s:save_cpo
  39. unlet s:save_cpo
  40. " vim: set sw=4 sts=4 et fdm=marker: