Skip to content

Instantly share code, notes, and snippets.

@mwillbanks
Created March 21, 2016 18:02
Show Gist options
  • Save mwillbanks/90c982b3aa22a77aad97 to your computer and use it in GitHub Desktop.
Save mwillbanks/90c982b3aa22a77aad97 to your computer and use it in GitHub Desktop.
This code will walk the path backwards looking for the proper javascript checker in each directory until it hits the root. Currently only supporting jscs and jshint as a fallback.
" jscs returns exit code when no config file is present
" if it does not exist, we use jshint
function! DetectSyntasticJavascriptChecker()
let stack = split(getcwd(), '/')
let len = len(stack)
while len >= 0
let len = len - 1
let path = '/' . join(stack[0:len], '/')
if (filereadable(path . '/.jscsrc'))
return ['jscs']
endif
endwhile
return ['jshint']
endfunction
let g:syntastic_javascript_checkers=DetectSyntasticJavascriptChecker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment