-
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
eslint fixer does not change directory (unlike eslint checker) and therefore cannot find plugins #3094
Comments
diff --git a/autoload/ale/fixers/eslint.vim b/autoload/ale/fixers/eslint.vim
index 62e692b1..2dbf5f30 100644
--- a/autoload/ale/fixers/eslint.vim
+++ b/autoload/ale/fixers/eslint.vim
@@ -3,7 +3,12 @@
function! ale#fixers#eslint#Fix(buffer) abort
let l:executable = ale#handlers#eslint#GetExecutable(a:buffer)
- let l:command = ale#node#Executable(a:buffer, l:executable)
+
+ let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
+ let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
+ let l:cd_command = !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : ''
+
+ let l:command = l:cd_command . ale#node#Executable(a:buffer, l:executable)
\ . ' --version'
return ale#semver#RunWithVersionCheck( I was going to suggest the above patch, but I think it might be a bit more complicated. Can you try it out anyways? To apply it, save the patch, and run |
I think I actually hacked together something more or less exactly like that. iirc it didn't quite work. not at a proper computer rn but will take a look on monday... |
had a bash ⬆️ will add tests if i get a spare moment, and can figure them out. |
To match the ESLint linter, as changed in 9ee57d4 (which I forgot to apply to the fixer, whoops). Fixes: dense-analysis#3094 Closes: dense-analysis#3095 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
* Split eslint#GetCdString from eslint#GetCommand Move the code for finding the project root and building the cd string into a separate function so that it can be reused in the eslint fixer. Signed-off-by: Kevin Locke <kevin@kevinlocke.name> * Run ESLint fixer from project root dir To match the ESLint linter, as changed in 9ee57d4 (which I forgot to apply to the fixer, whoops). Fixes: #3094 Closes: #3095 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
* Split eslint#GetCdString from eslint#GetCommand Move the code for finding the project root and building the cd string into a separate function so that it can be reused in the eslint fixer. Signed-off-by: Kevin Locke <kevin@kevinlocke.name> * Run ESLint fixer from project root dir To match the ESLint linter, as changed in 9ee57d4 (which I forgot to apply to the fixer, whoops). Fixes: #3094 Closes: #3095 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Information
VIM version
Operating System: ubuntu 19.10
What went wrong
I've been trying to configure eslint for a react/typescript project. Got the linter working, but not the fixer. my javascript files are in a subfolder of my main project root.
Reproducing the bug
:ALEFix
and nothing happens.here's what i think is happening: the checker does a
cd
to the folder that containsnode_modules
and the.eslintrc.js
. but when it gets run as a fixer, it does not do that CD.vs
rerunning the above manually gives
if I
cd
into theui
directory, then it runs ok.:ALEInfo
The text was updated successfully, but these errors were encountered: