Add basic qmllint support (#1419)

* Add basic qmllint support

* Use temp file, remove superfluous error code key, adjust author info

* Add qmllint handler parse test
This commit is contained in:
P M 2018-03-25 12:55:59 +02:00 committed by w0rp
parent d14558da32
commit 107516c757
4 changed files with 50 additions and 0 deletions

View File

@ -139,6 +139,7 @@ formatting.
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [prospector](http://github.com/landscapeio/prospector), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pyls](https://github.com/palantir/python-language-server), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
| QML | [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) |
| R | [lintr](https://github.com/jimhester/lintr) |
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [refmt](https://github.com/reasonml/reason-cli) |
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |

View File

@ -0,0 +1,29 @@
" Author: pylipp (www.github.com/pylipp)
" Description: qmllint for QML files
" Find lines like
" /home/foo_user42/code-base/qml/Screen.qml:11 : Expected token `}'
function! ale_linters#qml#qmllint#Handle(buffer, lines) abort
let l:pattern = '\v^[/_-a-zA-z0-9\. ]+:(\d+) : (.*)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'E',
\}
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('qml', {
\ 'name': 'qmllint',
\ 'output_stream': 'stderr',
\ 'executable': 'qmllint',
\ 'command': 'qmllint %t',
\ 'callback': 'ale_linters#qml#qmllint#Handle',
\})

View File

@ -365,6 +365,7 @@ Notes:
* Pug: `pug-lint`
* Puppet: `puppet`, `puppet-lint`
* Python: `autopep8`, `flake8`, `isort`, `mypy`, `prospector`, `pycodestyle`, `pyls`, `pylint`!!, `yapf`
* QML: `qmllint`
* R: `lintr`
* ReasonML: `merlin`, `ols`, `refmt`
* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good`

View File

@ -0,0 +1,19 @@
Before:
runtime ale_linters/qml/qmllint.vim
After:
call ale#linter#Reset()
Execute(The qmllint handler should parse error messages correctly):
AssertEqual
\ [
\ {
\ 'lnum': 2,
\ 'col': 0,
\ 'type': 'E',
\ 'text': 'Expected token ''}'''
\ }
\ ],
\ ale_linters#qml#qmllint#Handle(1, [
\ '/tmp/ab34cd56/Test.qml:2 : Expected token ''}'''
\ ])