Extension can't find typescript-eslint parser with yarn's pnpm linker installation layout #1812
Labels
bug
Issue identified by VS Code Team member as probable bug
help wanted
Issues identified as good community contribution opportunities
Milestone
With Yarn v4's pnpm linker, this extension no longer works on TS files due to issues the installation layout causes with the regexps the extension uses to detect parsers.
(This is probably blocking my team's repo from moving to yarn v4 + pnpm linker, since we'd really prefer not to lose eslint support in the editor, and I got everything else working.)
Repro
https://github.com/ecraig12345/repro-yarn-pnpm-eslint
yarn
yarn lint
and observe two errorsindex.js
(which works with the default parser) and observe aprefer-const
lint error in the editorindex.ts
and observe that there's no lint error shown with the same codeThere are also no related diagnostic messages shown in the "Output" console for the plugin, either in normal or debug mode.
Analysis
With Yarn v4's
pnpm
linker, the realpath of@typescript-eslint/parser
is something likenode_modules/.store/@typescript-eslint-parser-virtual-783997822c/package
as shown below. (node_modules/@typescript-eslint/parser
also exists, but it's a symlink.)This breaks the extension's TS parser detection because it expects the resolved parser realpath to match one of these regexps. (The paths for
babel-eslint
andvue-eslint-parser
would be broken too because of the auto-generated suffixes on the folders, as well as the extrapackage
folder in the path.)vscode-eslint/server/src/eslint.ts
Lines 755 to 757 in 8173467
Suggested fix
One option would be to change the regexps to be slightly more flexible, e.g.:
/\/@typescript-eslint[/+-]parser[/@-]/
. I think the other regexps with paths would need to be like/\/babel-eslint(-[^/]*\/package)?\/lib\/index.js$/
.Another option would be to modify whichever part of the code is resolving the extension to a realpath to preserve the symlinked path instead, but that would probably be harder to track down.
Notes
Interestingly, this is NOT broken with actual
pnpm
(note the@typescript-eslint/parser
segment at the end of the path).The text was updated successfully, but these errors were encountered: