summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/linter.vim2
-rw-r--r--test/test_ale_linter_get.vader12
2 files changed, 13 insertions, 1 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 0cd3f9b1..f99d32a9 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -108,7 +108,7 @@ function! ale#linter#Get(original_filetype) abort
elseif type(l:linter_names) == type([])
" Select only the linters we or the user has specified.
for l:linter in l:all_linters
- if index(l:linter_names, l:linter.name)
+ if index(l:linter_names, l:linter.name) >= 0
call add(l:combined_linters, l:linter)
endif
endfor
diff --git a/test/test_ale_linter_get.vader b/test/test_ale_linter_get.vader
new file mode 100644
index 00000000..80691a59
--- /dev/null
+++ b/test/test_ale_linter_get.vader
@@ -0,0 +1,12 @@
+Before:
+ let g:ale_linters = {}
+
+After:
+ let g:ale_linters = {}
+
+Execute (Defaults should be correct):
+ AssertEqual [{'output_stream': 'stdout', 'name': 'eslint', 'executable': 'eslint', 'command': 'eslint -f unix --stdin --stdin-filename %s', 'callback': 'ale_linters#javascript#eslint#Handle'}, {'output_stream': 'stdout', 'name': 'jscs', 'executable': 'jscs', 'command': 'jscs -r unix -n -', 'callback': 'ale#handlers#HandleUnixFormatAsError'}, {'output_stream': 'stdout', 'name': 'jshint', 'executable': 'jshint', 'command_callback': 'ale_linters#javascript#jshint#GetCommand', 'callback': 'ale#handlers#HandleUnixFormatAsError'}], ale#linter#Get('javascript')
+
+Execute (You should be able to select only a few linters):
+ let g:ale_linters = {'javascript': ['eslint']}
+ AssertEqual [{'output_stream': 'stdout', 'name': 'eslint', 'executable': 'eslint', 'command': 'eslint -f unix --stdin --stdin-filename %s', 'callback': 'ale_linters#javascript#eslint#Handle'}], ale#linter#Get('javascript')