mirror of https://github.com/dense-analysis/ale
add slim-lint (#388)
* add slim-lint * add slim readme entry * add slim entry to doc * add slimlint vader test
This commit is contained in:
parent
3f3d8b0014
commit
fae26369d4
|
@ -96,6 +96,7 @@ name. That seems to be the fairest way to arrange this table.
|
|||
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| Scala | [scalac](http://scala-lang.org) |
|
||||
| Slim | [slim-lint](https://github.com/sds/slim-lint)
|
||||
| SML | [smlnj](http://www.smlnj.org/) |
|
||||
| Swift | [swiftlint](https://swift.org/) |
|
||||
| Tex | [proselint](http://proselint.com/) |
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
" Author: Markus Doits - https://github.com/doits
|
||||
" Description: slim-lint for Slim files, based on hamllint.vim
|
||||
|
||||
function! ale_linters#slim#slimlint#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" <path>:5 [W] LineLength: Line is too long. [150/120]
|
||||
let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:line in a:lines
|
||||
let l:match = matchlist(l:line, l:pattern)
|
||||
|
||||
if len(l:match) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'type': l:match[2],
|
||||
\ 'text': l:match[3]
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('slim', {
|
||||
\ 'name': 'slimlint',
|
||||
\ 'executable': 'slim-lint',
|
||||
\ 'command': 'slim-lint %t',
|
||||
\ 'callback': 'ale_linters#slim#slimlint#Handle'
|
||||
\})
|
|
@ -118,6 +118,7 @@ The following languages and tools are supported.
|
|||
* SASS: 'sasslint', 'stylelint'
|
||||
* SCSS: 'sasslint', 'scsslint', 'stylelint'
|
||||
* Scala: 'scalac'
|
||||
* Slim: 'slim-lint'
|
||||
* SML: 'smlnj'
|
||||
* Swift: 'swiftlint'
|
||||
* Tex: 'proselint'
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
" Author: Markus Doits <markus.doits@googlemail.com>
|
||||
|
||||
Execute(The slim handler should parse lines correctly):
|
||||
runtime ale_linters/slim/slimlint.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 1,
|
||||
\ 'text': 'RedundantDiv: `div` is redundant when class attribute shortcut is present',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 2,
|
||||
\ 'text': 'LineLength: Line is too long. [136/80]',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 3,
|
||||
\ 'text': 'Invalid syntax',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#slim#slimlint#Handle(347, [
|
||||
\ 'inv.slim:1 [W] RedundantDiv: `div` is redundant when class attribute shortcut is present',
|
||||
\ 'inv.slim:2 [W] LineLength: Line is too long. [136/80]',
|
||||
\ 'inv.slim:3 [E] Invalid syntax',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
Loading…
Reference in New Issue