Skip to content
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

do not show error in symbolic link folder #1351

Closed
zhuoyan123 opened this issue Oct 13, 2021 · 11 comments
Closed

do not show error in symbolic link folder #1351

zhuoyan123 opened this issue Oct 13, 2021 · 11 comments

Comments

@zhuoyan123
Copy link

I worked on mac os, this is my workspace
20211013092038

the 'src' is linked to another folder, when I make error in some file in src, vscode-eslint can not give me error info, but webpack gives me.

this is stat when I maked an error
image

this is the info by command 'ls -l' in root
image

@dbaeumer
Copy link
Member

All I can recommend is to exclude the folder in this case using an .eslintignore file

@zhuoyan123
Copy link
Author

All I can recommend is to exclude the folder in this case using an .eslintignore file

You had not understand me, I want it display errors in symlink but not ignore.

@dbaeumer dbaeumer reopened this Oct 19, 2021
@dbaeumer
Copy link
Member

@zhuoyan123 does the validation happen correctly when you use eslint in the terminal. If this is the case can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

@zhuoyan123
Copy link
Author

zhuoyan123 commented Oct 20, 2021

@zhuoyan123 does the validation happen correctly when you use eslint in the terminal. If this is the case can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

this is my project in github, https://github.com/zhuoyan123/vscode-eslint-symlinks
you can clone it, and then repeat my problems, my vscode had install eslint before

@dbaeumer
Copy link
Member

The validation doesn't happen correctly in the terminal. If I run ./node_modules/.bin/eslint src/App.test.js I get

Oops! Something went wrong! :(

ESLint: 7.11.0

ESLint couldn't find the plugin "eslint-plugin-flowtype".

(The package "eslint-plugin-flowtype" was not found when loaded as a Node module from the directory "/workspaces/vscode-eslint-symlinks/project".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-flowtype@latest --save-dev

The plugin "eslint-plugin-flowtype" was referenced from the config file in ".eslintrc.js » eslint-config-react-app".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

The extension can only validate files correctly iff the validation happens correctly in the terminal. I will close the issue for now.

If you still see problems after the validation happens correctly in the terminal please ping and I will reopen.

@CarstenWalther
Copy link

I had the same problem. The eslint extension did not show linter errors from files in a symlinked folder. Running eslint from the terminal worked fine though.

As a workaround set the nodePath configuration to your node_modules directory. E.g. "eslint.nodePath": "node_modules". Then it should show linter errors for files in symlinked folders.

@zhuoyan123
Copy link
Author

I had the same problem. The eslint extension did not show linter errors from files in a symlinked folder. Running eslint from the terminal worked fine though.

As a workaround set the nodePath configuration to your node_modules directory. E.g. "eslint.nodePath": "node_modules". Then it should show linter errors for files in symlinked folders.

Your method works, thank you very much

@romamik
Copy link

romamik commented Nov 23, 2022

Can confirm that issue is still here and that the workaround suggested by @CarstenWalther works.
I've prepared the repository with reproduction: https://github.com/romamik/eslint-vs-code-bug
There is a readme with steps to reproduce there.
@dbaeumer Please consider reopening this issue.

@dbaeumer
Copy link
Member

@romamik thanks for the GitHub repository. The underlying problem here is how node deals with sym links and there is nothing I can do about this except that you can provide me with the location of the eslint module by settting eslint.nodePath. Here is what is happening in node:

@dbaeumer ➜ /workspaces/eslint-vs-code-bug/vscode-workspace/src-symlinked (master) $ node
Welcome to Node.js v16.18.1.
Type ".help" for more information.
> process.cwd()
'/workspaces/eslint-vs-code-bug/my-src'

Even though I start node on the symlinked folder node does a realpath and actually opens on '/workspaces/eslint-vs-code-bug/my-src'. As a consequence, the eslint server doesn't find an Eslint npm package since there is none up the parent chain from '/workspaces/eslint-vs-code-bug/my-src'.

I tried various things to convince node to not fall back to the real path but wasn't able to do so. If someone has an idea I am happy to further experiement.

It does work in the terminal since there we start with a symlinked path in the terminal.

@dbaeumer
Copy link
Member

An easier fix is to denote the workspace root as the working directory to use by using the following setting:

	"eslint.workingDirectories": [
		"."
	]

@romamik
Copy link

romamik commented Nov 24, 2022

They are speaking about __filename/__dirname there, but these behave the same. nodejs/node#22602

I agree that nothing can be done here without proper information from the node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants