fix: look for yarn pnp when looking for eslint projdir
This commit is contained in:
parent
80a48d01be
commit
d12774d76a
1 changed files with 14 additions and 1 deletions
|
@ -55,8 +55,21 @@ function! ale#handlers#eslint#GetCwd(buffer) abort
|
||||||
let l:nmi = strridx(l:executable, 'node_modules')
|
let l:nmi = strridx(l:executable, 'node_modules')
|
||||||
let l:project_dir = l:executable[0:l:nmi - 2]
|
let l:project_dir = l:executable[0:l:nmi - 2]
|
||||||
else
|
else
|
||||||
|
" Patched behaviour: looks up yarn pnp before node_modules to add
|
||||||
|
" support for Yarn Berry.
|
||||||
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
|
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
|
||||||
|
let l:yarn_cpnp = ale#path#FindNearestFile(a:buffer, '.pnp.cjs')
|
||||||
|
let l:yarn_pnp = ale#path#FindNearestFile(a:buffer, '.pnp.js')
|
||||||
|
|
||||||
|
if !empty(l:yarn_pnp)
|
||||||
|
let l:project_dir = !empty(l:yarn_pnp) ? fnamemodify(l:yarn_pnp, ':h') : ''
|
||||||
|
elseif !empty(l:yarn_cpnp)
|
||||||
|
let l:project_dir = !empty(l:yarn_cpnp) ? fnamemodify(l:yarn_cpnp, ':h') : ''
|
||||||
|
elseif !empty(l:modules_dir)
|
||||||
let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
|
let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
|
||||||
|
else
|
||||||
|
let l:project_dir = ''
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return !empty(l:project_dir) ? l:project_dir : ''
|
return !empty(l:project_dir) ? l:project_dir : ''
|
||||||
|
|
Reference in a new issue