]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/fecs.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / handlers / fecs.vim
1 " Author: harttle <yangjvn@126.com>
2 " Description: fecs http://fecs.baidu.com/
3
4 call ale#Set('javascript_fecs_executable', 'fecs')
5 call ale#Set('javascript_fecs_use_global', get(g:, 'ale_use_global_executables', 0))
6
7 function! ale#handlers#fecs#GetCommand(buffer) abort
8     return '%e check --colors=false --rule=true %t'
9 endfunction
10
11 function! ale#handlers#fecs#GetExecutable(buffer) abort
12     return ale#path#FindExecutable(a:buffer, 'javascript_fecs', [
13     \   'node_modules/.bin/fecs',
14     \   'node_modules/fecs/bin/fecs',
15     \])
16 endfunction
17
18 function! ale#handlers#fecs#Handle(buffer, lines) abort
19     " Matches patterns looking like the following
20     "
21     " fecs  WARN → line 20, col 25: Unexpected console statement.     (no-console)
22     " fecs ERROR → line 24, col 36: Missing radix parameter.  (radix)
23     "
24     let l:pattern = '\v^.*(WARN|ERROR)\s+→\s+line (\d+),\s+col\s+(\d+):\s+(.*)$'
25     let l:output = []
26
27     for l:match in ale#util#GetMatches(a:lines, l:pattern)
28         let l:obj = {
29         \   'lnum': l:match[2] + 0,
30         \   'col': l:match[3] + 0,
31         \   'text': l:match[4]
32         \}
33
34         let l:code_match = matchlist(l:match[4], '\v^(.{-})\s*\((.+)\)$')
35
36         if !empty(l:code_match)
37             let l:obj.code = l:code_match[2]
38             let l:obj.text = l:code_match[1]
39         endif
40
41         if l:match[1] is# 'WARN'
42             let l:obj.type = 'W'
43         elseif l:match[1] is# 'ERROR'
44             let l:obj.type = 'E'
45         endif
46
47         call add(l:output, l:obj)
48     endfor
49
50     return l:output
51 endfunction
52