From 2a575ca551929140c59b824c9a4caf120beb225c Mon Sep 17 00:00:00 2001 From: Ty-Lucas Kelley Date: Sat, 3 Mar 2018 19:16:41 -0500 Subject: [PATCH 1/3] add basic support for markdownlint --- README.md | 2 +- ale_linters/markdown/markdownlint.vim | 11 +++++++++++ autoload/ale/handlers/markdownlint.vim | 17 +++++++++++++++++ doc/ale.txt | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 ale_linters/markdown/markdownlint.vim create mode 100644 autoload/ale/handlers/markdownlint.vim diff --git a/README.md b/README.md index d5335e2..4524936 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ formatting. | Lua | [luac](https://www.lua.org/manual/5.1/luac.html), [luacheck](https://github.com/mpeterv/luacheck) | | Mail | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) | | Make | [checkmake](https://github.com/mrtazz/checkmake) | -| Markdown | [alex](https://github.com/wooorm/alex) !!, [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | +| Markdown | [alex](https://github.com/wooorm/alex) !!, [markdownlint](https://github.com/DavidAnson/markdownlint), [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | | 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) | diff --git a/ale_linters/markdown/markdownlint.vim b/ale_linters/markdown/markdownlint.vim new file mode 100644 index 0000000..5c8af65 --- /dev/null +++ b/ale_linters/markdown/markdownlint.vim @@ -0,0 +1,11 @@ +" Author: Ty-Lucas Kelley +" Description: Adds support for markdownlint + +call ale#linter#Define('markdown', { + \ 'name': 'markdownlint', + \ 'executable': 'markdownlint', + \ 'lint_file': 1, + \ 'output_stream': 'both', + \ 'command': 'markdownlint %s', + \ 'callback': 'ale#handlers#markdownlint#Handle' +\ }) diff --git a/autoload/ale/handlers/markdownlint.vim b/autoload/ale/handlers/markdownlint.vim new file mode 100644 index 0000000..12fc501 --- /dev/null +++ b/autoload/ale/handlers/markdownlint.vim @@ -0,0 +1,17 @@ +" Author: Ty-Lucas Kelley +" Description: Adds support for markdownlint + +function! ale#handlers#markdownlint#Handle(buffer, lines) abort + let l:pattern=': \(\d*\): \(MD\d\{3}\)\(\/\)\([A-Za-z0-9-]\+\)\(.*\)$' + let l:output=[] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], + \ 'type': 'W', + \ }) + endfor + + return l:output +endfunction diff --git a/doc/ale.txt b/doc/ale.txt index 95c3c0e..d411bb2 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -344,7 +344,7 @@ Notes: * Lua: `luac`, `luacheck` * Mail: `alex`!!, `proselint`, `vale` * Make: `checkmake` -* Markdown: `alex`!!, `mdl`, `prettier`, `proselint`, `redpen`, `remark-lint`, `vale`, `write-good` +* Markdown: `alex`!!, `markdownlint`!!, `mdl`, `prettier`, `proselint`, `redpen`, `remark-lint`, `vale`, `write-good` * MATLAB: `mlint` * Nim: `nim check`!! * nix: `nix-instantiate` From c572cfd2d2ea9449b51fa7009df78f0a5ce77b96 Mon Sep 17 00:00:00 2001 From: Ty-Lucas Kelley Date: Sat, 3 Mar 2018 19:17:31 -0500 Subject: [PATCH 2/3] add vim README.md to readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4524936..7c0b17a 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ formatting. | Lua | [luac](https://www.lua.org/manual/5.1/luac.html), [luacheck](https://github.com/mpeterv/luacheck) | | Mail | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) | | Make | [checkmake](https://github.com/mrtazz/checkmake) | -| Markdown | [alex](https://github.com/wooorm/alex) !!, [markdownlint](https://github.com/DavidAnson/markdownlint), [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | +| Markdown | [alex](https://github.com/wooorm/alex) !!, [markdownlint](https://github.com/DavidAnson/markdownlint) !!, [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | | 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) | From 32091fb8ad01d46084305100f4aa074114141516 Mon Sep 17 00:00:00 2001 From: Ty-Lucas Kelley Date: Sat, 3 Mar 2018 19:32:32 -0500 Subject: [PATCH 3/3] add test for markdownlint hander --- test/handler/test_markdownlint_handler.vader | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/handler/test_markdownlint_handler.vader diff --git a/test/handler/test_markdownlint_handler.vader b/test/handler/test_markdownlint_handler.vader new file mode 100644 index 0000000..db6acc6 --- /dev/null +++ b/test/handler/test_markdownlint_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/markdown/markdownlint.vim + +After: + call ale#linter#Reset() + +Execute(The Markdownlint handler should parse output correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'text': '(MD002/first-header-h1) First header should be a top level header [Expected: h1; Actual: h2]', + \ 'type': 'W' + \ }, + \ { + \ 'lnum': 298, + \ 'text': '(MD033/no-inline-html) Inline HTML [Element: p]', + \ 'type': 'W' + \ } + \ ], + \ ale#handlers#markdownlint#Handle(0, [ + \ 'README.md: 1: MD002/first-header-h1 First header should be a top level header [Expected: h1; Actual: h2]', + \ 'README.md: 298: MD033/no-inline-html Inline HTML [Element: p]' + \ ])