-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(eslint): yarn 2 project cwd #3684
fix(eslint): yarn 2 project cwd #3684
Conversation
@@ -52,14 +52,20 @@ function! ale#handlers#eslint#GetCwd(buffer) abort | |||
let l:executable = ale#node#FindNearestExecutable(a:buffer, s:executables) | |||
|
|||
if !empty(l:executable) | |||
let l:nmi = strridx(l:executable, 'node_modules') | |||
let l:project_dir = l:executable[0:l:nmi - 2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was causing the CWD to be set to /path/to/project/.yarn/sdks/eslint/bin/eslint.
instead of /path/to/project
which made the command fail as eslint.
doesn't exist and definitely isn't a directory.
(executable check - success) /path/to/project/.yarn/sdks/eslint/bin/eslint.js
(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/path/to/project/.yarn/sdks/eslint/bin/eslint.'' && ''/path/to/project/.yarn/sdks/eslint/bin/eslint.js'' -f json --stdin --stdin-filename ''/path/to/project/src/some/file.js'' < ''/var/folders/tr/.../file.js''']
endif | ||
|
||
return !empty(l:project_dir) ? l:project_dir : '' | ||
return strlen(l:modules_root) > strlen(l:sdks_root) ? l:modules_root : l:sdks_root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The longest value is the nearer directory.
Sorry to be noisy, but checking on the status here. I implemented a solution with passing tests. Is there anything else you need from me to get this merged? Thanks. |
Cheers! 🍻 |
Thank you!! |
@shannonmoeller This doesn't seem to be working for me. I have eslint 8.33.0 installed in a project. When I try to run
I assume this isn't an issue with your code, but with some change in eslint. Any idea what might fix this? Thanks! As a workaround I've added this to my vimrc:
|
Improves logic around detecting a project root based on the presence of eslint in
node_modules
or.yarn/sdks
. Helps with, but still not a complete fix for #2970.