Merge pull request #1730 from watagashi/local-remark-lint-with-new-test

Support remark-lint installed locally with new test
This commit is contained in:
w0rp 2018-07-16 13:32:26 +01:00 committed by GitHub
commit b413e03b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 4 deletions

View File

@ -140,7 +140,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) !!, [textlint](https://textlint.github.io/), [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), [textlint](https://textlint.github.io/), [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) |
| Mercury | [mmc](http://mercurylang.org) !! |
| NASM | [nasm](https://www.nasm.us/) !! |

View File

@ -1,5 +1,23 @@
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
" Description: remark-lint for Markdown files
call ale#Set('markdown_remark_lint_executable', 'remark')
call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('markdown_remark_lint_options', '')
function! ale_linters#markdown#remark_lint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [
\ 'node_modules/.bin/remark',
\])
endfunction
function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort
let l:executable = ale_linters#markdown#remark_lint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
return ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --no-stdout --no-color'
endfunction
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'
@ -26,9 +44,8 @@ endfunction
call ale#linter#Define('markdown', {
\ 'name': 'remark-lint',
\ 'executable': 'remark',
\ 'command': 'remark --no-stdout --no-color %s',
\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable',
\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
\ 'lint_file': 1,
\ 'output_stream': 'stderr',
\})

View File

@ -28,6 +28,33 @@ prettier *ale-markdown-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================
remark-lint *ale-markdown-remark-lint*
g:ale_markdown_remark_lint_executable *g:ale_markdown_remark_lint_executable*
*b:ale_markdown_remark_lint_executable*
Type: |String|
Default: `'remark'`
See |ale-integrations-local-executables|
g:ale_markdown_remark_lint_options *g:ale_markdown_remark_lint_options*
*b:ale_markdown_remark_lint_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to remark-lint.
g:ale_markdown_remark_lint_use_global *g:ale_markdown_remark_lint_use_global*
*b:ale_markdown_remark_lint_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
textlint *ale-markdown-textlint*

View File

@ -0,0 +1,37 @@
Before:
" This is just one language for the linter.
call ale#assert#SetUpLinterTest('markdown', 'remark_lint')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'remark',
\ ale#Escape('remark') . ' --no-stdout --no-color'
Execute(The executable should be configurable):
let b:ale_markdown_remark_lint_executable = 'foobar'
AssertLinter 'foobar',
\ ale#Escape('foobar') . ' --no-stdout --no-color'
Execute(The options should be configurable):
let b:ale_markdown_remark_lint_options = '--something'
AssertLinter 'remark',
\ ale#Escape('remark') . ' --something --no-stdout --no-color'
Execute(The local executable from .bin should be used if available):
call ale#test#SetFilename('remark_lint_paths/with_bin_path/foo.md')
AssertLinter
\ ale#path#Simplify(g:dir . '/remark_lint_paths/with_bin_path/node_modules/.bin/remark'),
\ ale#Escape(ale#path#Simplify(g:dir . '/remark_lint_paths/with_bin_path/node_modules/.bin/remark'))
\ . ' --no-stdout --no-color'
Execute(The global executable should be uesd if the option is set):
let b:ale_markdown_remark_lint_use_global = 1
call ale#test#SetFilename('remark_lint_paths/with_bin_path/foo.md')
AssertLinter 'remark', ale#Escape('remark')
\ . ' --no-stdout --no-color'