Skip to content

Commit

Permalink
#2132 Remove the need for the hidden add_newline option by tweaking t…
Browse files Browse the repository at this point in the history
…he flow command
  • Loading branch information
w0rp committed Jan 12, 2019
1 parent d8a53cc commit 6644563
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
5 changes: 3 additions & 2 deletions ale_linters/javascript/flow.vim
Expand Up @@ -54,7 +54,8 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
return ale#Escape(l:executable)
\ . ' check-contents'
\ . (l:use_respect_pragma ? ' --respect-pragma': '')
\ . ' --json --from ale %s'
\ . ' --json --from ale %s < %t'
\ . (!has('win32') ? '; echo' : '')
endfunction

" Filter lines of flow output until we find the first line where the JSON
Expand Down Expand Up @@ -172,5 +173,5 @@ call ale#linter#Define('javascript', {
\ {'callback': 'ale_linters#javascript#flow#GetCommand'},
\ ],
\ 'callback': 'ale_linters#javascript#flow#Handle',
\ 'add_newline': !has('win32'),
\ 'read_buffer': 0,
\})
10 changes: 0 additions & 10 deletions autoload/ale/engine.vim
Expand Up @@ -525,16 +525,6 @@ function! s:RunJob(options) abort
let l:read_buffer = 0
endif

" Add a newline to commands which need it.
" This is only used for Flow for now, and is not documented.
if l:linter.add_newline
if has('win32')
let l:command = l:command . '; echo.'
else
let l:command = l:command . '; echo'
endif
endif

let l:command = ale#job#PrepareCommand(l:buffer, l:command)
let l:job_options = {
\ 'mode': 'nl',
Expand Down
1 change: 0 additions & 1 deletion autoload/ale/linter.vim
Expand Up @@ -80,7 +80,6 @@ function! ale#linter#PreProcess(filetype, linter) abort
endif

let l:obj = {
\ 'add_newline': get(a:linter, 'add_newline', 0),
\ 'name': get(a:linter, 'name'),
\ 'lsp': get(a:linter, 'lsp', ''),
\}
Expand Down
6 changes: 3 additions & 3 deletions test/test_flow_command.vader
Expand Up @@ -15,7 +15,7 @@ Execute(flow should return a command to run if a .flowconfig file exists):

AssertEqual
\ ale#Escape('flow')
\ . ' check-contents --respect-pragma --json --from ale %s',
\ . ' check-contents --respect-pragma --json --from ale %s < %t; echo',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [])

Execute(flow should not use the respect pragma argument if the option is off):
Expand All @@ -25,15 +25,15 @@ Execute(flow should not use the respect pragma argument if the option is off):

AssertEqual
\ ale#Escape('flow')
\ . ' check-contents --json --from ale %s',
\ . ' check-contents --json --from ale %s < %t; echo',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [])

Execute(flow should should not use --respect-pragma for old versions):
call ale#test#SetFilename('flow/a/sub/dummy')

AssertEqual
\ ale#Escape('flow')
\ . ' check-contents --json --from ale %s',
\ . ' check-contents --json --from ale %s < %t; echo',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [
\ 'Warning: `flow --version` is deprecated in favor of `flow version`',
\ 'Flow, a static type checker for JavaScript, version 0.27.0',
Expand Down
8 changes: 4 additions & 4 deletions test/test_linter_retrieval.vader
Expand Up @@ -2,8 +2,8 @@ Before:
Save g:ale_linters
Save g:ale_linter_aliases

let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': '', 'add_newline': 0}
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': [], 'lsp': '', 'add_newline': 0}
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': [], 'lsp': ''}
call ale#linter#Reset()
call ale#linter#PreventLoading('testft')
call ale#linter#PreventLoading('javascript')
Expand Down Expand Up @@ -160,7 +160,7 @@ Execute (Buffer-local overrides for aliases should be used):

Execute (Linters should be loaded from disk appropriately):
call ale#linter#Reset()
AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': '', 'add_newline': 0}], ale#linter#Get('testft')
AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}], ale#linter#Get('testft')


Execute (Linters for later filetypes should replace the former ones):
Expand All @@ -178,5 +178,5 @@ Execute (Linters for later filetypes should replace the former ones):
\})

AssertEqual [
\ {'output_stream': 'stdout', 'lint_file': 0, 'read_buffer': 1, 'name': 'eslint', 'executable': 'x', 'lsp': '', 'aliases': [], 'command': 'x', 'callback': 'x', 'add_newline': 0}
\ {'output_stream': 'stdout', 'lint_file': 0, 'read_buffer': 1, 'name': 'eslint', 'executable': 'x', 'lsp': '', 'aliases': [], 'command': 'x', 'callback': 'x'}
\], ale#linter#Get('javascript.typescript')

0 comments on commit 6644563

Please sign in to comment.