Created
March 21, 2016 18:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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