Skip to content

Conversation

@chenhebing
Copy link

What's the problem this PR addresses?

#6007
...

How did you fix it?

Removed a call to path.dirname and set nodePath to ".yarn/sdks/eslint"
...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Copy link
Member

@arcanis arcanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the VSCode-Eslint documentation, nodePath needs to point to a node_modules folder:

eslint.nodePath - use this setting if an installed ESLint package can't be detected, for example /myGlobalNodePackages/node_modules.

@chenhebing
Copy link
Author

According to the VSCode-Eslint documentation, nodePath needs to point to a node_modules folder:

eslint.nodePath - use this setting if an installed ESLint package can't be detected, for example /myGlobalNodePackages/node_modules.

Jan 23, 2024
View reviewed changes

Yes, there is no problem parsing node_modules under normal circumstances. But in submodule, there is a problem that it cannot be parsed. It can be seen from the VSCode-Eslint plug-in source code that the eslint plug-in is parsed through require.resolve of nodejs. In submodule, if it cannot be resolved in node_modules, it will be searched upward. It seems to be a depth-first search.

https://github.com/microsoft/vscode-languageserver-node/blob/4812428a8621dff4153282407fc71494b994eda3/server/src/node/files.ts#L41

@clemyan
Copy link
Member

clemyan commented Oct 28, 2025

vscode-eslint essentially just run require.resolve('eslint') with cwd and NODE_PATH both equal to eslint.nodePath, which means node_modules/eslint directories above the project directory will take precedence over <eslint.nodePath>/eslint.

As far as I understand the node resolution algorithm, when running require.resolve('eslint') with cwd inside a eslint package directory, that will have even higher precedence over node_modules/eslint directories above. So setting eslint.nodePath to .yarn/sdks/eslint is indeed the correct fix

@clemyan clemyan requested a review from arcanis October 28, 2025 13:43
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

Successfully merging this pull request may close these issues.

3 participants