Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for remark-lint #1010

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ formatting.
| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) |
| LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) |
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !! |
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
Expand Down
28 changes: 28 additions & 0 deletions ale_linters/markdown/remark_lint.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
" Author rhysd https://rhysd.github.io/
" Description: remark-lint for Markdown files

function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
" matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint'
let l:pattern = '^ \+\(\d\+\):\(\d\+\) \(warning\|error\) \(.\+\)$'
let l:output = []

for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\ 'text': l:match[4],
\})
endfor

return l:output
endfunction

call ale#linter#Define('markdown', {
\ 'name': 'remark-lint',
\ 'executable': 'remark',
\ 'command': 'remark --no-stdout --no-color %s',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
\ 'lint_file': 1,
\ 'output_stream': 'stderr',
\})
2 changes: 1 addition & 1 deletion doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Notes:
* LaTeX (tex): `chktex`, `lacheck`, `proselint`
* LLVM: `llc`
* Lua: `luacheck`
* Markdown: `mdl`, `proselint`, `vale`
* Markdown: `mdl`, `proselint`, `vale`, `remark-lint`
* MATLAB: `mlint`
* Nim: `nim check`!!
* nix: `nix-instantiate`
Expand Down
27 changes: 27 additions & 0 deletions test/handler/test_remark_lint_handler.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Before:
runtime ale_linters/markdown/remark_lint.vim

Execute(Warning and error messages should be handled correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 4,
\ 'type': 'W',
\ 'text': 'Incorrect list-item indent: add 1 space list-item-indent remark-lint',
\ },
\ {
\ 'lnum': 3,
\ 'col': 5,
\ 'type': 'E',
\ 'text': 'Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
\ },
\ ],
\ ale_linters#markdown#remark_lint#Handle(1, [
\ 'foo.md',
\ ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint',
\ ' 3:5 error Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
\ '',
\ '⚠ 1 warnings',
\ '✘ 1 errors',
\])