Closed archseer closed 6 years ago
This was probably an issue with new files, and can't be fixed in ALE.
It's not, it's still reproducible in a vanilla Vue project, meanwhile VS Code / Vetur doesn't have such issues. I haven't been able to figure out exactly what happens, but I think it's ran via a different current directory between cases.
Here's me opening a file in vim, then running :ALELint
Command History:
(executable check - success) /<path>/ui/node_modules/eslint/bin/eslint.js
(finished - exit code 1) ['/usr/local/bin/zsh', '-c', '''/<path>/ui/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/<path>/ui/src/vi
ews/Calendar.vue'' < ''/var/folders/_j/_477qt2d0llgr9vxdkmmc_mw0000gn/T/nvimEhL8RI/7/Calendar.vue''']
<<<OUTPUT STARTS>>>
/<path>/ui/src/views/Calendar.vue:92:23: Unable to resolve path to module '@/components/calendar/MonthView.vue'. [Error/import/no-unresolved]
/<path>/ui/src/views/Calendar.vue:93:21: Unable to resolve path to module '@/components/calendar/DayView.vue'. [Error/import/no-unresolved]
/<path>/ui/src/views/Calendar.vue:94:22: Unable to resolve path to module '@/components/calendar/WeekView.vue'. [Error/import/no-unresolved]
/<path>/ui/src/views/Calendar.vue:95:26: Unable to resolve path to module '@/components/calendar/timeline/View.vue'. [Error/import/no-unresolved]
/<path>/ui/src/views/Calendar.vue:96:31: Unable to resolve path to module '@/mixins/CalendarMathMixin'. [Error/import/no-unresolved]
/<path>/ui/src/views/Calendar.vue:96:31: Missing file extension for "@/mixins/CalendarMathMixin" [Error/import/extensions]
6 problems
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/zsh', '-c', '''/<path>/ui/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/<path>/ui/src/vi
ews/Calendar.vue'' < ''/var/folders/_j/_477qt2d0llgr9vxdkmmc_mw0000gn/T/nvimEhL8RI/8/Calendar.vue''']
<<<NO OUTPUT RETURNED>>>
I think potentially, when I initially open vim, it runs eslint according to project (git) root, whereas I opened the editor inside
Okay, this is a problem with an ESLint plugin, and they should fix it: https://github.com/benmosher/eslint-plugin-import/issues/1158
ALE can't automatically determine which working directory to use for ESLint, and ESLint plugins shouldn't care what your working directory is. The plugin authors will have to fix it.
I revert that commit because it just broke the same thing for other people in different ways.
It looks like eslint doesn't intend to fix this on their side. Is there a workaround for this or is ALE no longer usable for javascript projects?
It's a bug in the ESLint plugin, and the bug should be fixed in the plugin. You can work around the issue by writing your configuration file in JavaScript and by defining the packageDir
variable with __dirname
.
Unlike import/no-extraneous-dependencies.md, import/no-unresolved doesn't have a packageDir
option.
Is there nothing else that can be done about this?
BTW, I've suggested the change that would fix this in the plugin's GitHub, but if they choose to not accept it, it would require a fork, which seems pretty high-maintenance for future users that may stumble upon this.
Information
VIM version
NVIM v0.2.2 Build type: Release
Operating System: OS X
:ALEInfo
What went wrong
The first lint somehow fails to pick up the extra .ts files I have. Running :ALELint triggers a second lint and the list of errors corrects itself. I initially thought that maybe it's linting from the wrong directory, but it doesn't seem to be the case.