All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Prashanth Chandra <https://github.com/prashcr>, Jonathan Clem <https://jclem.net>
2 " Description: tslint for TypeScript files
4 call ale#handlers#tslint#InitVariables()
6 function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
7 " Do not output any errors for empty files if the option is on.
8 if ale#Var(a:buffer, 'typescript_tslint_ignore_empty_files')
9 \&& getbufline(a:buffer, 1, '$') == ['']
13 let l:dir = expand('#' . a:buffer . ':p:h')
16 for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
17 if get(l:error, 'ruleName', '') is# 'no-implicit-dependencies'
22 \ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
23 \ 'text': l:error.failure,
24 \ 'lnum': l:error.startPosition.line + 1,
25 \ 'col': l:error.startPosition.character + 1,
26 \ 'end_lnum': l:error.endPosition.line + 1,
27 \ 'end_col': l:error.endPosition.character + 1,
30 let l:filename = ale#path#GetAbsPath(l:dir, l:error.name)
32 " Assume temporary files are this file.
33 if !ale#path#IsTempName(l:filename)
34 let l:item.filename = l:filename
37 if has_key(l:error, 'ruleName')
38 let l:item.code = l:error.ruleName
41 call add(l:output, l:item)
47 function! ale_linters#typescript#tslint#GetCommand(buffer) abort
48 let l:tslint_config_path = ale#path#ResolveLocalPath(
51 \ ale#Var(a:buffer, 'typescript_tslint_config_path')
53 let l:tslint_config_option = !empty(l:tslint_config_path)
54 \ ? ' -c ' . ale#Escape(l:tslint_config_path)
57 let l:tslint_rules_dir = ale#Var(a:buffer, 'typescript_tslint_rules_dir')
58 let l:tslint_rules_option = !empty(l:tslint_rules_dir)
59 \ ? ' -r ' . ale#Escape(l:tslint_rules_dir)
62 return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
64 \ . l:tslint_config_option
65 \ . l:tslint_rules_option
69 call ale#linter#Define('typescript', {
71 \ 'executable': function('ale#handlers#tslint#GetExecutable'),
73 \ 'command': function('ale_linters#typescript#tslint#GetCommand'),
74 \ 'callback': 'ale_linters#typescript#tslint#Handle',