ecraig12345 / repro-yarn-pnpm-eslint

Issue repro with yarn pnpm linker and vscode-eslint extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demonstrating an issue with vscode-eslint in a repo using Yarn v4 with pnpm linker.

Steps

  1. Clone repo and open in VS Code
  2. yarn
  3. Observe that yarn lint shows two errors
  4. Open index.js and observe a prefer-const lint error in the editor
  5. Open index.ts and observe that there's no lint error shown with the same code

With Yarn v4's pnpm linker, the realpath of @typescript-eslint/parser is something like node_modules/.store/@typescript-eslint-parser-virtual-783997822c/package as shown below. (node_modules/@typescript-eslint/parser also exists, but it's a symlink.)

This is a problem for the extension's parser detection because it expects the resolved parser realpath to match /\/@typescript-eslint\/parser\// .

node_modules
├── .store
│   └── @typescript-eslint-parser-virtual-783997822c
│       ├── node_modules
│       │   └── @typescript-eslint
│       │       └── parser -> ../../package
│       └── package
│           ├── (contents)
│           └── package.json
└── @typescript-eslint
    └── parser -> ../.store/@typescript-eslint-parser-virtual-783997822c/package

Interestingly, pnpm itself doesn't have this problem (note the @typescript-eslint/parser segment at the end of the path).

node_modules
├── .pnpm
│   └── @typescript-eslint+parser@7.3.1_eslint@8.57.0_typescript@5.4.2
│       └── node_modules
│           └── @typescript-eslint
│               └── parser
│                   ├── (contents)
│                   └── package.json
└── @typescript-eslint
    └── parser -> ../.pnpm/@typescript-eslint+parser@7.3.1_eslint@8.57.0_typescript@5.4.2/node_modules/@typescript-eslint/parser

(You can demo this by removing the packageManager setting from package.json, npm i -g pnpm, pnpm i.)

About

Issue repro with yarn pnpm linker and vscode-eslint extension


Languages

Language:JavaScript 54.7%Language:TypeScript 45.3%