eslint.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "============================================================================
  2. "File: eslint.vim
  3. "Description: Javascript syntax checker - using eslint
  4. "Maintainer: Maksim Ryzhikov <rv.maksim at gmail dot 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_eslint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_eslint_checker = 1
  15. if !exists('g:syntastic_javascript_eslint_sort')
  16. let g:syntastic_javascript_eslint_sort = 1
  17. endif
  18. let s:save_cpo = &cpo
  19. set cpo&vim
  20. function! SyntaxCheckers_javascript_eslint_IsAvailable() dict
  21. if !executable(self.getExec())
  22. return 0
  23. endif
  24. return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 1])
  25. endfunction
  26. function! SyntaxCheckers_javascript_eslint_GetLocList() dict
  27. call syntastic#log#deprecationWarn('javascript_eslint_conf', 'javascript_eslint_args',
  28. \ "'--config ' . syntastic#util#shexpand(OLD_VAR)")
  29. let makeprg = self.makeprgBuild({ 'args_before': '-f compact' })
  30. let errorformat =
  31. \ '%E%f: line %l\, col %c\, Error - %m,' .
  32. \ '%W%f: line %l\, col %c\, Warning - %m'
  33. let loclist = SyntasticMake({
  34. \ 'makeprg': makeprg,
  35. \ 'errorformat': errorformat,
  36. \ 'postprocess': ['guards'] })
  37. for e in loclist
  38. let e['col'] += 1
  39. endfor
  40. return loclist
  41. endfunction
  42. call g:SyntasticRegistry.CreateAndRegisterChecker({
  43. \ 'filetype': 'javascript',
  44. \ 'name': 'eslint'})
  45. let &cpo = s:save_cpo
  46. unlet s:save_cpo
  47. " vim: set sw=4 sts=4 et fdm=marker: