summaryrefslogtreecommitdiff
path: root/ale_linters/javascript/eslint.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-26 10:02:48 +0100
committerw0rp <devw0rp@gmail.com>2017-05-26 10:02:48 +0100
commit7fe1119cf1154480d8035a078ff06d6739892551 (patch)
treea7f22201a5e75336858e9c37f81b33e8752ad1fe /ale_linters/javascript/eslint.vim
parentc89587785b6fc4cba844b7eda2dbd65d15185374 (diff)
downloadale-7fe1119cf1154480d8035a078ff06d6739892551.zip
#576 Run the eslint.js file created by React with node on Windows
Diffstat (limited to 'ale_linters/javascript/eslint.vim')
-rw-r--r--ale_linters/javascript/eslint.vim16
1 files changed, 14 insertions, 2 deletions
diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim
index acf17a4d..9f3bdcef 100644
--- a/ale_linters/javascript/eslint.vim
+++ b/ale_linters/javascript/eslint.vim
@@ -5,8 +5,20 @@ let g:ale_javascript_eslint_options =
\ get(g:, 'ale_javascript_eslint_options', '')
function! ale_linters#javascript#eslint#GetCommand(buffer) abort
- return ale#handlers#eslint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'javascript_eslint_options')
+ let l:executable = ale#handlers#eslint#GetExecutable(a:buffer)
+
+ if ale#Has('win32') && l:executable =~? 'eslint\.js$'
+ " For Windows, if we detect an eslint.js script, we need to execute
+ " it with node, or the file can be opened with a text editor.
+ let l:head = 'node ' . ale#Escape(l:executable)
+ else
+ let l:head = ale#Escape(l:executable)
+ endif
+
+ let l:options = ale#Var(a:buffer, 'javascript_eslint_options')
+
+ return l:head
+ \ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -f unix --stdin --stdin-filename %s'
endfunction