Vscode-eslint: Doesn't work with external config file from node module

Created on 17 Dec 2019  路  16Comments  路  Source: microsoft/vscode-eslint

I have my own eslint config that is hooked into .eslintrc.js ->
extends: ['eslint-config-myconfig']

this causes an error to be thrown in VSCode, note that the same setup works in Atom.io

Failed to load plugin 'promise' declared in 'myProject/.eslintrc.js 禄 eslint-config-myconfig': Cannot find module 'eslint-plugin-promise' Require stack: - /Users/{...myWorkspace}/__placeholder__.js Referenced from: /Users/{...myWorkspace}/{...myProject}/node_modules/eslint-config-myconfig/index.js

needs more info

Most helpful comment

@skaraman have a look at the eslint.workingDirectories setting which allows you to customize these setups (https://github.com/microsoft/vscode-eslint#settings-options). They new [{ "mode": "auto" }] might be your friend here.

All 16 comments

@skaraman can you please provide me with a GitHub repository I can clone that demos what you are experiencing. Thanks.

@dbaeumer setting up a repo isn't something i can do just to preserve my project integretity but you can reproduce this issue by using https://www.npmjs.com/package/eslint-config-synacor in a project, it follows the same principles, please review the readme

@skaraman my experience shows that bugs like this depend on many things, especially on workspace settings and versions used. So I would highly appreciate if you could provide me with reproducible steps.

If you use eslint from the terminal validating that file from the workspace folder (e.g. the folder you have open in VS Code) will it succeed ? Or do you need to do a cd into one of the sub folders. If so you need to tell eslint about these working directories using the eslint.workingDirectories setting.

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@dbaeumer
I've setup a test repo here - https://github.com/skaraman/test
Current behavior
current
error

Expected behavior
expected

I don't think it's an issue with workingDirectories but if it is, please let me know again
This is what atom looks like without the node_modules installed but with the package.json config setup to expect one -
withoutNodeModule

@skaraman can you please had a eslintrc config file. Otherwise it is hard to tell what is going wrong.

I do see errors with my eslint configuration.

capture

The issue is that the config file is in a node module. Why don鈥檛 I need esconfig in atom? What is your configuration file?

This is what I see in VS Code

capture

and this when running eslint in a terminal:

capture

which is the same result. I am not sure what atom does but I try to stay as close as possible to what happens when running eslint from the terminal.

What do you see when you run eslint from the terminal ?

Hi @dbaeumer I see correct errors in terminal Screen Shot 2020-01-08 at 10 41 59 AM

but i also see this output from eslint saying failed to load 'compat'
Screen Shot 2020-01-08 at 11 24 49 AM
(last part cut off just says Require stack: - /Users/semyonkaraman/Desktop/dev/vscode/__placeholder__.js)

Can you run in the terminal with --debug to see which config files are read and provide them to me as well (best in the GitHub repository so we are using the same config)

there's a lot of output so i put it in a txt file, all the config is in the node modules so you should have it with npm i and i'm not sure which files you need (if you still need some let me know which ones from the output.txt) , i don't have eslint installed globally either
debug_output.txt

Actually comparing your output with mine reports exactly the same errors and for me they are even correctly reported in VS Code itself. I have actually no idea why in you setup the compat plugin can not be loaded. On which folder do you open the workspace ?

you figured it out!
the workspace i have is setup on a 'dev' root of my own, then i have subfolders for projects, then i have subfolders for branches (you should be able to see by the smudges in the screenshot above), when i open the branch in the workspace as the root, the eslint plugin works and reports errors correctly
Screen Shot 2020-01-09 at 9 50 16 AM

@dbaeumer Although changing the workspace solves the issue, i would appreciate it if you could try to resolve the issue when there are high up folders, i would like to have a workspace where i can have project folders as some of my projects are like this :
myProject1/oneBranch
myProject1/twoBranch
myProject2/oneBranch
myProject2/twoBranch

if i have two of these same branches set at the roots it's hard to tell what branch is from what project

@skaraman have a look at the eslint.workingDirectories setting which allows you to customize these setups (https://github.com/microsoft/vscode-eslint#settings-options). They new [{ "mode": "auto" }] might be your friend here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

empz picture empz  路  66Comments

dracozombie19 picture dracozombie19  路  72Comments

kasvtv picture kasvtv  路  107Comments

nicobarray picture nicobarray  路  75Comments

singleghost picture singleghost  路  20Comments