mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-18 10:15:56 +08:00
Add textlint for Asciidoc and add it to Fixers (#2193)
* Add textlint for asciidoc * Add textlint --fix
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
" Author: januswel, w0rp
|
||||
|
||||
Before:
|
||||
" This is just one language for the linter.
|
||||
call ale#assert#SetUpLinterTest('asciidoc', 'textlint')
|
||||
|
||||
" The configuration is shared between many languages.
|
||||
Save g:ale_textlint_executable
|
||||
Save g:ale_textlint_use_global
|
||||
Save g:ale_textlint_options
|
||||
|
||||
let g:ale_textlint_executable = 'textlint'
|
||||
let g:ale_textlint_use_global = 0
|
||||
let g:ale_textlint_options = ''
|
||||
|
||||
unlet! b:ale_textlint_executable
|
||||
unlet! b:ale_textlint_use_global
|
||||
unlet! b:ale_textlint_options
|
||||
|
||||
After:
|
||||
unlet! b:command_tail
|
||||
unlet! b:ale_textlint_executable
|
||||
unlet! b:ale_textlint_use_global
|
||||
unlet! b:ale_textlint_options
|
||||
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'textlint',
|
||||
\ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s'
|
||||
|
||||
Execute(The executable should be configurable):
|
||||
let b:ale_textlint_executable = 'foobar'
|
||||
|
||||
AssertLinter 'foobar',
|
||||
\ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s'
|
||||
|
||||
Execute(The options should be configurable):
|
||||
let b:ale_textlint_options = '--something'
|
||||
|
||||
AssertLinter 'textlint',
|
||||
\ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s'
|
||||
|
||||
Execute(The local executable from .bin should be used if available):
|
||||
call ale#test#SetFilename('textlint_paths/with_bin_path/foo.txt')
|
||||
|
||||
AssertLinter
|
||||
\ ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'),
|
||||
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'))
|
||||
\ . ' -f json --stdin --stdin-filename %s'
|
||||
|
||||
Execute(The local executable from textlint/bin should be used if available):
|
||||
call ale#test#SetFilename('textlint_paths/with_textlint_bin_path/foo.txt')
|
||||
|
||||
if has('win32')
|
||||
AssertLinter
|
||||
\ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
|
||||
\ ale#Escape('node.exe') . ' ' . ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s'
|
||||
else
|
||||
AssertLinter
|
||||
\ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
|
||||
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s'
|
||||
endif
|
||||
42
test/fixers/test_textlint_fixer_callback.vader
Normal file
42
test/fixers/test_textlint_fixer_callback.vader
Normal file
@@ -0,0 +1,42 @@
|
||||
Before:
|
||||
Save g:ale_textlint_executable
|
||||
Save g:ale_textlint_options
|
||||
Save g:ale_textlint_use_global
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_textlint_executable = 'xxxinvalid'
|
||||
let g:ale_textlint_options = ''
|
||||
let g:ale_textlint_use_global = 0
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The textlint callback should return the correct default values):
|
||||
call ale#test#SetFilename('../markdown_files/testfile.md')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' --fix'
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#textlint#Fix(bufnr(''))
|
||||
|
||||
Execute(The textlint callback should include custom textlint options):
|
||||
let g:ale_textlint_options = "--quiet"
|
||||
call ale#test#SetFilename('../markdown_files/testfile.md')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' --fix'
|
||||
\ . ' ' . g:ale_textlint_options
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#textlint#Fix(bufnr(''))
|
||||
0
test/markdown_files/testfile.md
Normal file
0
test/markdown_files/testfile.md
Normal file
Reference in New Issue
Block a user