Fix 2816 - Standard fix does not work.

The standard linter --fix fails if the file being input is not relative
to the project root (https://github.com/standard/standard/issues/1384).

This MR attempts to fix this by changing the command so the input file
is relative to the project root and the output is to a temporary file.

Preliminary tests with toy javascript projects seem to indicate this
works fine.
This commit is contained in:
Horacio Sanson 2020-03-12 16:00:30 +09:00
parent bbe5153fcb
commit c207d6a550
2 changed files with 3 additions and 3 deletions

View file

@ -27,7 +27,7 @@ function! ale#fixers#standard#Fix(buffer) abort
return { return {
\ 'command': ale#node#Executable(a:buffer, l:executable) \ 'command': ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --fix %t', \ . ' --fix --stdin < %s > %t',
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\} \}
endfunction endfunction

View file

@ -15,7 +15,7 @@ Execute(The executable path should be correct):
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '') \ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js')) \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js'))
\ . ' --fix %t', \ . ' --fix --stdin < %s > %t',
\ }, \ },
\ ale#fixers#standard#Fix(bufnr('')) \ ale#fixers#standard#Fix(bufnr(''))
@ -26,6 +26,6 @@ Execute(Custom options should be supported):
AssertEqual AssertEqual
\ { \ {
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\ 'command': ale#Escape('standard') . ' --foo-bar --fix %t', \ 'command': ale#Escape('standard') . ' --foo-bar --fix --stdin < %s > %t',
\ }, \ },
\ ale#fixers#standard#Fix(bufnr('')) \ ale#fixers#standard#Fix(bufnr(''))