Automatically use eslint_d for eslint, when available
This commit is contained in:
parent
c31cd12bdd
commit
3840cebbc4
@ -9,22 +9,21 @@ function! ale#handlers#eslint#GetExecutable(buffer) abort
|
|||||||
return ale#Var(a:buffer, 'javascript_eslint_executable')
|
return ale#Var(a:buffer, 'javascript_eslint_executable')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Look for the kinds of paths that create-react-app generates first.
|
" Look for eslint_d first, then the path React uses, then the basic
|
||||||
let l:executable = ale#path#ResolveLocalPath(
|
" eslint path.
|
||||||
\ a:buffer,
|
for l:path in [
|
||||||
|
\ 'node_modules/.bin/eslint_d',
|
||||||
\ 'node_modules/eslint/bin/eslint.js',
|
\ 'node_modules/eslint/bin/eslint.js',
|
||||||
\ ''
|
|
||||||
\)
|
|
||||||
|
|
||||||
if !empty(l:executable)
|
|
||||||
return l:executable
|
|
||||||
endif
|
|
||||||
|
|
||||||
return ale#path#ResolveLocalPath(
|
|
||||||
\ a:buffer,
|
|
||||||
\ 'node_modules/.bin/eslint',
|
\ 'node_modules/.bin/eslint',
|
||||||
\ ale#Var(a:buffer, 'javascript_eslint_executable')
|
\]
|
||||||
\)
|
let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
|
||||||
|
|
||||||
|
if !empty(l:executable)
|
||||||
|
return l:executable
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return ale#Var(a:buffer, 'javascript_eslint_executable')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:FindConfig(buffer) abort
|
function! s:FindConfig(buffer) abort
|
||||||
|
0
test/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d
generated
vendored
Normal file
0
test/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d
generated
vendored
Normal file
@ -16,7 +16,7 @@ After:
|
|||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
|
|
||||||
Execute(create-react-app directories should be detected correctly):
|
Execute(create-react-app directories should be detected correctly):
|
||||||
new eslint-test-files/react-app/subdir/testfile.js
|
silent noautocmd new eslint-test-files/react-app/subdir/testfile.js
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js',
|
\ g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js',
|
||||||
@ -27,7 +27,7 @@ Execute(create-react-app directories should be detected correctly):
|
|||||||
Execute(use-global should override create-react-app detection):
|
Execute(use-global should override create-react-app detection):
|
||||||
let g:ale_javascript_eslint_use_global = 1
|
let g:ale_javascript_eslint_use_global = 1
|
||||||
|
|
||||||
new eslint-test-files/react-app/subdir/testfile.js
|
silent noautocmd new eslint-test-files/react-app/subdir/testfile.js
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ 'eslint_d',
|
\ 'eslint_d',
|
||||||
@ -36,7 +36,7 @@ Execute(use-global should override create-react-app detection):
|
|||||||
:q
|
:q
|
||||||
|
|
||||||
Execute(other app directories should be detected correctly):
|
Execute(other app directories should be detected correctly):
|
||||||
new eslint-test-files/other-app/subdir/testfile.js
|
silent noautocmd new eslint-test-files/other-app/subdir/testfile.js
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ g:dir . '/eslint-test-files/node_modules/.bin/eslint',
|
\ g:dir . '/eslint-test-files/node_modules/.bin/eslint',
|
||||||
@ -47,10 +47,19 @@ Execute(other app directories should be detected correctly):
|
|||||||
Execute(use-global should override other app directories):
|
Execute(use-global should override other app directories):
|
||||||
let g:ale_javascript_eslint_use_global = 1
|
let g:ale_javascript_eslint_use_global = 1
|
||||||
|
|
||||||
new eslint-test-files/other-app/subdir/testfile.js
|
silent noautocmd new eslint-test-files/other-app/subdir/testfile.js
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ 'eslint_d',
|
\ 'eslint_d',
|
||||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||||
|
|
||||||
:q
|
:q
|
||||||
|
|
||||||
|
Execute(eslint_d should be detected correctly):
|
||||||
|
silent noautocmd new eslint-test-files/app-with-eslint-d/testfile.js
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d',
|
||||||
|
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||||
|
|
||||||
|
:q
|
||||||
|
Loading…
Reference in New Issue
Block a user