mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-26 12:56:54 +08:00
eslint: Use cwd from executable location to fix nested projects (#3222)
* Split FindNearestExecutable from FindExecutable The path searching in ale#node#FindExecutable() will be useful for eslint. Refactor it into a separate function so it can be used without regard for the state of the _use_global and _executable variables. Signed-off-by: Kevin Locke <kevin@kevinlocke.name> * eslint: Set project root from local executable Using the nearest directory with node_modules does not work correctly for nested projects where the eslint dependencies are in the outer project. For example: https://github.com/dense-analysis/ale/issues/3143#issuecomment-652452362 Adopt the behavior of SublimeLinter, which runs from project_root determined by the presence of the eslint executable in node_modules/.bin (or eslint in dependencies/devDependencies of package.json, which we can add later as necessary). See [NodeLinter#find_local_executable]. [NodeLinter#find_local_executable]: https://github.com/SublimeLinter/SublimeLinter/blob/056e6f6/lint/base_linter/node_linter.py#L109 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
@@ -12,6 +12,18 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
|
||||
return ale#Var(a:buffer, a:base_var_name . '_executable')
|
||||
endif
|
||||
|
||||
let l:nearest = ale#node#FindNearestExecutable(a:buffer, a:path_list)
|
||||
|
||||
if !empty(l:nearest)
|
||||
return l:nearest
|
||||
endif
|
||||
|
||||
return ale#Var(a:buffer, a:base_var_name . '_executable')
|
||||
endfunction
|
||||
|
||||
" Given a buffer number, a base variable name, and a list of paths to search
|
||||
" for in ancestor directories, detect the executable path for a Node program.
|
||||
function! ale#node#FindNearestExecutable(buffer, path_list) abort
|
||||
for l:path in a:path_list
|
||||
let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
|
||||
|
||||
@@ -20,7 +32,7 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ale#Var(a:buffer, a:base_var_name . '_executable')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Create a executable string which executes a Node.js script command with a
|
||||
|
||||
Reference in New Issue
Block a user