]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/ale_linters/coffee/coffeelint.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:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / coffee / coffeelint.vim
diff --git a/.vim/bundle/ale/ale_linters/coffee/coffeelint.vim b/.vim/bundle/ale/ale_linters/coffee/coffeelint.vim
new file mode 100644 (file)
index 0000000..b7c85fa
--- /dev/null
@@ -0,0 +1,43 @@
+" Author: Prashanth Chandra https://github.com/prashcr
+" Description: coffeelint linter for coffeescript files
+
+function! ale_linters#coffee#coffeelint#GetExecutable(buffer) abort
+    return ale#path#ResolveLocalPath(
+    \   a:buffer,
+    \   'node_modules/.bin/coffeelint',
+    \   'coffeelint'
+    \)
+endfunction
+
+function! ale_linters#coffee#coffeelint#GetCommand(buffer) abort
+    return ale_linters#coffee#coffeelint#GetExecutable(a:buffer)
+    \   . ' --stdin --reporter csv'
+endfunction
+
+function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
+    " Matches patterns like the following:
+    "
+    " path,lineNumber,lineNumberEnd,level,message
+    " stdin,14,,error,Throwing strings is forbidden
+    "
+    " Note that we currently ignore lineNumberEnd for multiline errors
+    let l:pattern = 'stdin,\(\d\+\),\(\d*\),\(.\{-1,}\),\(.\+\)'
+    let l:output = []
+
+    for l:match in ale#util#GetMatches(a:lines, l:pattern)
+        call add(l:output, {
+        \   'lnum': str2nr(l:match[1]),
+        \   'type': l:match[3] is# 'error' ? 'E' : 'W',
+        \   'text': l:match[4],
+        \})
+    endfor
+
+    return l:output
+endfunction
+
+call ale#linter#Define('coffee', {
+\   'name': 'coffeelint',
+\   'executable': function('ale_linters#coffee#coffeelint#GetExecutable'),
+\   'command': function('ale_linters#coffee#coffeelint#GetCommand'),
+\   'callback': 'ale_linters#coffee#coffeelint#Handle',
+\})