summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorRoeland <10061147+roelandmoors@users.noreply.github.com>2021-10-09 07:33:07 +0200
committerGitHub <noreply@github.com>2021-10-09 14:33:07 +0900
commit1ee7580557733bab22b764170958a0189810b3bb (patch)
tree758d160e085b6a2f4a27464905653226b4f9cadf /ale_linters
parent42a6e039cb36fbc5a60215b2be55e54c364b15e9 (diff)
downloadale-1ee7580557733bab22b764170958a0189810b3bb.zip
Add support for erblint (#3931)
* support for erblint * fix tests * test for handler * wrong names * typo * doc layout * CI failed?
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/eruby/erblint.vim51
1 files changed, 51 insertions, 0 deletions
diff --git a/ale_linters/eruby/erblint.vim b/ale_linters/eruby/erblint.vim
new file mode 100644
index 00000000..19960185
--- /dev/null
+++ b/ale_linters/eruby/erblint.vim
@@ -0,0 +1,51 @@
+" Author: Roeland Moors - https://github.com/roelandmoors
+" based on the ale ruumba and robocop linters
+" Description: ERB Lint, support for https://github.com/Shopify/erb-lint
+
+call ale#Set('eruby_erblint_executable', 'erblint')
+call ale#Set('eruby_erblint_options', '')
+
+function! ale_linters#eruby#erblint#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable')
+
+ return ale#ruby#EscapeExecutable(l:executable, 'erblint')
+ \ . ' --format json '
+ \ . ale#Var(a:buffer, 'eruby_erblint_options')
+ \ . ' --stdin %s'
+endfunction
+
+function! ale_linters#eruby#erblint#Handle(buffer, lines) abort
+ if empty(a:lines)
+ return []
+ endif
+
+ let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], [])
+
+ if !has_key(l:errors, 'summary')
+ \|| l:errors['summary']['offenses'] == 0
+ \|| empty(l:errors['files'])
+ return []
+ endif
+
+ let l:output = []
+
+ for l:error in l:errors['files'][0]['offenses']
+ call add(l:output, {
+ \ 'lnum': l:error['location']['start_line'] + 0,
+ \ 'col': l:error['location']['start_column'] + 0,
+ \ 'end_col': l:error['location']['last_column'] + 0,
+ \ 'code': l:error['linter'],
+ \ 'text': l:error['message'],
+ \ 'type': 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('eruby', {
+\ 'name': 'erblint',
+\ 'executable': {b -> ale#Var(b, 'eruby_erblint_executable')},
+\ 'command': function('ale_linters#eruby#erblint#GetCommand'),
+\ 'callback': 'ale_linters#eruby#erblint#Handle',
+\})