summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/typescript/tslint.vim31
1 files changed, 27 insertions, 4 deletions
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index 2f4d235e..8eeb98d7 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -1,6 +1,20 @@
" Author: Prashanth Chandra https://github.com/prashcr
" Description: tslint for TypeScript files
+let g:ale_typescript_tslint_executable =
+\ get(g:, 'ale_typescript_tslint_executable', 'tslint')
+
+let g:ale_typescript_tslint_config_path =
+\ get(g:, 'ale_typescript_tslint_config_path', '')
+
+function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
+ return ale#util#ResolveLocalPath(
+ \ a:buffer,
+ \ 'node_modules/.bin/tslint',
+ \ g:ale_typescript_tslint_executable
+ \)
+endfunction
+
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
" Matches patterns like the following:
"
@@ -37,15 +51,24 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
endfunction
function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort
- let l:tsconfig_path = ale#util#FindNearestFile(a:buffer, 'tslint.json')
- let l:tslint_options = empty(l:tsconfig_path) ? '' : '-c ' . l:tsconfig_path
+ let g:ale_typescript_tslint_config_path =
+ \ empty(g:ale_typescript_tslint_config_path) ?
+ \ ale#util#FindNearestFile(a:buffer, 'tslint.json')
+ \ : g:ale_typescript_tslint_config_path
+
+ let l:tslint_options =
+ \ empty(g:ale_typescript_tslint_config_path) ?
+ \ ''
+ \ : '-c ' . fnameescape(g:ale_typescript_tslint_config_path)
- return 'tslint ' . l:tslint_options . ' %t'
+ return ale_linters#typescript#tslint#GetExecutable(a:buffer)
+ \ . ' ' . l:tslint_options
+ \ . ' %t'
endfunction
call ale#linter#Define('typescript', {
\ 'name': 'tslint',
-\ 'executable': 'tslint',
+\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable',
\ 'command_callback': 'ale_linters#typescript#tslint#BuildLintCommand',
\ 'callback': 'ale_linters#typescript#tslint#Handle',
\})