summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorP M <10617122+pylipp@users.noreply.github.com>2018-03-25 12:55:59 +0200
committerw0rp <w0rp@users.noreply.github.com>2018-03-25 11:55:59 +0100
commit107516c757df82d2ee84426de9b35fd52e953c5c (patch)
treee1286692393802e69f8f2620b9e4d14341ba7b94
parentd14558da32dd3d776c298fea6456c92870b46d5d (diff)
downloadale-107516c757df82d2ee84426de9b35fd52e953c5c.zip
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
-rw-r--r--README.md1
-rw-r--r--ale_linters/qml/qmllint.vim29
-rw-r--r--doc/ale.txt1
-rw-r--r--test/handler/test_qmllint_handler.vader19
4 files changed, 50 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9c90e3b6..4efad641 100644
--- a/README.md
+++ b/README.md
@@ -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) |
diff --git a/ale_linters/qml/qmllint.vim b/ale_linters/qml/qmllint.vim
new file mode 100644
index 00000000..c2258a14
--- /dev/null
+++ b/ale_linters/qml/qmllint.vim
@@ -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',
+\})
diff --git a/doc/ale.txt b/doc/ale.txt
index c5b1c071..d3fc576c 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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`
diff --git a/test/handler/test_qmllint_handler.vader b/test/handler/test_qmllint_handler.vader
new file mode 100644
index 00000000..fcc65eb5
--- /dev/null
+++ b/test/handler/test_qmllint_handler.vader
@@ -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 ''}'''
+ \ ])